Skip to content

fix: unify file and image types #3050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/ExpoMessaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"expo-image-manipulator": "~13.0.6",
"expo-image-picker": "~16.0.6",
"expo-linking": "~7.0.5",
"expo-media-library": "~17.0.6",
"expo-router": "~4.0.17",
"expo-sharing": "~13.0.1",
"expo-splash-screen": "~0.29.22",
Expand Down
23 changes: 14 additions & 9 deletions examples/ExpoMessaging/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4301,11 +4301,6 @@ expo-linking@~7.0.5:
expo-constants "~17.0.5"
invariant "^2.2.4"

expo-media-library@~17.0.6:
version "17.0.6"
resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-17.0.6.tgz#355f5f5abf0b5b35cdf009f18567cbba12d8dc82"
integrity sha512-LUnfrddmee1xLOkyG2NN1l9xQbtvMX3fbM1brEGHg0SKSndvjod3FQdhTzZEYAariqW2RSxQR8v1IsheIoLQXg==

expo-modules-autolinking@2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-2.0.8.tgz#b00c10ebb589ce2220548bbaee4865db1cf1f1f7"
Expand Down Expand Up @@ -5540,6 +5535,11 @@ linkifyjs@^4.1.1:
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.1.1.tgz#73d427e3bbaaf4ca8e71c589ad4ffda11a9a5fde"
integrity sha512-zFN/CTVmbcVef+WaDXT63dNzzkfRBKT1j464NJQkV7iSgJU0sLBus9W0HBwnXK13/hf168pbrx/V/bjEHOXNHA==

linkifyjs@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.2.0.tgz#9dd30222b9cbabec9c950e725ec00031c7fa3f08"
integrity sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==

locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
Expand Down Expand Up @@ -5943,6 +5943,11 @@ mime@1.6.0:
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==

mime@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.7.tgz#0b7a98b08c63bd3c10251e797d67840c9bde9f13"
integrity sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==

mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
Expand Down Expand Up @@ -7402,10 +7407,9 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0:
version "0.0.0"
uid ""

stream-chat@9.0.0-rc.8:
version "9.0.0-rc.8"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.0.0-rc.8.tgz#e188e481841493584691ae491916843d0ef5f9cd"
integrity sha512-P+Ksnu1cQQfL1t2/QTJ5rr/z2Jehvd2ap41xZgtfbJssHSD7ahe14TCF/1L7q4jjaNlZcTtLcKXCWbbOdKjDcg==
"stream-chat@https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917":
version "0.0.0-development"
resolved "https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917"
dependencies:
"@types/jsonwebtoken" "^9.0.8"
"@types/ws" "^8.5.14"
Expand All @@ -7414,6 +7418,7 @@ stream-chat@9.0.0-rc.8:
form-data "^4.0.0"
isomorphic-ws "^5.0.0"
jsonwebtoken "^9.0.2"
linkifyjs "^4.2.0"
ws "^8.18.1"

stream-slice@^0.1.2:
Expand Down
33 changes: 29 additions & 4 deletions examples/SampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,27 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-image-picker (8.2.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.11.18.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-netinfo (11.4.1):
- React-Core
- react-native-safe-area-context (5.2.0):
Expand Down Expand Up @@ -2284,6 +2305,7 @@ DEPENDENCIES:
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
- "react-native-cameraroll (from `../node_modules/@react-native-camera-roll/camera-roll`)"
- "react-native-document-picker (from `../node_modules/@react-native-documents/picker`)"
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-video (from `../node_modules/react-native-video`)
Expand Down Expand Up @@ -2439,6 +2461,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-camera-roll/camera-roll"
react-native-document-picker:
:path: "../node_modules/@react-native-documents/picker"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-safe-area-context:
Expand Down Expand Up @@ -2557,7 +2581,7 @@ SPEC CHECKSUMS:
op-sqlite: c33561ea312a2ae38aae032fd3a42635dc6b57e8
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 36fe2295e44b10d831836cc0d1daec5f8abcf809
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
RCTDeprecation: b2eecf2d60216df56bc5e6be5f063826d3c1ee35
RCTRequired: 78522de7dc73b81f3ed7890d145fa341f5bb32ea
RCTTypeSafety: c135dd2bf50402d87fd12884cbad5d5e64850edd
Expand Down Expand Up @@ -2589,8 +2613,9 @@ SPEC CHECKSUMS:
React-Mapbuffer: 0df2a235bd0182f5cbed6c5f095e66deca12e335
React-microtasksnativemodule: b31e56a980634f383221bfefd5111d04c14c110b
react-native-blob-util: 875bbeee07e4ada135e4edf9fc7b22acf8d9721d
react-native-cameraroll: 36dc62b41c7943a79ac2f7cf4d3da10d4138513f
react-native-cameraroll: cdc91c4c953d1a18aa3ce88b5a25698025c8c4d2
react-native-document-picker: 19be73c0423e4bc886cef74ec282eff750698013
react-native-image-picker: 1c620a65f900a47d6d12ec94874c6a1820ebea7d
react-native-netinfo: f0a9899081c185db1de5bb2fdc1c88c202a059ac
react-native-safe-area-context: 0b43456abcaaa3c8323bbfafe9c5f0f9511219d2
react-native-video: a225b4d4d3286f3253dc7b00a62e7c8e59d04d51
Expand Down Expand Up @@ -2637,9 +2662,9 @@ SPEC CHECKSUMS:
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
stream-chat-react-native: 6b89c43ee042e7a6f00e6eaddf3228b712884846
stream-chat-react-native: aa6626ef9dd68e28b1239c9f2ee2fc7ce1fd3c3f
Yoga: be02ca501b03c79d7027a6bbbd0a8db985034f11

PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d

COCOAPODS: 1.16.2
COCOAPODS: 1.14.3
1 change: 1 addition & 0 deletions examples/SampleApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-native-fast-image": "^8.6.3",
"react-native-gesture-handler": "^2.24.0",
"react-native-haptic-feedback": "^2.3.3",
"react-native-image-picker": "^8.2.0",
"react-native-reanimated": "^3.17.1",
"react-native-safe-area-context": "^5.2.0",
"react-native-screens": "^4.9.1",
Expand Down
10 changes: 10 additions & 0 deletions examples/SampleApp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6273,6 +6273,11 @@ mime@^2.4.1:
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==

mime@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.7.tgz#0b7a98b08c63bd3c10251e797d67840c9bde9f13"
integrity sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==

mimic-fn@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
Expand Down Expand Up @@ -6890,6 +6895,11 @@ react-native-haptic-feedback@^2.3.3:
resolved "https://registry.yarnpkg.com/react-native-haptic-feedback/-/react-native-haptic-feedback-2.3.3.tgz#88b6876e91399a69bd1b551fe1681b2f3dc1214e"
integrity sha512-svS4D5PxfNv8o68m9ahWfwje5NqukM3qLS48+WTdhbDkNUkOhP9rDfDSRHzlhk4zq+ISjyw95EhLeh8NkKX5vQ==

react-native-image-picker@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-8.2.0.tgz#d8656fdd1a0f1ad262c9c129d4f75900b685e56e"
integrity sha512-jIGllQJuJIn0YKss/JEeb0Kos1HSsnIpU+i3bYxR27sOxSyDZQyP9dKR22olssQPlfH+rGNR/Jc6xKRkhm48vw==

react-native-is-edge-to-edge@1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/react-native-is-edge-to-edge/-/react-native-is-edge-to-edge-1.1.6.tgz#69ec13f70d76e9245e275eed4140d0873a78f902"
Expand Down
12 changes: 6 additions & 6 deletions examples/TypeScriptMessaging/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3564,7 +3564,7 @@ es6-iterator@^2.0.3:
es5-ext "^0.10.35"
es6-symbol "^3.1.1"

es6-symbol@^3.1.1, es6-symbol@^3.1.3:
es6-symbol@^3.1.1, es6-symbol@^3.1.3, es6-symbol@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.4.tgz#f4e7d28013770b4208ecbf3e0bf14d3bcb557b8c"
integrity sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==
Expand Down Expand Up @@ -5287,7 +5287,7 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==

linkifyjs@^4.1.1:
linkifyjs@^4.1.1, linkifyjs@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-4.2.0.tgz#9dd30222b9cbabec9c950e725ec00031c7fa3f08"
integrity sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==
Expand Down Expand Up @@ -6929,10 +6929,9 @@ statuses@~1.5.0:
version "0.0.0"
uid ""

stream-chat@9.0.0-rc.8:
version "9.0.0-rc.8"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.0.0-rc.8.tgz#e188e481841493584691ae491916843d0ef5f9cd"
integrity sha512-P+Ksnu1cQQfL1t2/QTJ5rr/z2Jehvd2ap41xZgtfbJssHSD7ahe14TCF/1L7q4jjaNlZcTtLcKXCWbbOdKjDcg==
"stream-chat@https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917":
version "0.0.0-development"
resolved "https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917"
dependencies:
"@types/jsonwebtoken" "^9.0.8"
"@types/ws" "^8.5.14"
Expand All @@ -6941,6 +6940,7 @@ stream-chat@9.0.0-rc.8:
form-data "^4.0.0"
isomorphic-ws "^5.0.0"
jsonwebtoken "^9.0.2"
linkifyjs "^4.2.0"
ws "^8.18.1"

strict-uri-encode@^2.0.0:
Expand Down
5 changes: 3 additions & 2 deletions package/expo-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
"main": "src/index.js",
"types": "types/index.d.ts",
"dependencies": {
"mime": "^4.0.7",
"stream-chat-react-native-core": "link:../"
},
"peerDependencies": {
"expo": ">=51.0.0",
"expo-av": "*",
"expo-video": "*",
"expo-clipboard": "*",
"expo-document-picker": "*",
"expo-file-system": "*",
"expo-haptics": "*",
"expo-image-manipulator": "*",
"expo-image-picker": "*",
"expo-media-library": "*",
"expo-sharing": "*"
"expo-sharing": "*",
"expo-video": "*"
},
"peerDependenciesMeta": {
"expo-av": {
Expand Down
13 changes: 7 additions & 6 deletions package/expo-package/src/optionalDependencies/getPhotos.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Platform } from 'react-native';
import mime from 'mime';

import type { File } from 'stream-chat-react-native-core';

let MediaLibrary;

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

import { getLocalAssetUri } from './getLocalAssetUri';

type ReturnType = {
assets: Array<Omit<Asset, 'source'> & { source: 'picker' }>;
assets: File[];
endCursor: string | undefined;
hasNextPage: boolean;
iOSLimited: boolean;
Expand Down Expand Up @@ -52,14 +54,13 @@ export const getPhotos = MediaLibrary
const assets = await Promise.all(
results.assets.map(async (asset) => {
const localUri = await getLocalAssetUri(asset.id);
const mimeType = mime.getType(asset.filename);
return {
duration: asset.duration * 1000,
height: asset.height,
id: asset.id,
name: asset.filename,
originalUri: asset.uri,
source: 'picker' as const,
type: asset.mediaType,
thumb_url: asset.mediaType === 'photo' ? undefined : asset.uri,
type: mimeType,
uri: localUri || asset.uri,
width: asset.width,
};
Expand Down
12 changes: 10 additions & 2 deletions package/expo-package/src/optionalDependencies/pickDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ export const pickDocument = DocumentPicker
// Applicable to latest version of expo-document-picker
if (assets) {
return {
assets,
assets: assets.map((asset) => ({
...asset,
type: asset.mimeType,
})),
cancelled: false,
};
}
// Applicable to older version of expo-document-picker
return {
assets: [rest],
assets: [
{
...rest,
type: rest.mimeType,
},
],
cancelled: false,
};
} catch (err) {
Expand Down
3 changes: 1 addition & 2 deletions package/expo-package/src/optionalDependencies/pickImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ export const pickImage = ImagePicker
duration: asset.duration,
name: asset.fileName,
size: asset.fileSize,
source: 'picker',
type: asset.mimeType,
uri: asset.uri,
}));
return { assets, cancelled: false, source: 'picker' };
return { assets, cancelled: false };
} else {
return { cancelled: true };
}
Expand Down
3 changes: 0 additions & 3 deletions package/expo-package/src/optionalDependencies/takePhoto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const takePhoto = ImagePicker
duration: photo.duration, // in milliseconds
name: 'video_recording_' + date + '.' + photo.uri.split('.').pop(),
size: photo.fileSize,
source: 'camera',
type: photo.mimeType,
uri: photo.uri,
};
Expand Down Expand Up @@ -95,10 +94,8 @@ export const takePhoto = ImagePicker
const date = new Date().toISOString().replace(clearFilter, '_');
return {
cancelled: false,
mimeType: photo.mimeType,
name: 'image_' + date + '.' + photo.uri.split('.').pop(),
size: photo.fileSize,
source: 'camera',
type: photo.mimeType,
uri: photo.uri,
...size,
Expand Down
21 changes: 8 additions & 13 deletions package/expo-package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3764,6 +3764,11 @@ mime@1.6.0:
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==

mime@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/mime/-/mime-4.0.7.tgz#0b7a98b08c63bd3c10251e797d67840c9bde9f13"
integrity sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==

mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
Expand Down Expand Up @@ -4777,19 +4782,9 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0:
version "0.0.0"
uid ""

"stream-chat@https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917":
version "0.0.0-development"
resolved "https://github.com/GetStream/stream-chat-js.git#9bc79358e9d0a23e0ff7e2a056711289e5bdf917"
dependencies:
"@types/jsonwebtoken" "^9.0.8"
"@types/ws" "^8.5.14"
axios "^1.6.0"
base64-js "^1.5.1"
form-data "^4.0.0"
isomorphic-ws "^5.0.0"
jsonwebtoken "^9.0.2"
linkifyjs "^4.2.0"
ws "^8.18.1"
"stream-chat@link:../../../stream-chat-js":
version "0.0.0"
uid ""

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
Expand Down
3 changes: 2 additions & 1 deletion package/native-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
"types": "types/index.d.ts",
"dependencies": {
"es6-symbol": "^3.1.4",
"mime": "^4.0.7",
"stream-chat-react-native-core": "link:../"
},
"peerDependencies": {
"@react-native-camera-roll/camera-roll": ">=7.8.0",
"@react-native-clipboard/clipboard": ">=1.14.1",
"@react-native-documents/picker": ">=10.1.1",
"@stream-io/flat-list-mvcp": ">=0.10.3",
"react-native": ">=0.71.0",
"react-native-audio-recorder-player": ">=3.6.4",
"react-native-blob-util": ">=0.19.9",
"@react-native-documents/picker": ">=10.1.1",
"react-native-haptic-feedback": ">=2.2.0",
"react-native-image-picker": ">=7.1.2",
"react-native-share": ">=10.2.1",
Expand Down
Loading
Loading