Socket
Socket
Sign inDemoInstall

jsbridge

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsbridge - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

140

dist/index.js

@@ -1,139 +0,1 @@

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
/**
* Creator: yeliex
* Project: rkjsbridge
* Description:
*/
(function (env) {
var baseUrl = '';
var isJson = false;
var callbackStack = {};
var invoke = function invoke(url, params, callback) {
if (!baseUrl) {
throw 'jsbridge must be initialized at least once';
}
url = url.replace(/^\//, '').replace(/\/$/, '');
callbackStack['callback_' + Date.parse(new Date())] = callback;
var reqUrl = '' + baseUrl + url + (isJson ? '/' + JSON.stringify(params) : '?' + Object.keys(params).map(function (key) {
return key + '=' + params[key];
}).join('&'));
var request = document.createElement('IFRAME');
request.setAttribute("src", reqUrl);
document.documentElement.appendChild(request);
request.parentNode.removeChild(request);
request = null;
return true;
};
var callback = function callback(callbackName, params) {
try {
params = JSON.parse(params);
} catch (e) {
console.warn('JSBridge callback params should be JSON object with stringify \n returns ' + (typeof params === 'undefined' ? 'undefined' : _typeof(params)) + ' \n ' + params);
}
// do callback
if (!callbackStack || !callbackStack[callbackName]) {
throw 'cannot find callback function ' + callbackName + ' in ' + Object.keys(callbackStack);
}
try {
callbackStack[callbackName](params);
} catch (e) {
console.error(e);
} finally {
delete callbackStack[callbackName];
}
return true;
};
var init = function init() {
var protocol = arguments.length <= 0 || arguments[0] === undefined ? 'jsbridge' : arguments[0];
var hostname = arguments[1];
var port = arguments[2];
var json = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
if (port && !Number.isInteger(Number(port))) {
throw 'port must be number';
}
baseUrl = protocol.replace(/:|\//g, '') + '://' + hostname + (hostname && port ? ':' + port + '/' : '/');
isJson = json;
return {
invoke: invoke, callback: callback
};
};
var that = {
init: init,
callback: callback,
invoke: invoke
};
if (_typeof(env.module) === 'object') {
module.exports = init;
}
env.JSBridge = that;
})(undefined);
/***/ }
/******/ ]);
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};!function(t){var r="",o=!1,i={},c=function(e,t,n){if(!r)throw"jsbridge must be initialized at least once";e=e.replace(/^\//,"").replace(/\/$/,""),i["callback_"+Date.parse(new Date)]=n;var c=""+r+e+(o?"/"+JSON.stringify(t):"?"+Object.keys(t).map(function(e){return e+"="+t[e]}).join("&")),a=document.createElement("IFRAME");return a.setAttribute("src",c),document.documentElement.appendChild(a),a.parentNode.removeChild(a),a=null,!0},a=function(e,t){try{t=JSON.parse(t)}catch(r){console.warn("JSBridge callback params should be JSON object with stringify \n returns "+("undefined"==typeof t?"undefined":n(t))+" \n "+t)}if(!i||!i[e])throw"cannot find callback function "+e+" in "+Object.keys(i);try{i[e](t)}catch(r){console.error(r)}finally{delete i[e]}return!0},l=function(){var e=arguments.length<=0||void 0===arguments[0]?"jsbridge":arguments[0],t=arguments[1],n=arguments[2],i=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];if(n&&!Number.isInteger(Number(n)))throw"port must be number";return r=e.replace(/:|\//g,"")+"://"+t+(t&&n?":"+n+"/":"/"),o=i,{invoke:c,callback:a}},u={init:l,callback:a,invoke:c};"object"===n(t.module)&&(e.exports=l),t.JSBridge=u}(window||void 0)}]);

2

package.json
{
"name": "jsbridge",
"version": "1.0.4",
"version": "1.0.5",
"description": "JSBridge for jsvascript by yeliex",

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

@@ -84,2 +84,2 @@ /**

env.JSBridge = that;
})(this);
})(window || this);

@@ -24,3 +24,10 @@ /**

]
}
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
};

Sorry, the diff of this file is not supported yet

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