blank-web-sdk
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -65,3 +65,3 @@ var Blank = | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ return __webpack_require__(__webpack_require__.s = 6); | ||
/******/ }) | ||
@@ -73,2 +73,84 @@ /************************************************************************/ | ||
/* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(5).nextTick; | ||
var apply = Function.prototype.apply; | ||
var slice = Array.prototype.slice; | ||
var immediateIds = {}; | ||
var nextImmediateId = 0; | ||
// DOM APIs, for completeness | ||
exports.setTimeout = function() { | ||
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); | ||
}; | ||
exports.setInterval = function() { | ||
return new Timeout(apply.call(setInterval, window, arguments), clearInterval); | ||
}; | ||
exports.clearTimeout = | ||
exports.clearInterval = function(timeout) { timeout.close(); }; | ||
function Timeout(id, clearFn) { | ||
this._id = id; | ||
this._clearFn = clearFn; | ||
} | ||
Timeout.prototype.unref = Timeout.prototype.ref = function() {}; | ||
Timeout.prototype.close = function() { | ||
this._clearFn.call(window, this._id); | ||
}; | ||
// Does not start the time, just sets up the members needed. | ||
exports.enroll = function(item, msecs) { | ||
clearTimeout(item._idleTimeoutId); | ||
item._idleTimeout = msecs; | ||
}; | ||
exports.unenroll = function(item) { | ||
clearTimeout(item._idleTimeoutId); | ||
item._idleTimeout = -1; | ||
}; | ||
exports._unrefActive = exports.active = function(item) { | ||
clearTimeout(item._idleTimeoutId); | ||
var msecs = item._idleTimeout; | ||
if (msecs >= 0) { | ||
item._idleTimeoutId = setTimeout(function onTimeout() { | ||
if (item._onTimeout) | ||
item._onTimeout(); | ||
}, msecs); | ||
} | ||
}; | ||
// That's not how node.js implements it but the exposed api is the same. | ||
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { | ||
var id = nextImmediateId++; | ||
var args = arguments.length < 2 ? false : slice.call(arguments, 1); | ||
immediateIds[id] = true; | ||
nextTick(function onNextTick() { | ||
if (immediateIds[id]) { | ||
// fn.call() is faster so we optimize for the common use-case | ||
// @see http://jsperf.com/call-apply-segu | ||
if (args) { | ||
fn.apply(null, args); | ||
} else { | ||
fn.call(null); | ||
} | ||
// Prevent ids from leaking | ||
exports.clearImmediate(id); | ||
} | ||
}); | ||
return id; | ||
}; | ||
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { | ||
delete immediateIds[id]; | ||
}; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).setImmediate, __webpack_require__(0).clearImmediate)) | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
@@ -80,14 +162,17 @@ "use strict"; | ||
}); | ||
exports.WSClient = undefined; | ||
exports.DecodeJWT = exports.WSClient = undefined; | ||
var _WSClient2 = __webpack_require__(1); | ||
var _WSClient2 = __webpack_require__(2); | ||
var _WSClient3 = _interopRequireDefault(_WSClient2); | ||
var _jwt = __webpack_require__(4); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var WSClient = exports.WSClient = _WSClient3.default; | ||
var DecodeJWT = exports.DecodeJWT = _jwt.decode; | ||
/***/ }, | ||
/* 1 */ | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -104,3 +189,3 @@ | ||
var _doubleApi2 = __webpack_require__(2); | ||
var _doubleApi2 = __webpack_require__(3); | ||
@@ -179,2 +264,3 @@ var _doubleApi3 = _interopRequireDefault(_doubleApi2); | ||
this.onopen = null; | ||
this.onerror = null; | ||
@@ -471,3 +557,7 @@ Object.defineProperty(this, "state", { | ||
value: function _wsErrorHandler(err) { | ||
console.error(err); | ||
if (typeof this.onerror === "function") { | ||
this.onerror(err); | ||
} else { | ||
console.error(err); | ||
} | ||
} | ||
@@ -518,7 +608,7 @@ }, { | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(setImmediate) {"use strict"; | ||
@@ -533,3 +623,5 @@ Object.defineProperty(exports, "__esModule", { | ||
cb = function cb(e, d) { | ||
return e != null ? r(e) : f(d); | ||
return (setImmediate || setTimeout)(function () { | ||
e != null ? r(e) : f(d); | ||
}); | ||
}; | ||
@@ -542,8 +634,232 @@ }); | ||
}; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).setImmediate)) | ||
/***/ }, | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.decode = decode; | ||
function decode(token) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if (typeof token !== "string") { | ||
throw new Error("token must be a string"); | ||
} | ||
var pos = options.header === true ? 0 : 1; | ||
var base64Data = token.split(".")[pos]; | ||
var encodedData = atob(base64Data).replace(/(.)/g, function (m, p) { | ||
var code = p.charCodeAt(0).toString(16).toUpperCase(); | ||
if (code.length < 2) { | ||
code = "0" + code; | ||
} | ||
return "%" + code; | ||
}); | ||
try { | ||
var stringData = decodeURIComponent(encodedData); | ||
var data = JSON.parse(stringData); | ||
return data; | ||
// this.__setUserData({ user: { "_id": data.userId }, key: data.key }); | ||
// client.connect(); | ||
} catch (e) { | ||
throw new Error("invalid token specified: " + e.message); | ||
} | ||
} | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(0); | ||
module.exports = __webpack_require__(1); | ||
@@ -550,0 +866,0 @@ |
@@ -83,2 +83,3 @@ "use strict"; | ||
this.onopen = null; | ||
this.onerror = null; | ||
@@ -375,3 +376,7 @@ Object.defineProperty(this, "state", { | ||
value: function _wsErrorHandler(err) { | ||
console.error(err); | ||
if (typeof this.onerror === "function") { | ||
this.onerror(err); | ||
} else { | ||
console.error(err); | ||
} | ||
} | ||
@@ -378,0 +383,0 @@ }, { |
@@ -11,3 +11,5 @@ "use strict"; | ||
cb = function cb(e, d) { | ||
return e != null ? r(e) : f(d); | ||
return (setImmediate || setTimeout)(function () { | ||
e != null ? r(e) : f(d); | ||
}); | ||
}; | ||
@@ -14,0 +16,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.WSClient = undefined; | ||
exports.DecodeJWT = exports.WSClient = undefined; | ||
@@ -13,4 +13,7 @@ var _WSClient2 = require("./client/WSClient"); | ||
var _jwt = require("./jwt"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var WSClient = exports.WSClient = _WSClient3.default; | ||
var WSClient = exports.WSClient = _WSClient3.default; | ||
var DecodeJWT = exports.DecodeJWT = _jwt.decode; |
{ | ||
"name": "blank-web-sdk", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "SDK for web applications created with Blank back-end", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
51987
14
1314