Socket
Socket
Sign inDemoInstall

@chili-publish/publisher-interface

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chili-publish/publisher-interface - npm Package Compare versions

Comparing version 0.3.6 to 0.4.0

2

dist/chiliInternalWrapper.min.js

@@ -1,2 +0,2 @@

(()=>{var e,t,r,n,o,i,c,d;(t=e||(e={})).Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack",(n=r||(r={})).Fulfilled="fulfilled",n.Rejected="rejected",(i=o||(o={})).ConnectionDestroyed="ConnectionDestroyed",i.ConnectionTimeout="ConnectionTimeout",i.NoIframeSrc="NoIframeSrc",(c||(c={})).DataCloneError="DataCloneError",(d||(d={})).Message="message";var a=(e,t)=>{const r=[];let n=!1;return{destroy(o){n||(n=!0,t(`${e}: Destroying connection`),r.forEach((e=>{e(o)})))},onDestroy(e){n?e():r.push(e)}}},s=e=>(...t)=>{e&&console.log("[Penpal]",...t)};const u=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r}),w=e=>{const t=new Error;return Object.keys(e).forEach((r=>t[r]=e[r])),t};var g=(t,n,o)=>{const{localName:i,local:a,remote:s,originForSending:w,originForReceiving:g}=t;let l=!1;const S=t=>{if(t.source!==s||t.data.penpal!==e.Call)return;if("*"!==g&&t.origin!==g)return void o(`${i} received message from origin ${t.origin} which did not match expected origin ${g}`);const d=t.data,{methodName:a,args:S,id:b}=d;o(`${i}: Received ${a}() call`);const j=t=>n=>{if(o(`${i}: Sending ${a}() reply`),l)return void o(`${i}: Unable to send ${a}() reply due to destroyed connection`);const d={penpal:e.Reply,id:b,resolution:t,returnValue:n};t===r.Rejected&&n instanceof Error&&(d.returnValue=u(n),d.returnValueIsError=!0);try{s.postMessage(d,w)}catch(t){if(t.name===c.DataCloneError){const n={penpal:e.Reply,id:b,resolution:r.Rejected,returnValue:u(t),returnValueIsError:!0};s.postMessage(n,w)}throw t}};new Promise((e=>e(n[a].apply(n,S)))).then(j(r.Fulfilled),j(r.Rejected))};return a.addEventListener(d.Message,S),()=>{l=!0,a.removeEventListener(d.Message,S)}};let l=0;const S=e=>e?e.split("."):[],b=(e,t,r)=>{const n=S(t);return n.reduce(((e,t,o)=>(void 0===e[t]&&(e[t]={}),o===n.length-1&&(e[t]=r),e[t])),e),e},j=(e,t)=>{const r={};return Object.keys(e).forEach((n=>{const o=e[n],i=((e,t)=>{const r=S(t||"");return r.push(e),(e=>e.join("."))(r)})(n,t);"object"==typeof o&&Object.assign(r,j(o,i)),"function"==typeof o&&(r[i]=o)})),r},h=e=>{const t={};for(const r in e)b(t,r,e[r]);return t};var m=(t,n,i,c,a)=>{const{localName:s,local:u,remote:g,originForSending:S,originForReceiving:b}=n;let j=!1;a(`${s}: Connecting call sender`);const m=t=>(...n)=>{let i;a(`${s}: Sending ${t}() call`);try{g.closed&&(i=!0)}catch(e){i=!0}if(i&&c(),j){const e=new Error(`Unable to send ${t}() call due to destroyed connection`);throw e.code=o.ConnectionDestroyed,e}return new Promise(((o,i)=>{const c=++l,j=n=>{if(n.source!==g||n.data.penpal!==e.Reply||n.data.id!==c)return;if("*"!==b&&n.origin!==b)return void a(`${s} received message from origin ${n.origin} which did not match expected origin ${b}`);const l=n.data;a(`${s}: Received ${t}() reply`),u.removeEventListener(d.Message,j);let S=l.returnValue;l.returnValueIsError&&(S=w(S)),(l.resolution===r.Fulfilled?o:i)(S)};u.addEventListener(d.Message,j);const h={penpal:e.Call,id:c,methodName:t,args:n};g.postMessage(h,S)}))},p=i.reduce(((e,t)=>(e[t]=m(t),e)),{});return Object.assign(t,h(p)),()=>{j=!0}};var p=(e,t)=>{let r;return void 0!==e&&(r=window.setTimeout((()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=o.ConnectionTimeout,t(r)}),e)),()=>{clearTimeout(r)}},y=(t,r,n,o)=>{const{destroy:i,onDestroy:c}=n;return n=>{if(!(t instanceof RegExp?t.test(n.origin):"*"===t||t===n.origin))return void o(`Child: Handshake - Received SYN-ACK from origin ${n.origin} which did not match expected origin ${t}`);o("Child: Handshake - Received SYN-ACK, responding with ACK");const d="null"===n.origin?"*":n.origin,a={penpal:e.Ack,methodNames:Object.keys(r)};window.parent.postMessage(a,d);const s={localName:"Child",local:window,remote:window.parent,originForSending:d,originForReceiving:n.origin},u=g(s,r,o);c(u);const w={},l=m(w,s,n.data.methodNames,i,o);return c(l),w}};var v,O,f=(t={})=>{const{parentOrigin:r="*",methods:n={},timeout:o,debug:i=!1}=t,c=s(i),u=a("Child",c),{destroy:w,onDestroy:g}=u,l=j(n),S=y(r,l,u,c);return{promise:new Promise(((t,n)=>{const i=p(o,w),a=r=>{if((()=>{try{clearTimeout()}catch(e){return!1}return!0})()&&r.source===parent&&r.data&&r.data.penpal===e.SynAck){const e=S(r);e&&(window.removeEventListener(d.Message,a),i(),t(e))}};window.addEventListener(d.Message,a),(()=>{c("Child: Handshake - Sending SYN");const t={penpal:e.Syn},n=r instanceof RegExp?"*":r;window.parent.postMessage(t,n)})(),g((e=>{window.removeEventListener(d.Message,a),e&&n(e)}))})),destroy(){w()}}};function F(e){return{isOk:!0,isError:!1,ok:e,error:void 0}}function E(e){return{isOk:!1,isError:!0,ok:void 0,error:e}}(O=v||(v={}))[O.error=0]="error",O[O.ok=1]="ok",window.registeredFunctions=new Map,window.registeredEventFunctions=new Map;const P=setInterval((()=>{null!=window.editorObject&&null!=window.OnEditorEvent&&Z()}),500),A=(e,t)=>{try{return window.registeredFunctions.set(e,new Function("publisher","id",t)),F(void 0)}catch(e){return E(e.toString())}},k=(e,t)=>{try{return window.editorObject.AddListener(e),window.registeredEventFunctions.set(e,new Function("publisher","id",t)),F(void 0)}catch(e){return E(e.toString())}},C=e=>{try{const t=window.registeredFunctions.get(e);return null!=t?(t(window.publisher),F(void 0)):E(`Function ${e} not found`)}catch(e){return E(e.toString())}},I=(e,t)=>{try{return window.editorObject.Alert(e,t),F(void 0)}catch(e){return E(e.toString())}},$=()=>{try{return F(window.editorObject.GetDirtyState())}catch(e){return E(e.toString())}},N=()=>{try{return window.editorObject.NextPage(),F(void 0)}catch(e){return E(e.toString())}},R=()=>{try{return window.editorObject.PreviousPage(),F(void 0)}catch(e){return E(e.toString())}},L=e=>{try{return window.editorObject.SetSelectedPage(e),F(void 0)}catch(e){return E(e.toString())}},G=()=>{try{return F(window.editorObject.GetSelectedPage())}catch(e){return E(e.toString())}},M=()=>{try{return F(window.editorObject.GetSelectedPageName())}catch(e){return E(e.toString())}},D=()=>{try{return F(window.editorObject.GetNumPages())}catch(e){return E(e.toString())}},x=e=>{try{return window.editorObject.RemoveListener(e),F(void 0)}catch(e){return E(e.toString())}},V=e=>{try{return window.editorObject.AddListener(e),F(void 0)}catch(e){return E(e.toString())}},T=e=>{try{return F(window.editorObject.GetObject(e))}catch(e){return E(e.toString())}},H=(e,t,r)=>{try{return window.editorObject.SetProperty(e,t,r),F(void 0)}catch(e){return E(e.toString())}},K=(e,t,r)=>{try{return F(window.editorObject.ExecuteFunction(e,t,...r))}catch(e){return E(e.toString())}},Y=(e,t,r,n,o,i)=>{try{return F(window.editorObject.GetPageSnapshot(e,t,r,n,o,i))}catch(e){return E(e.toString())}},U=(e,t,r)=>{try{return F(window.editorObject.GetFrameSnapshot(e,t,r))}catch(e){return E(e.toString())}},q=e=>{try{return F(window.editorObject.GetFrameSubjectArea(e))}catch(e){return E(e.toString())}},z=(e,t,r,n,o)=>{try{return window.editorObject.SetFrameSubjectArea(e,t,r,n,o),F(void 0)}catch(e){return E(e.toString())}},B=e=>{try{return window.editorObject.ClearFrameSubjectArea(e),F(void 0)}catch(e){return E(e.toString())}},J=e=>{try{return F(window.editorObject.GetAssetSubjectInfo(e))}catch(e){return E(e.toString())}},Q=(e,t,r,n,o,i,c)=>{try{return window.editorObject.SetAssetSubjectInfo(e,t,r,n,o,i,c),F(void 0)}catch(e){return E(e.toString())}},W=e=>{try{return window.editorObject.ClearAssetSubjectInfo(e),F(void 0)}catch(e){return E(e.toString())}},X=(e,t)=>{try{return window.editorObject.SetVariableIsLocked(e,t),F(void 0)}catch(e){return E(e.toString())}},Z=()=>{clearInterval(P);const e=f({methods:{registerFunction:A,registerFunctionOnEvent:k,runRegisteredFunction:C,alert:I,getDirtyState:$,nextPage:N,previousPage:R,setSelectedPage:L,getSelectedPage:G,getSelectedPageName:M,getNumPages:D,removeListener:x,addListener:V,setProperty:H,getObject:T,executeFunction:K,getPageSnapshot:Y,getFrameSnapshot:U,getFrameSubjectArea:q,setFrameSubjectArea:z,clearFrameSubjectArea:B,getAssetSubjectInfo:J,setAssetSubjectInfo:Q,clearAssetSubjectInfo:W,setVariableIsLocked:X}});window.publisher={registerFunction:(e,t)=>{const r=A(e,t);if(r.isError)throw new Error(r.error);return r.ok},registerFunctionOnEvent:(e,t)=>{const r=k(e,t);if(r.isError)throw new Error(r.error);return r.ok},runRegisteredFunction:e=>{const t=C(e);if(t.isError)throw new Error(t.error);return t.ok},alert:window.editorObject.Alert,getDirtyState:window.editorObject.GetDirtyState,nextPage:window.editorObject.NextPage,previousPage:window.editorObject.PreviousPage,setSelectedPage:window.editorObject.SetSelectedPage,getSelectedPage:window.editorObject.GetSelectedPage,getSelectedPageName:window.editorObject.GetSelectedPageName,getNumPages:window.editorObject.GetNumPages,removeListener:window.editorObject.RemoveListener,addListener:window.editorObject.AddListener,getObject:window.editorObject.GetObject,setProperty:window.editorObject.SetProperty,executeFunction:window.editorObject.ExecuteFunction,getPageSnapshot:window.editorObject.GetPageSnapshot,getFrameSnapshot:window.editorObject.GetFrameSnapshot,getFrameSubjectArea:window.editorObject.GetFrameSubjectArea,setFrameSubjectArea:window.editorObject.SetFrameSubjectArea,clearFrameSubjectArea:window.editorObject.ClearFrameSubjectArea,getAssetSubjectInfo:window.editorObject.GetAssetSubjectInfo,setAssetSubjectInfo:window.editorObject.SetAssetSubjectInfo,clearAssetSubjectInfo:window.editorObject.ClearAssetSubjectInfo,setVariableIsLocked:window.editorObject.SetVariableIsLocked,editorObject:window.editorObject},window.OnEditorEvent=(t,r)=>{const n=window.registeredEventFunctions.get(t);null!=n&&n(window.publisher,r),e.promise.then((e=>{e.handleEvents(t,r)}))}}})();
(()=>{var e,t,r,n,o,i,c,d;(t=e||(e={})).Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack",(n=r||(r={})).Fulfilled="fulfilled",n.Rejected="rejected",(i=o||(o={})).ConnectionDestroyed="ConnectionDestroyed",i.ConnectionTimeout="ConnectionTimeout",i.NoIframeSrc="NoIframeSrc",(c||(c={})).DataCloneError="DataCloneError",(d||(d={})).Message="message";var a=(e,t)=>{const r=[];let n=!1;return{destroy(o){n||(n=!0,t(`${e}: Destroying connection`),r.forEach((e=>{e(o)})))},onDestroy(e){n?e():r.push(e)}}},s=e=>(...t)=>{e&&console.log("[Penpal]",...t)};const u=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r}),w=e=>{const t=new Error;return Object.keys(e).forEach((r=>t[r]=e[r])),t};var g=(t,n,o)=>{const{localName:i,local:a,remote:s,originForSending:w,originForReceiving:g}=t;let l=!1;const S=t=>{if(t.source!==s||t.data.penpal!==e.Call)return;if("*"!==g&&t.origin!==g)return void o(`${i} received message from origin ${t.origin} which did not match expected origin ${g}`);const d=t.data,{methodName:a,args:S,id:b}=d;o(`${i}: Received ${a}() call`);const j=t=>n=>{if(o(`${i}: Sending ${a}() reply`),l)return void o(`${i}: Unable to send ${a}() reply due to destroyed connection`);const d={penpal:e.Reply,id:b,resolution:t,returnValue:n};t===r.Rejected&&n instanceof Error&&(d.returnValue=u(n),d.returnValueIsError=!0);try{s.postMessage(d,w)}catch(t){if(t.name===c.DataCloneError){const n={penpal:e.Reply,id:b,resolution:r.Rejected,returnValue:u(t),returnValueIsError:!0};s.postMessage(n,w)}throw t}};new Promise((e=>e(n[a].apply(n,S)))).then(j(r.Fulfilled),j(r.Rejected))};return a.addEventListener(d.Message,S),()=>{l=!0,a.removeEventListener(d.Message,S)}};let l=0;const S=e=>e?e.split("."):[],b=(e,t,r)=>{const n=S(t);return n.reduce(((e,t,o)=>(void 0===e[t]&&(e[t]={}),o===n.length-1&&(e[t]=r),e[t])),e),e},j=(e,t)=>{const r={};return Object.keys(e).forEach((n=>{const o=e[n],i=((e,t)=>{const r=S(t||"");return r.push(e),(e=>e.join("."))(r)})(n,t);"object"==typeof o&&Object.assign(r,j(o,i)),"function"==typeof o&&(r[i]=o)})),r},m=e=>{const t={};for(const r in e)b(t,r,e[r]);return t};var h=(t,n,i,c,a)=>{const{localName:s,local:u,remote:g,originForSending:S,originForReceiving:b}=n;let j=!1;a(`${s}: Connecting call sender`);const h=t=>(...n)=>{let i;a(`${s}: Sending ${t}() call`);try{g.closed&&(i=!0)}catch(e){i=!0}if(i&&c(),j){const e=new Error(`Unable to send ${t}() call due to destroyed connection`);throw e.code=o.ConnectionDestroyed,e}return new Promise(((o,i)=>{const c=++l,j=n=>{if(n.source!==g||n.data.penpal!==e.Reply||n.data.id!==c)return;if("*"!==b&&n.origin!==b)return void a(`${s} received message from origin ${n.origin} which did not match expected origin ${b}`);const l=n.data;a(`${s}: Received ${t}() reply`),u.removeEventListener(d.Message,j);let S=l.returnValue;l.returnValueIsError&&(S=w(S)),(l.resolution===r.Fulfilled?o:i)(S)};u.addEventListener(d.Message,j);const m={penpal:e.Call,id:c,methodName:t,args:n};g.postMessage(m,S)}))},O=i.reduce(((e,t)=>(e[t]=h(t),e)),{});return Object.assign(t,m(O)),()=>{j=!0}};var O=(e,t)=>{let r;return void 0!==e&&(r=window.setTimeout((()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=o.ConnectionTimeout,t(r)}),e)),()=>{clearTimeout(r)}},v=(t,r,n,o)=>{const{destroy:i,onDestroy:c}=n;return n=>{if(!(t instanceof RegExp?t.test(n.origin):"*"===t||t===n.origin))return void o(`Child: Handshake - Received SYN-ACK from origin ${n.origin} which did not match expected origin ${t}`);o("Child: Handshake - Received SYN-ACK, responding with ACK");const d="null"===n.origin?"*":n.origin,a={penpal:e.Ack,methodNames:Object.keys(r)};window.parent.postMessage(a,d);const s={localName:"Child",local:window,remote:window.parent,originForSending:d,originForReceiving:n.origin},u=g(s,r,o);c(u);const w={},l=h(w,s,n.data.methodNames,i,o);return c(l),w}};var p,y,P=(t={})=>{const{parentOrigin:r="*",methods:n={},timeout:o,debug:i=!1}=t,c=s(i),u=a("Child",c),{destroy:w,onDestroy:g}=u,l=j(n),S=v(r,l,u,c);return{promise:new Promise(((t,n)=>{const i=O(o,w),a=r=>{if((()=>{try{clearTimeout()}catch(e){return!1}return!0})()&&r.source===parent&&r.data&&r.data.penpal===e.SynAck){const e=S(r);e&&(window.removeEventListener(d.Message,a),i(),t(e))}};window.addEventListener(d.Message,a),(()=>{c("Child: Handshake - Sending SYN");const t={penpal:e.Syn},n=r instanceof RegExp?"*":r;window.parent.postMessage(t,n)})(),g((e=>{window.removeEventListener(d.Message,a),e&&n(e)}))})),destroy(){w()}}};function f(e){return{isOk:!0,isError:!1,ok:e,error:void 0}}function F(e){return{isOk:!1,isError:!0,ok:void 0,error:e}}(y=p||(p={}))[y.error=0]="error",y[y.ok=1]="ok",window.registeredFunctions=new Map,window.registeredEventFunctions=new Map,window.listenerEventShimFunctions=new Map;const A=setInterval((()=>{null!=window.editorObject&&null!=window.OnEditorEvent&&Z()}),500),E=(e,t)=>{try{return window.registeredFunctions.set(e,new Function(t)),f(void 0)}catch(e){return F(e.toString())}},G=(e,t)=>{try{return window.editorObject.AddListener(e),window.registeredEventFunctions.set(e,new Function("targetID",t)),f(void 0)}catch(e){return F(e.toString())}},I=(e,t)=>{try{const r=window.registeredFunctions.get(e);return null!=r?Promise.resolve(r(...t)).then((e=>f(e)),(e=>F(e.toString()))):Promise.resolve(F(`Function ${e} not found`))}catch(e){return Promise.resolve(F(e.toString()))}},C=(e,t)=>{try{return window.editorObject.Alert(e,t),f(void 0)}catch(e){return F(e.toString())}},k=()=>{try{return f(window.editorObject.GetDirtyState())}catch(e){return F(e.toString())}},N=()=>{try{return window.editorObject.NextPage(),f(void 0)}catch(e){return F(e.toString())}},L=()=>{try{return window.editorObject.PreviousPage(),f(void 0)}catch(e){return F(e.toString())}},$=e=>{try{return window.editorObject.SetSelectedPage(e),f(void 0)}catch(e){return F(e.toString())}},R=()=>{try{return f(window.editorObject.GetSelectedPage())}catch(e){return F(e.toString())}},x=()=>{try{return f(window.editorObject.GetSelectedPageName())}catch(e){return F(e.toString())}},D=()=>{try{return f(window.editorObject.GetNumPages())}catch(e){return F(e.toString())}},M=e=>{try{return window.editorObject.RemoveListener(e),f(void 0)}catch(e){return F(e.toString())}},V=e=>{try{return window.editorObject.AddListener(e),f(void 0)}catch(e){return F(e.toString())}},T=e=>{try{return f(window.editorObject.GetObject(e))}catch(e){return F(e.toString())}},H=(e,t,r)=>{try{return window.editorObject.SetProperty(e,t,r),f(void 0)}catch(e){return F(e.toString())}},K=(e,t,r)=>{try{return f(window.editorObject.ExecuteFunction(e,t,...r))}catch(e){return F(e.toString())}},Y=(e,t,r,n,o,i)=>{try{return f(window.editorObject.GetPageSnapshot(e,t,r,n,o,i))}catch(e){return F(e.toString())}},U=(e,t,r)=>{try{return f(window.editorObject.GetFrameSnapshot(e,t,r))}catch(e){return F(e.toString())}},q=e=>{try{return f(window.editorObject.GetFrameSubjectArea(e))}catch(e){return F(e.toString())}},z=(e,t,r,n,o)=>{try{return window.editorObject.SetFrameSubjectArea(e,t,r,n,o),f(void 0)}catch(e){return F(e.toString())}},B=e=>{try{return window.editorObject.ClearFrameSubjectArea(e),f(void 0)}catch(e){return F(e.toString())}},J=e=>{try{return f(window.editorObject.GetAssetSubjectInfo(e))}catch(e){return F(e.toString())}},Q=(e,t,r,n,o,i,c)=>{try{return window.editorObject.SetAssetSubjectInfo(e,t,r,n,o,i,c),f(void 0)}catch(e){return F(e.toString())}},W=e=>{try{return window.editorObject.ClearAssetSubjectInfo(e),f(void 0)}catch(e){return F(e.toString())}},X=(e,t)=>{try{return window.editorObject.SetVariableIsLocked(e,t),f(void 0)}catch(e){return F(e.toString())}},Z=()=>{clearInterval(A);const e=P({methods:{registerFunction:E,registerFunctionOnEvent:G,executeRegisteredFunction:I,alert:C,getDirtyState:k,nextPage:N,previousPage:L,setSelectedPage:$,getSelectedPage:R,getSelectedPageName:x,getNumPages:D,removeListener:M,addListener:V,setProperty:H,getObject:T,executeFunction:K,getPageSnapshot:Y,getFrameSnapshot:U,getFrameSubjectArea:q,setFrameSubjectArea:z,clearFrameSubjectArea:B,getAssetSubjectInfo:J,setAssetSubjectInfo:Q,clearAssetSubjectInfo:W,setVariableIsLocked:X}});window.publisher={customFunction:{register:te(((e,t)=>{const r=E(e,t);if(r.isError)throw new Error(r.error);return r.ok})),registerOnEvent:te(((e,t)=>{const r=G(e,t);if(r.isError)throw new Error(r.error);return r.ok})),execute:(e,...t)=>I(e,t).then((e=>{if(e.isError)throw new Error(e.error);return e.ok}))},alert:te(window.editorObject.Alert),getDirtyState:te(window.editorObject.GetDirtyState),nextPage:te(window.editorObject.NextPage),previousPage:te(window.editorObject.PreviousPage),setSelectedPage:te(window.editorObject.SetSelectedPage),getSelectedPage:te(window.editorObject.GetSelectedPage),getSelectedPageName:te(window.editorObject.GetSelectedPageName),getNumPages:te(window.editorObject.GetNumPages),removeListener:te(ee),addListener:te(_),getObject:te(window.editorObject.GetObject),setProperty:te(window.editorObject.SetProperty),executeFunction:te(window.editorObject.ExecuteFunction),getPageSnapshot:te(window.editorObject.GetPageSnapshot),getFrameSnapshot:te(window.editorObject.GetFrameSnapshot),getFrameSubjectArea:te(window.editorObject.GetFrameSubjectArea),setFrameSubjectArea:te(window.editorObject.SetFrameSubjectArea),clearFrameSubjectArea:te(window.editorObject.ClearFrameSubjectArea),getAssetSubjectInfo:te(window.editorObject.GetAssetSubjectInfo),setAssetSubjectInfo:te(window.editorObject.SetAssetSubjectInfo),clearAssetSubjectInfo:te(window.editorObject.ClearAssetSubjectInfo),setVariableIsLocked:te(window.editorObject.SetVariableIsLocked),editorObject:{Alert:te(window.editorObject.Alert),GetDirtyState:te(window.editorObject.GetDirtyState),NextPage:te(window.editorObject.NextPage),PreviousPage:te(window.editorObject.PreviousPage),SetSelectedPage:te(window.editorObject.SetSelectedPage),GetSelectedPage:te(window.editorObject.GetSelectedPage),GetSelectedPageName:te(window.editorObject.GetSelectedPageName),GetNumPages:te(window.editorObject.GetNumPages),RemoveListener:te(ee),AddListener:te(_),GetObject:te(window.editorObject.GetObject),SetProperty:te(window.editorObject.SetProperty),ExecuteFunction:te(window.editorObject.ExecuteFunction),GetPageSnapshot:te(window.editorObject.GetPageSnapshot),GetFrameSnapshot:te(window.editorObject.GetFrameSnapshot),GetFrameSubjectArea:te(window.editorObject.GetFrameSubjectArea),SetFrameSubjectArea:te(window.editorObject.SetFrameSubjectArea),ClearFrameSubjectArea:te(window.editorObject.ClearFrameSubjectArea),GetAssetSubjectInfo:te(window.editorObject.GetAssetSubjectInfo),SetAssetSubjectInfo:te(window.editorObject.SetAssetSubjectInfo),ClearAssetSubjectInfo:te(window.editorObject.ClearAssetSubjectInfo),SetVariableIsLocked:te(window.editorObject.SetVariableIsLocked)}},window.OnEditorEvent=(t,r)=>{const n=window.registeredEventFunctions.get(t);null!=n&&n(r);const o=window.listenerEventShimFunctions.get(t);null!=o&&o(r),e.promise.then((e=>{e.handleEvents(t,r)}))}};function _(e,t){window.editorObject.AddListener(e),null!=t&&window.listenerEventShimFunctions.set(e,t)}function ee(e){window.editorObject.RemoveListener(e),window.listenerEventShimFunctions.delete(e)}function te(e){return(...t)=>Promise.resolve(e(...t))}})();
//# sourceMappingURL=chiliInternalWrapper.min.js.map

@@ -1,2 +0,2 @@

var e,t,r,i,o,n,s,c,a,d,h,u,l={};e=l,t="PublisherInterface",r=()=>T,i=e=>T=e,Object.defineProperty(e,t,{get:r,set:i,enumerable:!0,configurable:!0}),(n=o||(o={})).Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",(c=s||(s={})).Fulfilled="fulfilled",c.Rejected="rejected",(d=a||(a={})).ConnectionDestroyed="ConnectionDestroyed",d.ConnectionTimeout="ConnectionTimeout",d.NoIframeSrc="NoIframeSrc",(h||(h={})).DataCloneError="DataCloneError",(u||(u={})).Message="message";var g=(e,t)=>{const r=[];let i=!1;return{destroy(o){i||(i=!0,t(`${e}: Destroying connection`),r.forEach((e=>{e(o)})))},onDestroy(e){i?e():r.push(e)}}},f=e=>(...t)=>{e&&console.log("[Penpal]",...t)};const v={"http:":"80","https:":"443"},b=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,m=["file:","data:"];var w=e=>{if(e&&m.find((t=>e.startsWith(t))))return"null";const t=document.location,r=b.exec(e);let i,o,n;r?(i=r[1]?r[1]:t.protocol,o=r[2],n=r[4]):(i=t.protocol,o=t.hostname,n=t.port);return`${i}//${o}${n&&n!==v[i]?`:${n}`:""}`};const p=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r}),E=e=>{const t=new Error;return Object.keys(e).forEach((r=>t[r]=e[r])),t};var y=(e,t,r)=>{const{localName:i,local:n,remote:c,originForSending:a,originForReceiving:d}=e;let l=!1;const g=e=>{if(e.source!==c||e.data.penpal!==o.Call)return;if("*"!==d&&e.origin!==d)return void r(`${i} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:g,id:f}=n;r(`${i}: Received ${u}() call`);const v=e=>t=>{if(r(`${i}: Sending ${u}() reply`),l)return void r(`${i}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:o.Reply,id:f,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(n.returnValue=p(t),n.returnValueIsError=!0);try{c.postMessage(n,a)}catch(e){if(e.name===h.DataCloneError){const t={penpal:o.Reply,id:f,resolution:s.Rejected,returnValue:p(e),returnValueIsError:!0};c.postMessage(t,a)}throw e}};new Promise((e=>e(t[u].apply(t,g)))).then(v(s.Fulfilled),v(s.Rejected))};return n.addEventListener(u.Message,g),()=>{l=!0,n.removeEventListener(u.Message,g)}};let S=0;const P=e=>e?e.split("."):[],L=(e,t,r)=>{const i=P(t);return i.reduce(((e,t,o)=>(void 0===e[t]&&(e[t]={}),o===i.length-1&&(e[t]=r),e[t])),e),e},j=(e,t)=>{const r={};return Object.keys(e).forEach((i=>{const o=e[i],n=((e,t)=>{const r=P(t||"");return r.push(e),(e=>e.join("."))(r)})(i,t);"object"==typeof o&&Object.assign(r,j(o,n)),"function"==typeof o&&(r[n]=o)})),r},D=e=>{const t={};for(const r in e)L(t,r,e[r]);return t};var F=(e,t,r,i,n)=>{const{localName:c,local:d,remote:h,originForSending:l,originForReceiving:g}=t;let f=!1;n(`${c}: Connecting call sender`);const v=e=>(...t)=>{let r;n(`${c}: Sending ${e}() call`);try{h.closed&&(r=!0)}catch(e){r=!0}if(r&&i(),f){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=a.ConnectionDestroyed,t}return new Promise(((r,i)=>{const a=++S,f=t=>{if(t.source!==h||t.data.penpal!==o.Reply||t.data.id!==a)return;if("*"!==g&&t.origin!==g)return void n(`${c} received message from origin ${t.origin} which did not match expected origin ${g}`);const l=t.data;n(`${c}: Received ${e}() reply`),d.removeEventListener(u.Message,f);let v=l.returnValue;l.returnValueIsError&&(v=E(v)),(l.resolution===s.Fulfilled?r:i)(v)};d.addEventListener(u.Message,f);const v={penpal:o.Call,id:a,methodName:e,args:t};h.postMessage(v,l)}))},b=r.reduce(((e,t)=>(e[t]=v(t),e)),{});return Object.assign(e,D(b)),()=>{f=!0}},A=(e,t,r,i,o)=>{const{destroy:n,onDestroy:s}=i;let c,a;const d={};return i=>{if("*"!==t&&i.origin!==t)return void o(`Parent: Handshake - Received ACK message from origin ${i.origin} which did not match expected origin ${t}`);o("Parent: Handshake - Received ACK");const h={localName:"Parent",local:window,remote:i.source,originForSending:r,originForReceiving:t};c&&c(),c=y(h,e,o),s(c),a&&a.forEach((e=>{delete d[e]})),a=i.data.methodNames;const u=F(d,h,a,n,o);return s(u),d}},k=(e,t,r,i)=>n=>{if(!n.source)return;if("*"!==r&&n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:o.SynAck,methodNames:Object.keys(t)};n.source.postMessage(s,i)};var I=(e,t)=>{const{destroy:r,onDestroy:i}=t,o=setInterval((()=>{e.isConnected||(clearInterval(o),r())}),6e4);i((()=>{clearInterval(o)}))},$=(e,t)=>{let r;return void 0!==e&&(r=window.setTimeout((()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=a.ConnectionTimeout,t(r)}),e)),()=>{clearTimeout(r)}},C=e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=a.NoIframeSrc,e}},N=e=>{let{iframe:t,methods:r={},childOrigin:i,timeout:n,debug:s=!1}=e;const c=f(s),a=g("Parent",c),{onDestroy:d,destroy:h}=a;i||(C(t),i=w(t.src));const l="null"===i?"*":i,v=j(r),b=k(c,v,i,l),m=A(v,i,l,a,c);return{promise:new Promise(((e,r)=>{const i=$(n,h),s=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==o.Syn)if(r.data.penpal!==o.Ack);else{const t=m(r);t&&(i(),e(t))}else b(r)};window.addEventListener(u.Message,s),c("Parent: Awaiting handshake"),I(t,a),d((e=>{window.removeEventListener(u.Message,s),e&&r(e)}))})),destroy(){h()}}};var R,x=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((i=i.apply(e,t||[])).next())}))},O=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},M=function(e,t,r,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,r):o?o.value=r:t.set(e,r),r};class T{constructor(){this.chiliEventListenerCallbacks=new Map,this.debug=!1,this.creationTime="",R.set(this,null),this.getProperty=this.getObject}static build(e,t={}){var r;return x(this,void 0,void 0,(function*(){const i=new T;i.child=yield N({iframe:e,methods:{handleEvents:i.handleEvents.bind(i)},timeout:t.timeout,debug:t.penpalDebug}).promise,i.debug=null!==(r=t.penpalDebug)&&void 0!==r&&r,i.creationTime=(new Date).toLocaleString(),i.createDebugLog("build()");const o=t.events;if(null!=o&&o.length>0)for(const e of o)"string"==typeof e?i.addListener(e):i.addListener(e.name,e.func);return i}))}handleEvents(e,t){var r;return this.chiliEventListenerCallbacks.has(e)&&(null===(r=this.chiliEventListenerCallbacks.get(e))||void 0===r||r(t)),e}createDebugLog(e){this.debug&&console.log(`[PublisherInterface - ${this.creationTime}]`,`Creating ${e} call request`)}get editorObject(){return null==O(this,R,"f")&&M(this,R,{Alert:this.alert.bind(this),GetDirtyState:this.getDirtyState.bind(this),NextPage:this.nextPage.bind(this),PreviousPage:this.previousPage.bind(this),SetSelectedPage:this.setSelectedPage.bind(this),GetSelectedPage:this.getSelectedPage.bind(this),GetSelectedPageName:this.getSelectedPageName.bind(this),GetNumPages:this.getNumPages.bind(this),RemoveListener:this.removeListener.bind(this),AddListener:this.addListener.bind(this),GetObject:this.getObject.bind(this),SetProperty:this.setProperty.bind(this),ExecuteFunction:this.executeFunction.bind(this),GetPageSnapshot:this.getPageSnapshot.bind(this),GetFrameSnapshot:this.getFrameSnapshot.bind(this),GetFrameSubjectArea:this.getFrameSubjectArea.bind(this),SetFrameSubjectArea:this.setFrameSubjectArea.bind(this),ClearFrameSubjectArea:this.clearFrameSubjectArea.bind(this),GetAssetSubjectInfo:this.getAssetSubjectInfo.bind(this),SetAssetSubjectInfo:this.setAssetSubjectInfo.bind(this),ClearAssetSubjectInfo:this.clearAssetSubjectInfo.bind(this),SetVariableIsLocked:this.setVariableIsLocked.bind(this)},"f"),O(this,R,"f")}registerFunction(e,t){return x(this,void 0,void 0,(function*(){this.createDebugLog("registerFunction()");const r=yield this.child.registerFunction(e,t);if(r.isError)throw new Error(r.error)}))}registerFunctionOnEvent(e,t){return x(this,void 0,void 0,(function*(){this.createDebugLog("registerFunction()");const r=yield this.child.registerFunctionOnEvent(e,t);if(r.isError)throw new Error(r.error)}))}runRegisteredFunction(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("runReisteredFunction()");const t=yield this.child.runRegisteredFunction(e);if(t.isError)throw new Error(t.error);return t.ok}))}alert(e,t){return x(this,void 0,void 0,(function*(){this.createDebugLog("alert()");const r=yield this.child.alert(e,t);if(r.isError)throw new Error(r.error)}))}getDirtyState(){return x(this,void 0,void 0,(function*(){this.createDebugLog("getDirtyState()");const e=yield this.child.getDirtyState();if(e.isError)throw new Error(e.error);return e.ok}))}nextPage(){return x(this,void 0,void 0,(function*(){this.createDebugLog("nextPage()");const e=yield this.child.nextPage();if(e.isError)throw new Error(e.error)}))}previousPage(){return x(this,void 0,void 0,(function*(){this.createDebugLog("previousPage()");const e=yield this.child.previousPage();if(e.isError)throw new Error(e.error)}))}setSelectedPage(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("setSelectedPage()");const t=yield this.child.setSelectedPage(e);if(t.isError)throw new Error(t.error)}))}getSelectedPage(){return x(this,void 0,void 0,(function*(){this.createDebugLog("getSelectedPage()");const e=yield this.child.getSelectedPage();if(e.isError)throw new Error(e.error);return e.ok}))}getSelectedPageName(){return x(this,void 0,void 0,(function*(){this.createDebugLog("getSelectedPageName()");const e=yield this.child.getSelectedPageName();if(e.isError)throw new Error(e.error);return e.ok}))}getNumPages(){return x(this,void 0,void 0,(function*(){this.createDebugLog("getNumPages()");const e=yield this.child.getNumPages();if(e.isError)throw new Error(e.error);return e.ok}))}removeListener(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("removeListener()"),this.chiliEventListenerCallbacks.delete(e);const t=yield this.child.removeListener(e);if(t.isError)throw new Error(t.error)}))}addListener(e,t){return x(this,void 0,void 0,(function*(){this.createDebugLog("addListener()"),this.chiliEventListenerCallbacks.set(e,null==t?t=>{null!=window.OnEditorEvent&&window.OnEditorEvent(e,t)}:t);const r=yield this.child.addListener(e);if(r.isError)throw new Error(r.error)}))}getObject(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("getObject()");const t=yield this.child.getObject(e);if(t.isError)throw new Error(t.error);return t.ok}))}setProperty(e,t,r){return x(this,void 0,void 0,(function*(){this.createDebugLog("setProperty()");const i=yield this.child.setProperty(e,t,r);if(i.isError)throw new Error(i.error)}))}executeFunction(e,t,...r){return x(this,void 0,void 0,(function*(){this.createDebugLog("executeFunction()");const i=yield this.child.executeFunction(e,t,r);if(i.isError)throw new Error(i.error);return i.ok}))}getPageSnapshot(e,t,r,i,o,n){return x(this,void 0,void 0,(function*(){this.createDebugLog("getPageSnapshot()");const s=yield this.child.getPageSnapshot(e,t,r,i,o,n);if(s.isError)throw new Error(s.error);return s.ok}))}getFrameSnapshot(e,t,r){return x(this,void 0,void 0,(function*(){this.createDebugLog("getFrameSnapshot()");const i=yield this.child.getFrameSnapshot(e,t,r);if(i.isError)throw new Error(i.error);return i.ok}))}getFrameSubjectArea(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("getFrameSubjectArea()");const t=yield this.child.getFrameSubjectArea(e);if(t.isError)throw new Error(t.error);return t.ok}))}setFrameSubjectArea(e,t,r,i,o){return x(this,void 0,void 0,(function*(){this.createDebugLog("setFrameSubjectArea()");const n=yield this.child.setFrameSubjectArea(e,t,r,i,o);if(n.isError)throw new Error(n.error)}))}clearFrameSubjectArea(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("clearFrameSubjectArea()");const t=yield this.child.clearFrameSubjectArea(e);if(t.isError)throw new Error(t.error)}))}getAssetSubjectInfo(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("getAssetSubjectInfo()");const t=yield this.child.getAssetSubjectInfo(e);if(t.isError)throw new Error(t.error);return t.ok}))}setAssetSubjectInfo(e,t,r,i,o,n,s){return x(this,void 0,void 0,(function*(){this.createDebugLog("setAssetSubjectInfo()");const c=yield this.child.setAssetSubjectInfo(e,t,r,i,o,n,s);if(c.isError)throw new Error(c.error)}))}clearAssetSubjectInfo(e){return x(this,void 0,void 0,(function*(){this.createDebugLog("clearAssetSubjectInfo()");const t=yield this.child.clearAssetSubjectInfo(e);if(t.isError)throw new Error(t.error)}))}setVariableIsLocked(e,t){return x(this,void 0,void 0,(function*(){this.createDebugLog("setVariableIsLocked()");const r=yield this.child.setVariableIsLocked(e,t);if(r.isError)throw new Error(r.error)}))}}R=new WeakMap;export{T as PublisherInterface,l as default};
var e,t,r,i,o,n,s,c,a,d,u,h,l={};e=l,t="PublisherInterface",r=()=>T,i=e=>T=e,Object.defineProperty(e,t,{get:r,set:i,enumerable:!0,configurable:!0}),(n=o||(o={})).Call="call",n.Reply="reply",n.Syn="syn",n.SynAck="synAck",n.Ack="ack",(c=s||(s={})).Fulfilled="fulfilled",c.Rejected="rejected",(d=a||(a={})).ConnectionDestroyed="ConnectionDestroyed",d.ConnectionTimeout="ConnectionTimeout",d.NoIframeSrc="NoIframeSrc",(u||(u={})).DataCloneError="DataCloneError",(h||(h={})).Message="message";var g=(e,t)=>{const r=[];let i=!1;return{destroy(o){i||(i=!0,t(`${e}: Destroying connection`),r.forEach((e=>{e(o)})))},onDestroy(e){i?e():r.push(e)}}},f=e=>(...t)=>{e&&console.log("[Penpal]",...t)};const v={"http:":"80","https:":"443"},b=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,m=["file:","data:"];var w=e=>{if(e&&m.find((t=>e.startsWith(t))))return"null";const t=document.location,r=b.exec(e);let i,o,n;r?(i=r[1]?r[1]:t.protocol,o=r[2],n=r[4]):(i=t.protocol,o=t.hostname,n=t.port);return`${i}//${o}${n&&n!==v[i]?`:${n}`:""}`};const E=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r}),p=e=>{const t=new Error;return Object.keys(e).forEach((r=>t[r]=e[r])),t};var y=(e,t,r)=>{const{localName:i,local:n,remote:c,originForSending:a,originForReceiving:d}=e;let l=!1;const g=e=>{if(e.source!==c||e.data.penpal!==o.Call)return;if("*"!==d&&e.origin!==d)return void r(`${i} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:h,args:g,id:f}=n;r(`${i}: Received ${h}() call`);const v=e=>t=>{if(r(`${i}: Sending ${h}() reply`),l)return void r(`${i}: Unable to send ${h}() reply due to destroyed connection`);const n={penpal:o.Reply,id:f,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(n.returnValue=E(t),n.returnValueIsError=!0);try{c.postMessage(n,a)}catch(e){if(e.name===u.DataCloneError){const t={penpal:o.Reply,id:f,resolution:s.Rejected,returnValue:E(e),returnValueIsError:!0};c.postMessage(t,a)}throw e}};new Promise((e=>e(t[h].apply(t,g)))).then(v(s.Fulfilled),v(s.Rejected))};return n.addEventListener(h.Message,g),()=>{l=!0,n.removeEventListener(h.Message,g)}};let S=0;const P=e=>e?e.split("."):[],L=(e,t,r)=>{const i=P(t);return i.reduce(((e,t,o)=>(void 0===e[t]&&(e[t]={}),o===i.length-1&&(e[t]=r),e[t])),e),e},j=(e,t)=>{const r={};return Object.keys(e).forEach((i=>{const o=e[i],n=((e,t)=>{const r=P(t||"");return r.push(e),(e=>e.join("."))(r)})(i,t);"object"==typeof o&&Object.assign(r,j(o,n)),"function"==typeof o&&(r[n]=o)})),r},F=e=>{const t={};for(const r in e)L(t,r,e[r]);return t};var D=(e,t,r,i,n)=>{const{localName:c,local:d,remote:u,originForSending:l,originForReceiving:g}=t;let f=!1;n(`${c}: Connecting call sender`);const v=e=>(...t)=>{let r;n(`${c}: Sending ${e}() call`);try{u.closed&&(r=!0)}catch(e){r=!0}if(r&&i(),f){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=a.ConnectionDestroyed,t}return new Promise(((r,i)=>{const a=++S,f=t=>{if(t.source!==u||t.data.penpal!==o.Reply||t.data.id!==a)return;if("*"!==g&&t.origin!==g)return void n(`${c} received message from origin ${t.origin} which did not match expected origin ${g}`);const l=t.data;n(`${c}: Received ${e}() reply`),d.removeEventListener(h.Message,f);let v=l.returnValue;l.returnValueIsError&&(v=p(v)),(l.resolution===s.Fulfilled?r:i)(v)};d.addEventListener(h.Message,f);const v={penpal:o.Call,id:a,methodName:e,args:t};u.postMessage(v,l)}))},b=r.reduce(((e,t)=>(e[t]=v(t),e)),{});return Object.assign(e,F(b)),()=>{f=!0}},A=(e,t,r,i,o)=>{const{destroy:n,onDestroy:s}=i;let c,a;const d={};return i=>{if("*"!==t&&i.origin!==t)return void o(`Parent: Handshake - Received ACK message from origin ${i.origin} which did not match expected origin ${t}`);o("Parent: Handshake - Received ACK");const u={localName:"Parent",local:window,remote:i.source,originForSending:r,originForReceiving:t};c&&c(),c=y(u,e,o),s(c),a&&a.forEach((e=>{delete d[e]})),a=i.data.methodNames;const h=D(d,u,a,n,o);return s(h),d}},k=(e,t,r,i)=>n=>{if(!n.source)return;if("*"!==r&&n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:o.SynAck,methodNames:Object.keys(t)};n.source.postMessage(s,i)};var I=(e,t)=>{const{destroy:r,onDestroy:i}=t,o=setInterval((()=>{e.isConnected||(clearInterval(o),r())}),6e4);i((()=>{clearInterval(o)}))},$=(e,t)=>{let r;return void 0!==e&&(r=window.setTimeout((()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=a.ConnectionTimeout,t(r)}),e)),()=>{clearTimeout(r)}},C=e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=a.NoIframeSrc,e}},N=e=>{let{iframe:t,methods:r={},childOrigin:i,timeout:n,debug:s=!1}=e;const c=f(s),a=g("Parent",c),{onDestroy:d,destroy:u}=a;i||(C(t),i=w(t.src));const l="null"===i?"*":i,v=j(r),b=k(c,v,i,l),m=A(v,i,l,a,c);return{promise:new Promise(((e,r)=>{const i=$(n,u),s=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==o.Syn)if(r.data.penpal!==o.Ack);else{const t=m(r);t&&(i(),e(t))}else b(r)};window.addEventListener(h.Message,s),c("Parent: Awaiting handshake"),I(t,a),d((e=>{window.removeEventListener(h.Message,s),e&&r(e)}))})),destroy(){u()}}};var x,R=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((i=i.apply(e,t||[])).next())}))},O=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},M=function(e,t,r,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,r):o?o.value=r:t.set(e,r),r};class T{constructor(){this.customFunction={register:function(e,t){throw new Error("Function not implemented.")},registerOnEvent:function(e,t){throw new Error("Function not implemented.")},execute:function(e,t){throw new Error("Function not implemented.")}},this.chiliEventListenerCallbacks=new Map,this.debug=!1,this.creationTime="",x.set(this,null),this.getProperty=this.getObject}static build(e,t={}){var r;return R(this,void 0,void 0,(function*(){const i=new T;var o,n;i.child=yield N({iframe:e,methods:{handleEvents:i.handleEvents.bind(i)},timeout:t.timeout,debug:t.penpalDebug}).promise,i.customFunction=(o=i.child,n=i.createDebugLog.bind(i),{register:function(e,t){return R(this,void 0,void 0,(function*(){n("registerFunction()");const r=yield o.registerFunction(e,t);if(r.isError)throw new Error(r.error)}))},registerOnEvent:function(e,t){return R(this,void 0,void 0,(function*(){n("registerFunction()");const r=yield o.registerFunctionOnEvent(e,t);if(r.isError)throw new Error(r.error)}))},execute:function(e,...t){return R(this,void 0,void 0,(function*(){n("executeRegisteredFunction()");const r=yield o.executeRegisteredFunction(e,t);if(r.isError)throw new Error(r.error);return r.ok}))}}),i.debug=null!==(r=t.penpalDebug)&&void 0!==r&&r,i.creationTime=(new Date).toLocaleString(),i.createDebugLog("build()");const s=t.events;if(null!=s&&s.length>0)for(const e of s)"string"==typeof e?i.addListener(e):i.addListener(e.name,e.func);return i}))}handleEvents(e,t){var r;return this.chiliEventListenerCallbacks.has(e)&&(null===(r=this.chiliEventListenerCallbacks.get(e))||void 0===r||r(t)),e}createDebugLog(e){this.debug&&console.log(`[PublisherInterface - ${this.creationTime}]`,`Creating ${e} call request`)}get editorObject(){return null==O(this,x,"f")&&M(this,x,{Alert:this.alert.bind(this),GetDirtyState:this.getDirtyState.bind(this),NextPage:this.nextPage.bind(this),PreviousPage:this.previousPage.bind(this),SetSelectedPage:this.setSelectedPage.bind(this),GetSelectedPage:this.getSelectedPage.bind(this),GetSelectedPageName:this.getSelectedPageName.bind(this),GetNumPages:this.getNumPages.bind(this),RemoveListener:this.removeListener.bind(this),AddListener:this.addListener.bind(this),GetObject:this.getObject.bind(this),SetProperty:this.setProperty.bind(this),ExecuteFunction:this.executeFunction.bind(this),GetPageSnapshot:this.getPageSnapshot.bind(this),GetFrameSnapshot:this.getFrameSnapshot.bind(this),GetFrameSubjectArea:this.getFrameSubjectArea.bind(this),SetFrameSubjectArea:this.setFrameSubjectArea.bind(this),ClearFrameSubjectArea:this.clearFrameSubjectArea.bind(this),GetAssetSubjectInfo:this.getAssetSubjectInfo.bind(this),SetAssetSubjectInfo:this.setAssetSubjectInfo.bind(this),ClearAssetSubjectInfo:this.clearAssetSubjectInfo.bind(this),SetVariableIsLocked:this.setVariableIsLocked.bind(this)},"f"),O(this,x,"f")}alert(e,t){return R(this,void 0,void 0,(function*(){this.createDebugLog("alert()");const r=yield this.child.alert(e,t);if(r.isError)throw new Error(r.error)}))}getDirtyState(){return R(this,void 0,void 0,(function*(){this.createDebugLog("getDirtyState()");const e=yield this.child.getDirtyState();if(e.isError)throw new Error(e.error);return e.ok}))}nextPage(){return R(this,void 0,void 0,(function*(){this.createDebugLog("nextPage()");const e=yield this.child.nextPage();if(e.isError)throw new Error(e.error)}))}previousPage(){return R(this,void 0,void 0,(function*(){this.createDebugLog("previousPage()");const e=yield this.child.previousPage();if(e.isError)throw new Error(e.error)}))}setSelectedPage(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("setSelectedPage()");const t=yield this.child.setSelectedPage(e);if(t.isError)throw new Error(t.error)}))}getSelectedPage(){return R(this,void 0,void 0,(function*(){this.createDebugLog("getSelectedPage()");const e=yield this.child.getSelectedPage();if(e.isError)throw new Error(e.error);return e.ok}))}getSelectedPageName(){return R(this,void 0,void 0,(function*(){this.createDebugLog("getSelectedPageName()");const e=yield this.child.getSelectedPageName();if(e.isError)throw new Error(e.error);return e.ok}))}getNumPages(){return R(this,void 0,void 0,(function*(){this.createDebugLog("getNumPages()");const e=yield this.child.getNumPages();if(e.isError)throw new Error(e.error);return e.ok}))}removeListener(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("removeListener()"),this.chiliEventListenerCallbacks.delete(e);const t=yield this.child.removeListener(e);if(t.isError)throw new Error(t.error)}))}addListener(e,t){return R(this,void 0,void 0,(function*(){this.createDebugLog("addListener()"),this.chiliEventListenerCallbacks.set(e,null==t?t=>{null!=window.OnEditorEvent&&window.OnEditorEvent(e,t)}:t);const r=yield this.child.addListener(e);if(r.isError)throw new Error(r.error)}))}getObject(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("getObject()");const t=yield this.child.getObject(e);if(t.isError)throw new Error(t.error);return t.ok}))}setProperty(e,t,r){return R(this,void 0,void 0,(function*(){this.createDebugLog("setProperty()");const i=yield this.child.setProperty(e,t,r);if(i.isError)throw new Error(i.error)}))}executeFunction(e,t,...r){return R(this,void 0,void 0,(function*(){this.createDebugLog("executeFunction()");const i=yield this.child.executeFunction(e,t,r);if(i.isError)throw new Error(i.error);return i.ok}))}getPageSnapshot(e,t,r,i,o,n){return R(this,void 0,void 0,(function*(){this.createDebugLog("getPageSnapshot()");const s=yield this.child.getPageSnapshot(e,t,r,i,o,n);if(s.isError)throw new Error(s.error);return s.ok}))}getFrameSnapshot(e,t,r){return R(this,void 0,void 0,(function*(){this.createDebugLog("getFrameSnapshot()");const i=yield this.child.getFrameSnapshot(e,t,r);if(i.isError)throw new Error(i.error);return i.ok}))}getFrameSubjectArea(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("getFrameSubjectArea()");const t=yield this.child.getFrameSubjectArea(e);if(t.isError)throw new Error(t.error);return t.ok}))}setFrameSubjectArea(e,t,r,i,o){return R(this,void 0,void 0,(function*(){this.createDebugLog("setFrameSubjectArea()");const n=yield this.child.setFrameSubjectArea(e,t,r,i,o);if(n.isError)throw new Error(n.error)}))}clearFrameSubjectArea(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("clearFrameSubjectArea()");const t=yield this.child.clearFrameSubjectArea(e);if(t.isError)throw new Error(t.error)}))}getAssetSubjectInfo(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("getAssetSubjectInfo()");const t=yield this.child.getAssetSubjectInfo(e);if(t.isError)throw new Error(t.error);return t.ok}))}setAssetSubjectInfo(e,t,r,i,o,n,s){return R(this,void 0,void 0,(function*(){this.createDebugLog("setAssetSubjectInfo()");const c=yield this.child.setAssetSubjectInfo(e,t,r,i,o,n,s);if(c.isError)throw new Error(c.error)}))}clearAssetSubjectInfo(e){return R(this,void 0,void 0,(function*(){this.createDebugLog("clearAssetSubjectInfo()");const t=yield this.child.clearAssetSubjectInfo(e);if(t.isError)throw new Error(t.error)}))}setVariableIsLocked(e,t){return R(this,void 0,void 0,(function*(){this.createDebugLog("setVariableIsLocked()");const r=yield this.child.setVariableIsLocked(e,t);if(r.isError)throw new Error(r.error)}))}}x=new WeakMap;export{T as PublisherInterface,l as default};
//# sourceMappingURL=PublisherInterface.min.js.map

@@ -18,4 +18,28 @@ export type buildOptions = {

};
export type CustomFunctionsInterface = {
/**
* Register a custom function on the iframe window side. The function takes a parameter: publisher. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param name - The name of the function to register.
* @param body - The body of the function.
*/
register: (name: string, body: string) => Promise<void>;
/**
* Register a custom function on the iframe window side that runs when an event is called. The function takes two parameters: publisher and targetID. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param eventName - The name of the event to trigger the function.
* @param body - The body of the function.
*/
registerOnEvent: (eventName: string, body: string) => Promise<void>;
/**
* Executes a function that was registered originally by registerFunction on the iframe window side and allows you to pass any number of args. It will return the result of the called function.
*
* @param name - The name of the function to run.
* @param args - Arguments that will be passed to the function
*/
execute: (name: string, ...args: any) => Promise<any>;
};
export class PublisherInterface {
#private;
customFunction: CustomFunctionsInterface;
private constructor();

@@ -35,22 +59,2 @@ /**

/**
* Register a custom function on the iframe side. The function takes one parameter: publisher. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param name - The name of the function to register.
* @param body - The body of the function.
*/
registerFunction(name: string, body: string): Promise<void>;
/**
* Register a custom function on the iframe side that runs when an event is called. The function takes two parameters: publisher and id. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param eventName - The name of the event to trigger the function.
* @param body - The body of the function.
*/
registerFunctionOnEvent(eventName: string, body: string): Promise<void>;
/**
* Runs function that was registered originally by reisterFunction on the iframe side.
*
* @param name - The name of the functin to run.
*/
runRegisteredFunction(name: string): Promise<string | number | boolean | object | null | undefined>;
/**
* Displays a modal box within the editor UI containing a title with a message.

@@ -120,3 +124,3 @@ *

*/
addListener(eventName: string, callbackFunction?: (targetId: string) => void): Promise<void>;
addListener(eventName: string, callbackFunction?: (target: string) => void): Promise<void>;
/**

@@ -151,6 +155,6 @@ * Gets the value of the property or object found at given chiliPath.

* @param functionName - A case-sensitive string of the name of the function to execute.
* @param params - Parameters to be passed to function of functionName.
* @param args - Parameters to be passed to function of functionName.
* @returns Returns the return of executed function.
*/
executeFunction(chiliPath: string, functionName: string, ...params: (string | number | boolean | null | undefined)[]): Promise<string | number | boolean | object | null | undefined>;
executeFunction(chiliPath: string, functionName: string, ...args: (string | number | boolean | null | undefined)[]): Promise<string | number | boolean | object | null | undefined>;
/**

@@ -157,0 +161,0 @@ * Returns a base64 encoded PNG snapshot image of a specific page.

@@ -48,5 +48,42 @@ var $7i1sb$penpal = require("penpal");

var $3db7bcc71a7ab568$var$_PublisherInterface_editorObject;
const $3db7bcc71a7ab568$var$createCustomFunctionsInterface = function(chiliWrapper, createDebugLog) {
return {
register: function(name, body) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
createDebugLog("registerFunction()");
const response = yield chiliWrapper.registerFunction(name, body);
if (response.isError) throw new Error(response.error);
});
},
registerOnEvent: function(eventName, body) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
createDebugLog("registerFunction()");
const response = yield chiliWrapper.registerFunctionOnEvent(eventName, body);
if (response.isError) throw new Error(response.error);
});
},
execute: function(name, ...args) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
createDebugLog("executeRegisteredFunction()");
const response = yield chiliWrapper.executeRegisteredFunction(name, args);
if (response.isError) throw new Error(response.error);
return response.ok;
});
}
};
};
class $3db7bcc71a7ab568$export$a13915682e709c4f {
// eslint-disable-next-line @typescript-eslint/no-empty-function
constructor(){
this.customFunction = {
register: function(name, body) {
throw new Error("Function not implemented.");
},
registerOnEvent: function(eventName, body) {
throw new Error("Function not implemented.");
},
execute: function(name, args) {
throw new Error("Function not implemented.");
}
};
this.chiliEventListenerCallbacks = new Map();

@@ -80,2 +117,3 @@ this.debug = false;

}).promise;
publisherInterface.customFunction = $3db7bcc71a7ab568$var$createCustomFunctionsInterface(publisherInterface.child, publisherInterface.createDebugLog.bind(publisherInterface));
publisherInterface.debug = (_a = options.penpalDebug) !== null && _a !== void 0 ? _a : false;

@@ -133,38 +171,2 @@ publisherInterface.creationTime = new Date().toLocaleString();

/**
* Register a custom function on the iframe side. The function takes one parameter: publisher. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param name - The name of the function to register.
* @param body - The body of the function.
*/ registerFunction(name, body) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
this.createDebugLog("registerFunction()");
const response = yield this.child.registerFunction(name, body);
if (response.isError) throw new Error(response.error);
});
}
/**
* Register a custom function on the iframe side that runs when an event is called. The function takes two parameters: publisher and id. This function has access to the window. You can access other custom functions registered using window.registeredFunctions, which is a Map.
*
* @param eventName - The name of the event to trigger the function.
* @param body - The body of the function.
*/ registerFunctionOnEvent(eventName, body) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
this.createDebugLog("registerFunction()");
const response = yield this.child.registerFunctionOnEvent(eventName, body);
if (response.isError) throw new Error(response.error);
});
}
/**
* Runs function that was registered originally by reisterFunction on the iframe side.
*
* @param name - The name of the functin to run.
*/ runRegisteredFunction(name) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
this.createDebugLog("runReisteredFunction()");
const response = yield this.child.runRegisteredFunction(name);
if (response.isError) throw new Error(response.error);
return response.ok;
});
}
/**
* Displays a modal box within the editor UI containing a title with a message.

@@ -286,4 +288,4 @@ *

this.createDebugLog("addListener()");
this.chiliEventListenerCallbacks.set(eventName, callbackFunction == null ? (targetId)=>{
if (window.OnEditorEvent != null) window.OnEditorEvent(eventName, targetId);
this.chiliEventListenerCallbacks.set(eventName, callbackFunction == null ? (targetID)=>{
if (window.OnEditorEvent != null) window.OnEditorEvent(eventName, targetID);
} : callbackFunction);

@@ -330,8 +332,8 @@ const response = yield this.child.addListener(eventName);

* @param functionName - A case-sensitive string of the name of the function to execute.
* @param params - Parameters to be passed to function of functionName.
* @param args - Parameters to be passed to function of functionName.
* @returns Returns the return of executed function.
*/ executeFunction(chiliPath, functionName, ...params) {
*/ executeFunction(chiliPath, functionName, ...args) {
return $3db7bcc71a7ab568$var$__awaiter(this, void 0, void 0, function*() {
this.createDebugLog("executeFunction()");
const response = yield this.child.executeFunction(chiliPath, functionName, params);
const response = yield this.child.executeFunction(chiliPath, functionName, args);
if (response.isError) throw new Error(response.error);

@@ -338,0 +340,0 @@ return response.ok;

{
"name": "@chili-publish/publisher-interface",
"version": "0.3.6",
"version": "0.4.0",
"author": "chili-publish",

@@ -5,0 +5,0 @@ "description": "PublisherInterface is a class object that allows you to interact with the CHILI Publisher editorObject via postMessage without the complexity of postMessage.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc