Skip to content

Commit b28252b

Browse files
authored
fix: unify file and image types (#3050)
* fix: unify file and image types * fix: refine types * fix: remove props from auto complete input
1 parent 491a957 commit b28252b

File tree

37 files changed

+365
-397
lines changed

37 files changed

+365
-397
lines changed

examples/ExpoMessaging/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"expo-image-manipulator": "~13.0.6",
2424
"expo-image-picker": "~16.0.6",
2525
"expo-linking": "~7.0.5",
26-
"expo-media-library": "~17.0.6",
2726
"expo-router": "~4.0.17",
2827
"expo-sharing": "~13.0.1",
2928
"expo-splash-screen": "~0.29.22",

examples/ExpoMessaging/yarn.lock

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4301,11 +4301,6 @@ expo-linking@~7.0.5:
43014301
expo-constants "~17.0.5"
43024302
invariant "^2.2.4"
43034303

4304-
expo-media-library@~17.0.6:
4305-
version "17.0.6"
4306-
resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-17.0.6.tgz#355f5f5abf0b5b35cdf009f18567cbba12d8dc82"
4307-
integrity sha512-LUnfrddmee1xLOkyG2NN1l9xQbtvMX3fbM1brEGHg0SKSndvjod3FQdhTzZEYAariqW2RSxQR8v1IsheIoLQXg==
4308-
43094304
43104305
version "2.0.8"
43114306
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-2.0.8.tgz#b00c10ebb589ce2220548bbaee4865db1cf1f1f7"
@@ -5540,6 +5535,11 @@ linkifyjs@^4.1.1:
55405535
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.1.1.tgz#73d427e3bbaaf4ca8e71c589ad4ffda11a9a5fde"
55415536
integrity sha512-zFN/CTVmbcVef+WaDXT63dNzzkfRBKT1j464NJQkV7iSgJU0sLBus9W0HBwnXK13/hf168pbrx/V/bjEHOXNHA==
55425537

5538+
linkifyjs@^4.2.0:
5539+
version "4.2.0"
5540+
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.2.0.tgz#9dd30222b9cbabec9c950e725ec00031c7fa3f08"
5541+
integrity sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==
5542+
55435543
locate-path@^3.0.0:
55445544
version "3.0.0"
55455545
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
@@ -5943,6 +5943,11 @@ [email protected]:
59435943
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
59445944
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
59455945

5946+
mime@^4.0.7:
5947+
version "4.0.7"
5948+
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.7.tgz#0b7a98b08c63bd3c10251e797d67840c9bde9f13"
5949+
integrity sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==
5950+
59465951
mimic-fn@^1.0.0:
59475952
version "1.2.0"
59485953
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
@@ -7402,10 +7407,9 @@ [email protected], stream-buffers@~2.2.0:
74027407
version "0.0.0"
74037408
uid ""
74047409

7405-
7406-
version "9.0.0-rc.8"
7407-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.0.0-rc.8.tgz#e188e481841493584691ae491916843d0ef5f9cd"
7408-
integrity sha512-P+Ksnu1cQQfL1t2/QTJ5rr/z2Jehvd2ap41xZgtfbJssHSD7ahe14TCF/1L7q4jjaNlZcTtLcKXCWbbOdKjDcg==
7410+
"stream-chat@https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917":
7411+
version "0.0.0-development"
7412+
resolved "https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917"
74097413
dependencies:
74107414
"@types/jsonwebtoken" "^9.0.8"
74117415
"@types/ws" "^8.5.14"
@@ -7414,6 +7418,7 @@ [email protected]:
74147418
form-data "^4.0.0"
74157419
isomorphic-ws "^5.0.0"
74167420
jsonwebtoken "^9.0.2"
7421+
linkifyjs "^4.2.0"
74177422
ws "^8.18.1"
74187423

74197424
stream-slice@^0.1.2:

examples/SampleApp/ios/Podfile.lock

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,27 @@ PODS:
14751475
- ReactCommon/turbomodule/bridging
14761476
- ReactCommon/turbomodule/core
14771477
- Yoga
1478+
- react-native-image-picker (8.2.0):
1479+
- DoubleConversion
1480+
- glog
1481+
- hermes-engine
1482+
- RCT-Folly (= 2024.11.18.00)
1483+
- RCTRequired
1484+
- RCTTypeSafety
1485+
- React-Core
1486+
- React-debug
1487+
- React-Fabric
1488+
- React-featureflags
1489+
- React-graphics
1490+
- React-ImageManager
1491+
- React-NativeModulesApple
1492+
- React-RCTFabric
1493+
- React-rendererdebug
1494+
- React-utils
1495+
- ReactCodegen
1496+
- ReactCommon/turbomodule/bridging
1497+
- ReactCommon/turbomodule/core
1498+
- Yoga
14781499
- react-native-netinfo (11.4.1):
14791500
- React-Core
14801501
- react-native-safe-area-context (5.2.0):
@@ -2284,6 +2305,7 @@ DEPENDENCIES:
22842305
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
22852306
- "react-native-cameraroll (from `../node_modules/@react-native-camera-roll/camera-roll`)"
22862307
- "react-native-document-picker (from `../node_modules/@react-native-documents/picker`)"
2308+
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
22872309
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
22882310
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
22892311
- react-native-video (from `../node_modules/react-native-video`)
@@ -2439,6 +2461,8 @@ EXTERNAL SOURCES:
24392461
:path: "../node_modules/@react-native-camera-roll/camera-roll"
24402462
react-native-document-picker:
24412463
:path: "../node_modules/@react-native-documents/picker"
2464+
react-native-image-picker:
2465+
:path: "../node_modules/react-native-image-picker"
24422466
react-native-netinfo:
24432467
:path: "../node_modules/@react-native-community/netinfo"
24442468
react-native-safe-area-context:
@@ -2557,7 +2581,7 @@ SPEC CHECKSUMS:
25572581
op-sqlite: c33561ea312a2ae38aae032fd3a42635dc6b57e8
25582582
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
25592583
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
2560-
RCT-Folly: 36fe2295e44b10d831836cc0d1daec5f8abcf809
2584+
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
25612585
RCTDeprecation: b2eecf2d60216df56bc5e6be5f063826d3c1ee35
25622586
RCTRequired: 78522de7dc73b81f3ed7890d145fa341f5bb32ea
25632587
RCTTypeSafety: c135dd2bf50402d87fd12884cbad5d5e64850edd
@@ -2589,8 +2613,9 @@ SPEC CHECKSUMS:
25892613
React-Mapbuffer: 0df2a235bd0182f5cbed6c5f095e66deca12e335
25902614
React-microtasksnativemodule: b31e56a980634f383221bfefd5111d04c14c110b
25912615
react-native-blob-util: 875bbeee07e4ada135e4edf9fc7b22acf8d9721d
2592-
react-native-cameraroll: 36dc62b41c7943a79ac2f7cf4d3da10d4138513f
2616+
react-native-cameraroll: cdc91c4c953d1a18aa3ce88b5a25698025c8c4d2
25932617
react-native-document-picker: 19be73c0423e4bc886cef74ec282eff750698013
2618+
react-native-image-picker: 1c620a65f900a47d6d12ec94874c6a1820ebea7d
25942619
react-native-netinfo: f0a9899081c185db1de5bb2fdc1c88c202a059ac
25952620
react-native-safe-area-context: 0b43456abcaaa3c8323bbfafe9c5f0f9511219d2
25962621
react-native-video: a225b4d4d3286f3253dc7b00a62e7c8e59d04d51
@@ -2637,9 +2662,9 @@ SPEC CHECKSUMS:
26372662
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
26382663
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
26392664
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2640-
stream-chat-react-native: 6b89c43ee042e7a6f00e6eaddf3228b712884846
2665+
stream-chat-react-native: aa6626ef9dd68e28b1239c9f2ee2fc7ce1fd3c3f
26412666
Yoga: be02ca501b03c79d7027a6bbbd0a8db985034f11
26422667

26432668
PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d
26442669

2645-
COCOAPODS: 1.16.2
2670+
COCOAPODS: 1.14.3

examples/SampleApp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"react-native-fast-image": "^8.6.3",
4343
"react-native-gesture-handler": "^2.24.0",
4444
"react-native-haptic-feedback": "^2.3.3",
45+
"react-native-image-picker": "^8.2.0",
4546
"react-native-reanimated": "^3.17.1",
4647
"react-native-safe-area-context": "^5.2.0",
4748
"react-native-screens": "^4.9.1",

examples/SampleApp/yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,6 +6273,11 @@ mime@^2.4.1:
62736273
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
62746274
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
62756275

6276+
mime@^4.0.7:
6277+
version "4.0.7"
6278+
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.7.tgz#0b7a98b08c63bd3c10251e797d67840c9bde9f13"
6279+
integrity sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==
6280+
62766281
mimic-fn@^2.1.0:
62776282
version "2.1.0"
62786283
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
@@ -6890,6 +6895,11 @@ react-native-haptic-feedback@^2.3.3:
68906895
resolved "https://registry.yarnpkg.com/react-native-haptic-feedback/-/react-native-haptic-feedback-2.3.3.tgz#88b6876e91399a69bd1b551fe1681b2f3dc1214e"
68916896
integrity sha512-svS4D5PxfNv8o68m9ahWfwje5NqukM3qLS48+WTdhbDkNUkOhP9rDfDSRHzlhk4zq+ISjyw95EhLeh8NkKX5vQ==
68926897

6898+
react-native-image-picker@^8.2.0:
6899+
version "8.2.0"
6900+
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-8.2.0.tgz#d8656fdd1a0f1ad262c9c129d4f75900b685e56e"
6901+
integrity sha512-jIGllQJuJIn0YKss/JEeb0Kos1HSsnIpU+i3bYxR27sOxSyDZQyP9dKR22olssQPlfH+rGNR/Jc6xKRkhm48vw==
6902+
68936903
68946904
version "1.1.6"
68956905
resolved "https://registry.yarnpkg.com/react-native-is-edge-to-edge/-/react-native-is-edge-to-edge-1.1.6.tgz#69ec13f70d76e9245e275eed4140d0873a78f902"

examples/TypeScriptMessaging/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,7 +3564,7 @@ es6-iterator@^2.0.3:
35643564
es5-ext "^0.10.35"
35653565
es6-symbol "^3.1.1"
35663566

3567-
es6-symbol@^3.1.1, es6-symbol@^3.1.3:
3567+
es6-symbol@^3.1.1, es6-symbol@^3.1.3, es6-symbol@^3.1.4:
35683568
version "3.1.4"
35693569
resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.4.tgz#f4e7d28013770b4208ecbf3e0bf14d3bcb557b8c"
35703570
integrity sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==
@@ -5287,7 +5287,7 @@ lines-and-columns@^1.1.6:
52875287
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
52885288
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
52895289

5290-
linkifyjs@^4.1.1:
5290+
linkifyjs@^4.1.1, linkifyjs@^4.2.0:
52915291
version "4.2.0"
52925292
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.2.0.tgz#9dd30222b9cbabec9c950e725ec00031c7fa3f08"
52935293
integrity sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==
@@ -6929,10 +6929,9 @@ statuses@~1.5.0:
69296929
version "0.0.0"
69306930
uid ""
69316931

6932-
6933-
version "9.0.0-rc.8"
6934-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.0.0-rc.8.tgz#e188e481841493584691ae491916843d0ef5f9cd"
6935-
integrity sha512-P+Ksnu1cQQfL1t2/QTJ5rr/z2Jehvd2ap41xZgtfbJssHSD7ahe14TCF/1L7q4jjaNlZcTtLcKXCWbbOdKjDcg==
6932+
"stream-chat@https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917":
6933+
version "0.0.0-development"
6934+
resolved "https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917"
69366935
dependencies:
69376936
"@types/jsonwebtoken" "^9.0.8"
69386937
"@types/ws" "^8.5.14"
@@ -6941,6 +6940,7 @@ [email protected]:
69416940
form-data "^4.0.0"
69426941
isomorphic-ws "^5.0.0"
69436942
jsonwebtoken "^9.0.2"
6943+
linkifyjs "^4.2.0"
69446944
ws "^8.18.1"
69456945

69466946
strict-uri-encode@^2.0.0:

package/expo-package/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@
1010
"main": "src/index.js",
1111
"types": "types/index.d.ts",
1212
"dependencies": {
13+
"mime": "^4.0.7",
1314
"stream-chat-react-native-core": "link:../"
1415
},
1516
"peerDependencies": {
1617
"expo": ">=51.0.0",
1718
"expo-av": "*",
18-
"expo-video": "*",
1919
"expo-clipboard": "*",
2020
"expo-document-picker": "*",
2121
"expo-file-system": "*",
2222
"expo-haptics": "*",
2323
"expo-image-manipulator": "*",
2424
"expo-image-picker": "*",
2525
"expo-media-library": "*",
26-
"expo-sharing": "*"
26+
"expo-sharing": "*",
27+
"expo-video": "*"
2728
},
2829
"peerDependenciesMeta": {
2930
"expo-av": {

package/expo-package/src/optionalDependencies/getPhotos.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { Platform } from 'react-native';
2+
import mime from 'mime';
3+
4+
import type { File } from 'stream-chat-react-native-core';
25

36
let MediaLibrary;
47

@@ -13,12 +16,11 @@ if (!MediaLibrary) {
1316
'expo-media-library is not installed. Please install it or you can choose to install expo-image-picker for native image picker.',
1417
);
1518
}
16-
import type { Asset } from 'stream-chat-react-native-core';
1719

1820
import { getLocalAssetUri } from './getLocalAssetUri';
1921

2022
type ReturnType = {
21-
assets: Array<Omit<Asset, 'source'> & { source: 'picker' }>;
23+
assets: File[];
2224
endCursor: string | undefined;
2325
hasNextPage: boolean;
2426
iOSLimited: boolean;
@@ -52,14 +54,13 @@ export const getPhotos = MediaLibrary
5254
const assets = await Promise.all(
5355
results.assets.map(async (asset) => {
5456
const localUri = await getLocalAssetUri(asset.id);
57+
const mimeType = mime.getType(asset.filename);
5558
return {
5659
duration: asset.duration * 1000,
5760
height: asset.height,
58-
id: asset.id,
5961
name: asset.filename,
60-
originalUri: asset.uri,
61-
source: 'picker' as const,
62-
type: asset.mediaType,
62+
thumb_url: asset.mediaType === 'photo' ? undefined : asset.uri,
63+
type: mimeType,
6364
uri: localUri || asset.uri,
6465
width: asset.width,
6566
};

package/expo-package/src/optionalDependencies/pickDocument.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,21 @@ export const pickDocument = DocumentPicker
3838
// Applicable to latest version of expo-document-picker
3939
if (assets) {
4040
return {
41-
assets,
41+
assets: assets.map((asset) => ({
42+
...asset,
43+
type: asset.mimeType,
44+
})),
4245
cancelled: false,
4346
};
4447
}
4548
// Applicable to older version of expo-document-picker
4649
return {
47-
assets: [rest],
50+
assets: [
51+
{
52+
...rest,
53+
type: rest.mimeType,
54+
},
55+
],
4856
cancelled: false,
4957
};
5058
} catch (err) {

package/expo-package/src/optionalDependencies/pickImage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ export const pickImage = ImagePicker
4545
duration: asset.duration,
4646
name: asset.fileName,
4747
size: asset.fileSize,
48-
source: 'picker',
4948
type: asset.mimeType,
5049
uri: asset.uri,
5150
}));
52-
return { assets, cancelled: false, source: 'picker' };
51+
return { assets, cancelled: false };
5352
} else {
5453
return { cancelled: true };
5554
}

0 commit comments

Comments
 (0)