...
 
Commits (6)
*
!dist/jio-latest-node.js
!dist/jio-latest.js
!README.md
!COPYING
!package.json
......@@ -150,7 +150,8 @@ ${JIOVERSION}: ${EXTERNALDIR}/URI.js \
${SRCDIR}/jio.storage/cryptstorage.js \
${SRCDIR}/jio.storage/websqlstorage.js \
${SRCDIR}/jio.storage/fbstorage.js \
${SRCDIR}/jio.storage/cloudooostorage.js
${SRCDIR}/jio.storage/cloudooostorage.js \
${SRCDIR}/jio.storage/mappingstorage.js
@mkdir -p $(@D)
cat $^ > $@
......@@ -189,6 +190,7 @@ ${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
${SRCDIR}/jio.storage/drivetojiomapping.js \
${SRCDIR}/jio.storage/documentstorage.js \
${SRCDIR}/jio.storage/fbstorage.js \
${SRCDIR}/jio.storage/mappingstorage.js \
${SRCDIR}/node/jio-end.js
@mkdir -p $(@D)
cat $^ > $@
......
// Generated by CoffeeScript 1.12.2
// Generated by CoffeeScript 1.12.7
(function() {
var InvalidStateError, NetworkError, ProgressEvent, SecurityError, SyntaxError, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, http, https, os, url,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
......@@ -323,7 +323,7 @@
'access-control-request-method': true,
connection: true,
'content-length': true,
// cookie: true,
cookie: true,
cookie2: true,
date: true,
dnt: true,
......@@ -341,7 +341,7 @@
};
XMLHttpRequest.prototype._privateHeaders = {
// 'set-cookie': true,
'set-cookie': true,
'set-cookie2': true
};
......@@ -363,6 +363,7 @@
};
XMLHttpRequest.prototype._sendHttp = function(data) {
var that;
if (this._sync) {
throw new Error("Synchronous XHR processing not implemented");
}
......@@ -372,9 +373,11 @@
} else {
data || (data = '');
}
this.upload._setData(data);
this._finalizeHeaders();
this._sendHxxpRequest();
that = this;
this.upload._setData(data, function() {
that._finalizeHeaders();
return that._sendHxxpRequest();
});
return void 0;
};
......@@ -709,11 +712,13 @@
XMLHttpRequest.XMLHttpRequest = XMLHttpRequest;
XMLHttpRequest.FormData = FormData;
SecurityError = (function(superClass) {
extend(SecurityError, superClass);
function SecurityError() {
SecurityError.__super__.constructor.apply(this, arguments);
SecurityError.__super__.constructor.call(this);
}
return SecurityError;
......@@ -726,7 +731,7 @@
extend(InvalidStateError, superClass);
function InvalidStateError() {
InvalidStateError.__super__.constructor.apply(this, arguments);
InvalidStateError.__super__.constructor.call(this);
}
return InvalidStateError;
......@@ -750,7 +755,7 @@
extend(NetworkError, superClass);
function NetworkError() {
NetworkError.__super__.constructor.apply(this, arguments);
NetworkError.__super__.constructor.call(this);
}
return NetworkError;
......@@ -763,7 +768,7 @@
extend(SyntaxError, superClass);
function SyntaxError() {
SyntaxError.__super__.constructor.apply(this, arguments);
SyntaxError.__super__.constructor.call(this);
}
return SyntaxError;
......@@ -813,10 +818,10 @@
return void 0;
};
XMLHttpRequestUpload.prototype._setData = function(data) {
var body, i, j, k, offset, ref, ref1, view;
XMLHttpRequestUpload.prototype._setData = function(data, cb) {
var body, i, j, k, offset, ref, ref1, that, view;
if (typeof data === 'undefined' || data === null) {
return;
return cb();
}
if (typeof data === 'string') {
if (data.length !== 0) {
......@@ -840,10 +845,23 @@
body[i] = view[i + offset];
}
this._body = body;
} else if (data instanceof FormData) {
body = '';
this._contentType = data.getHeaders()['content-type'];
data.on('data', function(data) {
return body += data.toString();
});
that = this;
data.on('end', function() {
that._body = body;
return cb();
});
data.resume();
return;
} else {
throw new Error("Unsupported send() data " + data);
}
return void 0;
return cb();
};
XMLHttpRequestUpload.prototype._finalizeHeaders = function(headers, loweredHeaders) {
......@@ -872,4 +890,4 @@
XMLHttpRequest.XMLHttpRequestUpload = XMLHttpRequestUpload;
}).call(this);
\ No newline at end of file
}).call(this);
......@@ -20,6 +20,15 @@
"output",
"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": {
"npm": ">=1.3"
}
......
......@@ -65,8 +65,8 @@
* @return {Promise} The promise
*/
function ajax(param) {
var xhr = new XMLHttpRequest();
return new RSVP.Promise(function (resolve, reject) {
var xhr = new window.XMLHttpRequest();
return new RSVP.Promise(function (resolve, reject, notify) {
var k;
xhr.open(param.type || "GET", param.url, true);
xhr.responseType = param.dataType || "";
......@@ -84,6 +84,11 @@
resolve(e);
});
xhr.addEventListener("error", reject);
xhr.addEventListener("progress", function (e) {
if (notify) {
notify(e);
}
});
if (typeof param.xhrFields === 'object' && param.xhrFields !== null) {
for (k in param.xhrFields) {
if (param.xhrFields.hasOwnProperty(k)) {
......
......@@ -38,10 +38,11 @@
if (options.xhrFields === undefined) {
options.xhrFields = {};
}
if (storage._access_token !== undefined) {
if (storage._access_token) {
if (options.headers === undefined) {
options.headers = {};
}
options.headers.Accept = "*/*";
options.headers['X-ACCESS-TOKEN'] = storage._access_token;
options.xhrFields.withCredentials = false;
} else {
......
module = node_module;
jIO.node_env = window;
module.exports = jIO;
} ({}));
\ No newline at end of file
module.exports = window;
}({}));
var RSVP = window.RSVP,
moment = global.moment,
UriTemplate = window.UriTemplate,
Rusha = window.Rusha;
var RSVP = require('rsvp'),
moment = require('moment'),
Rusha = require('rusha'),
XMLHttpRequest = require('xhr2'),
FormData = require('form-data'),
URI = require('urijs'),
UriTemplate = require('uritemplate'),
process = require('process');
// Allow xhr2 to export XMLHttpRequest
module = {};
window.moment = moment;
window.FormData = window.FormData || FormData;
window.XMLHttpRequest = window.XMLHttpRequest || XMLHttpRequest;
(function (define, exports) {
var navigator = null,
window = {},
node_module = module;
module = undefined;
(function (window) {
var navigator = {};
......@@ -18,13 +18,20 @@
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*global window */
(function (window, jIO, Blob) {
/*global window, ArrayBuffer */
(function (window, jIO, Blob, ArrayBuffer) {
"use strict";
var FormData,
originalAjax;
function convertToBlob(evt, convert) {
if (convert && evt.target.response instanceof ArrayBuffer) {
evt.target.response = new Blob([evt.target.response]);
}
return evt;
}
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
// Using_XMLHttpRequest#Submitting_forms_and_uploading_files
FormData = function FormData() {
......@@ -43,11 +50,17 @@
originalAjax = jIO.util.ajax;
jIO.util.ajax = function ajax(param) {
var convertToArrayBuffer = param.dataType === 'blob';
if (convertToArrayBuffer) {
param.dataType = 'arraybuffer';
}
if (param.data instanceof Blob) {
// Blob is not supported by xhr2, so convert to ArrayBuffer instead
return jIO.util.readBlobAsArrayBuffer(param.data).then(function (data) {
param.data = data.target.result;
return originalAjax(param);
return originalAjax(param).then(function (evt) {
return convertToBlob(evt, convertToArrayBuffer);
});
});
}
......@@ -63,10 +76,12 @@
return originalAjax(param);
}
return originalAjax(param);
return originalAjax(param).then(function (evt) {
return convertToBlob(evt, convertToArrayBuffer);
});
};
}(window, window.jIO, window.Blob));
}(window, window.jIO, window.Blob, ArrayBuffer));
// Define a global variable to allow storages to access jIO
var jIO = window.jIO,
......
......@@ -162,15 +162,14 @@ parse: function parse(input) {
vstack.length = vstack.length - n;
lstack.length = lstack.length - n;
}
_token_stack:
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
};
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];
......
......@@ -332,7 +332,7 @@
}
}
if (option.sort_on) {
if (option.sort_on && option.sort_on.length) {
sortOn(option.sort_on, item_list, this._key_schema);
}
......