@firebase/storage 0.8.3 → 0.8.4-canary.1048c4f2d
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/CHANGELOG.md +8 -0
- package/dist/index.browser.cjs.js +45 -63
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +182 -178
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +44 -63
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +45 -63
- package/dist/index.esm5.js.map +1 -1
- package/dist/src/api.browser.d.ts +17 -0
- package/dist/src/api.d.ts +1 -1
- package/dist/src/api.node.d.ts +17 -0
- package/dist/src/implementation/connection.d.ts +6 -6
- package/dist/src/implementation/requestinfo.d.ts +11 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.node.d.ts +7 -0
- package/dist/src/platform/browser/connection.d.ts +1 -25
- package/dist/src/platform/node/connection.d.ts +1 -0
- package/dist/storage.d.ts +18 -9
- package/dist/test/browser/connection.test.d.ts +17 -0
- package/dist/test/unit/connection.test.d.ts +17 -0
- package/package.json +9 -9
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,57 @@ 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
|
}
|
|
758
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
780
759
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
781
760
|
connection
|
|
782
|
-
.send(
|
|
761
|
+
.send(_this.url_, _this.method_, _this.body_, _this.headers_)
|
|
783
762
|
.then(function () {
|
|
784
|
-
if (
|
|
763
|
+
if (_this.progressCallback_ !== null) {
|
|
785
764
|
connection.removeUploadProgressListener(progressListener);
|
|
786
765
|
}
|
|
787
|
-
|
|
766
|
+
_this.pendingConnection_ = null;
|
|
788
767
|
var hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
789
768
|
var status = connection.getStatus();
|
|
790
|
-
if (!hitServer ||
|
|
769
|
+
if (!hitServer || _this.isRetryStatusCode_(status)) {
|
|
791
770
|
var wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
792
771
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
793
772
|
return;
|
|
794
773
|
}
|
|
795
|
-
var successCode =
|
|
774
|
+
var successCode = _this.successCodes_.indexOf(status) !== -1;
|
|
796
775
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
797
776
|
});
|
|
798
|
-
}
|
|
777
|
+
};
|
|
799
778
|
/**
|
|
800
779
|
* @param requestWentThrough - True if the request eventually went
|
|
801
780
|
* through, false if it hit the retry limit or was canceled.
|
|
802
781
|
*/
|
|
803
|
-
function
|
|
804
|
-
var resolve =
|
|
805
|
-
var reject =
|
|
782
|
+
var backoffDone = function (requestWentThrough, status) {
|
|
783
|
+
var resolve = _this.resolve_;
|
|
784
|
+
var reject = _this.reject_;
|
|
806
785
|
var connection = status.connection;
|
|
807
786
|
if (status.wasSuccessCode) {
|
|
808
787
|
try {
|
|
809
|
-
var result =
|
|
788
|
+
var result = _this.callback_(connection, connection.getResponseText());
|
|
810
789
|
if (isJustDef(result)) {
|
|
811
790
|
resolve(result);
|
|
812
791
|
}
|
|
@@ -822,8 +801,8 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
822
801
|
if (connection !== null) {
|
|
823
802
|
var err = unknown();
|
|
824
803
|
err.serverResponse = connection.getResponseText();
|
|
825
|
-
if (
|
|
826
|
-
reject(
|
|
804
|
+
if (_this.errorCallback_) {
|
|
805
|
+
reject(_this.errorCallback_(connection, err));
|
|
827
806
|
}
|
|
828
807
|
else {
|
|
829
808
|
reject(err);
|
|
@@ -831,7 +810,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
831
810
|
}
|
|
832
811
|
else {
|
|
833
812
|
if (status.canceled) {
|
|
834
|
-
var err =
|
|
813
|
+
var err = _this.appDelete_ ? appDeleted() : canceled();
|
|
835
814
|
reject(err);
|
|
836
815
|
}
|
|
837
816
|
else {
|
|
@@ -840,7 +819,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
840
819
|
}
|
|
841
820
|
}
|
|
842
821
|
}
|
|
843
|
-
}
|
|
822
|
+
};
|
|
844
823
|
if (this.canceled_) {
|
|
845
824
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
846
825
|
}
|
|
@@ -3368,7 +3347,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3368
3347
|
}());
|
|
3369
3348
|
|
|
3370
3349
|
var name = "@firebase/storage";
|
|
3371
|
-
var version = "0.8.
|
|
3350
|
+
var version = "0.8.4-canary.1048c4f2d";
|
|
3372
3351
|
|
|
3373
3352
|
/**
|
|
3374
3353
|
* @license
|
|
@@ -3597,7 +3576,10 @@ function factory(container, _a) {
|
|
|
3597
3576
|
}
|
|
3598
3577
|
function registerStorage() {
|
|
3599
3578
|
_registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|
|
3600
|
-
|
|
3579
|
+
//RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
|
|
3580
|
+
registerVersion(name, version, '');
|
|
3581
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
3582
|
+
registerVersion(name, version, 'esm5');
|
|
3601
3583
|
}
|
|
3602
3584
|
registerStorage();
|
|
3603
3585
|
|