Skip to content

Commit 3bf212a

Browse files
committed
build
1 parent 6cd0632 commit 3bf212a

File tree

1 file changed

+82
-88
lines changed

1 file changed

+82
-88
lines changed

build/jsroot.js

Lines changed: 82 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -861,120 +861,114 @@ function findFunction(name) {
861861
}
862862

863863

864-
/** @summary Assign methods to request
864+
/** @summary Method to create http request, without promise can be used only in browser environment
865865
* @private */
866-
function setRequestMethods(xhr, url, kind, user_accept_callback, user_reject_callback) {
867-
xhr.http_callback = isFunc(user_accept_callback) ? user_accept_callback.bind(xhr) : function() {};
868-
xhr.error_callback = isFunc(user_reject_callback) ? user_reject_callback.bind(xhr) : function(err) { console.warn(err.message); this.http_callback(null); }.bind(xhr);
866+
function createHttpRequest(url, kind, user_accept_callback, user_reject_callback, use_promise) {
869867

870-
if (!kind) kind = 'buf';
868+
function configureXhr(xhr) {
869+
xhr.http_callback = isFunc(user_accept_callback) ? user_accept_callback.bind(xhr) : () => {};
870+
xhr.error_callback = isFunc(user_reject_callback) ? user_reject_callback.bind(xhr) : function(err) { console.warn(err.message); this.http_callback(null); }.bind(xhr);
871871

872-
let method = 'GET', is_async = true, p = kind.indexOf(';sync');
873-
if (p > 0) { kind = kind.slice(0,p); is_async = false; }
874-
switch (kind) {
875-
case 'head': method = 'HEAD'; break;
876-
case 'posttext': method = 'POST'; kind = 'text'; break;
877-
case 'postbuf': method = 'POST'; kind = 'buf'; break;
878-
case 'post':
879-
case 'multi': method = 'POST'; break;
880-
}
872+
if (!kind) kind = 'buf';
881873

882-
xhr.kind = kind;
874+
let method = 'GET', is_async = true, p = kind.indexOf(';sync');
875+
if (p > 0) { kind = kind.slice(0,p); is_async = false; }
876+
switch (kind) {
877+
case 'head': method = 'HEAD'; break;
878+
case 'posttext': method = 'POST'; kind = 'text'; break;
879+
case 'postbuf': method = 'POST'; kind = 'buf'; break;
880+
case 'post':
881+
case 'multi': method = 'POST'; break;
882+
}
883883

884-
if (settings.WithCredentials)
885-
xhr.withCredentials = true;
884+
xhr.kind = kind;
886885

887-
if (settings.HandleWrongHttpResponse && (method == 'GET') && isFunc(xhr.addEventListener))
888-
xhr.addEventListener('progress', function(oEvent) {
889-
if (oEvent.lengthComputable && this.expected_size && (oEvent.loaded > this.expected_size)) {
890-
this.did_abort = true;
891-
this.abort();
892-
this.error_callback(Error(`Server sends more bytes ${oEvent.loaded} than expected ${this.expected_size}. Abort I/O operation`), 598);
893-
}
894-
}.bind(xhr));
886+
if (settings.WithCredentials)
887+
xhr.withCredentials = true;
888+
889+
if (settings.HandleWrongHttpResponse && (method == 'GET') && isFunc(xhr.addEventListener))
890+
xhr.addEventListener('progress', function(oEvent) {
891+
if (oEvent.lengthComputable && this.expected_size && (oEvent.loaded > this.expected_size)) {
892+
this.did_abort = true;
893+
this.abort();
894+
this.error_callback(Error(`Server sends more bytes ${oEvent.loaded} than expected ${this.expected_size}. Abort I/O operation`), 598);
895+
}
896+
}.bind(xhr));
895897

896-
xhr.onreadystatechange = function() {
898+
xhr.onreadystatechange = function() {
897899

898-
if (this.did_abort) return;
900+
if (this.did_abort) return;
899901

900-
if ((this.readyState === 2) && this.expected_size) {
901-
let len = parseInt(this.getResponseHeader('Content-Length'));
902-
if (Number.isInteger(len) && (len > this.expected_size) && !settings.HandleWrongHttpResponse) {
903-
this.did_abort = true;
904-
this.abort();
905-
return this.error_callback(Error(`Server response size ${len} larger than expected ${this.expected_size}. Abort I/O operation`), 599);
902+
if ((this.readyState === 2) && this.expected_size) {
903+
let len = parseInt(this.getResponseHeader('Content-Length'));
904+
if (Number.isInteger(len) && (len > this.expected_size) && !settings.HandleWrongHttpResponse) {
905+
this.did_abort = true;
906+
this.abort();
907+
return this.error_callback(Error(`Server response size ${len} larger than expected ${this.expected_size}. Abort I/O operation`), 599);
908+
}
906909
}
907-
}
908910

909-
if (this.readyState != 4) return;
911+
if (this.readyState != 4) return;
910912

911-
if ((this.status != 200) && (this.status != 206) && !browser$1.qt5 &&
912-
// in these special cases browsers not always set status
913-
!((this.status == 0) && ((url.indexOf('file://') == 0) || (url.indexOf('blob:') == 0)))) {
914-
return this.error_callback(Error(`Fail to load url ${url}`), this.status);
915-
}
913+
if ((this.status != 200) && (this.status != 206) && !browser$1.qt5 &&
914+
// in these special cases browsers not always set status
915+
!((this.status == 0) && ((url.indexOf('file://') == 0) || (url.indexOf('blob:') == 0)))) {
916+
return this.error_callback(Error(`Fail to load url ${url}`), this.status);
917+
}
916918

917-
if (this.nodejs_checkzip && (this.getResponseHeader('content-encoding') == 'gzip'))
918-
// special handling of gzipped JSON objects in Node.js
919-
return Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder$1; }).then(handle => {
920-
let res = handle.unzipSync(Buffer.from(this.response)),
921-
obj = JSON.parse(res); // zlib returns Buffer, use JSON to parse it
922-
return this.http_callback(parse(obj));
923-
});
919+
if (this.nodejs_checkzip && (this.getResponseHeader('content-encoding') == 'gzip'))
920+
// special handling of gzipped JSON objects in Node.js
921+
return Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder$1; }).then(handle => {
922+
let res = handle.unzipSync(Buffer.from(this.response)),
923+
obj = JSON.parse(res); // zlib returns Buffer, use JSON to parse it
924+
return this.http_callback(parse(obj));
925+
});
924926

925-
switch(this.kind) {
926-
case 'xml': return this.http_callback(this.responseXML);
927-
case 'text': return this.http_callback(this.responseText);
928-
case 'object': return this.http_callback(parse(this.responseText));
929-
case 'multi': return this.http_callback(parseMulti(this.responseText));
930-
case 'head': return this.http_callback(this);
931-
}
927+
switch(this.kind) {
928+
case 'xml': return this.http_callback(this.responseXML);
929+
case 'text': return this.http_callback(this.responseText);
930+
case 'object': return this.http_callback(parse(this.responseText));
931+
case 'multi': return this.http_callback(parseMulti(this.responseText));
932+
case 'head': return this.http_callback(this);
933+
}
932934

933-
// if no response type is supported, return as text (most probably, will fail)
934-
if (this.responseType === undefined)
935-
return this.http_callback(this.responseText);
935+
// if no response type is supported, return as text (most probably, will fail)
936+
if (this.responseType === undefined)
937+
return this.http_callback(this.responseText);
936938

937-
if ((this.kind == 'bin') && ('byteLength' in this.response)) {
938-
// if string representation in requested - provide it
939+
if ((this.kind == 'bin') && ('byteLength' in this.response)) {
940+
// if string representation in requested - provide it
939941

940-
let filecontent = '', u8Arr = new Uint8Array(this.response);
941-
for (let i = 0; i < u8Arr.length; ++i)
942-
filecontent += String.fromCharCode(u8Arr[i]);
942+
let filecontent = '', u8Arr = new Uint8Array(this.response);
943+
for (let i = 0; i < u8Arr.length; ++i)
944+
filecontent += String.fromCharCode(u8Arr[i]);
943945

944-
return this.http_callback(filecontent);
945-
}
946+
return this.http_callback(filecontent);
947+
}
946948

947-
this.http_callback(this.response);
948-
};
949+
this.http_callback(this.response);
950+
};
949951

