@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.
@@ -239,9 +239,6 @@ class XhrConnection {
239
239
  });
240
240
  });
241
241
  }
242
- /**
243
- * @override
244
- */
245
242
  send(url, method, body, headers) {
246
243
  if (this.sent_) {
247
244
  throw internalError('cannot .send() more than once');
@@ -263,18 +260,12 @@ class XhrConnection {
263
260
  }
264
261
  return this.sendPromise_;
265
262
  }
266
- /**
267
- * @override
268
- */
269
263
  getErrorCode() {
270
264
  if (!this.sent_) {
271
265
  throw internalError('cannot .getErrorCode() before sending');
272
266
  }
273
267
  return this.errorCode_;
274
268
  }
275
- /**
276
- * @override
277
- */
278
269
  getStatus() {
279
270
  if (!this.sent_) {
280
271
  throw internalError('cannot .getStatus() before sending');
@@ -286,39 +277,24 @@ class XhrConnection {
286
277
  return -1;
287
278
  }
288
279
  }
289
- /**
290
- * @override
291
- */
292
280
  getResponseText() {
293
281
  if (!this.sent_) {
294
282
  throw internalError('cannot .getResponseText() before sending');
295
283
  }
296
284
  return this.xhr_.responseText;
297
285
  }
298
- /**
299
- * Aborts the request.
300
- * @override
301
- */
286
+ /** Aborts the request. */
302
287
  abort() {
303
288
  this.xhr_.abort();
304
289
  }
305
- /**
306
- * @override
307
- */
308
290
  getResponseHeader(header) {
309
291
  return this.xhr_.getResponseHeader(header);
310
292
  }
311
- /**
312
- * @override
313
- */
314
293
  addUploadProgressListener(listener) {
315
294
  if (this.xhr_.upload != null) {
316
295
  this.xhr_.upload.addEventListener('progress', listener);
317
296
  }
318
297
  }
319
- /**
320
- * @override
321
- */
322
298
  removeUploadProgressListener(listener) {
323
299
  if (this.xhr_.upload != null) {
324
300
  this.xhr_.upload.removeEventListener('progress', listener);
@@ -700,22 +676,22 @@ function makeQueryString(params) {
700
676
  * limitations under the License.
701
677
  */
702
678
  class NetworkRequest {
703
- constructor(url, method, headers, body, successCodes, additionalRetryCodes, callback, errorCallback, timeout, progressCallback, pool) {
679
+ constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, pool_) {
680
+ this.url_ = url_;
681
+ this.method_ = method_;
682
+ this.headers_ = headers_;
683
+ this.body_ = body_;
684
+ this.successCodes_ = successCodes_;
685
+ this.additionalRetryCodes_ = additionalRetryCodes_;
686
+ this.callback_ = callback_;
687
+ this.errorCallback_ = errorCallback_;
688
+ this.timeout_ = timeout_;
689
+ this.progressCallback_ = progressCallback_;
690
+ this.pool_ = pool_;
704
691
  this.pendingConnection_ = null;
705
692
  this.backoffId_ = null;
706
693
  this.canceled_ = false;
707
694
  this.appDelete_ = false;
708
- this.url_ = url;
709
- this.method_ = method;
710
- this.headers_ = headers;
711
- this.body_ = body;
712
- this.successCodes_ = successCodes.slice();
713
- this.additionalRetryCodes_ = additionalRetryCodes.slice();
714
- this.callback_ = callback;
715
- this.errorCallback_ = errorCallback;
716
- this.progressCallback_ = progressCallback;
717
- this.timeout_ = timeout;
718
- this.pool_ = pool;
719
695
  this.promise_ = new Promise((resolve, reject) => {
720
696
  this.resolve_ = resolve;
721
697
  this.reject_ = reject;
@@ -726,54 +702,56 @@ class NetworkRequest {
726
702
  * Actually starts the retry loop.
727
703
  */
728
704
  start_() {
729
- const self = this;
730
- function doTheRequest(backoffCallback, canceled) {
705
+ const doTheRequest = (backoffCallback, canceled) => {
731
706
  if (canceled) {
732
707
  backoffCallback(false, new RequestEndStatus(false, null, true));
733
708
  return;
734
709
  }
735
- const connection = self.pool_.createConnection();
736
- self.pendingConnection_ = connection;
737
- function progressListener(progressEvent) {
710
+ const connection = this.pool_.createConnection();
711
+ this.pendingConnection_ = connection;
712
+ const progressListener = progressEvent => {
738
713
  const loaded = progressEvent.loaded;
739
- const total = progressEvent.lengthComputable ? progressEvent.total : -1;
740
- if (self.progressCallback_ !== null) {
741
- self.progressCallback_(loaded, total);
714
+ const total = progressEvent.lengthComputable
715
+ ? progressEvent.total
716
+ : -1;
717
+ if (this.progressCallback_ !== null) {
718
+ this.progressCallback_(loaded, total);
742
719
  }
743
- }
744
- if (self.progressCallback_ !== null) {
720
+ };
721
+ if (this.progressCallback_ !== null) {
745
722
  connection.addUploadProgressListener(progressListener);
746
723
  }
724
+ // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
747
725
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
748
726
  connection
749
- .send(self.url_, self.method_, self.body_, self.headers_)
727
+ .send(this.url_, this.method_, this.body_, this.headers_)
750
728
  .then(() => {
751
- if (self.progressCallback_ !== null) {
729
+ if (this.progressCallback_ !== null) {
752
730
  connection.removeUploadProgressListener(progressListener);
753
731
  }
754
- self.pendingConnection_ = null;
732
+ this.pendingConnection_ = null;
755
733
  const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
756
734
  const status = connection.getStatus();
757
- if (!hitServer || self.isRetryStatusCode_(status)) {
735
+ if (!hitServer || this.isRetryStatusCode_(status)) {
758
736
  const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
759
737
  backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
760
738
  return;
761
739
  }
762
- const successCode = self.successCodes_.indexOf(status) !== -1;
740
+ const successCode = this.successCodes_.indexOf(status) !== -1;
763
741
  backoffCallback(true, new RequestEndStatus(successCode, connection));
764
742
  });
765
- }
743
+ };
766
744
  /**
767
745
  * @param requestWentThrough - True if the request eventually went
768
746
  * through, false if it hit the retry limit or was canceled.
769
747
  */
770
- function backoffDone(requestWentThrough, status) {
771
- const resolve = self.resolve_;
772
- const reject = self.reject_;
748
+ const backoffDone = (requestWentThrough, status) => {
749
+ const resolve = this.resolve_;
750
+ const reject = this.reject_;
773
751
  const connection = status.connection;
774
752
  if (status.wasSuccessCode) {
775
753
  try {
776
- const result = self.callback_(connection, connection.getResponseText());
754
+ const result = this.callback_(connection, connection.getResponseText());
777
755
  if (isJustDef(result)) {
778
756
  resolve(result);
779
757
  }
@@ -789,8 +767,8 @@ class NetworkRequest {
789
767
  if (connection !== null) {
790
768
  const err = unknown();
791
769
  err.serverResponse = connection.getResponseText();
792
- if (self.errorCallback_) {
793
- reject(self.errorCallback_(connection, err));
770
+ if (this.errorCallback_) {
771
+ reject(this.errorCallback_(connection, err));
794
772
  }
795
773
  else {
796
774
  reject(err);
@@ -798,7 +776,7 @@ class NetworkRequest {
798
776
  }
799
777
  else {
800
778
  if (status.canceled) {
801
- const err = self.appDelete_ ? appDeleted() : canceled();
779
+ const err = this.appDelete_ ? appDeleted() : canceled();
802
780
  reject(err);
803
781
  }
804
782
  else {
@@ -807,7 +785,7 @@ class NetworkRequest {
807
785
  }
808
786
  }
809
787
  }
810
- }
788
+ };
811
789
  if (this.canceled_) {
812
790
  backoffDone(false, new RequestEndStatus(false, null, true));
813
791
  }
@@ -3167,7 +3145,7 @@ class FirebaseStorageImpl {
3167
3145
  }
3168
3146
 
3169
3147
  const name = "@firebase/storage";
3170
- const version = "0.8.3";
3148
+ const version = "0.8.4-canary.1048c4f2d";
3171
3149
 
3172
3150
  /**
3173
3151
  * @license
@@ -3393,7 +3371,10 @@ function factory(container, { instanceIdentifier: url }) {
3393
3371
  }
3394
3372
  function registerStorage() {
3395
3373
  _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
3396
- registerVersion(name, version);
3374
+ //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
3375
+ registerVersion(name, version, '');
3376
+ // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
3377
+ registerVersion(name, version, 'esm2017');
3397
3378
  }
3398
3379
  registerStorage();
3399
3380