Skip to content
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

Migrate to expo-file-system #3437

Closed
wants to merge 7 commits into from
Closed

Conversation

haileyok
Copy link
Contributor

@haileyok haileyok commented Apr 6, 2024

This implements the changes made in #3102

This also will help us to resolve an additional missing API declaration for NSPrivacyAccessedAPICategoryDiskSpace. Those changes have not yet been merged into Expo, but if we get too close to the May deadline without them merging, we can patch with some changes in this PR: expo/expo#27770 (or available in this canary, though I have not looked to see what other changes this includes https://www.npmjs.com/package/expo-file-system/v/0.0.1-canary-20240328-24ecc5e)

Copied from previous PR:

This removes migrates our use of react-native-fs and rn-fetch-blob to expo-file-system. It also makes use of expo-image-manipulator instead of using react-native-image-resizer.

It also fixes a bug where the image manipulator would try to save to the same file path again. We are now cleaning up after ourselves, so this can no longer happen. Of course, in cleaning up we are also preventing the unnecessary growth of the local file store as well.

Tests are also updated to reflect the use of new libraries.

Testing

  • Save image (Tests saving and cache)
    • iOS
    • Android
    • Not applicable on web
  • Share image (Tests saving and cache)
    • iOS
    • Android
    • Not applicable on web
  • Add a link card (Tests both saving and resizing/compression)
    • iOS
    • Android
    • Web - No changes, but verify it still works
  • Upload an image (Tests resizing/compression)
    • iOS
    • Android
    • Web - No changes, but verify it still works
  • Upload an avatar (Tests resizing/compression)
    • iOS
    • Android
    • Web - No changes, but verify it still works
  • Upload a banner (Tests resizing/compression)
    • iOS
    • Android
    • Web - No changes, but verify it still works

Copy link

github-actions bot commented Apr 6, 2024

The Pull Request introduced fingerprint changes against the base commit: 74cd1d4

Fingerprint diff
[{"type":"file","filePath":"package.json","reasons":["expoConfigPlugins"],"hash":"c657b83538ee25ee557744e830286fb114ab4318"},{"type":"dir","filePath":"node_modules/expo-asset/android","reasons":["expoAutolinkingAndroid"],"hash":"af5b4d4cbc21b57e912f408979d1fc9f0833ec8b"},{"type":"dir","filePath":"node_modules/expo-asset/ios","reasons":["expoAutolinkingIos"],"hash":"0b29a1648220236ff13a9c2c2df4b931cf0dd3b9"},{"type":"dir","filePath":"node_modules/expo-font/android","reasons":["expoAutolinkingAndroid"],"hash":"3c4319f24abf3559244d85e6447f6b2a1cdbdfc1"},{"type":"dir","filePath":"node_modules/expo-keep-awake/android","reasons":["expoAutolinkingAndroid"],"hash":"58cc84309d0aa5f07286eae2453fc978a4852e3a"},{"type":"dir","filePath":"node_modules/expo-modules-core/android","reasons":["expoAutolinkingAndroid"],"hash":"727d809c2cbc3902911445751e3ee6888f7ecff3"},{"type":"dir","filePath":"node_modules/expo/android","reasons":["expoAutolinkingAndroid"],"hash":"cf55d6f637e32e539d55b00bafc8a7a247699213"},{"type":"contents","id":"expoAutolinkingConfig:android","contents":"{\"extraDependencies\":[],\"modules\":[{\"packageName\":\"expo\",\"packageVersion\":\"51.0.0-preview.7\",\"projects\":[{\"name\":\"expo\",\"sourceDir\":\"node_modules/expo/android\"}],\"modules\":[]},{\"packageName\":\"expo-application\",\"packageVersion\":\"5.8.3\",\"projects\":[{\"name\":\"expo-application\",\"sourceDir\":\"node_modules/expo-application/android\"}],\"modules\":[\"expo.modules.application.ApplicationModule\"]},{\"packageName\":\"expo-asset\",\"packageVersion\":\"10.0.3\",\"projects\":[{\"name\":\"expo-asset\",\"sourceDir\":\"node_modules/expo-asset/android\"}],\"modules\":[\"expo.modules.asset.AssetModule\"]},{\"packageName\":\"expo-bluesky-gif-view\",\"packageVersion\":\"UNVERSIONED\",\"projects\":[{\"name\":\"expo-bluesky-gif-view\",\"sourceDir\":\"modules/expo-bluesky-gif-view/android\"}],\"modules\":[\"expo.modules.blueskygifview.ExpoBlueskyGifViewModule\"]},{\"packageName\":\"expo-camera\",\"packageVersion\":\"14.0.6\",\"projects\":[{\"name\":\"expo-camera\",\"sourceDir\":\"node_modules/expo-camera/android\"}],\"modules\":[\"expo.modules.camera.CameraViewModule\",\"expo.modules.camera.next.CameraViewNextModule\"]},{\"packageName\":\"expo-clipboard\",\"packageVersion\":\"5.0.1\",\"projects\":[{\"name\":\"expo-clipboard\",\"sourceDir\":\"node_modules/expo-clipboard/android\"}],\"modules\":[\"expo.modules.clipboard.ClipboardModule\"]},{\"packageName\":\"expo-constants\",\"packageVersion\":\"15.4.5\",\"projects\":[{\"name\":\"expo-constants\",\"sourceDir\":\"node_modules/expo-constants/android\"}],\"modules\":[\"expo.modules.constants.ConstantsModule\"]},{\"packageName\":\"expo-dev-client\",\"packageVersion\":\"3.3.11\",\"projects\":[{\"name\":\"expo-dev-client\",\"sourceDir\":\"node_modules/expo-dev-client/android\"}],\"modules\":[]},{\"packageName\":\"expo-dev-launcher\",\"packageVersion\":\"3.6.9\",\"projects\":[{\"name\":\"expo-dev-launcher\",\"sourceDir\":\"node_modules/expo-dev-launcher/android\"}],\"plugins\":[{\"id\":\"expo-dev-launcher-gradle-plugin\",\"group\":\"expo.modules\",\"sourceDir\":\"/home/runner/work/social-app/social-app/node_modules/expo-dev-launcher/expo-dev-launcher-gradle-plugin\"}],\"modules\":[]},{\"packageName\":\"expo-dev-menu\",\"packageVersion\":\"4.5.8\",\"projects\":[{\"name\":\"expo-dev-menu\",\"sourceDir\":\"node_modules/expo-dev-menu/android\"}],\"modules\":[\"expo.modules.devmenu.modules.DevMenuModule\",\"expo.modules.devmenu.modules.DevMenuPreferences\"]},{\"packageName\":\"expo-dev-menu-interface\",\"packageVersion\":\"1.7.2\",\"projects\":[{\"name\":\"expo-dev-menu-interface\",\"sourceDir\":\"node_modules/expo-dev-menu-interface/android\"}],\"modules\":[]},{\"packageName\":\"expo-device\",\"packageVersion\":\"5.9.3\",\"projects\":[{\"name\":\"expo-device\",\"sourceDir\":\"node_modules/expo-device/android\"}],\"modules\":[\"expo.modules.device.DeviceModule\"]},{\"packageName\":\"expo-eas-client\",\"packageVersion\":\"0.11.0\",\"projects\":[{\"name\":\"expo-eas-client\",\"sourceDir\":\"node_modules/expo-eas-client/android\"}],\"modules\":[\"expo.modules.easclient.EASClientModule\"]},{\"packageName\":\"expo-file-system\",\"packageVersion\":\"16.0.9\",\"projects\":[{\"name\":\"expo-file-system\",\"sourceDir\":\"node_modules/expo-file-system/android\"}],\"modules\":[\"expo.modules.filesystem.FileSystemModule\"]},{\"packageName\":\"expo-font\",\"packageVersion\":\"12.0.4\",\"projects\":[{\"name\":\"expo-font\",\"sourceDir\":\"node_modules/expo-font/android\"}],\"modules\":[\"expo.modules.font.FontLoaderModule\"]},{\"packageName\":\"expo-haptics\",\"packageVersion\":\"12.8.1\",\"projects\":[{\"name\":\"expo-haptics\",\"sourceDir\":\"node_modules/expo-haptics/android\"}],\"modules\":[\"expo.modules.haptics.HapticsModule\"]},{\"packageName\":\"expo-image\",\"packageVersion\":\"1.10.6\",\"projects\":[{\"name\":\"expo-image\",\"sourceDir\":\"node_modules/expo-image/android\"}],\"modules\":[\"expo.modules.image.ExpoImageModule\"]},{\"packageName\":\"expo-image-loader\",\"packageVersion\":\"4.6.0\",\"projects\":[{\"name\":\"expo-image-loader\",\"sourceDir\":\"node_modules/expo-image-loader/android\"}],\"modules\":[]},{\"packageName\":\"expo-image-manipulator\",\"packageVersion\":\"11.8.0\",\"projects\":[{\"name\":\"expo-image-manipulator\",\"sourceDir\":\"node_modules/expo-image-manipulator/android\"}],\"modules\":[\"expo.modules.imagemanipulator.ImageManipulatorModule\"]},{\"packageName\":\"expo-image-picker\",\"packageVersion\":\"14.7.1\",\"projects\":[{\"name\":\"expo-image-picker\",\"sourceDir\":\"node_modules/expo-image-picker/android\"}],\"modules\":[\"expo.modules.imagepicker.ImagePickerModule\"]},{\"packageName\":\"expo-json-utils\",\"packageVersion\":\"0.12.0\",\"projects\":[{\"name\":\"expo-json-utils\",\"sourceDir\":\"node_modules/expo-json-utils/android\"}],\"modules\":[]},{\"packageName\":\"expo-keep-awake\",\"packageVersion\":\"13.0.1\",\"projects\":[{\"name\":\"expo-keep-awake\",\"sourceDir\":\"node_modules/expo-keep-awake/android\"}],\"modules\":[\"expo.modules.keepawake.KeepAwakeModule\"]},{\"packageName\":\"expo-linear-gradient\",\"packageVersion\":\"12.7.2\",\"projects\":[{\"name\":\"expo-linear-gradient\",\"sourceDir\":\"node_modules/expo-linear-gradient/android\"}],\"modules\":[\"expo.modules.lineargradient.LinearGradientModule\"]},{\"packageName\":\"expo-localization\",\"packageVersion\":\"14.8.3\",\"projects\":[{\"name\":\"expo-localization\",\"sourceDir\":\"node_modules/expo-localization/android\"}],\"modules\":[\"expo.modules.localization.LocalizationModule\"]},{\"packageName\":\"expo-manifests\",\"packageVersion\":\"0.13.0\",\"projects\":[{\"name\":\"expo-manifests\",\"sourceDir\":\"node_modules/expo-manifests/android\"}],\"modules\":[]},{\"packageName\":\"expo-media-library\",\"packageVersion\":\"15.9.1\",\"projects\":[{\"name\":\"expo-media-library\",\"sourceDir\":\"node_modules/expo-media-library/android\"}],\"modules\":[\"expo.modules.medialibrary.MediaLibraryModule\"]},{\"packageName\":\"expo-modules-core\",\"packageVersion\":\"1.12.3\",\"projects\":[{\"name\":\"expo-modules-core\",\"sourceDir\":\"node_modules/expo-modules-core/android\"}],\"modules\":[]},{\"packageName\":\"expo-navigation-bar\",\"packageVersion\":\"2.8.1\",\"projects\":[{\"name\":\"expo-navigation-bar\",\"sourceDir\":\"node_modules/expo-navigation-bar/android\"}],\"modules\":[\"expo.modules.navigationbar.NavigationBarModule\"]},{\"packageName\":\"expo-notifications\",\"packageVersion\":\"0.27.6\",\"projects\":[{\"name\":\"expo-notifications\",\"sourceDir\":\"node_modules/expo-notifications/android\"}],\"modules\":[\"expo.modules.notifications.badge.BadgeModule\",\"expo.modules.notifications.notifications.background.ExpoBackgroundNotificationTasksModule\",\"expo.modules.notifications.notifications.categories.ExpoNotificationCategoriesModule\",\"expo.modules.notifications.notifications.channels.NotificationChannelGroupManagerModule\",\"expo.modules.notifications.notifications.channels.NotificationChannelManagerModule\",\"expo.modules.notifications.notifications.emitting.NotificationsEmitter\",\"expo.modules.notifications.notifications.handling.NotificationsHandler\",\"expo.modules.notifications.permissions.NotificationPermissionsModule\",\"expo.modules.notifications.notifications.presentation.ExpoNotificationPresentationModule\",\"expo.modules.notifications.notifications.scheduling.NotificationScheduler\",\"expo.modules.notifications.serverregistration.ServerRegistrationModule\",\"expo.modules.notifications.tokens.PushTokenModule\"]},{\"packageName\":\"expo-receive-android-intents\",\"packageVersion\":\"UNVERSIONED\",\"projects\":[{\"name\":\"expo-receive-android-intents\",\"sourceDir\":\"modules/expo-receive-android-intents/android\"}],\"modules\":[\"xyz.blueskyweb.app.exporeceiveandroidintents.ExpoReceiveAndroidIntentsModule\"]},{\"packageName\":\"expo-sharing\",\"packageVersion\":\"11.10.0\",\"projects\":[{\"name\":\"expo-sharing\",\"sourceDir\":\"node_modules/expo-sharing/android\"}],\"modules\":[\"expo.modules.sharing.SharingModule\"]},{\"packageName\":\"expo-splash-screen\",\"packageVersion\":\"0.26.4\",\"projects\":[{\"name\":\"expo-splash-screen\",\"sourceDir\":\"node_modules/expo-splash-screen/android\"}],\"modules\":[\"expo.modules.splashscreen.SplashScreenModule\"]},{\"packageName\":\"expo-structured-headers\",\"packageVersion\":\"3.7.0\",\"projects\":[{\"name\":\"expo-structured-headers\",\"sourceDir\":\"node_modules/expo-structured-headers/android\"}],\"modules\":[]},{\"packageName\":\"expo-system-ui\",\"packageVersion\":\"2.9.3\",\"projects\":[{\"name\":\"expo-system-ui\",\"sourceDir\":\"node_modules/expo-system-ui/android\"}],\"modules\":[\"expo.modules.systemui.SystemUIModule\"]},{\"packageName\":\"expo-task-manager\",\"packageVersion\":\"11.7.2\",\"projects\":[{\"name\":\"expo-task-manager\",\"sourceDir\":\"node_modules/expo-task-manager/android\"}],\"modules\":[\"expo.modules.taskManager.TaskManagerModule\"]},{\"packageName\":\"expo-updates\",\"packageVersion\":\"0.24.12\",\"projects\":[{\"name\":\"expo-updates\",\"sourceDir\":\"node_modules/expo-updates/android\"}],\"plugins\":[{\"id\":\"expo-updates-gradle-plugin\",\"group\":\"expo.modules\",\"sourceDir\":\"/home/runner/work/social-app/social-app/node_modules/expo-updates/expo-updates-gradle-plugin\"}],\"modules\":[\"expo.modules.updates.UpdatesModule\"]},{\"packageName\":\"expo-updates-interface\",\"packageVersion\":\"0.15.1\",\"projects\":[{\"name\":\"expo-updates-interface\",\"sourceDir\":\"node_modules/expo-updates-interface/android\"}],\"modules\":[]},{\"packageName\":\"expo-web-browser\",\"packageVersion\":\"12.8.2\",\"projects\":[{\"name\":\"expo-web-browser\",\"sourceDir\":\"node_modules/expo-web-browser/android\"}],\"modules\":[\"expo.modules.webbrowser.WebBrowserModule\"]},{\"packageName\":\"unimodules-app-loader\",\"packageVersion\":\"4.5.0\",\"projects\":[{\"name\":\"unimodules-app-loader\",\"sourceDir\":\"node_modules/unimodules-app-loader/android\"}],\"modules\":[]}]}","reasons":["expoAutolinkingAndroid"],"hash":"542260f9fc1098db11213e8d3667a78cd1fcf216"},{"type":"contents","id":"expoAutolinkingConfig:ios","contents":"{\"extraDependencies\":[],\"modules\":[{\"packageName\":\"expo-asset\",\"packageVersion\":\"10.0.3\",\"pods\":[{\"podName\":\"ExpoAsset\",\"podspecDir\":\"node_modules/expo-asset/ios\"}],\"swiftModuleNames\":[\"ExpoAsset\"],\"modules\":[\"AssetModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-bluesky-gif-view\",\"packageVersion\":\"UNVERSIONED\",\"pods\":[{\"podName\":\"ExpoBlueskyGifView\",\"podspecDir\":\"modules/expo-bluesky-gif-view/ios\"}],\"swiftModuleNames\":[\"ExpoBlueskyGifView\"],\"modules\":[\"ExpoBlueskyGifViewModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-camera\",\"packageVersion\":\"14.0.6\",\"pods\":[{\"podName\":\"ExpoCamera\",\"podspecDir\":\"node_modules/expo-camera/ios\"}],\"swiftModuleNames\":[\"ExpoCamera\"],\"modules\":[\"CameraViewModule\",\"CameraViewNextModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-clipboard\",\"packageVersion\":\"5.0.1\",\"pods\":[{\"podName\":\"ExpoClipboard\",\"podspecDir\":\"node_modules/expo-clipboard/ios\"}],\"swiftModuleNames\":[\"ExpoClipboard\"],\"modules\":[\"ClipboardModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-dev-client\",\"packageVersion\":\"3.3.11\",\"pods\":[{\"podName\":\"expo-dev-client\",\"podspecDir\":\"node_modules/expo-dev-client/ios\"}],\"swiftModuleNames\":[\"expo_dev_client\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-dev-launcher\",\"packageVersion\":\"3.6.9\",\"pods\":[{\"podName\":\"expo-dev-launcher\",\"podspecDir\":\"node_modules/expo-dev-launcher\"}],\"swiftModuleNames\":[\"EXDevLauncher\"],\"modules\":[\"DevLauncherInternal\",\"DevLauncherAuth\",\"RNCSafeAreaProviderManager\"],\"appDelegateSubscribers\":[\"ExpoDevLauncherAppDelegateSubscriber\"],\"reactDelegateHandlers\":[\"ExpoDevLauncherReactDelegateHandler\"],\"debugOnly\":true},{\"packageName\":\"expo-dev-menu\",\"packageVersion\":\"4.5.8\",\"pods\":[{\"podName\":\"expo-dev-menu\",\"podspecDir\":\"node_modules/expo-dev-menu\"}],\"swiftModuleNames\":[\"EXDevMenu\"],\"modules\":[\"DevMenuModule\",\"DevMenuInternalModule\",\"DevMenuPreferences\",\"RNCSafeAreaProviderManager\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[\"ExpoDevMenuReactDelegateHandler\"],\"debugOnly\":true},{\"packageName\":\"expo-dev-menu-interface\",\"packageVersion\":\"1.7.2\",\"pods\":[{\"podName\":\"expo-dev-menu-interface\",\"podspecDir\":\"node_modules/expo-dev-menu-interface/ios\"}],\"swiftModuleNames\":[\"expo_dev_menu_interface\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-eas-client\",\"packageVersion\":\"0.11.0\",\"pods\":[{\"podName\":\"EASClient\",\"podspecDir\":\"node_modules/expo-eas-client/ios\"}],\"swiftModuleNames\":[\"EASClient\"],\"modules\":[\"EASClientModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-haptics\",\"packageVersion\":\"12.8.1\",\"pods\":[{\"podName\":\"ExpoHaptics\",\"podspecDir\":\"node_modules/expo-haptics/ios\"}],\"swiftModuleNames\":[\"ExpoHaptics\"],\"modules\":[\"HapticsModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-image-loader\",\"packageVersion\":\"4.6.0\",\"pods\":[{\"podName\":\"EXImageLoader\",\"podspecDir\":\"node_modules/expo-image-loader/ios\"}],\"swiftModuleNames\":[\"EXImageLoader\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-image-manipulator\",\"packageVersion\":\"11.8.0\",\"pods\":[{\"podName\":\"ExpoImageManipulator\",\"podspecDir\":\"node_modules/expo-image-manipulator/ios\"}],\"swiftModuleNames\":[\"ExpoImageManipulator\"],\"modules\":[\"ImageManipulatorModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-image-picker\",\"packageVersion\":\"14.7.1\",\"pods\":[{\"podName\":\"ExpoImagePicker\",\"podspecDir\":\"node_modules/expo-image-picker/ios\"}],\"swiftModuleNames\":[\"ExpoImagePicker\"],\"modules\":[\"ImagePickerModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-json-utils\",\"packageVersion\":\"0.12.0\",\"pods\":[{\"podName\":\"EXJSONUtils\",\"podspecDir\":\"node_modules/expo-json-utils/ios\"}],\"swiftModuleNames\":[\"EXJSONUtils\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-linear-gradient\",\"packageVersion\":\"12.7.2\",\"pods\":[{\"podName\":\"ExpoLinearGradient\",\"podspecDir\":\"node_modules/expo-linear-gradient/ios\"}],\"swiftModuleNames\":[\"ExpoLinearGradient\"],\"modules\":[\"LinearGradientModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-manifests\",\"packageVersion\":\"0.13.0\",\"pods\":[{\"podName\":\"EXManifests\",\"podspecDir\":\"node_modules/expo-manifests/ios\"}],\"swiftModuleNames\":[\"EXManifests\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-media-library\",\"packageVersion\":\"15.9.1\",\"pods\":[{\"podName\":\"EXMediaLibrary\",\"podspecDir\":\"node_modules/expo-media-library/ios\"}],\"swiftModuleNames\":[\"EXMediaLibrary\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-notifications\",\"packageVersion\":\"0.27.6\",\"pods\":[{\"podName\":\"EXNotifications\",\"podspecDir\":\"node_modules/expo-notifications/ios\"}],\"swiftModuleNames\":[\"EXNotifications\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-scroll-forwarder\",\"packageVersion\":\"UNVERSIONED\",\"pods\":[{\"podName\":\"ExpoScrollForwarder\",\"podspecDir\":\"modules/expo-scroll-forwarder/ios\"}],\"swiftModuleNames\":[\"ExpoScrollForwarder\"],\"modules\":[\"ExpoScrollForwarderModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-sharing\",\"packageVersion\":\"11.10.0\",\"pods\":[{\"podName\":\"ExpoSharing\",\"podspecDir\":\"node_modules/expo-sharing/ios\"}],\"swiftModuleNames\":[\"ExpoSharing\"],\"modules\":[\"SharingModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-structured-headers\",\"packageVersion\":\"3.7.0\",\"pods\":[{\"podName\":\"EXStructuredHeaders\",\"podspecDir\":\"node_modules/expo-structured-headers/ios\"}],\"swiftModuleNames\":[\"EXStructuredHeaders\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-system-ui\",\"packageVersion\":\"2.9.3\",\"pods\":[{\"podName\":\"ExpoSystemUI\",\"podspecDir\":\"node_modules/expo-system-ui/ios\"}],\"swiftModuleNames\":[\"ExpoSystemUI\"],\"modules\":[\"ExpoSystemUIModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-task-manager\",\"packageVersion\":\"11.7.2\",\"pods\":[{\"podName\":\"EXTaskManager\",\"podspecDir\":\"node_modules/expo-task-manager/ios\"}],\"swiftModuleNames\":[\"EXTaskManager\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-updates-interface\",\"packageVersion\":\"0.15.1\",\"pods\":[{\"podName\":\"EXUpdatesInterface\",\"podspecDir\":\"node_modules/expo-updates-interface/ios\"}],\"swiftModuleNames\":[\"EXUpdatesInterface\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"expo-web-browser\",\"packageVersion\":\"12.8.2\",\"pods\":[{\"podName\":\"ExpoWebBrowser\",\"podspecDir\":\"node_modules/expo-web-browser/ios\"}],\"swiftModuleNames\":[\"ExpoWebBrowser\"],\"modules\":[\"WebBrowserModule\"],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false},{\"packageName\":\"unimodules-app-loader\",\"packageVersion\":\"4.5.0\",\"pods\":[{\"podName\":\"UMAppLoader\",\"podspecDir\":\"node_modules/unimodules-app-loader/ios\"}],\"swiftModuleNames\":[\"UMAppLoader\"],\"modules\":[],\"appDelegateSubscribers\":[],\"reactDelegateHandlers\":[],\"debugOnly\":false}]}","reasons":["expoAutolinkingIos"],"hash":"7940c995a85fbdd4466736b82845edcce8348d81"},{"type":"contents","id":"expoConfig","contents":"{\"android\":{\"adaptiveIcon\":{\"backgroundColor\":\"#1185FE\",\"backgroundImage\":\"./assets/icon-android-background.png\",\"foregroundImage\":\"./assets/icon-android-foreground.png\",\"monochromeImage\":\"./assets/icon-android-foreground.png\"},\"googleServicesFile\":\"./google-services.json\",\"icon\":\"./assets/icon.png\",\"intentFilters\":[{\"action\":\"VIEW\",\"autoVerify\":true,\"category\":[\"BROWSABLE\",\"DEFAULT\"],\"data\":[false,{\"host\":\"bsky.app\",\"scheme\":\"https\"}]}],\"package\":\"xyz.blueskyweb.app\",\"splash\":{\"backgroundColor\":\"#0c7cff\",\"dark\":{\"backgroundColor\":\"#0f141b\",\"image\":\"./assets/splash-dark.png\",\"resizeMode\":\"cover\"},\"image\":\"./assets/splash.png\",\"resizeMode\":\"cover\"}},\"androidNavigationBar\":{\"backgroundColor\":\"#0f141b\",\"barStyle\":\"light-content\"},\"androidStatusBar\":{\"backgroundColor\":\"#00000000\",\"barStyle\":\"light-content\"},\"assetBundlePatterns\":[\"**/*\"],\"extra\":{\"eas\":{\"build\":{\"experimental\":{\"ios\":{\"appExtensions\":[{\"bundleIdentifier\":\"xyz.blueskyweb.app.Share-with-Bluesky\",\"entitlements\":{\"com.apple.security.application-groups\":[\"group.app.bsky\"]},\"targetName\":\"Share-with-Bluesky\"}]}}},\"projectId\":\"55bd077a-d905-4184-9c7f-94789ba0f302\"}},\"hooks\":{\"postPublish\":[{\"config\":{\"dist\":\"undefined.1.80.0.\",\"organization\":\"blueskyweb\",\"project\":\"react-native\",\"release\":\"1.80.0\"},\"file\":\"sentry-expo/upload-sourcemaps\"}]},\"icon\":\"./assets/icon.png\",\"ios\":{\"associatedDomains\":[\"applinks:bsky.app\",\"applinks:staging.bsky.app\"],\"bundleIdentifier\":\"xyz.blueskyweb.app\",\"config\":{\"usesNonExemptEncryption\":false},\"entitlements\":{\"com.apple.security.application-groups\":\"group.app.bsky\"},\"infoPlist\":{\"NSCameraUsageDescription\":\"Used for profile pictures, posts, and other kinds of content.\",\"NSMicrophoneUsageDescription\":\"Used for posts and other kinds of content.\",\"NSPhotoLibraryAddUsageDescription\":\"Used to save images to your library.\",\"NSPhotoLibraryUsageDescription\":\"Used for profile pictures, posts, and other kinds of content\",\"UIBackgroundModes\":[\"remote-notification\"]},\"splash\":{\"backgroundColor\":\"#ffffff\",\"dark\":{\"backgroundColor\":\"#001429\",\"image\":\"./assets/splash-dark.png\",\"resizeMode\":\"cover\"},\"image\":\"./assets/splash.png\",\"resizeMode\":\"cover\"},\"supportsTablet\":false},\"name\":\"Bluesky\",\"orientation\":\"portrait\",\"owner\":\"blueskysocial\",\"platforms\":[\"android\",\"ios\",\"web\"],\"plugins\":[\"./plugins/shareExtension/withShareExtensions.js\",\"./plugins/withAndroidManifestFCMIconPlugin.js\",\"./plugins/withAndroidManifestPlugin.js\",\"./plugins/withAndroidSplashScreenStatusBarTranslucentPlugin.js\",\"./plugins/withAndroidStylesWindowBackgroundPlugin.js\",\"expo-localization\",[\"expo-build-properties\",{\"android\":{\"buildToolsVersion\":\"34.0.0\",\"compileSdkVersion\":34,\"kotlinVersion\":\"1.8.0\",\"newArchEnabled\":false,\"targetSdkVersion\":34},\"ios\":{\"deploymentTarget\":\"13.4\",\"newArchEnabled\":true}}],[\"expo-notifications\",{\"color\":\"#1185fe\",\"icon\":\"./assets/icon-android-notification.png\"}]],\"scheme\":\"bluesky\",\"sdkVersion\":\"51.0.0\",\"slug\":\"bluesky\",\"splash\":{\"backgroundColor\":\"#ffffff\",\"image\":\"./assets/splash.png\",\"resizeMode\":\"cover\"},\"updates\":{\"checkAutomatically\":\"NEVER\",\"enabled\":false,\"fallbackToCacheTimeout\":30000,\"url\":\"https://updates.bsky.app/manifest\"},\"userInterfaceStyle\":\"automatic\",\"version\":\"1.80.0\",\"web\":{\"favicon\":\"./assets/favicon.png\"}}","reasons":["expoConfig"],"hash":"8e5286cab2bced62300a5c566e2af5f79a38e6b4"},{"type":"contents","id":"rncliAutolinkingConfig","contents":"{\"react-native-uitextview\":{\"root\":\"node_modules/react-native-uitextview\",\"name\":\"react-native-uitextview\",\"platforms\":{\"ios\":{\"podspecPath\":\"node_modules/react-native-uitextview/react-native-uitextview.podspec\",\"version\":\"1.1.6\",\"configurations\":[],\"scriptPhases\":[]},\"android\":null}}}","reasons":["bareRncliAutolinking"],"hash":"ae5dfbdd8900d5c4f4c99b5480e254e9d5744dd7"}]