950-
xhr.open(method, url, is_async);
952+
xhr.open(method, url, is_async);
951953

952-
if ((kind == 'bin') || (kind == 'buf'))
953-
xhr.responseType = 'arraybuffer';
954+
if ((kind == 'bin') || (kind == 'buf'))
955+
xhr.responseType = 'arraybuffer';
954956

955-
if (nodejs && (method == 'GET') && (kind === 'object') && (url.indexOf('.json.gz') > 0)) {
956-
xhr.nodejs_checkzip = true;
957-
xhr.responseType = 'arraybuffer';
958-
}
957+
if (nodejs && (method == 'GET') && (kind === 'object') && (url.indexOf('.json.gz') > 0)) {
958+
xhr.nodejs_checkzip = true;
959+
xhr.responseType = 'arraybuffer';
960+
}
959961

960-
return xhr;
961-
}
962+
return xhr;
963+
}
962964

963-
/** @summary Method to create http request, without promise can be used only in browser environment
964-
* @private */
965-
function createHttpRequest(url, kind, user_accept_callback, user_reject_callback, use_promise) {
966965
if (isNodeJs()) {
967966
if (!use_promise)
968-
throw Error('Not allowed to create http requests in node without promise');
969-
return Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder$1; }).then(h => {
970-
let xhr = new h.default();
971-
setRequestMethods(xhr, url, kind, user_accept_callback, user_reject_callback);
972-
return xhr;
973-
});
967+
throw Error('Not allowed to create http requests in node.js without promise');
968+
return Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder$1; }).then(h => configureXhr(new h.default()));
974969
}
975970

976-
let xhr = new XMLHttpRequest();
977-
setRequestMethods(xhr, url, kind, user_accept_callback, user_reject_callback);
971+
let xhr = configureXhr(new XMLHttpRequest());
978972
return use_promise ? Promise.resolve(xhr) : xhr;
979973
}
980974

@@ -95518,7 +95512,7 @@ class TFile {
9551895512
if (file.fAcceptRanges && !first_req.getResponseHeader('Accept-Ranges')) {
9551995513
file.fAcceptRanges = false;
9552095514
if (res?.byteLength === place[1]) {
95521-
// special case with cernbox, let try to get full size content
95515+
// special case with cernbox, let try to get full size content
9552295516
console.warn(`First block is ${place[1]} bytes but browser does not provides access to header - try to read full file`);
9552395517
first_block_retry = true;
9552495518
return send_new_request();
@@ -95583,7 +95577,7 @@ class TFile {
9558395577

9558495578
let hdr_range = this.getResponseHeader('Content-Range'), segm_start = 0, segm_last = -1;
9558595579

95586-
if (hdr_range && hdr_range.indexOf('bytes') >= 0) {
95580+
if (isStr(hdr_range) && hdr_range.indexOf('bytes') >= 0) {
9558795581
let parts = hdr_range.slice(hdr_range.indexOf('bytes') + 6).split(/[\s-\/]+/);
9558895582
if (parts.length === 3) {
9558995583
segm_start = parseInt(parts[0]);

0 commit comments

Comments
 (0)