Socket
Socket
Sign inDemoInstall

crossframe

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crossframe - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "crossframe",
"version": "2.0.0",
"version": "2.0.1",
"description": "Send messages between a page and its (sandboxed) iframes with ease.",

@@ -5,0 +5,0 @@ "main": "src/crossframe.js",

@@ -7,6 +7,5 @@ /*

(function() {
var EVENT_MESSAGE = 'CF2_MESSAGE';
var EVENT_READY = 'CF2_READY';
var webviewReady = false;

@@ -27,5 +26,5 @@ var webviewReadyFns = [];

function CrossFrame( el, opts ) {
this._opts = opts || {};
if( typeof this._opts.delay !== 'number' ) {

@@ -44,10 +43,10 @@ this._opts.delay = 50;

this._post = this._post.bind(this);
this._destroyed = false;
this._posting = false;
this._postNext = this._postNext.bind(this);
this._postQueue = [];
this._el = el;
this._el = el;
this._clear();
if( webview ) {

@@ -62,9 +61,9 @@ if( document && document.addEventListener ) {

}
if( webview ) {
onWebviewReady(function(){
this._ready();
this._ready();
}.bind(this));
} else {
this._ready();
this._ready();
}

@@ -82,3 +81,3 @@

this._isReady = false;
if( webview ) {

@@ -93,8 +92,10 @@ if( document && document.removeEventListener ) {

}
}
this._destroyed = true;
};
CrossFrame.prototype._debug = function(){
if( window.DEBUG )
console.log.bind( null, '[CrossFrame]' ).apply( null, arguments );
}
};

@@ -104,5 +105,5 @@ CrossFrame.prototype.onMessage = function( e ){

if( e.data.indexOf(EVENT_MESSAGE) !== 0 ) return;
this._debug('onMessage', e)
this._debug('onMessage', e);
var str = e.data;

@@ -119,6 +120,6 @@ str = str.substr( EVENT_MESSAGE.length );

callbackId: obj.callbackId
}
};
this.postMessage( message );
}.bind(this)
}.bind(this);

@@ -138,3 +139,3 @@ var eventListeners = this._eventlisteners[ obj.event ];

}
}
};

@@ -146,6 +147,5 @@ CrossFrame.prototype.on = function( event, callback ) {

return this;
}
};
CrossFrame.prototype.emit = function( event, data, callback ) {
var callbackId = null;

@@ -162,3 +162,3 @@ if( typeof callback === 'function' ) {

callbackId: callbackId
}
};

@@ -168,46 +168,45 @@ this.postMessage( message );

return this;
}
};
CrossFrame.prototype.destroy = function(){
this._clear();
}
};
CrossFrame.prototype.ready = function( callback ){
if( this._isReady ) {
callback();
} else {
} else {
this._readyFns.push( callback );
}
}
};
CrossFrame.prototype._ready = function() {
this._isReady = true;
this._readyFns.forEach(function(readyFn){
readyFn();
});
}
};
CrossFrame.prototype.postReady = function( message ) {
this._post( EVENT_READY );
}
};
CrossFrame.prototype.postMessage = function( message ) {
this._post( EVENT_MESSAGE + hexEncode( objToJson(message) ) );
}
};
CrossFrame.prototype._post = function( message ) {
this._debug('_post()', message);
this._postQueue.push( message );
this._postNext();
}
};
CrossFrame.prototype._postNext = function() {
if( this._destroyed ) return;
if( this._posting ) return;
var message = this._postQueue.shift();

@@ -226,3 +225,3 @@ if( typeof message === 'undefined' ) return;

target.postMessage( message, '*' );
setTimeout(function(){

@@ -233,4 +232,3 @@ this._posting = false;

}
}
};

@@ -243,3 +241,3 @@ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {

}
function onWebviewReady( callback ) {

@@ -252,6 +250,6 @@ if( webviewReady ) {

}
function getParameterByName(name, url) {
if( window
&& window.location
if( window
&& window.location
&& window.location.href ) {

@@ -266,3 +264,3 @@ if (!url) url = window.location.href;

}
return '';

@@ -294,6 +292,6 @@ }

}
function hexEncode(input){
var hex, i;
var result = "";

@@ -304,3 +302,3 @@ for (i=0; i<input.length; i++) {

}
return result

@@ -316,6 +314,5 @@ }

}
return back;
}
})()
})();
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