Commit 26f7e25d authored by Guillaume Royer's avatar Guillaume Royer

chore: fix to use require

parent 56eb48fa
...@@ -162,13 +162,7 @@ ${JIONODELATEST}: ${JIONODEVERSION} ...@@ -162,13 +162,7 @@ ${JIONODELATEST}: ${JIONODEVERSION}
cp $< $@ cp $< $@
${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \ ${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
${EXTERNALDIR}/rsvp-2.0.4.js \
${EXTERNALDIR}/moment.js \
${EXTERNALDIR}/URI.js \
${EXTERNALDIR}/uritemplate.js \
${EXTERNALDIR}/rusha.js \
${SRCDIR}/node/jio-external.js \ ${SRCDIR}/node/jio-external.js \
${EXTERNALDIR}/xhr2.js \
${SRCDIR}/queries/parser-begin.js \ ${SRCDIR}/queries/parser-begin.js \
${SRCDIR}/queries/build/parser.js \ ${SRCDIR}/queries/build/parser.js \
${SRCDIR}/queries/parser-end.js \ ${SRCDIR}/queries/parser-end.js \
......
...@@ -20,6 +20,15 @@ ...@@ -20,6 +20,15 @@
"output", "output",
"cloud" "cloud"
], ],
"dependencies": {
"form-data": "^2.3.2",
"moment": "^2.21.0",
"rsvp": "git+https://lab.nexedi.com/nexedi/rsvp.js.git",
"rusha": "0.8.2",
"urijs": "^1.19.1",
"uritemplate": "git+https://lab.nexedi.com/nexedi/uritemplate-js.git",
"xhr2": "git+https://github.com/clearroad/node-xhr2.git"
},
"engines": { "engines": {
"npm": ">=1.3" "npm": ">=1.3"
} }
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
}); });
}; };
window.Blob = Blob;//window.Blob || Blob; window.Blob = window.Blob || Blob;
function FileReader() { function FileReader() {
EventTarget.call(this); EventTarget.call(this);
...@@ -220,8 +220,7 @@ ...@@ -220,8 +220,7 @@
}(window, WeakMap, ArrayBuffer, Uint8Array)); }(window, WeakMap, ArrayBuffer, Uint8Array));
var XMLHttpRequest = global.XMLHttpRequest || module.exports, var Blob = window.Blob,
Blob = window.Blob,
atob = window.atob, atob = window.atob,
btoa = window.btoa, btoa = window.btoa,
FileReader = window.FileReader, FileReader = window.FileReader,
......
module = node_module;
jIO.node_env = window; jIO.node_env = window;
module.exports = jIO; module.exports = window;
}({}));
} ({}));
\ No newline at end of file
var RSVP = window.RSVP, var RSVP = require('rsvp'),
moment = global.moment, moment = require('moment'),
UriTemplate = window.UriTemplate, Rusha = require('rusha'),
Rusha = window.Rusha; XMLHttpRequest = require('xhr2'),
FormData = require('form-data'),
URI = require('urijs'),
UriTemplate = require('uritemplate'),
process = require('process');
// Allow xhr2 to export XMLHttpRequest window.moment = moment;
module = {}; window.FormData = window.FormData || FormData;
window.XMLHttpRequest = window.XMLHttpRequest || XMLHttpRequest;
(function (define, exports) { (function (window) {
var navigator = null, var navigator = {};
window = {},
node_module = module;
module = undefined;
...@@ -19,12 +19,9 @@ ...@@ -19,12 +19,9 @@
*/ */
/*global window, ArrayBuffer */ /*global window, ArrayBuffer */
(function (window, jIO, Blob, ArrayBuffer) { (function (jIO, Blob, FormData, ArrayBuffer) {
"use strict"; "use strict";
var FormData,
originalAjax;
function convertToBlob(evt, convert) { function convertToBlob(evt, convert) {
if (convert && evt.target.response instanceof ArrayBuffer) { if (convert && evt.target.response instanceof ArrayBuffer) {
evt.target.response = new Blob([evt.target.response]); evt.target.response = new Blob([evt.target.response]);
...@@ -32,23 +29,7 @@ ...@@ -32,23 +29,7 @@
return evt; return evt;
} }
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/ var originalAjax = jIO.util.ajax;
// Using_XMLHttpRequest#Submitting_forms_and_uploading_files
FormData = function FormData() {
this.boundary = "---------------------------" + Date.now().toString(16);
this.body = '';
};
FormData.prototype.append = function (name, value, filename) {
this.body += '--' + this.boundary +
'\r\nContent-Disposition: form-data; name="' + name;
if (filename !== undefined) {
this.body += '"; filename="' + filename;
}
this.body += '"\r\n\r\n' + value + '\r\n';
};
window.FormData = FormData;
originalAjax = jIO.util.ajax;
jIO.util.ajax = function ajax(param) { jIO.util.ajax = function ajax(param) {
var convertToArrayBuffer = param.dataType === 'blob'; var convertToArrayBuffer = param.dataType === 'blob';
if (convertToArrayBuffer) { if (convertToArrayBuffer) {
...@@ -81,9 +62,8 @@ ...@@ -81,9 +62,8 @@
}); });
}; };
}(window, window.jIO, window.Blob, ArrayBuffer)); }(window.jIO, window.Blob, window.FormData, ArrayBuffer));
// Define a global variable to allow storages to access jIO // Define a global variable to allow storages to access jIO
var jIO = window.jIO, var jIO = window.jIO,
FormData = window.FormData,
jiodate = window.jiodate; jiodate = window.jiodate;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment