Skip to content

Commit abd8915

Browse files
committed
Cast ReadableStream to ReadableStream<UInt8Array>
1 parent 01854cc commit abd8915

File tree

8 files changed

+7
-15
lines changed

8 files changed

+7
-15
lines changed

packages/storage/src/api.browser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import { StorageReference } from './public-types';
1919
import { Reference, getBlobInternal } from './reference';
2020
import { getModularInstance } from '@firebase/util';
21-
import { ReadableStream } from 'stream/web';
2221

2322
/**
2423
* Downloads the data at the object's location. Returns an error if the object

packages/storage/src/api.node.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import { StorageReference } from './public-types';
1919
import { Reference, getStreamInternal } from './reference';
2020
import { getModularInstance } from '@firebase/util';
21-
import { ReadableStream } from 'stream/web';
2221

2322
/**
2423
* Downloads the data at the object's location. Returns an error if the object

packages/storage/src/implementation/connection.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import { ReadableStream } from 'stream/web';
18-
1917
/** Network headers */
2018
export type Headers = Record<string, string>;
2119

2220
/** Response type exposed by the networking APIs. */
23-
export type ConnectionType = string | ArrayBuffer | Blob | ReadableStream;
21+
export type ConnectionType = string | ArrayBuffer | Blob | ReadableStream<Uint8Array>;
2422

2523
/**
2624
* A lightweight wrapper around XMLHttpRequest with a

packages/storage/src/platform/browser/connection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
Headers
2323
} from '../../implementation/connection';
2424
import { internalError } from '../../implementation/error';
25-
import { ReadableStream } from 'stream/web';
2625

2726
/** An override for the text-based Connection. Used in tests. */
2827
let textFactoryOverride: (() => Connection<string>) | null = null;

packages/storage/src/platform/connection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
newStreamConnection as nodeNewStreamConnection,
2323
injectTestConnection as nodeInjectTestConnection
2424
} from './node/connection';
25-
import { ReadableStream } from 'stream/web';
2625

2726
export function injectTestConnection(
2827
factory: (() => Connection<string>) | null
@@ -46,7 +45,7 @@ export function newBlobConnection(): Connection<Blob> {
4645
return nodeNewBlobConnection();
4746
}
4847

49-
export function newStreamConnection(): Connection<ReadableStream> {
48+
export function newStreamConnection(): Connection<ReadableStream<Uint8Array>> {
5049
// This file is only used in Node.js tests using ts-node.
5150
return nodeNewStreamConnection();
5251
}

packages/storage/src/platform/node/connection.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '../../implementation/connection';
2323
import { internalError } from '../../implementation/error';
2424
import { fetch as undiciFetch, Headers as undiciHeaders } from 'undici';
25-
import { ReadableStream } from 'stream/web';
2625

2726
/** An override for the text-based Connection. Used in tests. */
2827
let textFactoryOverride: (() => Connection<string>) | null = null;
@@ -147,8 +146,8 @@ export function newBytesConnection(): Connection<ArrayBuffer> {
147146
return new FetchBytesConnection();
148147
}
149148

150-
export class FetchStreamConnection extends FetchConnection<ReadableStream> {
151-
private stream_: ReadableStream | null = null;
149+
export class FetchStreamConnection extends FetchConnection<ReadableStream<Uint8Array>> {
150+
private stream_: ReadableStream<Uint8Array> | null = null;
152151

153152
async send(
154153
url: string,
@@ -170,7 +169,7 @@ export class FetchStreamConnection extends FetchConnection<ReadableStream> {
170169
this.headers_ = response.headers;
171170
this.statusCode_ = response.status;
172171
this.errorCode_ = ErrorCode.NO_ERROR;
173-
this.stream_ = response.body;
172+
this.stream_ = response.body as ReadableStream<Uint8Array>;
174173
} catch (e) {
175174
this.errorText_ = (e as Error)?.message;
176175
// emulate XHR which sets status to 0 when encountering a network error
@@ -187,7 +186,7 @@ export class FetchStreamConnection extends FetchConnection<ReadableStream> {
187186
}
188187
}
189188

190-
export function newStreamConnection(): Connection<ReadableStream> {
189+
export function newStreamConnection(): Connection<ReadableStream<Uint8Array>> {
191190
return new FetchStreamConnection();
192191
}
193192

packages/storage/src/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @fileoverview Defines the Firebase StorageReference class.
2020
*/
2121

22-
import { ReadableStream, TransformStream, Transformer } from 'stream/web';
22+
// import { ReadableStream, TransformStream, Transformer } from 'stream/web';
2323

2424
import { FbsBlob } from './implementation/blob';
2525
import { Location } from './implementation/location';

packages/storage/test/node/stream.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { createApp, createStorage } from '../integration/integration.test';
2020
import { FirebaseApp, deleteApp } from '@firebase/app';
2121
import { getStream, ref, uploadBytes } from '../../src/index.node';
2222
import * as types from '../../src/public-types';
23-
import { ReadableStream } from 'stream/web';
2423

2524
// See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/getReader
2625
async function readData(readableStream: ReadableStream): Promise<Uint8Array> {

0 commit comments

Comments
 (0)