From d0b49a6ebe84af607c5b44b4bb87e03500a07e26 Mon Sep 17 00:00:00 2001 From: Andre Date: Wed, 26 Oct 2022 19:59:28 -0700 Subject: [PATCH] feat: make RCTBlobManager TurboModule-compatible (#35047) Summary: Currently, RCTBlobManager (the native module for Blob support) cannot be loaded on iOS when the new architecture is enabled. ## Changelog [General] [Added] - `BlobModule` to `RCTCoreModulesClassProvider` Pull Request resolved: https://github.com/facebook/react-native/pull/35047 Test Plan: The snippet below can be used to test Blob support with the new architecture enabled. ``` // App.tsx import { useEffect } from 'react'; import { View } from 'react-native'; function uriToBlob(uri: any) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; xhr.onload = () => { const blob = xhr.response; resolve(blob); }; xhr.onerror = err => { reject(err); }; xhr.open('GET', uri); xhr.send(); }); } export default function App() { useEffect(() => { uriToBlob('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'); }); return ; } ``` Related issue: https://github.com/facebook/react-native/issues/35042 Reviewed By: NickGerleman Differential Revision: D40716048 Pulled By: cipolleschi fbshipit-source-id: 17643d230fa7ea83baee363d137d51f87818baa8 --- React/CoreModules/CoreModulesPlugins.h | 1 + React/CoreModules/CoreModulesPlugins.mm | 1 + 2 files changed, 2 insertions(+) diff --git a/React/CoreModules/CoreModulesPlugins.h b/React/CoreModules/CoreModulesPlugins.h index 55015a55c1276b..632fd5aeab1ba2 100644 --- a/React/CoreModules/CoreModulesPlugins.h +++ b/React/CoreModules/CoreModulesPlugins.h @@ -54,6 +54,7 @@ Class RCTWebSocketModuleCls(void) __attribute__((used)); Class RCTDevLoadingViewCls(void) __attribute__((used)); Class RCTDevSplitBundleLoaderCls(void) __attribute__((used)); Class RCTEventDispatcherCls(void) __attribute__((used)); +Class RCTBlobManagerCls(void) __attribute__((used)); #ifdef __cplusplus } diff --git a/React/CoreModules/CoreModulesPlugins.mm b/React/CoreModules/CoreModulesPlugins.mm index e74ddb8ee0192d..8915f029c3fb21 100644 --- a/React/CoreModules/CoreModulesPlugins.mm +++ b/React/CoreModules/CoreModulesPlugins.mm @@ -37,6 +37,7 @@ Class RCTCoreModulesClassProvider(const char *name) { {"PerfMonitor", RCTPerfMonitorCls}, {"DevMenu", RCTDevMenuCls}, {"DevSettings", RCTDevSettingsCls}, + {"BlobModule", RCTBlobManagerCls}, {"RedBox", RCTRedBoxCls}, {"LogBox", RCTLogBoxCls}, {"WebSocketExecutor", RCTWebSocketExecutorCls},