add support for nodejs require in clientside util and rpc modules
This commit is contained in:
parent
0abb4f222d
commit
03bfb57051
@ -1,7 +1,5 @@
|
|||||||
(function (window) {
|
(function (window) {
|
||||||
define([], function () {
|
var Util = {};
|
||||||
var Util = window.CryptPad_Util = {};
|
|
||||||
|
|
||||||
Util.mkAsync = function (f) {
|
Util.mkAsync = function (f) {
|
||||||
return function () {
|
return function () {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
@ -349,6 +347,14 @@ define([], function () {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
|
module.exports = Util;
|
||||||
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
|
define([], function () {
|
||||||
|
window.CryptPad_Util = Util;
|
||||||
return Util;
|
return Util;
|
||||||
});
|
});
|
||||||
}(self));
|
} else {
|
||||||
|
window.CryptPad_Util = Util;
|
||||||
|
}
|
||||||
|
}(typeof(self) !== 'undefined'? self: this));
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
define([
|
(function () {
|
||||||
'/common/common-util.js',
|
var factory = function (Util, Nacl) {
|
||||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
|
||||||
], function (Util) {
|
|
||||||
var Nacl = window.nacl;
|
|
||||||
|
|
||||||
var uid = Util.uid;
|
var uid = Util.uid;
|
||||||
var signMsg = function (data, signKey) {
|
var signMsg = function (data, signKey) {
|
||||||
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
|
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
|
||||||
@ -337,4 +333,18 @@ types of messages:
|
|||||||
};
|
};
|
||||||
|
|
||||||
return { create: create, createAnonymous: createAnonymous };
|
return { create: create, createAnonymous: createAnonymous };
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
|
module.exports = factory(require("./common-util"), require("tweetnacl"));
|
||||||
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
|
define([
|
||||||
|
'/common/common-util.js',
|
||||||
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||||
|
], function (Util) {
|
||||||
|
return factory(Util, window.Nacl);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// I'm not gonna bother supporting any other kind of instanciation
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user