@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.cjs.js
CHANGED
|
@@ -226,7 +226,7 @@ function internalError(message) {
|
|
|
226
226
|
* limitations under the License.
|
|
227
227
|
*/
|
|
228
228
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
-
const fetch = nodeFetch__default[
|
|
229
|
+
const fetch = nodeFetch__default["default"];
|
|
230
230
|
/**
|
|
231
231
|
* Network layer that works in Node.
|
|
232
232
|
*
|
|
@@ -669,22 +669,22 @@ function makeQueryString(params) {
|
|
|
669
669
|
* limitations under the License.
|
|
670
670
|
*/
|
|
671
671
|
class NetworkRequest {
|
|
672
|
-
constructor(
|
|
672
|
+
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, pool_) {
|
|
673
|
+
this.url_ = url_;
|
|
674
|
+
this.method_ = method_;
|
|
675
|
+
this.headers_ = headers_;
|
|
676
|
+
this.body_ = body_;
|
|
677
|
+
this.successCodes_ = successCodes_;
|
|
678
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
679
|
+
this.callback_ = callback_;
|
|
680
|
+
this.errorCallback_ = errorCallback_;
|
|
681
|
+
this.timeout_ = timeout_;
|
|
682
|
+
this.progressCallback_ = progressCallback_;
|
|
683
|
+
this.pool_ = pool_;
|
|
673
684
|
this.pendingConnection_ = null;
|
|
674
685
|
this.backoffId_ = null;
|
|
675
686
|
this.canceled_ = false;
|
|
676
687
|
this.appDelete_ = false;
|
|
677
|
-
this.url_ = url;
|
|
678
|
-
this.method_ = method;
|
|
679
|
-
this.headers_ = headers;
|
|
680
|
-
this.body_ = body;
|
|
681
|
-
this.successCodes_ = successCodes.slice();
|
|
682
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
683
|
-
this.callback_ = callback;
|
|
684
|
-
this.errorCallback_ = errorCallback;
|
|
685
|
-
this.progressCallback_ = progressCallback;
|
|
686
|
-
this.timeout_ = timeout;
|
|
687
|
-
this.pool_ = pool;
|
|
688
688
|
this.promise_ = new Promise((resolve, reject) => {
|
|
689
689
|
this.resolve_ = resolve;
|
|
690
690
|
this.reject_ = reject;
|
|
@@ -695,54 +695,55 @@ class NetworkRequest {
|
|
|
695
695
|
* Actually starts the retry loop.
|
|
696
696
|
*/
|
|
697
697
|
start_() {
|
|
698
|
-
const
|
|
699
|
-
function doTheRequest(backoffCallback, canceled) {
|
|
698
|
+
const doTheRequest = (backoffCallback, canceled) => {
|
|
700
699
|
if (canceled) {
|
|
701
700
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
702
701
|
return;
|
|
703
702
|
}
|
|
704
|
-
const connection =
|
|
705
|
-
|
|
706
|
-
|
|
703
|
+
const connection = this.pool_.createConnection();
|
|
704
|
+
this.pendingConnection_ = connection;
|
|
705
|
+
const progressListener = progressEvent => {
|
|
707
706
|
const loaded = progressEvent.loaded;
|
|
708
|
-
const total = progressEvent.lengthComputable
|
|
709
|
-
|
|
710
|
-
|
|
707
|
+
const total = progressEvent.lengthComputable
|
|
708
|
+
? progressEvent.total
|
|
709
|
+
: -1;
|
|
710
|
+
if (this.progressCallback_ !== null) {
|
|
711
|
+
this.progressCallback_(loaded, total);
|
|
711
712
|
}
|
|
712
|
-
}
|
|
713
|
-
if (
|
|
713
|
+
};
|
|
714
|
+
if (this.progressCallback_ !== null) {
|
|
714
715
|
connection.addUploadProgressListener(progressListener);
|
|
715
716
|
}
|
|
716
717
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
717
718
|
connection
|
|
718
|
-
.send(
|
|
719
|
+
.send(this.url_, this.method_, this.body_, this.headers_)
|
|
719
720
|
.then(() => {
|
|
720
|
-
if (
|
|
721
|
+
if (this.progressCallback_ !== null) {
|
|
721
722
|
connection.removeUploadProgressListener(progressListener);
|
|
722
723
|
}
|
|
723
|
-
|
|
724
|
+
this.pendingConnection_ = null;
|
|
724
725
|
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
725
726
|
const status = connection.getStatus();
|
|
726
|
-
if (!hitServer ||
|
|
727
|
+
if (!hitServer || this.isRetryStatusCode_(status)) {
|
|
727
728
|
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
728
729
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
729
730
|
return;
|
|
730
731
|
}
|
|
731
|
-
const successCode =
|
|
732
|
+
const successCode = this.successCodes_.indexOf(status) !== -1;
|
|
732
733
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
733
734
|
});
|
|
734
|
-
}
|
|
735
|
+
};
|
|
735
736
|
/**
|
|
736
737
|
* @param requestWentThrough - True if the request eventually went
|
|
737
738
|
* through, false if it hit the retry limit or was canceled.
|
|
738
739
|
*/
|
|
739
|
-
|
|
740
|
-
const resolve =
|
|
741
|
-
const reject =
|
|
740
|
+
const backoffDone = (requestWentThrough, status) => {
|
|
741
|
+
const resolve = this.resolve_;
|
|
742
|
+
const reject = this.reject_;
|
|
742
743
|
const connection = status.connection;
|
|
743
744
|
if (status.wasSuccessCode) {
|
|
744
745
|
try {
|
|
745
|
-
const result =
|
|
746
|
+
const result = this.callback_(connection, connection.getResponseText());
|
|
746
747
|
if (isJustDef(result)) {
|
|
747
748
|
resolve(result);
|
|
748
749
|
}
|
|
@@ -758,8 +759,8 @@ class NetworkRequest {
|
|
|
758
759
|
if (connection !== null) {
|
|
759
760
|
const err = unknown();
|
|
760
761
|
err.serverResponse = connection.getResponseText();
|
|
761
|
-
if (
|
|
762
|
-
reject(
|
|
762
|
+
if (this.errorCallback_) {
|
|
763
|
+
reject(this.errorCallback_(connection, err));
|
|
763
764
|
}
|
|
764
765
|
else {
|
|
765
766
|
reject(err);
|
|
@@ -767,7 +768,7 @@ class NetworkRequest {
|
|
|
767
768
|
}
|
|
768
769
|
else {
|
|
769
770
|
if (status.canceled) {
|
|
770
|
-
const err =
|
|
771
|
+
const err = this.appDelete_ ? appDeleted() : canceled();
|
|
771
772
|
reject(err);
|
|
772
773
|
}
|
|
773
774
|
else {
|
|
@@ -776,7 +777,7 @@ class NetworkRequest {
|
|
|
776
777
|
}
|
|
777
778
|
}
|
|
778
779
|
}
|
|
779
|
-
}
|
|
780
|
+
};
|
|
780
781
|
if (this.canceled_) {
|
|
781
782
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
782
783
|
}
|
|
@@ -3141,7 +3142,7 @@ class FirebaseStorageImpl {
|
|
|
3141
3142
|
}
|
|
3142
3143
|
|
|
3143
3144
|
const name = "@firebase/storage";
|
|
3144
|
-
const version = "0.8.3-canary.
|
|
3145
|
+
const version = "0.8.3-canary.88ea06930";
|
|
3145
3146
|
|
|
3146
3147
|
/**
|
|
3147
3148
|
* @license
|