Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ekolabs/iframily

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ekolabs/iframily - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

3

dist/iframily.min.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Iframily=t():e.Iframily=t()}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";e.exports={PARENT:"parent",CHILD:"child",FRAMILY_ID_PREFIX:"__iframily__",FRAMILY_INIT:"iframily_init",FRAMILY_INIT_SUCCESSFUL:"iframily_init_successful",ATTEMPT_TO_CONNECT_INTERVAL:200}},function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(0),o=["sendMessage","dispose"];e.exports=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=t,this._onPairedHandler=i.onPairedHandler||function(){},this._onDisposedHandler=i.onDisposedHandler||function(){},this._targetOrigin=i.targetOrigin||"*",this._iframilyUid="".concat(r.FRAMILY_ID_PREFIX).concat(this._id),this._msgHandler=n||function(){},this._hasConnected=!1,this._disposed=!1,this._msgQueue=[],this._pendingCb={},this._cbUid=0,this._bindPublicMethods(),this._init()}var t,n,s;return t=e,(n=[{key:"_bindPublicMethods",value:function(){o.forEach(function(e){this[e]=this[e].bind(this)}.bind(this))}},{key:"_init",value:function(){throw new Error("To be overridden in extending classes.")}},{key:"_sendQueuedMessages",value:function(){this._msgQueue.forEach((function(e){e()})),this._msgQueue=[]}},{key:"_postMessage",value:function(e){try{this._targetWindow.postMessage(e,this._targetOrigin)}catch(e){console.error("[Iframily] - Error when posting message:",e)}}},{key:"_sendMessage",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={_iframilyUid:this._iframilyUid,_fromType:this._iframilyType,msg:e};t&&(this._cbUid++,this._pendingCb[this._cbUid]=t,i._cbUid=this._cbUid),this._hasConnected||n.forceSend?this._postMessage(i):(console.warn("[Iframily] - No one connected yet, queuing message:",e),this._msgQueue.push(this._postMessage.bind(this,i)))}},{key:"_sendResponse",value:function(e,t){var n={_iframilyUid:this._iframilyUid,_fromType:this._iframilyType,_isResponse:!0,_cbUid:e,_isResolved:t.isResolved,_isRejected:t.isRejected,_cbResolveValue:t.value,_cbRejectError:t.err};this._postMessage(n)}},{key:"_handleMessage",value:function(e){var t=this;e._isResponse?this._handleResponse(e):Promise.resolve().then((function(){return t._msgHandler(e.msg)})).then((function(n){t._sendResponse(e._cbUid,{isResolved:!0,value:n})})).catch((function(n){t._sendResponse(e._cbUid,{isRejected:!0,err:n})}))}},{key:"_handleResponse",value:function(e){if(e._cbUid){var t=this._pendingCb[e._cbUid];if(e._isResolved)t.resolve(e._cbResolveValue);else{if(!e._isRejected)throw new Error("Missing resolve/reject information on response: ".concat(e));t.reject(e._cbRejectError)}delete this._pendingCb[e._cbUid]}}},{key:"_displayDisposedError",value:function(){console.error("[Iframily] - Attempting to use a disposed instance")}},{key:"sendMessage",value:function(e){var t=this;return this._disposed?this._displayDisposedError():new Promise((function(n,i){t._sendMessage(e,{resolve:n,reject:i})}))}},{key:"dispose",value:function(){if(this._disposed)return this._displayDisposedError();this._hasConnected=!1,this._msgQueue=[],this._disposed=!0,this._onDisposedHandler()}},{key:"disposed",get:function(){return this._disposed}},{key:"id",get:function(){return this._id}}])&&i(t.prototype,n),s&&i(t,s),e}()},function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(3),o=n(4),s=n(0),a={},c={};e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,u;return t=e,u=[{key:"initParent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!a[e]||a[e].disposed)return a[e]=new o(e,t,n),a[e];console.error('[Iframily] - A parent iframily with id "'.concat(e,'" was already inited, please use another id or dispose the existing one first.'))}},{key:"initChild",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!c[e]||c[e].disposed)return c[e]=new r(e,t,n),c[e];console.error('[Iframily] - A child iframily with id "'.concat(e,'" was already inited, please use another id or dispose the existing one first.'))}},{key:"isIframilyMessage",value:function(e){var t=e&&e.data;return t&&t._iframilyUid&&t._iframilyUid.includes(s.FRAMILY_ID_PREFIX)}}],(n=null)&&i(t.prototype,n),u&&i(t,u),e}()},function(e,t,n){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(n):r.value}})(e,t,n||e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=f(e);if(t){var r=f(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=n(1),d=n(0);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,i,u=c(l);function l(){return r(this,l),u.apply(this,arguments)}return t=l,(n=[{key:"_init",value:function(){var e=this;this._iframilyType=d.CHILD,this._targetWindow=window.parent,this._handleMessage=this._handleMessage.bind(this),window.addEventListener("message",this._handleMessage),this._attemptToConnectInterval=setInterval(function t(){return e._sendMessage(d.FRAMILY_INIT,null,{forceSend:!0}),t}(),d.ATTEMPT_TO_CONNECT_INTERVAL)}},{key:"_handleMessage",value:function(e){var t=e&&e.data;t&&t._iframilyUid===this._iframilyUid&&t._fromType===d.PARENT&&(this._hasConnected||t.msg!==d.FRAMILY_INIT_SUCCESSFUL?this._hasConnected&&s(f(l.prototype),"_handleMessage",this).call(this,t):(this._hasConnected=!0,clearInterval(this._attemptToConnectInterval),this._onPairedHandler(),this._sendQueuedMessages()))}},{key:"dispose",value:function(){s(f(l.prototype),"dispose",this).call(this),window.removeEventListener("message",this._handleMessage),clearInterval(this._attemptToConnectInterval)}}])&&o(t.prototype,n),i&&o(t,i),l}(l)},function(e,t,n){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(n):r.value}})(e,t,n||e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=f(e);if(t){var r=f(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=n(1),d=n(0);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,i,u=c(l);function l(){return r(this,l),u.apply(this,arguments)}return t=l,(n=[{key:"_init",value:function(){this._iframilyType=d.PARENT,this._handleMessage=this._handleMessage.bind(this),window.addEventListener("message",this._handleMessage)}},{key:"_handleMessage",value:function(e){var t=e&&e.data;if(t&&t._iframilyUid===this._iframilyUid&&t._fromType===d.CHILD)if(t.msg===d.FRAMILY_INIT){if(!this._hasConnected)for(var n=document.getElementsByTagName("iframe"),i=0;i<n.length;i++)if(n[i].contentWindow===e.source){this._targetWindow=n[i].contentWindow,this._hasConnected=!0,this._onPairedHandler(),this._sendMessage(d.FRAMILY_INIT_SUCCESSFUL),this._sendQueuedMessages();break}}else this._hasConnected&&s(f(l.prototype),"_handleMessage",this).call(this,t)}},{key:"dispose",value:function(){s(f(l.prototype),"dispose",this).call(this),window.removeEventListener("message",this._handleMessage)}}])&&o(t.prototype,n),i&&o(t,i),l}(l)}])}));
//# sourceMappingURL=iframily.min.js.map
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Iframily=t():e.Iframily=t()}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";e.exports={PARENT:"parent",CHILD:"child",FRAMILY_ID_PREFIX:"__iframily__",FRAMILY_INIT:"iframily_init",FRAMILY_INIT_SUCCESSFUL:"iframily_init_successful",ATTEMPT_TO_CONNECT_INTERVAL:200}},function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(0),o=["sendMessage","dispose"];e.exports=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=t,this._onPairedHandler=i.onPairedHandler||function(){},this._onDisposedHandler=i.onDisposedHandler||function(){},this._targetOrigin=i.targetOrigin||"*",this._iframilyUid="".concat(r.FRAMILY_ID_PREFIX).concat(this._id),this._msgHandler=n||function(){},this._hasConnected=!1,this._disposed=!1,this._msgQueue=[],this._pendingCb={},this._cbUid=0,this._bindPublicMethods(),this._init()}var t,n,s;return t=e,(n=[{key:"_bindPublicMethods",value:function(){o.forEach(function(e){this[e]=this[e].bind(this)}.bind(this))}},{key:"_init",value:function(){throw new Error("To be overridden in extending classes.")}},{key:"_sendQueuedMessages",value:function(){this._msgQueue.forEach((function(e){e()})),this._msgQueue=[]}},{key:"_postMessage",value:function(e){try{this._targetWindow.postMessage(e,this._targetOrigin)}catch(e){console.error("[Iframily] - Error when posting message:",e)}}},{key:"_sendMessage",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={_iframilyUid:this._iframilyUid,_fromType:this._iframilyType,msg:e};t&&(this._cbUid++,this._pendingCb[this._cbUid]=t,i._cbUid=this._cbUid),this._hasConnected||n.forceSend?this._postMessage(i):(console.warn("[Iframily] - No one connected yet, queuing message:",e),this._msgQueue.push(this._postMessage.bind(this,i)))}},{key:"_sendResponse",value:function(e,t){var n={_iframilyUid:this._iframilyUid,_fromType:this._iframilyType,_isResponse:!0,_cbUid:e,_isResolved:t.isResolved,_isRejected:t.isRejected,_cbResolveValue:t.value,_cbRejectError:t.err};this._postMessage(n)}},{key:"_handleMessage",value:function(e){var t=this;e._isResponse?this._handleResponse(e):Promise.resolve().then((function(){return t._msgHandler(e.msg)})).then((function(n){t._sendResponse(e._cbUid,{isResolved:!0,value:n})})).catch((function(n){t._sendResponse(e._cbUid,{isRejected:!0,err:n})}))}},{key:"_handleResponse",value:function(e){if(e._cbUid){var t=this._pendingCb[e._cbUid];if(e._isResolved)t.resolve(e._cbResolveValue);else{if(!e._isRejected)throw new Error("Missing resolve/reject information on response: ".concat(e));t.reject(e._cbRejectError)}delete this._pendingCb[e._cbUid]}}},{key:"_displayDisposedError",value:function(){console.error("[Iframily] - Attempting to use a disposed instance")}},{key:"sendMessage",value:function(e){var t=this;return this._disposed?this._displayDisposedError():new Promise((function(n,i){t._sendMessage(e,{resolve:n,reject:i})}))}},{key:"dispose",value:function(){if(this._disposed)return this._displayDisposedError();this._hasConnected=!1,this._msgQueue=[],this._disposed=!0,this._onDisposedHandler()}},{key:"disposed",get:function(){return this._disposed}},{key:"id",get:function(){return this._id}}])&&i(t.prototype,n),s&&i(t,s),e}()},function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(3),o=n(4),s=n(0),a={},c={};e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,u;return t=e,u=[{key:"initParent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!a[e]||a[e].disposed)return a[e]=new o(e,t,n),a[e];console.error('[Iframily] - A parent iframily with id "'.concat(e,'" was already inited, please use another id or dispose the existing one first.'))}},{key:"initChild",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!c[e]||c[e].disposed)return c[e]=new r(e,t,n),c[e];console.error('[Iframily] - A child iframily with id "'.concat(e,'" was already inited, please use another id or dispose the existing one first.'))}},{key:"isIframilyMessage",value:function(e){var t=e&&e.data;return t&&t._iframilyUid&&t._iframilyUid.includes(s.FRAMILY_ID_PREFIX)}}],(n=null)&&i(t.prototype,n),u&&i(t,u),e}()},function(e,t,n){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(n):r.value}})(e,t,n||e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=f(e);if(t){var r=f(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=n(1),d=n(0);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,i,u=c(l);function l(){return r(this,l),u.apply(this,arguments)}return t=l,(n=[{key:"_init",value:function(){var e=this;this._iframilyType=d.CHILD,this._targetWindow=window.parent,this._handleMessage=this._handleMessage.bind(this),window.addEventListener("message",this._handleMessage),this._attemptToConnectInterval=setInterval(function t(){return e._sendMessage(d.FRAMILY_INIT,null,{forceSend:!0}),t}(),d.ATTEMPT_TO_CONNECT_INTERVAL)}},{key:"_handleMessage",value:function(e){var t=e&&e.data;t&&t._iframilyUid===this._iframilyUid&&t._fromType===d.PARENT&&(this._hasConnected||t.msg!==d.FRAMILY_INIT_SUCCESSFUL?this._hasConnected&&s(f(l.prototype),"_handleMessage",this).call(this,t):(this._hasConnected=!0,clearInterval(this._attemptToConnectInterval),this._onPairedHandler(),this._sendQueuedMessages()))}},{key:"dispose",value:function(){s(f(l.prototype),"dispose",this).call(this),window.removeEventListener("message",this._handleMessage),clearInterval(this._attemptToConnectInterval)}}])&&o(t.prototype,n),i&&o(t,i),l}(l)},function(e,t,n){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(n):r.value}})(e,t,n||e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=f(e);if(t){var r=f(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=n(1),d=n(0);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(l,e);var t,n,i,u=c(l);function l(){return r(this,l),u.apply(this,arguments)}return t=l,(n=[{key:"_init",value:function(){this._iframilyType=d.PARENT,this._handleMessage=this._handleMessage.bind(this),window.addEventListener("message",this._handleMessage)}},{key:"_handleMessage",value:function(e){var t=e&&e.data;if(t&&t._iframilyUid===this._iframilyUid&&t._fromType===d.CHILD)if(t.msg===d.FRAMILY_INIT){if(!this._hasConnected)for(var n=document.getElementsByTagName("iframe"),i=0;i<n.length;i++)if(n[i].contentWindow===e.source){this._targetWindow=n[i].contentWindow,this._hasConnected=!0,this._onPairedHandler(),this._sendMessage(d.FRAMILY_INIT_SUCCESSFUL),this._sendQueuedMessages();break}}else this._hasConnected&&s(f(l.prototype),"_handleMessage",this).call(this,t)}},{key:"dispose",value:function(){s(f(l.prototype),"dispose",this).call(this),window.removeEventListener("message",this._handleMessage)}}])&&o(t.prototype,n),i&&o(t,i),l}(l)}])}));
{
"name": "@ekolabs/iframily",
"version": "0.1.2",
"version": "0.1.3",
"description": "Modern iframes communication",

@@ -5,0 +5,0 @@ "main": "dist/iframily.min.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc