@checksub_team/peaks_timeline 1.6.4 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/peaks.js +38 -20
- package/src/data-retriever.js +46 -22
- package/src/source.js +4 -4
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14015,27 +14015,45 @@ module.exports = function (Data) {
|
|
|
14015
14015
|
}
|
|
14016
14016
|
};
|
|
14017
14017
|
DataRetriever.prototype._retireveDataOnline = function (source, url) {
|
|
14018
|
-
var self = this;
|
|
14019
14018
|
var data = new Data();
|
|
14020
14019
|
this._data[url] = data;
|
|
14021
14020
|
this._waitingForData[url] = [source];
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14021
|
+
this._fetch(url, data, 1000, 10);
|
|
14022
|
+
};
|
|
14023
|
+
DataRetriever.prototype._fetch = function (url, data, delay, limit) {
|
|
14024
|
+
var self = this;
|
|
14025
|
+
function later(delay) {
|
|
14026
|
+
return new Promise(function (resolve) {
|
|
14027
|
+
setTimeout(resolve, delay);
|
|
14028
|
+
});
|
|
14029
|
+
}
|
|
14030
|
+
function recur(timesTried, err) {
|
|
14031
|
+
if (timesTried >= limit) {
|
|
14032
|
+
return Promise.reject(err);
|
|
14030
14033
|
}
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
self._waitingForData[url].forEach(function (src) {
|
|
14035
|
-
self._peaks.emit('data.retrieved', data, src, url);
|
|
14034
|
+
return fetch(url).catch(function (err) {
|
|
14035
|
+
later(delay).then(function () {
|
|
14036
|
+
recur(timesTried + 1, err);
|
|
14036
14037
|
});
|
|
14037
|
-
}
|
|
14038
|
-
|
|
14038
|
+
}).then(function (response) {
|
|
14039
|
+
return response.blob();
|
|
14040
|
+
}).then(function (blob) {
|
|
14041
|
+
var type = blob.type;
|
|
14042
|
+
if (type) {
|
|
14043
|
+
type = type.split('/')[0];
|
|
14044
|
+
} else {
|
|
14045
|
+
type = 'other';
|
|
14046
|
+
}
|
|
14047
|
+
data.type = type;
|
|
14048
|
+
data.content = URL.createObjectURL(blob);
|
|
14049
|
+
if (self._waitingForData[url]) {
|
|
14050
|
+
self._waitingForData[url].forEach(function (src) {
|
|
14051
|
+
self._peaks.emit('data.retrieved', data, src, url);
|
|
14052
|
+
});
|
|
14053
|
+
}
|
|
14054
|
+
});
|
|
14055
|
+
}
|
|
14056
|
+
return recur(0);
|
|
14039
14057
|
};
|
|
14040
14058
|
return DataRetriever;
|
|
14041
14059
|
}(_dereq_('./data'));
|
|
@@ -18404,13 +18422,13 @@ module.exports = function (Utils) {
|
|
|
18404
18422
|
}
|
|
18405
18423
|
if (Utils.isNullOrUndefined(options.previewHeight)) {
|
|
18406
18424
|
options.previewHeight = 0;
|
|
18407
|
-
} else if (!Utils.
|
|
18408
|
-
throw new TypeError('peaks.sources.' + context + ': previewHeight must be
|
|
18425
|
+
} else if (!Utils.isNumber(options.previewHeight)) {
|
|
18426
|
+
throw new TypeError('peaks.sources.' + context + ': previewHeight must be a number');
|
|
18409
18427
|
}
|
|
18410
18428
|
if (Utils.isNullOrUndefined(options.binaryHeight)) {
|
|
18411
18429
|
options.binaryHeight = 0;
|
|
18412
|
-
} else if (!Utils.
|
|
18413
|
-
throw new TypeError('peaks.sources.' + context + ': binaryHeight must be
|
|
18430
|
+
} else if (!Utils.isNumber(options.binaryHeight)) {
|
|
18431
|
+
throw new TypeError('peaks.sources.' + context + ': binaryHeight must be a number');
|
|
18414
18432
|
}
|
|
18415
18433
|
if (options.previewUrl && !options.previewHeight) {
|
|
18416
18434
|
if (options.binaryHeight) {
|
package/src/data-retriever.js
CHANGED
|
@@ -54,36 +54,60 @@ define([
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
DataRetriever.prototype._retireveDataOnline = function(source, url) {
|
|
57
|
-
var self = this;
|
|
58
|
-
|
|
59
57
|
var data = new Data();
|
|
60
58
|
|
|
61
59
|
this._data[url] = data;
|
|
62
60
|
this._waitingForData[url] = [source];
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return response.blob();
|
|
67
|
-
})
|
|
68
|
-
.then(function(blob) {
|
|
69
|
-
var type = blob.type;
|
|
70
|
-
|
|
71
|
-
if (type) {
|
|
72
|
-
type = type.split('/')[0];
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
type = 'other';
|
|
76
|
-
}
|
|
62
|
+
this._fetch(url, data, 1000, 10);
|
|
63
|
+
};
|
|
77
64
|
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
DataRetriever.prototype._fetch = function(url, data, delay, limit) {
|
|
66
|
+
var self = this;
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
}
|
|
68
|
+
function later(delay) {
|
|
69
|
+
return new Promise(function(resolve) {
|
|
70
|
+
setTimeout(resolve, delay);
|
|
86
71
|
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function recur(timesTried, err) {
|
|
75
|
+
if (timesTried >= limit) {
|
|
76
|
+
return Promise.reject(err);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return fetch(url)
|
|
80
|
+
.catch(function(err) {
|
|
81
|
+
later(delay)
|
|
82
|
+
.then(function() {
|
|
83
|
+
recur(timesTried + 1, err);
|
|
84
|
+
});
|
|
85
|
+
})
|
|
86
|
+
.then(function(response) {
|
|
87
|
+
return response.blob();
|
|
88
|
+
})
|
|
89
|
+
.then(function(blob) {
|
|
90
|
+
var type = blob.type;
|
|
91
|
+
|
|
92
|
+
if (type) {
|
|
93
|
+
type = type.split('/')[0];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
type = 'other';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
data.type = type;
|
|
100
|
+
data.content = URL.createObjectURL(blob);
|
|
101
|
+
|
|
102
|
+
if (self._waitingForData[url]) {
|
|
103
|
+
self._waitingForData[url].forEach(function(src) {
|
|
104
|
+
self._peaks.emit('data.retrieved', data, src, url);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return recur(0);
|
|
87
111
|
};
|
|
88
112
|
|
|
89
113
|
return DataRetriever;
|
package/src/source.js
CHANGED
|
@@ -216,15 +216,15 @@ define([
|
|
|
216
216
|
if (Utils.isNullOrUndefined(options.previewHeight)) {
|
|
217
217
|
options.previewHeight = 0;
|
|
218
218
|
}
|
|
219
|
-
else if (!Utils.
|
|
220
|
-
throw new TypeError('peaks.sources.' + context + ': previewHeight must be
|
|
219
|
+
else if (!Utils.isNumber(options.previewHeight)) {
|
|
220
|
+
throw new TypeError('peaks.sources.' + context + ': previewHeight must be a number');
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
if (Utils.isNullOrUndefined(options.binaryHeight)) {
|
|
224
224
|
options.binaryHeight = 0;
|
|
225
225
|
}
|
|
226
|
-
else if (!Utils.
|
|
227
|
-
throw new TypeError('peaks.sources.' + context + ': binaryHeight must be
|
|
226
|
+
else if (!Utils.isNumber(options.binaryHeight)) {
|
|
227
|
+
throw new TypeError('peaks.sources.' + context + ': binaryHeight must be a number');
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
if (options.previewUrl && !options.previewHeight) {
|