@firebase/storage 0.12.6-dataconnect-preview.d986d4bf2 → 0.13.0-20240814182916

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
 
@@ -588,22 +587,6 @@ function makeQueryString(params) {
588
587
  return queryPart;
589
588
  }
590
589
 
591
- /**
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
590
  /**
608
591
  * Error codes for requests made by the XhrIo wrapper.
609
592
  */
@@ -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.
@@ -3381,7 +3363,7 @@ class FirebaseStorageImpl {
3381
3363
  }
3382
3364
 
3383
3365
  const name = "@firebase/storage";
3384
- const version = "0.12.6-dataconnect-preview.d986d4bf2";
3366
+ const version = "0.13.0-20240814182916";
3385
3367
 
3386
3368
  /**
3387
3369
  * @license