add support for nodejs require in clientside util and rpc modules

pull/1/head
ansuz 5 years ago
parent 0abb4f222d
commit 03bfb57051

@ -1,7 +1,5 @@
(function (window) {
define([], function () {
var Util = window.CryptPad_Util = {};
var Util = {};
Util.mkAsync = function (f) {
return function () {
var args = Array.prototype.slice.call(arguments);
@ -349,6 +347,14 @@ define([], function () {
return false;
};
return Util;
});
}(self));
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;
});
} else {
window.CryptPad_Util = Util;
}
}(typeof(self) !== 'undefined'? self: this));

@ -1,9 +1,5 @@
define([
'/common/common-util.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
], function (Util) {
var Nacl = window.nacl;
(function () {
var factory = function (Util, Nacl) {
var uid = Util.uid;
var signMsg = function (data, signKey) {
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
@ -337,4 +333,18 @@ types of messages:
};
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…
Cancel
Save