@firebase/storage 0.12.6 → 0.13.0

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.
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var app = require('@firebase/app');
6
6
  var util = require('@firebase/util');
7
- var stream = require('stream');
8
7
  var undici = require('undici');
9
8
  var component = require('@firebase/component');
10
9
 
@@ -589,23 +588,7 @@ function makeQueryString(params) {
589
588
  }
590
589
 
591
590
  /**
592
- * @license
593
- * Copyright 2017 Google LLC
594
- *
595
- * Licensed under the Apache License, Version 2.0 (the "License");
596
- * you may not use this file except in compliance with the License.
597
- * You may obtain a copy of the License at
598
- *
599
- * http://www.apache.org/licenses/LICENSE-2.0
600
- *
601
- * Unless required by applicable law or agreed to in writing, software
602
- * distributed under the License is distributed on an "AS IS" BASIS,
603
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
604
- * See the License for the specific language governing permissions and
605
- * limitations under the License.
606
- */
607
- /**
608
- * Error codes for requests made by the the XhrIo wrapper.
591
+ * Error codes for requests made by the XhrIo wrapper.
609
592
  */
610
593
  var ErrorCode;
611
594
  (function (ErrorCode) {
@@ -2910,32 +2893,31 @@ function getBytesInternal(ref, maxDownloadSizeBytes) {
2910
2893
  function getStreamInternal(ref, maxDownloadSizeBytes) {
2911
2894
  ref._throwIfRoot('getStream');
2912
2895
  const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
2913
- /** A transformer that passes through the first n bytes. */
2914
- const newMaxSizeTransform = n => {
2896
+ // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result
2897
+ const newMaxSizeTransform = (n) => {
2915
2898
  let missingBytes = n;
2916
2899
  return {
2917
- transform(chunk, encoding, callback) {
2900
+ transform(chunk, controller) {
2918
2901
  // GCS may not honor the Range header for small files
2919
2902
  if (chunk.length < missingBytes) {
2920
- this.push(chunk);
2903
+ controller.enqueue(chunk);
2921
2904
  missingBytes -= chunk.length;
2922
2905
  }
2923
2906
  else {
2924
- this.push(chunk.slice(0, missingBytes));
2925
- this.emit('end');
2907
+ controller.enqueue(chunk.slice(0, missingBytes));
2908
+ controller.terminate();
2926
2909
  }
2927
- callback();
2928
2910
  }
2929
2911
  };
2930
2912
  };
2931
2913
  const result = maxDownloadSizeBytes !== undefined
2932
- ? new stream.Transform(newMaxSizeTransform(maxDownloadSizeBytes))
2933
- : new stream.PassThrough();
2914
+ ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))
2915
+ : new TransformStream(); // The default transformer forwards all chunks to its readable side
2934
2916
  ref.storage
2935
2917
  .makeRequestWithTokens(requestInfo, newStreamConnection)
2936
- .then(stream => stream.pipe(result))
2937
- .catch(e => result.destroy(e));
2938
- return result;
2918
+ .then(readableStream => readableStream.pipeThrough(result))
2919
+ .catch(err => result.writable.abort(err));
2920
+ return result.readable;
2939
2921
  }
2940
2922
  /**
2941
2923
  * Uploads data to this object's location.
@@ -3071,7 +3053,7 @@ function list$1(ref, options) {
3071
3053
  }
3072
3054
  /**
3073
3055
  * A `Promise` that resolves with the metadata for this object. If this
3074
- * object doesn't exist or metadata cannot be retreived, the promise is
3056
+ * object doesn't exist or metadata cannot be retrieved, the promise is
3075
3057
  * rejected.
3076
3058
  * @public
3077
3059
  * @param ref - StorageReference to get metadata from.
@@ -3381,7 +3363,7 @@ class FirebaseStorageImpl {
3381
3363
  }
3382
3364
 
3383
3365
  const name = "@firebase/storage";
3384
- const version = "0.12.6";
3366
+ const version = "0.13.0";
3385
3367
 
3386
3368
  /**
3387
3369
  * @license
@@ -3480,7 +3462,7 @@ function uploadBytesResumable(ref, data, metadata) {
3480
3462
  }
3481
3463
  /**
3482
3464
  * A `Promise` that resolves with the metadata for this object. If this
3483
- * object doesn't exist or metadata cannot be retreived, the promise is
3465
+ * object doesn't exist or metadata cannot be retrieved, the promise is
3484
3466
  * rejected.
3485
3467
  * @public
3486
3468
  * @param ref - {@link StorageReference} to get metadata from.