@firebase/storage 0.8.3-canary.85d2c4d29 → 0.8.3-canary.88ea06930
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/dist/index.browser.cjs.js +40 -62
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +39 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +39 -62
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +40 -62
- package/dist/index.esm5.js.map +1 -1
- package/dist/src/implementation/connection.d.ts +2 -6
- package/dist/src/implementation/requestinfo.d.ts +11 -3
- package/dist/src/platform/browser/connection.d.ts +1 -25
- package/dist/storage.d.ts +14 -9
- package/package.json +8 -8
|
@@ -252,9 +252,6 @@ var XhrConnection = /** @class */ (function () {
|
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
/**
|
|
256
|
-
* @override
|
|
257
|
-
*/
|
|
258
255
|
XhrConnection.prototype.send = function (url, method, body, headers) {
|
|
259
256
|
if (this.sent_) {
|
|
260
257
|
throw internalError('cannot .send() more than once');
|
|
@@ -276,18 +273,12 @@ var XhrConnection = /** @class */ (function () {
|
|
|
276
273
|
}
|
|
277
274
|
return this.sendPromise_;
|
|
278
275
|
};
|
|
279
|
-
/**
|
|
280
|
-
* @override
|
|
281
|
-
*/
|
|
282
276
|
XhrConnection.prototype.getErrorCode = function () {
|
|
283
277
|
if (!this.sent_) {
|
|
284
278
|
throw internalError('cannot .getErrorCode() before sending');
|
|
285
279
|
}
|
|
286
280
|
return this.errorCode_;
|
|
287
281
|
};
|
|
288
|
-
/**
|
|
289
|
-
* @override
|
|
290
|
-
*/
|
|
291
282
|
XhrConnection.prototype.getStatus = function () {
|
|
292
283
|
if (!this.sent_) {
|
|
293
284
|
throw internalError('cannot .getStatus() before sending');
|
|
@@ -299,39 +290,24 @@ var XhrConnection = /** @class */ (function () {
|
|
|
299
290
|
return -1;
|
|
300
291
|
}
|
|
301
292
|
};
|
|
302
|
-
/**
|
|
303
|
-
* @override
|
|
304
|
-
*/
|
|
305
293
|
XhrConnection.prototype.getResponseText = function () {
|
|
306
294
|
if (!this.sent_) {
|
|
307
295
|
throw internalError('cannot .getResponseText() before sending');
|
|
308
296
|
}
|
|
309
297
|
return this.xhr_.responseText;
|
|
310
298
|
};
|
|
311
|
-
/**
|
|
312
|
-
* Aborts the request.
|
|
313
|
-
* @override
|
|
314
|
-
*/
|
|
299
|
+
/** Aborts the request. */
|
|
315
300
|
XhrConnection.prototype.abort = function () {
|
|
316
301
|
this.xhr_.abort();
|
|
317
302
|
};
|
|
318
|
-
/**
|
|
319
|
-
* @override
|
|
320
|
-
*/
|
|
321
303
|
XhrConnection.prototype.getResponseHeader = function (header) {
|
|
322
304
|
return this.xhr_.getResponseHeader(header);
|
|
323
305
|
};
|
|
324
|
-
/**
|
|
325
|
-
* @override
|
|
326
|
-
*/
|
|
327
306
|
XhrConnection.prototype.addUploadProgressListener = function (listener) {
|
|
328
307
|
if (this.xhr_.upload != null) {
|
|
329
308
|
this.xhr_.upload.addEventListener('progress', listener);
|
|
330
309
|
}
|
|
331
310
|
};
|
|
332
|
-
/**
|
|
333
|
-
* @override
|
|
334
|
-
*/
|
|
335
311
|
XhrConnection.prototype.removeUploadProgressListener = function (listener) {
|
|
336
312
|
if (this.xhr_.upload != null) {
|
|
337
313
|
this.xhr_.upload.removeEventListener('progress', listener);
|
|
@@ -736,23 +712,23 @@ function makeQueryString(params) {
|
|
|
736
712
|
* limitations under the License.
|
|
737
713
|
*/
|
|
738
714
|
var NetworkRequest = /** @class */ (function () {
|
|
739
|
-
function NetworkRequest(
|
|
715
|
+
function NetworkRequest(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, pool_) {
|
|
740
716
|
var _this = this;
|
|
717
|
+
this.url_ = url_;
|
|
718
|
+
this.method_ = method_;
|
|
719
|
+
this.headers_ = headers_;
|
|
720
|
+
this.body_ = body_;
|
|
721
|
+
this.successCodes_ = successCodes_;
|
|
722
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
723
|
+
this.callback_ = callback_;
|
|
724
|
+
this.errorCallback_ = errorCallback_;
|
|
725
|
+
this.timeout_ = timeout_;
|
|
726
|
+
this.progressCallback_ = progressCallback_;
|
|
727
|
+
this.pool_ = pool_;
|
|
741
728
|
this.pendingConnection_ = null;
|
|
742
729
|
this.backoffId_ = null;
|
|
743
730
|
this.canceled_ = false;
|
|
744
731
|
this.appDelete_ = false;
|
|
745
|
-
this.url_ = url;
|
|
746
|
-
this.method_ = method;
|
|
747
|
-
this.headers_ = headers;
|
|
748
|
-
this.body_ = body;
|
|
749
|
-
this.successCodes_ = successCodes.slice();
|
|
750
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
751
|
-
this.callback_ = callback;
|
|
752
|
-
this.errorCallback_ = errorCallback;
|
|
753
|
-
this.progressCallback_ = progressCallback;
|
|
754
|
-
this.timeout_ = timeout;
|
|
755
|
-
this.pool_ = pool;
|
|
756
732
|
this.promise_ = new Promise(function (resolve, reject) {
|
|
757
733
|
_this.resolve_ = resolve;
|
|
758
734
|
_this.reject_ = reject;
|
|
@@ -763,54 +739,56 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
763
739
|
* Actually starts the retry loop.
|
|
764
740
|
*/
|
|
765
741
|
NetworkRequest.prototype.start_ = function () {
|
|
766
|
-
var
|
|
767
|
-
function
|
|
742
|
+
var _this = this;
|
|
743
|
+
var doTheRequest = function (backoffCallback, canceled) {
|
|
768
744
|
if (canceled) {
|
|
769
745
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
770
746
|
return;
|
|
771
747
|
}
|
|
772
|
-
var connection =
|
|
773
|
-
|
|
774
|
-
function
|
|
748
|
+
var connection = _this.pool_.createConnection();
|
|
749
|
+
_this.pendingConnection_ = connection;
|
|
750
|
+
var progressListener = function (progressEvent) {
|
|
775
751
|
var loaded = progressEvent.loaded;
|
|
776
|
-
var total = progressEvent.lengthComputable
|
|
777
|
-
|
|
778
|
-
|
|
752
|
+
var total = progressEvent.lengthComputable
|
|
753
|
+
? progressEvent.total
|
|
754
|
+
: -1;
|
|
755
|
+
if (_this.progressCallback_ !== null) {
|
|
756
|
+
_this.progressCallback_(loaded, total);
|
|
779
757
|
}
|
|
780
|
-
}
|
|
781
|
-
if (
|
|
758
|
+
};
|
|
759
|
+
if (_this.progressCallback_ !== null) {
|
|
782
760
|
connection.addUploadProgressListener(progressListener);
|
|
783
761
|
}
|
|
784
762
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
785
763
|
connection
|
|
786
|
-
.send(
|
|
764
|
+
.send(_this.url_, _this.method_, _this.body_, _this.headers_)
|
|
787
765
|
.then(function () {
|
|
788
|
-
if (
|
|
766
|
+
if (_this.progressCallback_ !== null) {
|
|
789
767
|
connection.removeUploadProgressListener(progressListener);
|
|
790
768
|
}
|
|
791
|
-
|
|
769
|
+
_this.pendingConnection_ = null;
|
|
792
770
|
var hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
793
771
|
var status = connection.getStatus();
|
|
794
|
-
if (!hitServer ||
|
|
772
|
+
if (!hitServer || _this.isRetryStatusCode_(status)) {
|
|
795
773
|
var wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
796
774
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
797
775
|
return;
|
|
798
776
|
}
|
|
799
|
-
var successCode =
|
|
777
|
+
var successCode = _this.successCodes_.indexOf(status) !== -1;
|
|
800
778
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
801
779
|
});
|
|
802
|
-
}
|
|
780
|
+
};
|
|
803
781
|
/**
|
|
804
782
|
* @param requestWentThrough - True if the request eventually went
|
|
805
783
|
* through, false if it hit the retry limit or was canceled.
|
|
806
784
|
*/
|
|
807
|
-
function
|
|
808
|
-
var resolve =
|
|
809
|
-
var reject =
|
|
785
|
+
var backoffDone = function (requestWentThrough, status) {
|
|
786
|
+
var resolve = _this.resolve_;
|
|
787
|
+
var reject = _this.reject_;
|
|
810
788
|
var connection = status.connection;
|
|
811
789
|
if (status.wasSuccessCode) {
|
|
812
790
|
try {
|
|
813
|
-
var result =
|
|
791
|
+
var result = _this.callback_(connection, connection.getResponseText());
|
|
814
792
|
if (isJustDef(result)) {
|
|
815
793
|
resolve(result);
|
|
816
794
|
}
|
|
@@ -826,8 +804,8 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
826
804
|
if (connection !== null) {
|
|
827
805
|
var err = unknown();
|
|
828
806
|
err.serverResponse = connection.getResponseText();
|
|
829
|
-
if (
|
|
830
|
-
reject(
|
|
807
|
+
if (_this.errorCallback_) {
|
|
808
|
+
reject(_this.errorCallback_(connection, err));
|
|
831
809
|
}
|
|
832
810
|
else {
|
|
833
811
|
reject(err);
|
|
@@ -835,7 +813,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
835
813
|
}
|
|
836
814
|
else {
|
|
837
815
|
if (status.canceled) {
|
|
838
|
-
var err =
|
|
816
|
+
var err = _this.appDelete_ ? appDeleted() : canceled();
|
|
839
817
|
reject(err);
|
|
840
818
|
}
|
|
841
819
|
else {
|
|
@@ -844,7 +822,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
844
822
|
}
|
|
845
823
|
}
|
|
846
824
|
}
|
|
847
|
-
}
|
|
825
|
+
};
|
|
848
826
|
if (this.canceled_) {
|
|
849
827
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
850
828
|
}
|
|
@@ -3372,7 +3350,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3372
3350
|
}());
|
|
3373
3351
|
|
|
3374
3352
|
var name = "@firebase/storage";
|
|
3375
|
-
var version = "0.8.3-canary.
|
|
3353
|
+
var version = "0.8.3-canary.88ea06930";
|
|
3376
3354
|
|
|
3377
3355
|
/**
|
|
3378
3356
|
* @license
|