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