mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
Summary: Adds `ArrayBuffer` support to C++ TurboModules. This includes: - Codegen support for `ArrayBufferTypeAnnotation` in module specs - `AsyncArrayBuffer` — a move-only bridging type for holding ArrayBuffer data off the JS thread - `Bridging<AsyncArrayBuffer>::toJs` for resolving promises with native-backed or owned-bytes buffers iOS and Android support will follow in separate PRs. The new codegen type is currently restricted to C++ TurboModules via `excludedPlatforms: ['iOS', 'android']`. ## Changelog: [GENERAL] [ADDED] - Add `ArrayBuffer` support to C++ TurboModules Pull Request resolved: https://github.com/facebook/react-native/pull/56729 Test Plan: - JS parser/generators tests added. - New bridging unit tests in `BridgingTest.cpp` cover `AsyncArrayBuffer` construction and JS bridging. - `rn-tester`: `getArrayBuffer`, `processAsyncBuffer`, and `getAsyncBuffer` methods added to `NativeCxxModuleExample` in demo app. ``` [chpurrer@54913.od /data/sandcastle/boxes/fbsource (a00a9a84e7)]$ buck test //xplat/js/react-native-github/packages/react-native/ReactCommon/react/bridging:tests ↷ Skip: fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/react/bridging:tests - BridgingTest.asyncArrayBufferBorrowNativeBackedTest (0.0s) Note: Google Test filter = BridgingTest.asyncArrayBufferBorrowNativeBackedTest [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from BridgingTest [ RUN ] BridgingTest.asyncArrayBufferBorrowNativeBackedTest xplat/js/react-native-github/packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp:865: Skipped Runtime does not expose tryGetMutableBuffer; borrow always throws [ SKIPPED ] BridgingTest.asyncArrayBufferBorrowNativeBackedTest (7 ms) [----------] 1 test from BridgingTest (7 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (7 ms total) [ PASSED ] 0 tests. [ SKIPPED ] 1 test, listed below: [ SKIPPED ] BridgingTest.asyncArrayBufferBorrowNativeBackedTest Buck UI: https://www.internalfb.com/buck2/4a7fa180-4ce6-4dcf-b685-45d183bd4091 Test UI: https://www.internalfb.com/intern/testinfra/testrun/30680772470375729 Network: Up: 0B Down: 0B (reSessionID-9a7e839f-b20c-4d94-944f-8d1720e694f8) Command: test. Time elapsed: 3.0s Buck UI: https://www.internalfb.com/buck2/4a7fa180-4ce6-4dcf-b685-45d183bd4091 Tests finished: Pass 31. Fail 0. Timeout 0. Fatal 0. Skip 1. Omit 0. Infra Failure 0. Build failure 0 [chpurrer@54913.od /data/sandcastle/boxes/fbsource (a00a9a84e7)]$ ``` ## RNTester-ios ``` buck install -r rntester-ios ``` https://pxl.cl/9TgTf Reviewed By: javache Differential Revision: D105629442 Pulled By: christophpurrer fbshipit-source-id: 91f6e3d16f69ba792469e02d6e539794e70b7101