Generated by PR labeler 🤖

Copy link

github-actions bot commented Apr 6, 2024

Old size New size Diff
6.36 MB 6.38 MB 14.54 KB (0.22%)

Comment on lines +48 to +51
try {
deleteAsync(blob)
} catch (e) {} // Don't need to handle
return res
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No logical change, only cleaning up.

Comment on lines -96 to -108
// NOTE
// for some reason expo-sharing refuses to work on iOS
// ...and visa versa
// -prf
if (isIOS) {
await RNShare.share({url: imagePath})
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer the case, and so we can simplify this logic. No real changes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(In regards to "expo-sharing refuses to work on iOS"). I'm fine with reverting though.

Comment on lines 93 to 98
await Sharing.shareAsync(imagePath, {
mimeType: 'image/png',
UTI: 'image/png',
})

deleteAsync(imagePath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same logic, just a different library.

Comment on lines +102 to +112
let imageUri = await ExpoImage.getCachePathAsync(uri)
if (!imageUri) {
// download the file to cache
// NOTE
// assuming PNG
// we're currently relying on the fact our CDN only serves pngs
// -prf
imageUri = await downloadImage(uri, createPath('png'), 5e3)
}

const imagePath = await moveToPermanentPath(imageUri, '.png')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small logic change. The only difference from before is that we attempt to use the already downloaded image for sharing. This is extremely helpful on poorer connections.


// save
await MediaLibrary.createAssetAsync(imagePath)

deleteAsync(imagePath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No logic change, just cleanup.

Comment on lines +271 to +291
export function getResizedDimensions(originalDims: {
width: number
height: number
}) {
if (
originalDims.width <= POST_IMG_MAX.width &&
originalDims.height <= POST_IMG_MAX.height
) {
return originalDims
}

const ratio = Math.min(
POST_IMG_MAX.width / originalDims.width,
POST_IMG_MAX.height / originalDims.height,
)

return {
width: Math.round(originalDims.width * ratio),
height: Math.round(originalDims.height * ratio),
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion is necessary to remove the old image manipulator package. There's some tests to ensure that this works properly.

Comment on lines +255 to +269
async function downloadImage(uri: string, path: string, timeout: number) {
const downloadResumable = createDownloadResumable(uri, path, {
cache: true,
})

const to1 = setTimeout(() => downloadResumable.cancelAsync(), timeout)
const downloadRes = await downloadResumable.downloadAsync()
clearTimeout(to1)

if (!downloadRes?.uri) {
throw new Error()
}

return normalizePath(downloadRes.uri)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the removal of rn-fetch-blob. We can revert this portion if we want to for now.

Comment on lines +243 to +244
if (!str.startsWith('file://')) {
return `file://${str}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same logic as before, but there's no need to differentiate platforms in any case.

Comment on lines 212 to 224
// This is just to try and clean up whenever we can. We won't always be able to, so in cases where we can't
// we just catch the error.
// Paths that are image caches shouldn't be removed. com.hackemist.SDImageCache is used by SDWebImage and
// image_manager_disk_cache is used by Glide
if (
!path.includes('com.hackemist.SDImageCache') &&
!path.includes('image_manager_disk_cache')
) {
try {
deleteAsync(path)
} catch (e) {
// No need to handle
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new logic, but it has no affect on the client. It only removes old files.

Comment on lines 189 to 191
} else {
await deleteAsync(resizeRes.uri)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another piece of new logic that only cleans up, no changes.

Comment on lines -36 to -38
const newPath = reqBody.replace(/\.jpe?g$/, '.bin')
await RNFS.moveFile(reqBody, newPath)
reqBody = newPath
Copy link
Contributor Author

@haileyok haileyok Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we revert, this isn't a good move. From testing, some of these files could not be moved and would result in an error. We need to try/catch this and fallback to a copy if necessary.

Comment on lines 56 to 76
let downloadRes
try {
const downloadResPromise = RNFetchBlob.config({
fileCache: true,
appendExt,
}).fetch('GET', opts.uri)
const to1 = setTimeout(() => downloadResPromise.cancel(), opts.timeout)
downloadRes = await downloadResPromise
clearTimeout(to1)

let localUri = downloadRes.path()
if (!localUri.startsWith('file://')) {
localUri = `file://${localUri}`
}
const path = createPath(appendExt)

return await doResize(localUri, opts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only deduplication. No logical change.

@haileyok haileyok marked this pull request as draft April 12, 2024 21:52
# Conflicts:
#	__tests__/lib/images.test.ts
#	package.json
#	src/lib/api/index.ts
#	src/lib/media/manip.ts
#	yarn.lock
Copy link

render bot commented Apr 28, 2024

@haileyok haileyok closed this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant