Skip to content

Commit f01bbe9

Browse files
authored
feat: replace polyfills with normal dependencies (#52)
* save * fix
1 parent 8ccb744 commit f01bbe9

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ npm install react-native-fast-io --save
2626

2727
- React Native 0.76 or higher
2828
- Nitro Modules
29-
- Polyfills:
30-
- TextDecoder, e.g. `@bacons/text-decoder`
31-
- Streams, e.g. `web-streams-polyfill/polyfill`
32-
- AsyncIterator, e.g. `@azure/core-asynciterator-polyfill`
3329

3430
### Usage
3531

example/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import '@bacons/text-decoder/install'
2-
import 'web-streams-polyfill/polyfill'
31
import '@azure/core-asynciterator-polyfill'
42

53
import { AppRegistry } from 'react-native'

example/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
"server": "bun server/index.ts"
99
},
1010
"dependencies": {
11-
"@azure/core-asynciterator-polyfill": "^1.0.2",
12-
"@bacons/text-decoder": "^0.0.0",
1311
"cli-table3": "^0.6.5",
1412
"react": "18.3.1",
1513
"react-native": "0.76.0",
1614
"react-native-fast-io": "0.1.1",
17-
"react-native-nitro-modules": "^0.15.0",
18-
"web-streams-polyfill": "^4.0.0"
15+
"react-native-nitro-modules": "^0.15.0"
1916
},
2017
"devDependencies": {
2118
"@babel/core": "^7.20.0",

example/tests/filesystem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react'
22
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
33
import { fetch } from 'react-native-fast-io/fetch'
4-
import { showOpenFilePicker } from 'react-native-fast-io/fs'
4+
import { File, showOpenFilePicker } from 'react-native-fast-io/fs'
55
import { CompressionStream } from 'react-native-fast-io/streams'
66

77
import { BASE_URL } from './benchmark'

packages/react-native-fast-io/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
"react-native-nitro-modules": "^0.15.0"
4747
},
4848
"dependencies": {
49-
"event-target-shim": "^6.0.2"
49+
"event-target-shim": "^6.0.2",
50+
"@bacons/text-decoder": "^0.0.0",
51+
"web-streams-polyfill": "^4.0.0"
5052
},
5153
"devDependencies": {
5254
"nitro-codegen": "^0.15.0",

packages/react-native-fast-io/src/w3c/blob.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { ReadableStream } from './streams'
2+
import { TextDecoder } from './text'
3+
14
export class Blob implements globalThis.Blob {
25
private parts: Array<BlobPart>
36

packages/react-native-fast-io/src/w3c/fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Network, RequestMethod } from '../native/network.nitro'
22
import { Blob } from './blob'
3-
import { fromReadableStream } from './streams'
3+
import { File } from './fs'
4+
import { fromReadableStream, ReadableStream } from './streams'
45

56
export function fetch(
67
url: string,

packages/react-native-fast-io/src/w3c/streams.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReadableStream, TransformStream, WritableStream } from 'web-streams-polyfill'
2+
13
import { CompressorFactory, DuplexStream, InputStream, OutputStream } from '../native/streams.nitro'
24

35
export const toReadableStream = (inputStream: InputStream) => {
@@ -76,3 +78,5 @@ export class CompressionStream implements globalThis.CompressionStream {
7678
this.writable = writable
7779
}
7880
}
81+
82+
export { ReadableStream, TransformStream, WritableStream }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { TextDecoder } from '@bacons/text-decoder'
2+
3+
export const TextEncoder = globalThis.TextEncoder

0 commit comments

Comments
 (0)