@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
#Unreleased
|
|
2
2
|
|
|
3
|
+
## 0.8.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a7e00b9eb`](https://github.com/firebase/firebase-js-sdk/commit/a7e00b9ebbb05b094a8bf620790146e750463c12) [#5578](https://github.com/firebase/firebase-js-sdk/pull/5578) (fixes [#5372](https://github.com/firebase/firebase-js-sdk/issues/5372)) - Do not throw from `connection.send` to enable retries in Node.js.
|
|
8
|
+
|
|
9
|
+
* [`93795c780`](https://github.com/firebase/firebase-js-sdk/commit/93795c7801d6b28ccbbe5855fd2f3fc377b1db5f) [#5596](https://github.com/firebase/firebase-js-sdk/pull/5596) - report build variants for packages
|
|
10
|
+
|
|
3
11
|
## 0.8.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -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,57 @@ 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
|
}
|
|
762
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
784
763
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
785
764
|
connection
|
|
786
|
-
.send(
|
|
765
|
+
.send(_this.url_, _this.method_, _this.body_, _this.headers_)
|
|
787
766
|
.then(function () {
|
|
788
|
-
if (
|
|
767
|
+
if (_this.progressCallback_ !== null) {
|
|
789
768
|
connection.removeUploadProgressListener(progressListener);
|
|
790
769
|
}
|
|
791
|
-
|
|
770
|
+
_this.pendingConnection_ = null;
|
|
792
771
|
var hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
793
772
|
var status = connection.getStatus();
|
|
794
|
-
if (!hitServer ||
|
|
773
|
+
if (!hitServer || _this.isRetryStatusCode_(status)) {
|
|
795
774
|
var wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
796
775
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
797
776
|
return;
|
|
798
777
|
}
|
|
799
|
-
var successCode =
|
|
778
|
+
var successCode = _this.successCodes_.indexOf(status) !== -1;
|
|
800
779
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
801
780
|
});
|
|
802
|
-
}
|
|
781
|
+
};
|
|
803
782
|
/**
|
|
804
783
|
* @param requestWentThrough - True if the request eventually went
|
|
805
784
|
* through, false if it hit the retry limit or was canceled.
|
|
806
785
|
*/
|
|
807
|
-
function
|
|
808
|
-
var resolve =
|
|
809
|
-
var reject =
|
|
786
|
+
var backoffDone = function (requestWentThrough, status) {
|
|
787
|
+
var resolve = _this.resolve_;
|
|
788
|
+
var reject = _this.reject_;
|
|
810
789
|
var connection = status.connection;
|
|
811
790
|
if (status.wasSuccessCode) {
|
|
812
791
|
try {
|
|
813
|
-
var result =
|
|
792
|
+
var result = _this.callback_(connection, connection.getResponseText());
|
|
814
793
|
if (isJustDef(result)) {
|
|
815
794
|
resolve(result);
|
|
816
795
|
}
|
|
@@ -826,8 +805,8 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
826
805
|
if (connection !== null) {
|
|
827
806
|
var err = unknown();
|
|
828
807
|
err.serverResponse = connection.getResponseText();
|
|
829
|
-
if (
|
|
830
|
-
reject(
|
|
808
|
+
if (_this.errorCallback_) {
|
|
809
|
+
reject(_this.errorCallback_(connection, err));
|
|
831
810
|
}
|
|
832
811
|
else {
|
|
833
812
|
reject(err);
|
|
@@ -835,7 +814,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
835
814
|
}
|
|
836
815
|
else {
|
|
837
816
|
if (status.canceled) {
|
|
838
|
-
var err =
|
|
817
|
+
var err = _this.appDelete_ ? appDeleted() : canceled();
|
|
839
818
|
reject(err);
|
|
840
819
|
}
|
|
841
820
|
else {
|
|
@@ -844,7 +823,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
844
823
|
}
|
|
845
824
|
}
|
|
846
825
|
}
|
|
847
|
-
}
|
|
826
|
+
};
|
|
848
827
|
if (this.canceled_) {
|
|
849
828
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
850
829
|
}
|
|
@@ -3372,7 +3351,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3372
3351
|
}());
|
|
3373
3352
|
|
|
3374
3353
|
var name = "@firebase/storage";
|
|
3375
|
-
var version = "0.8.
|
|
3354
|
+
var version = "0.8.4-canary.1048c4f2d";
|
|
3376
3355
|
|
|
3377
3356
|
/**
|
|
3378
3357
|
* @license
|
|
@@ -3601,7 +3580,10 @@ function factory(container, _a) {
|
|
|
3601
3580
|
}
|
|
3602
3581
|
function registerStorage() {
|
|
3603
3582
|
app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|
|
3604
|
-
|
|
3583
|
+
//RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
|
|
3584
|
+
app.registerVersion(name, version, '');
|
|
3585
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
3586
|
+
app.registerVersion(name, version, 'cjs5');
|
|
3605
3587
|
}
|
|
3606
3588
|
registerStorage();
|
|
3607
3589
|
|