@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.
@@ -1,6 +1,5 @@
1
1
  import { _getProvider, getApp, _registerComponent, registerVersion, SDK_VERSION } from '@firebase/app';
2
2
  import { FirebaseError, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort } from '@firebase/util';
3
- import { Transform, PassThrough } from 'stream';
4
3
  import { fetch } from 'undici';
5
4
  import { Component } from '@firebase/component';
6
5
 
@@ -585,23 +584,7 @@ function makeQueryString(params) {
585
584
  }
586
585
 
587
586
  /**
588
- * @license
589
- * Copyright 2017 Google LLC
590
- *
591
- * Licensed under the Apache License, Version 2.0 (the "License");
592
- * you may not use this file except in compliance with the License.
593
- * You may obtain a copy of the License at
594
- *
595
- * http://www.apache.org/licenses/LICENSE-2.0
596
- *
597
- * Unless required by applicable law or agreed to in writing, software
598
- * distributed under the License is distributed on an "AS IS" BASIS,
599
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
600
- * See the License for the specific language governing permissions and
601
- * limitations under the License.
602
- */
603
- /**
604
- * Error codes for requests made by the the XhrIo wrapper.
587
+ * Error codes for requests made by the XhrIo wrapper.
605
588
  */
606
589
  var ErrorCode;
607
590
  (function (ErrorCode) {
@@ -2906,32 +2889,31 @@ function getBytesInternal(ref, maxDownloadSizeBytes) {
2906
2889
  function getStreamInternal(ref, maxDownloadSizeBytes) {
2907
2890
  ref._throwIfRoot('getStream');
2908
2891
  const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
2909
- /** A transformer that passes through the first n bytes. */
2910
- const newMaxSizeTransform = n => {
2892
+ // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result
2893
+ const newMaxSizeTransform = (n) => {
2911
2894
  let missingBytes = n;
2912
2895
  return {
2913
- transform(chunk, encoding, callback) {
2896
+ transform(chunk, controller) {
2914
2897
  // GCS may not honor the Range header for small files
2915
2898
  if (chunk.length < missingBytes) {
2916
- this.push(chunk);
2899
+ controller.enqueue(chunk);
2917
2900
  missingBytes -= chunk.length;
2918
2901
  }
2919
2902
  else {
2920
- this.push(chunk.slice(0, missingBytes));
2921
- this.emit('end');
2903
+ controller.enqueue(chunk.slice(0, missingBytes));
2904
+ controller.terminate();
2922
2905
  }
2923
- callback();
2924
2906
  }
2925
2907
  };
2926
2908
  };
2927
2909
  const result = maxDownloadSizeBytes !== undefined
2928
- ? new Transform(newMaxSizeTransform(maxDownloadSizeBytes))
2929
- : new PassThrough();
2910
+ ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))
2911
+ : new TransformStream(); // The default transformer forwards all chunks to its readable side
2930
2912
  ref.storage
2931
2913
  .makeRequestWithTokens(requestInfo, newStreamConnection)
2932
- .then(stream => stream.pipe(result))
2933
- .catch(e => result.destroy(e));
2934
- return result;
2914
+ .then(readableStream => readableStream.pipeThrough(result))
2915
+ .catch(err => result.writable.abort(err));
2916
+ return result.readable;
2935
2917
  }
2936
2918
  /**
2937
2919
  * Uploads data to this object's location.
@@ -3067,7 +3049,7 @@ function list$1(ref, options) {
3067
3049
  }
3068
3050
  /**
3069
3051
  * A `Promise` that resolves with the metadata for this object. If this
3070
- * object doesn't exist or metadata cannot be retreived, the promise is
3052
+ * object doesn't exist or metadata cannot be retrieved, the promise is
3071
3053
  * rejected.
3072
3054
  * @public
3073
3055
  * @param ref - StorageReference to get metadata from.
@@ -3377,7 +3359,7 @@ class FirebaseStorageImpl {
3377
3359
  }
3378
3360
 
3379
3361
  const name = "@firebase/storage";
3380
- const version = "0.12.6";
3362
+ const version = "0.13.0";
3381
3363
 
3382
3364
  /**
3383
3365
  * @license
@@ -3476,7 +3458,7 @@ function uploadBytesResumable(ref, data, metadata) {
3476
3458
  }
3477
3459
  /**
3478
3460
  * A `Promise` that resolves with the metadata for this object. If this
3479
- * object doesn't exist or metadata cannot be retreived, the promise is
3461
+ * object doesn't exist or metadata cannot be retrieved, the promise is
3480
3462
  * rejected.
3481
3463
  * @public
3482
3464
  * @param ref - {@link StorageReference} to get metadata from.