ArrayBuffer support to C++ TurboModules (#56729)

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
This commit is contained in:
Kamil Paradowski authored and meta-codesync[bot] committed 2026-05-21 10:29:49 -07:00
1 parent 13ab72a600
commit 226ef2e7c5
48 files changed
+1552 -21

No files matched your search

+6 -1
View File
@@ -46,6 +46,10 @@ export interface VoidTypeAnnotation {
readonly type: 'VoidTypeAnnotation';
}
export interface ArrayBufferTypeAnnotation {
readonly type: 'ArrayBufferTypeAnnotation';
}
export interface BooleanLiteralTypeAnnotation {
readonly type: 'BooleanLiteralTypeAnnotation';
readonly value: boolean;
@@ -417,7 +421,8 @@ export type NativeModuleEventEmitterTypeAnnotation =
| ArrayTypeAnnotation<NativeModuleEventEmitterBaseTypeAnnotation>;
export type NativeModuleBaseTypeAnnotation =
NativeModuleStringTypeAnnotation
ArrayBufferTypeAnnotation
| NativeModuleStringTypeAnnotation
| StringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
| NativeModuleNumberTypeAnnotation
+5
View File
@@ -68,6 +68,10 @@ export type VoidTypeAnnotation = Readonly<{
type: 'VoidTypeAnnotation',
}>;
export type ArrayBufferTypeAnnotation = Readonly<{
type: 'ArrayBufferTypeAnnotation',
}>;
export type ObjectTypeAnnotation<+T> = Readonly<{
type: 'ObjectTypeAnnotation',
properties: ReadonlyArray<NamedShape<T>>,
@@ -411,6 +415,7 @@ export type NativeModuleEventEmitterTypeAnnotation =
| ArrayTypeAnnotation<NativeModuleEventEmitterBaseTypeAnnotation>;
export type NativeModuleBaseTypeAnnotation =
| ArrayBufferTypeAnnotation
| StringTypeAnnotation
| StringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
@@ -146,6 +146,8 @@ function serializeArg(
return wrap(val => `${val}.asObject(rt)`);
case 'MixedTypeAnnotation':
return wrap(val => `jsi::Value(rt, ${val})`);
case 'ArrayBufferTypeAnnotation':
return wrap(val => `${val}.asObject(rt).getArrayBuffer(rt)`);
default:
realTypeAnnotation.type as empty;
throw new Error(
@@ -307,6 +309,8 @@ function translatePrimitiveJSTypeToCpp(
return wrapOptional('jsi::Value', isRequired);
case 'MixedTypeAnnotation':
return wrapOptional('jsi::Value', isRequired);
case 'ArrayBufferTypeAnnotation':
return wrapOptional('jsi::ArrayBuffer', isRequired);
default:
realTypeAnnotation.type as empty;
throw new Error(createErrorMessage(realTypeAnnotation.type));
@@ -267,6 +267,10 @@ function translateFunctionParamToJavaType(
case 'FunctionTypeAnnotation':
imports.add('com.facebook.react.bridge.Callback');
return wrapOptional('Callback', isRequired);
case 'ArrayBufferTypeAnnotation':
throw new Error(
`${createErrorMessage(realTypeAnnotation.type)} ArrayBuffer is only supported for C++ TurboModules.`,
);
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(createErrorMessage(realTypeAnnotation.type));
@@ -361,6 +365,10 @@ function translateFunctionReturnTypeToJavaType(
case 'ArrayTypeAnnotation':
imports.add('com.facebook.react.bridge.WritableArray');
return wrapOptional('WritableArray', isRequired);
case 'ArrayBufferTypeAnnotation':
throw new Error(
`${createErrorMessage(realTypeAnnotation.type)} ArrayBuffer is only supported for C++ TurboModules.`,
);
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(createErrorMessage(realTypeAnnotation.type));
@@ -443,6 +451,10 @@ function getFalsyReturnStatementFromReturnType(
return 'return null;';
case 'ArrayTypeAnnotation':
return 'return null;';
case 'ArrayBufferTypeAnnotation':
throw new Error(
`${createErrorMessage(realTypeAnnotation.type)} ArrayBuffer is only supported for C++ TurboModules.`,
);
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(createErrorMessage(realTypeAnnotation.type));
@@ -216,6 +216,8 @@ function translateReturnTypeToKind(
return 'ObjectKind';
case 'ArrayTypeAnnotation':
return 'ArrayKind';
case 'ArrayBufferTypeAnnotation':
throw new Error('ArrayBuffer is only supported for C++ TurboModules.');
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(
@@ -303,6 +305,8 @@ function translateParamTypeToJniType(
return 'Lcom/facebook/react/bridge/ReadableArray;';
case 'FunctionTypeAnnotation':
return 'Lcom/facebook/react/bridge/Callback;';
case 'ArrayBufferTypeAnnotation':
throw new Error('ArrayBuffer is only supported for C++ TurboModules.');
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(
@@ -387,6 +391,8 @@ function translateReturnTypeToJniType(
return 'Lcom/facebook/react/bridge/WritableMap;';
case 'ArrayTypeAnnotation':
return 'Lcom/facebook/react/bridge/WritableArray;';
case 'ArrayBufferTypeAnnotation':
throw new Error('ArrayBuffer is only supported for C++ TurboModules.');
default:
realTypeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(
@@ -132,6 +132,10 @@ class StructCollector {
return wrapNullable(nullable, typeAnnotation);
case 'MixedTypeAnnotation':
throw new Error('Mixed types are unsupported in structs');
case 'ArrayBufferTypeAnnotation':
throw new Error(
'ArrayBuffer is unsupported in TurboModule struct types.',
);
case 'UnionTypeAnnotation':
try {
const validUnionType = parseValidUnionType(typeAnnotation);
@@ -387,6 +387,10 @@ function getReturnObjCType(
}
case 'GenericObjectTypeAnnotation':
return wrapOptional('NSDictionary *', isRequired);
case 'ArrayBufferTypeAnnotation':
throw new Error(
`Unsupported return type for ${methodName}: ArrayBuffer is only supported for C++ TurboModules.`,
);
default:
typeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(
@@ -459,6 +463,10 @@ function getReturnJSType(
validUnionType as empty;
throw new Error(`Unsupported union member types`);
}
case 'ArrayBufferTypeAnnotation':
throw new Error(
`Unsupported return type for ${methodName}: ArrayBuffer is only supported for C++ TurboModules.`,
);
default:
typeAnnotation.type as 'MixedTypeAnnotation';
throw new Error(
@@ -2600,6 +2600,89 @@ const CXX_ONLY_NATIVE_MODULES: SchemaType = {
},
};
const ARRAY_BUFFER_NATIVE_MODULE: SchemaType = {
modules: {
NativeSampleTurboModule: {
type: 'NativeModule',
aliasMap: {},
enumMap: {},
spec: {
eventEmitters: [],
methods: [
{
name: 'getArrayBuffer',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
type: 'ArrayBufferTypeAnnotation',
},
params: [],
},
},
{
name: 'voidArrayBuffer',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
type: 'VoidTypeAnnotation',
},
params: [
{
name: 'arg',
optional: false,
typeAnnotation: {
type: 'ArrayBufferTypeAnnotation',
},
},
],
},
},
{
name: 'voidNullableArrayBuffer',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
type: 'VoidTypeAnnotation',
},
params: [
{
name: 'arg',
optional: false,
typeAnnotation: {
type: 'NullableTypeAnnotation',
typeAnnotation: {
type: 'ArrayBufferTypeAnnotation',
},
},
},
],
},
},
{
name: 'promiseArrayBuffer',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
type: 'PromiseTypeAnnotation',
elementType: {
type: 'ArrayBufferTypeAnnotation',
},
},
params: [],
},
},
],
},
moduleName: 'SampleTurboModule',
excludedPlatforms: ['iOS', 'android'],
},
},
};
const SAMPLE_WITH_UPPERCASE_NAME: SchemaType = {
modules: {
NativeSampleTurboModule: {
@@ -2793,6 +2876,7 @@ const STRING_LITERALS: SchemaType = {
};
module.exports = {
array_buffer_native_module: ARRAY_BUFFER_NATIVE_MODULE,
complex_objects: COMPLEX_OBJECTS,
two_modules_different_files: TWO_MODULES_DIFFERENT_FILES,
empty_native_modules: EMPTY_NATIVE_MODULES,
@@ -38,6 +38,75 @@ private:
}
`;
exports[`GenerateModuleH can generate fixture array_buffer_native_module 1`] = `
Map {
"array_buffer_native_moduleJSI.h" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleH.js
*/
#pragma once
#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>
namespace facebook::react {
template <typename T>
class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule {
public:
static constexpr std::string_view kModuleName = \\"SampleTurboModule\\";
protected:
NativeSampleTurboModuleCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeSampleTurboModuleCxxSpec::kModuleName}, jsInvoker) {
methodMap_[\\"getArrayBuffer\\"] = MethodMetadata {.argCount = 0, .invoker = __getArrayBuffer};
methodMap_[\\"voidArrayBuffer\\"] = MethodMetadata {.argCount = 1, .invoker = __voidArrayBuffer};
methodMap_[\\"voidNullableArrayBuffer\\"] = MethodMetadata {.argCount = 1, .invoker = __voidNullableArrayBuffer};
methodMap_[\\"promiseArrayBuffer\\"] = MethodMetadata {.argCount = 0, .invoker = __promiseArrayBuffer};
}
private:
static jsi::Value __getArrayBuffer(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
static_assert(
bridging::getParameterCount(&T::getArrayBuffer) == 1,
\\"Expected getArrayBuffer(...) to have 1 parameters\\");
return bridging::callFromJs<jsi::ArrayBuffer>(rt, &T::getArrayBuffer, static_cast<NativeSampleTurboModuleCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
}
static jsi::Value __voidArrayBuffer(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
static_assert(
bridging::getParameterCount(&T::voidArrayBuffer) == 2,
\\"Expected voidArrayBuffer(...) to have 2 parameters\\");
bridging::callFromJs<void>(rt, &T::voidArrayBuffer, static_cast<NativeSampleTurboModuleCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
count <= 0 ? throw jsi::JSError(rt, \\"Expected argument in position 0 to be passed\\") : args[0].asObject(rt).getArrayBuffer(rt));return jsi::Value::undefined();
}
static jsi::Value __voidNullableArrayBuffer(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
static_assert(
bridging::getParameterCount(&T::voidNullableArrayBuffer) == 2,
\\"Expected voidNullableArrayBuffer(...) to have 2 parameters\\");
bridging::callFromJs<void>(rt, &T::voidNullableArrayBuffer, static_cast<NativeSampleTurboModuleCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
count <= 0 || args[0].isNull() || args[0].isUndefined() ? std::nullopt : std::make_optional(args[0].asObject(rt).getArrayBuffer(rt)));return jsi::Value::undefined();
}
static jsi::Value __promiseArrayBuffer(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
static_assert(
bridging::getParameterCount(&T::promiseArrayBuffer) == 1,
\\"Expected promiseArrayBuffer(...) to have 1 parameters\\");
return bridging::callFromJs<jsi::Value>(rt, &T::promiseArrayBuffer, static_cast<NativeSampleTurboModuleCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
}
};
} // namespace facebook::react
",
}
`;
exports[`GenerateModuleH can generate fixture complex_objects 1`] = `
Map {
"complex_objectsJSI.h" => "/**
@@ -65,6 +65,47 @@ namespace facebook::react {
}
`;
exports[`GenerateModuleHObjCpp can generate fixture array_buffer_native_module 1`] = `
Map {
"array_buffer_native_module.h" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleObjCpp
*
* We create an umbrella header (and corresponding implementation) here since
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
* must have a single output. More files => more genrule()s => slower builds.
*/
#ifndef __cplusplus
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
#endif
// Avoid multiple includes of array_buffer_native_module symbols
#ifndef array_buffer_native_module_H
#define array_buffer_native_module_H
#import <Foundation/Foundation.h>
#import <RCTRequired/RCTRequired.h>
#import <RCTTypeSafety/RCTConvertHelpers.h>
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTCxxConvert.h>
#import <React/RCTManagedPointer.h>
#import <ReactCommon/RCTTurboModule.h>
#import <optional>
#import <vector>
#endif // array_buffer_native_module_H
",
}
`;
exports[`GenerateModuleHObjCpp can generate fixture complex_objects 1`] = `
Map {
"complex_objects.h" => "/**
@@ -41,6 +41,8 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo
}
`;
exports[`GenerateModuleJavaSpec can generate fixture array_buffer_native_module 1`] = `Map {}`;
exports[`GenerateModuleJavaSpec can generate fixture complex_objects 1`] = `
Map {
"java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => "
@@ -35,6 +35,34 @@ std::shared_ptr<TurboModule> SampleWithUppercaseName_ModuleProvider(const std::s
}
`;
exports[`GenerateModuleJniCpp can generate fixture array_buffer_native_module 1`] = `
Map {
"jni/array_buffer_native_module-generated.cpp" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJniCpp.js
*/
#include \\"array_buffer_native_module.h\\"
namespace facebook::react {
std::shared_ptr<TurboModule> array_buffer_native_module_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
return nullptr;
}
} // namespace facebook::react
",
}
`;
exports[`GenerateModuleJniCpp can generate fixture complex_objects 1`] = `
Map {
"jni/complex_objects-generated.cpp" => "
@@ -66,6 +66,65 @@ target_compile_reactnative_options(react_codegen_SampleWithUppercaseName PRIVATE
}
`;
exports[`GenerateModuleJniH can generate fixture array_buffer_native_module 1`] = `
Map {
"jni/array_buffer_native_module.h" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJniH.js
*/
#pragma once
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
namespace facebook::react {
JSI_EXPORT
std::shared_ptr<TurboModule> array_buffer_native_module_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
} // namespace facebook::react
",
"jni/CMakeLists.txt" => "# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/array_buffer_native_module/*.cpp)
add_library(
react_codegen_array_buffer_native_module
OBJECT
\${react_codegen_SRCS}
)
target_include_directories(react_codegen_array_buffer_native_module PUBLIC . react/renderer/components/array_buffer_native_module)
target_link_libraries(
react_codegen_array_buffer_native_module
fbjni
jsi
# We need to link different libraries based on whether we are building rncore or not, that's necessary
# because we want to break a circular dependency between react_codegen_rncore and reactnative
reactnative
)
target_compile_reactnative_options(react_codegen_array_buffer_native_module PRIVATE)
",
}
`;
exports[`GenerateModuleJniH can generate fixture complex_objects 1`] = `
Map {
"jni/complex_objects.h" => "
@@ -40,6 +40,28 @@ namespace facebook::react {
}
`;
exports[`GenerateModuleMm can generate fixture array_buffer_native_module 1`] = `
Map {
"array_buffer_native_module-generated.mm" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleObjCpp
*
* We create an umbrella header (and corresponding implementation) here since
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
* must have a single output. More files => more genrule()s => slower builds.
*/
#import \\"array_buffer_native_module.h\\"
",
}
`;
exports[`GenerateModuleMm can generate fixture complex_objects 1`] = `
Map {
"complex_objects-generated.mm" => "/**
@@ -652,6 +652,39 @@ describe('emitPromise', () => {
});
});
});
describe('when Promise element type resolves to ArrayBufferTypeAnnotation', () => {
it('returns PromiseTypeAnnotation with ArrayBuffer element type', () => {
const result = emitPromise(
moduleName,
{
typeParameters: {
params: [{}],
type: 'TypeParameterInstantiation',
},
id: {
name: 'Promise',
},
},
parser,
false,
{},
{},
{},
function <T>(f: () => T): $FlowFixMe {
return f();
},
false,
() => ({
type: 'ArrayBufferTypeAnnotation',
}),
);
expect(result).toEqual({
type: 'PromiseTypeAnnotation',
elementType: {type: 'ArrayBufferTypeAnnotation'},
});
});
});
});
describe('emitGenericObject', () => {
@@ -1829,6 +1862,26 @@ describe('emitUnion', () => {
});
});
describe("when 'typeAnnotation.id.name' is 'ArrayBuffer'", () => {
const typeAnnotation = {
typeParameters: {
params: [1, 2],
type: 'GenericTypeAnnotation',
},
id: {
name: 'ArrayBuffer',
},
};
const expected = {
type: 'ArrayBufferTypeAnnotation',
};
const result = emitCommonTypesForUnitTest(typeAnnotation, false);
it("returns 'ArrayBufferTypeAnnotation'", () => {
expect(result).toEqual(expected);
});
});
describe("when 'typeAnnotation.id.name' is 'UnsafeObject'", () => {
const typeAnnotation = {
typeParameters: {
@@ -218,6 +218,7 @@ const UnsupportedObjectPropertyTypeToInvalidPropertyValueTypeMap = {
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
VoidTypeAnnotation: 'void',
PromiseTypeAnnotation: 'Promise',
ArrayBufferTypeAnnotation: 'ArrayBuffer',
};
function throwIfPropertyValueTypeIsUnsupported(
@@ -277,6 +278,7 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
VoidTypeAnnotation: 'void',
PromiseTypeAnnotation: 'Promise',
ArrayBufferTypeAnnotation: 'ArrayBuffer',
// TODO: Added as a work-around for now until TupleTypeAnnotation are fully supported in both flow and TS
// Right now they are partially treated as UnionTypeAnnotation
// UnionTypeAnnotation: 'UnionTypeAnnotation',
@@ -322,6 +322,34 @@ export interface Spec extends TurboModule {
export default TurboModuleRegistry.getEnforcing<Spec>('MixedValuesEnumNativeModule');
`;
const NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY = `
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {TurboModule} from '../RCTExport';
import * as TurboModuleRegistry from '../TurboModuleRegistry';
type Row = {
buf: ArrayBuffer,
};
export interface Spec extends TurboModule {
+useRow: (row: Row) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
module.exports = {
NATIVE_MODULES_WITH_READ_ONLY_OBJECT_NO_TYPE_FOR_CONTENT,
NATIVE_MODULES_WITH_UNNAMED_PARAMS,
@@ -335,4 +363,5 @@ module.exports = {
MIXED_VALUES_ENUM_NATIVE_MODULE,
NUMERIC_VALUES_ENUM_NATIVE_MODULE,
MAP_WITH_EXTRA_KEYS_NATIVE_MODULE,
NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY,
};
@@ -985,6 +985,33 @@ export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
const NATIVE_MODULE_WITH_ARRAY_BUFFER = `
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {TurboModule} from '../RCTExport';
import * as TurboModuleRegistry from '../TurboModuleRegistry';
export interface Spec extends TurboModule {
+getArrayBuffer: () => ArrayBuffer;
+voidArrayBuffer: (arg: ArrayBuffer) => void;
+voidNullableArrayBuffer: (arg: ?ArrayBuffer) => void;
+promiseArrayBuffer: () => Promise<ArrayBuffer>;
}
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
module.exports = {
NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY,
NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE,
@@ -1009,6 +1036,7 @@ module.exports = {
NATIVE_MODULE_WITH_UNION_RETURN_TYPES,
NATIVE_MODULE_WITH_EVENT_EMITTERS,
NATIVE_MODULE_WITH_OPAQUE_TYPES,
NATIVE_MODULE_WITH_ARRAY_BUFFER,
EMPTY_NATIVE_MODULE,
ANDROID_ONLY_NATIVE_MODULE,
IOS_ONLY_NATIVE_MODULE,
@@ -13,6 +13,8 @@ export enum SomeEnum {
^"
`;
exports[`RN Codegen Flow Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY 1`] = `"Module NativeSampleTurboModule: Object property '[object Object]' cannot have type 'ArrayBuffer'."`;
exports[`RN Codegen Flow Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`;
exports[`RN Codegen Flow Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`;
@@ -1110,6 +1112,90 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ALIASES
}"
`;
exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_BUFFER 1`] = `
"{
'modules': {
'NativeSampleTurboModule': {
'type': 'NativeModule',
'aliasMap': {},
'enumMap': {},
'spec': {
'eventEmitters': [],
'methods': [
{
'name': 'getArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
},
'params': []
}
},
{
'name': 'voidArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
}
}
]
}
},
{
'name': 'voidNullableArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'NullableTypeAnnotation',
'typeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
}
}
}
]
}
},
{
'name': 'promiseArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'PromiseTypeAnnotation',
'elementType': {
'type': 'ArrayBufferTypeAnnotation'
}
},
'params': []
}
}
]
},
'moduleName': 'SampleTurboModule'
}
}
}"
`;
exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS 1`] = `
"{
'modules': {
@@ -307,7 +307,8 @@ function parseObjectProperty(
if (
(propertyTypeAnnotation.type === 'FunctionTypeAnnotation' && !cxxOnly) ||
propertyTypeAnnotation.type === 'PromiseTypeAnnotation' ||
propertyTypeAnnotation.type === 'VoidTypeAnnotation'
propertyTypeAnnotation.type === 'VoidTypeAnnotation' ||
propertyTypeAnnotation.type === 'ArrayBufferTypeAnnotation'
) {
throwIfPropertyValueTypeIsUnsupported(
hasteModuleName,
@@ -11,6 +11,7 @@
'use strict';
import type {
ArrayBufferTypeAnnotation,
BooleanLiteralTypeAnnotation,
BooleanTypeAnnotation,
DoubleTypeAnnotation,
@@ -127,6 +128,14 @@ function emitVoid(nullable: boolean): Nullable<VoidTypeAnnotation> {
});
}
function emitArrayBuffer(
nullable: boolean,
): Nullable<ArrayBufferTypeAnnotation> {
return wrapNullable(nullable, {
type: 'ArrayBufferTypeAnnotation',
});
}
function emitStringish(nullable: boolean): Nullable<StringTypeAnnotation> {
return wrapNullable(nullable, {
type: 'StringTypeAnnotation',
@@ -351,20 +360,18 @@ function emitPromise(
},
});
} else {
let elementTypeResult;
try {
return wrapNullable(nullable, {
type: 'PromiseTypeAnnotation',
elementType: translateTypeAnnotation(
hasteModuleName,
typeAnnotation.typeParameters.params[0],
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
parser,
),
});
elementTypeResult = translateTypeAnnotation(
hasteModuleName,
typeAnnotation.typeParameters.params[0],
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
parser,
);
} catch {
return wrapNullable(nullable, {
type: 'PromiseTypeAnnotation',
@@ -373,6 +380,11 @@ function emitPromise(
},
});
}
return wrapNullable(nullable, {
type: 'PromiseTypeAnnotation',
elementType: elementTypeResult,
});
}
}
@@ -666,6 +678,7 @@ function emitCommonTypes(
UnsafeMixed: cxxOnly ? emitMixed : emitGenericObject,
unknown: cxxOnly ? emitMixed : emitGenericObject,
UnknownTypeAnnotation: cxxOnly ? emitMixed : emitGenericObject,
ArrayBuffer: emitArrayBuffer,
};
const typeAnnotationName = parser.convertKeywordToTypeAnnotation(
@@ -764,6 +777,7 @@ function emitUnionProp(
}
module.exports = {
emitArrayBuffer,
emitArrayType,
emitBoolean,
emitBooleanLiteral,
@@ -261,6 +261,31 @@ export interface Spec extends TurboModule {
export default TurboModuleRegistry.getEnforcing<Spec>('MapWithExtraKeysNativeModule');
`;
const NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY = `
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
type Row = {
buf: ArrayBuffer;
};
export interface Spec extends TurboModule {
readonly useRow: (row: Row) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
module.exports = {
NATIVE_MODULES_WITH_UNNAMED_PARAMS,
NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE,
@@ -273,4 +298,5 @@ module.exports = {
MIXED_VALUES_ENUM_NATIVE_MODULE,
NUMERIC_VALUES_ENUM_NATIVE_MODULE,
MAP_WITH_EXTRA_KEYS_NATIVE_MODULE,
NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY,
};
@@ -995,7 +995,32 @@ export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
const NATIVE_MODULE_WITH_ARRAY_BUFFER = `
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export interface Spec extends TurboModule {
readonly getArrayBuffer: () => ArrayBuffer;
readonly voidArrayBuffer: (arg: ArrayBuffer) => void;
readonly voidNullableArrayBuffer: (arg: ArrayBuffer | null) => void;
readonly promiseArrayBuffer: () => Promise<ArrayBuffer>;
}
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
`;
module.exports = {
NATIVE_MODULE_WITH_ARRAY_BUFFER,
NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY,
NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE,
NATIVE_MODULE_WITH_ARRAY2_WITH_UNION_AND_TOUPLE,
@@ -6,6 +6,8 @@ exports[`RN Codegen TypeScript Parser Fails with error message MAP_WITH_EXTRA_KE
exports[`RN Codegen TypeScript Parser Fails with error message MIXED_VALUES_ENUM_NATIVE_MODULE 1`] = `"Module NativeSampleTurboModule: Failed parsing the enum SomeEnum in NativeSampleTurboModule with the error: Enum values can not be mixed. They all must be either blank, number, or string values."`;
exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_BUFFER_IN_OBJECT_PROPERTY 1`] = `"Module NativeSampleTurboModule: Object property '[object Object]' cannot have type 'ArrayBuffer'."`;
exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`;
exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`;
@@ -1097,6 +1099,90 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_AL
}"
`;
exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_BUFFER 1`] = `
"{
'modules': {
'NativeSampleTurboModule': {
'type': 'NativeModule',
'aliasMap': {},
'enumMap': {},
'spec': {
'eventEmitters': [],
'methods': [
{
'name': 'getArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
},
'params': []
}
},
{
'name': 'voidArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
}
}
]
}
},
{
'name': 'voidNullableArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'NullableTypeAnnotation',
'typeAnnotation': {
'type': 'ArrayBufferTypeAnnotation'
}
}
}
]
}
},
{
'name': 'promiseArrayBuffer',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'PromiseTypeAnnotation',
'elementType': {
'type': 'ArrayBufferTypeAnnotation'
}
},
'params': []
}
}
]
},
'moduleName': 'SampleTurboModule'
}
}
}"
`;
exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS 1`] = `
"{
'modules': {
@@ -100,6 +100,8 @@ function formatTypeAnnotation(annotation: CompleteTypeAnnotation): string {
switch (annotation.type) {
case 'AnyTypeAnnotation':
return 'any';
case 'ArrayBufferTypeAnnotation':
return 'ArrayBuffer';
case 'ArrayTypeAnnotation':
return 'Array<' + formatTypeAnnotation(annotation.elementType) + '>';
case 'BooleanTypeAnnotation':
@@ -46,6 +46,9 @@ export function compareTypeAnnotationForSorting(
switch (typeA.type) {
case 'AnyTypeAnnotation':
return 0;
case 'ArrayBufferTypeAnnotation':
invariant(typeB.type === 'ArrayBufferTypeAnnotation', EQUALITY_MSG);
return originalPositionA - originalPositionB;
case 'ArrayTypeAnnotation':
invariant(typeB.type === 'ArrayTypeAnnotation', EQUALITY_MSG);
return compareTypeAnnotationForSorting(
@@ -281,6 +284,8 @@ function typeAnnotationArbitraryOrder(annotation: CompleteTypeAnnotation) {
return 28;
case 'UnionTypeAnnotation':
return 30;
case 'ArrayBufferTypeAnnotation':
return 31;
default:
annotation.type as empty;
return -1;
@@ -176,6 +176,7 @@ export function compareTypeAnnotation(
switch (newerAnnotation.type) {
case 'AnyTypeAnnotation':
case 'MixedTypeAnnotation':
case 'ArrayBufferTypeAnnotation':
case 'DoubleTypeAnnotation':
case 'FloatTypeAnnotation':
case 'Int32TypeAnnotation':
@@ -21,6 +21,7 @@ type AfterMismatchGeneric<Foo> = {};
type BeforeMatchingGeneric<T> = {};
type AfterMatchingGeneric<T> = {};
type ArrayBufferType = ArrayBuffer;
type BooleanType = boolean;
type StringType = string;
@@ -45,6 +46,7 @@ export interface Spec extends TurboModule {
+beforeMatchingGeneric: <T>(a: BeforeMatchingGeneric<T>) => void;
+afterMatchingGeneric: <T>(a: AfterMatchingGeneric<T>) => void;
+arrayBufferType: (a: ArrayBufferType) => void;
+booleanType: (a: BooleanType) => void;
+stringType: (a: StringType) => void;
@@ -271,6 +271,7 @@ Object {
"errorCode": "addedProps",
"message": "NativeModuleTest: Object added required properties, which native will not provide
-- afterMismatchGeneric
-- arrayBufferType
-- booleanType
-- exampleFunction
-- simpleArray
@@ -0,0 +1,180 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <span>
#include <string>
#include <react/bridging/Base.h>
namespace facebook::react {
namespace detail {
/**
* An owning implementation of jsi::MutableBuffer backed by a std::vector.
* Use this when the source of the bytes cannot be guaranteed to outlive the
* buffer (for example, returning data to JS from an asynchronous native call,
* or copying a JS ArrayBuffer argument before storing it).
*/
class OwnedBytesBuffer final : public jsi::MutableBuffer {
public:
explicit OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept : bytes_(std::move(bytes)) {}
size_t size() const override
{
return bytes_.size();
}
uint8_t *data() override
{
return bytes_.data();
}
private:
std::vector<uint8_t> bytes_;
};
} // namespace detail
template <>
struct Bridging<jsi::ArrayBuffer> {
static jsi::ArrayBuffer fromJs(jsi::Runtime &rt, const jsi::Object &obj)
{
if (!obj.isArrayBuffer(rt)) {
throw jsi::JSError(rt, "Expected ArrayBuffer");
}
return obj.getArrayBuffer(rt);
}
static jsi::Value toJs(jsi::Runtime &rt, jsi::ArrayBuffer buf)
{
return {rt, buf};
}
};
/* AsyncArrayBuffer holds ArrayBuffer bytes for use off the JS thread. Move-only.
*
* Always backed by a shared_ptr<jsi::MutableBuffer>: either one borrowed from
* a native-backed jsi::ArrayBuffer or an internal adapter wrapping owned
* bytes. May outlive the TurboModule call and be transferred across threads;
* concurrent reads and writes to the buffer contents (the bytes returned by
* data()) must be synchronized externally.
*/
class AsyncArrayBuffer {
public:
AsyncArrayBuffer(const AsyncArrayBuffer &) = delete;
AsyncArrayBuffer &operator=(const AsyncArrayBuffer &) = delete;
AsyncArrayBuffer(AsyncArrayBuffer &&) noexcept = default;
AsyncArrayBuffer &operator=(AsyncArrayBuffer &&) noexcept = default;
~AsyncArrayBuffer() = default;
// Zero-copy if the input has a native MutableBuffer; copies otherwise.
static AsyncArrayBuffer acquire(jsi::Runtime &rt, const jsi::ArrayBuffer &buffer)
{
throwIfDetached(rt, buffer, "AsyncArrayBuffer::acquire");
if (auto mutableBuf = buffer.tryGetMutableBuffer(rt)) {
return AsyncArrayBuffer{std::move(mutableBuf)};
}
return copyBytes(rt, buffer);
}
// Zero-copy. Throws if the input has no native MutableBuffer.
static AsyncArrayBuffer borrow(jsi::Runtime &rt, const jsi::ArrayBuffer &buffer)
{
throwIfDetached(rt, buffer, "AsyncArrayBuffer::borrow");
auto mutableBuf = buffer.tryGetMutableBuffer(rt);
if (!mutableBuf) {
throw jsi::JSError(
rt,
"AsyncArrayBuffer::borrow: ArrayBuffer has no native MutableBuffer. "
"Use AsyncArrayBuffer::acquire(rt, buffer) when the buffer origin is unknown.");
}
return AsyncArrayBuffer{std::move(mutableBuf)};
}
// Always copies.
static AsyncArrayBuffer copy(jsi::Runtime &rt, const jsi::ArrayBuffer &buffer)
{
throwIfDetached(rt, buffer, "AsyncArrayBuffer::copy");
return copyBytes(rt, buffer);
}
// Wraps an existing MutableBuffer. Safe to call from any thread.
static AsyncArrayBuffer wrap(std::shared_ptr<jsi::MutableBuffer> buffer) noexcept
{
return AsyncArrayBuffer{std::move(buffer)};
}
// Takes ownership of a byte vector. Safe to call from any thread.
static AsyncArrayBuffer wrap(std::vector<uint8_t> bytes)
{
return AsyncArrayBuffer{std::make_shared<detail::OwnedBytesBuffer>(std::move(bytes))};
}
uint8_t *data() noexcept
{
return buffer_->data();
}
const uint8_t *data() const noexcept
{
return buffer_->data();
}
size_t size() const noexcept
{
return buffer_->size();
}
// Returns the underlying MutableBuffer. Used by
// Bridging<AsyncArrayBuffer>::toJs to hand the buffer back to JS without a
// copy. Always non-null.
std::shared_ptr<jsi::MutableBuffer> getMutableBuffer() const noexcept
{
return buffer_;
}
private:
explicit AsyncArrayBuffer(std::shared_ptr<jsi::MutableBuffer> buffer) noexcept : buffer_{std::move(buffer)} {}
static AsyncArrayBuffer copyBytes(jsi::Runtime &rt, const jsi::ArrayBuffer &buffer)
{
auto bytes = std::span(buffer.data(rt), buffer.size(rt));
return wrap(std::vector<uint8_t>(bytes.begin(), bytes.end()));
}
// Best-effort detached check. jsi::ArrayBuffer::detached relies on the JS-level
// `detached` property, which some runtimes (e.g. Hermes) don't implement and
// signal by throwing. In that case we silently skip the check rather than
// surfacing a confusing error from an unrelated method.
static void throwIfDetached(jsi::Runtime &rt, const jsi::ArrayBuffer &buffer, const char *callerName)
{
bool detached = false;
try {
detached = buffer.detached(rt);
} catch (const jsi::JSINativeException &) {
return;
}
if (detached) {
throw jsi::JSError(rt, std::string(callerName) + ": ArrayBuffer is detached");
}
}
std::shared_ptr<jsi::MutableBuffer> buffer_;
};
template <>
struct Bridging<AsyncArrayBuffer> {
static jsi::Value toJs(jsi::Runtime &rt, AsyncArrayBuffer buffer)
{
return {rt, rt.createArrayBuffer(buffer.getMutableBuffer())};
}
};
} // namespace facebook::react
@@ -9,6 +9,7 @@
#include <react/bridging/AString.h>
#include <react/bridging/Array.h>
#include <react/bridging/ArrayBuffer.h>
#include <react/bridging/Bool.h>
#include <react/bridging/Class.h>
#include <react/bridging/Dynamic.h>
@@ -63,6 +63,8 @@ struct ConverterBase {
return std::move(value).getObject(rt_).getArray(rt_);
} else if constexpr (std::is_same_v<BaseT, jsi::Function>) {
return std::move(value).getObject(rt_).getFunction(rt_);
} else if constexpr (std::is_same_v<BaseT, jsi::ArrayBuffer>) {
return std::move(value).asObject(rt_).getArrayBuffer(rt_);
}
} else {
return std::move(value_);
@@ -117,6 +119,11 @@ struct Converter<jsi::Value> : public ConverterBase<jsi::Value> {
{
return std::move(value_).asObject(rt_).asFunction(rt_);
}
operator jsi::ArrayBuffer() &&
{
return std::move(value_).asObject(rt_).getArrayBuffer(rt_);
}
};
template <>
@@ -132,6 +139,11 @@ struct Converter<jsi::Object> : public ConverterBase<jsi::Object> {
{
return std::move(value_).asFunction(rt_);
}
operator jsi::ArrayBuffer() &&
{
return std::move(value_).getArrayBuffer(rt_);
}
};
template <typename T>
@@ -5,6 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
#include <span>
#include <utility>
#include "BridgingTest.h"
namespace facebook::react {
@@ -17,6 +20,7 @@ TEST_F(BridgingTest, jsiTest) {
jsi::Value object = jsi::Object(rt);
jsi::Value array = jsi::Array::createWithElements(rt, value, object);
jsi::Value func = function("() => {}");
jsi::Value arrayBuffer = eval("new ArrayBuffer(0)");
// The bridging mechanism needs to know how to copy and downcast values.
EXPECT_NO_THROW(bridging::fromJs<jsi::Value>(rt, value, invoker));
@@ -24,6 +28,7 @@ TEST_F(BridgingTest, jsiTest) {
EXPECT_NO_THROW(bridging::fromJs<jsi::Object>(rt, object, invoker));
EXPECT_NO_THROW(bridging::fromJs<jsi::Array>(rt, array, invoker));
EXPECT_NO_THROW(bridging::fromJs<jsi::Function>(rt, func, invoker));
EXPECT_NO_THROW(bridging::fromJs<jsi::ArrayBuffer>(rt, arrayBuffer, invoker));
// Should throw when attempting an invalid cast.
EXPECT_JSI_THROW(bridging::fromJs<jsi::Object>(rt, value, invoker));
@@ -31,6 +36,7 @@ TEST_F(BridgingTest, jsiTest) {
EXPECT_JSI_THROW(bridging::fromJs<jsi::Array>(rt, object, invoker));
EXPECT_JSI_THROW(bridging::fromJs<jsi::Array>(rt, string, invoker));
EXPECT_JSI_THROW(bridging::fromJs<jsi::Array>(rt, func, invoker));
EXPECT_JSI_THROW(bridging::fromJs<jsi::ArrayBuffer>(rt, value, invoker));
// Should be able to generically no-op convert JSI.
EXPECT_NO_THROW(bridging::toJs(rt, value, invoker));
@@ -195,9 +201,8 @@ TEST_F(BridgingTest, functionTest) {
auto object = jsi::Object(rt);
object.setProperty(rt, "foo", "bar");
auto lambda = [](std::map<std::string, std::string> map, std::string key) {
return map[key];
};
auto lambda = [](std::map<std::string, std::string> map,
const std::string& key) { return map[key]; };
auto func = bridging::toJs(rt, lambda, invoker);
@@ -280,7 +285,8 @@ TEST_F(BridgingTest, syncCallbackImplicitBridgingTest) {
TEST_F(BridgingTest, asyncCallbackTest) {
std::string output;
auto func = std::function<void(std::string)>([&](auto str) { output = str; });
auto func = std::function<void(std::string)>(
[&](auto str) { output = std::move(str); });
auto cb = bridging::fromJs<AsyncCallback<decltype(func), std::string>>(
rt, function("(func, str) => func(str)"), invoker);
@@ -304,7 +310,9 @@ TEST_F(BridgingTest, asyncCallbackTest) {
TEST_F(BridgingTest, asyncCallbackInvalidation) {
std::string output;
std::function<void(std::string)> func = [&](auto str) { output = str; };
std::function<void(std::string)> func = [&](auto str) {
output = std::move(str);
};
auto jsCallback = bridging::fromJs<AsyncCallback<>>(
rt, bridging::toJs(rt, func, invoker), invoker);
@@ -322,7 +330,8 @@ TEST_F(BridgingTest, asyncCallbackInvalidation) {
TEST_F(BridgingTest, asyncCallbackImplicitBridgingTest) {
std::string output;
auto func = std::function<void(std::string)>([&](auto str) { output = str; });
auto func = std::function<void(std::string)>(
[&](auto str) { output = std::move(str); });
{ // Value
auto cb = bridging::fromJs<AsyncCallback<decltype(func), jsi::Value, int>>(
rt, function("(func, a, b) => func(a + b)"), invoker);
@@ -775,6 +784,175 @@ TEST_F(BridgingTest, dynamicTest) {
EXPECT_TRUE(undefinedFromJsResult.isNull());
}
TEST_F(BridgingTest, arrayBufferTest) {
auto rawBuf = eval("new ArrayBuffer(7)");
auto buf = bridging::fromJs<jsi::ArrayBuffer>(rt, rawBuf, invoker);
EXPECT_EQ(7, buf.size(rt));
auto typedArrayBuf = eval("new Uint8Array([1, 2, 3]).buffer");
auto fromTa = bridging::fromJs<jsi::ArrayBuffer>(rt, typedArrayBuf, invoker);
EXPECT_EQ(3, fromTa.size(rt));
auto jsVal = bridging::toJs(rt, std::move(buf), invoker);
EXPECT_TRUE(jsVal.isArrayBuffer(rt));
auto roundTrip = bridging::fromJs<jsi::ArrayBuffer>(rt, jsVal, invoker);
EXPECT_EQ(7, roundTrip.size(rt));
EXPECT_JSI_THROW(
bridging::fromJs<jsi::ArrayBuffer>(rt, jsi::Value(1), invoker));
}
TEST_F(BridgingTest, asyncArrayBufferConstructorTest) {
// JS-heap-allocated buffer: acquire() copies into an internal buffer.
{
auto jsBuf = eval("new Uint8Array([10, 20, 30]).buffer")
.asObject(rt)
.getArrayBuffer(rt);
auto safe = AsyncArrayBuffer::acquire(rt, jsBuf);
EXPECT_EQ(3, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(10, data[0]);
EXPECT_EQ(20, data[1]);
EXPECT_EQ(30, data[2]);
}
// ArrayBuffer created from a native MutableBuffer: acquire() returns the
// same bytes. Whether it's zero-copy depends on whether the runtime
// implements tryGetMutableBuffer (e.g. Hermes does not, so acquire falls
// back to a copy).
{
auto nativeBuf = std::make_shared<detail::OwnedBytesBuffer>(
std::vector<uint8_t>{1, 2, 3, 4});
auto* rawPtr = nativeBuf.get();
auto jsBuf = jsi::ArrayBuffer(rt, nativeBuf);
auto safe = AsyncArrayBuffer::acquire(rt, jsBuf);
EXPECT_EQ(4, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(1, data[0]);
EXPECT_EQ(4, data[3]);
if (jsBuf.tryGetMutableBuffer(rt) != nullptr) {
EXPECT_EQ(rawPtr, safe.getMutableBuffer().get());
}
}
}
TEST_F(BridgingTest, asyncArrayBufferBorrowThrowsOnJsHeapTest) {
// JS-heap-allocated buffer: borrow throws.
auto jsBuf = eval("new ArrayBuffer(4)").asObject(rt).getArrayBuffer(rt);
EXPECT_JSI_THROW(AsyncArrayBuffer::borrow(rt, jsBuf));
}
TEST_F(BridgingTest, asyncArrayBufferBorrowNativeBackedTest) {
// Native-backed buffer: borrow succeeds, zero-copy. Only meaningful on
// runtimes that implement tryGetMutableBuffer.
auto nativeBuf =
std::make_shared<detail::OwnedBytesBuffer>(std::vector<uint8_t>{5, 6, 7});
auto* rawPtr = nativeBuf.get();
auto jsBuf = jsi::ArrayBuffer(rt, nativeBuf);
if (jsBuf.tryGetMutableBuffer(rt) == nullptr) {
GTEST_SKIP()
<< "Runtime does not expose tryGetMutableBuffer; borrow always throws";
}
auto safe = AsyncArrayBuffer::borrow(rt, jsBuf);
EXPECT_EQ(3, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(5, data[0]);
EXPECT_EQ(rawPtr, safe.getMutableBuffer().get());
}
TEST_F(BridgingTest, asyncArrayBufferCopyTest) {
// JS-heap-allocated buffer: copy succeeds.
{
auto jsBuf = eval("new Uint8Array([100, 200]).buffer")
.asObject(rt)
.getArrayBuffer(rt);
auto safe = AsyncArrayBuffer::copy(rt, jsBuf);
EXPECT_EQ(2, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(100, data[0]);
EXPECT_EQ(200, data[1]);
}
// Native-backed buffer: copy() still copies into an internal buffer.
{
auto nativeBuf = std::make_shared<detail::OwnedBytesBuffer>(
std::vector<uint8_t>{9, 8, 7});
auto* rawPtr = nativeBuf.get();
auto jsBuf = jsi::ArrayBuffer(rt, nativeBuf);
auto safe = AsyncArrayBuffer::copy(rt, jsBuf);
EXPECT_EQ(3, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(9, data[0]);
EXPECT_NE(rawPtr, safe.getMutableBuffer().get());
}
}
TEST_F(BridgingTest, asyncArrayBufferMoveTest) {
auto jsBuf =
eval("new Uint8Array([1, 2, 3]).buffer").asObject(rt).getArrayBuffer(rt);
auto safe = AsyncArrayBuffer::acquire(rt, jsBuf);
EXPECT_EQ(3, safe.size());
auto moved = std::move(safe);
EXPECT_EQ(3, moved.size());
auto data = std::span(moved.data(), moved.size());
EXPECT_EQ(1, data[0]);
}
TEST_F(BridgingTest, asyncArrayBufferWrapTest) {
// wrap(shared_ptr<MutableBuffer>): zero-copy, same underlying buffer.
{
auto nativeBuf = std::make_shared<detail::OwnedBytesBuffer>(
std::vector<uint8_t>{1, 2, 3});
auto* rawPtr = nativeBuf.get();
auto safe = AsyncArrayBuffer::wrap(nativeBuf);
EXPECT_EQ(3, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(1, data[0]);
EXPECT_EQ(3, data[2]);
EXPECT_EQ(rawPtr, safe.getMutableBuffer().get());
}
// wrap(vector<uint8_t>): bytes are owned by an internal MutableBuffer.
{
auto safe = AsyncArrayBuffer::wrap(std::vector<uint8_t>{10, 20, 30, 40});
EXPECT_EQ(4, safe.size());
auto data = std::span(safe.data(), safe.size());
EXPECT_EQ(10, data[0]);
EXPECT_EQ(40, data[3]);
EXPECT_NE(nullptr, safe.getMutableBuffer());
}
}
TEST_F(BridgingTest, asyncArrayBufferBridgingTest) {
// toJs with native-backed buffer: JS ArrayBuffer backed by the same
// MutableBuffer.
{
auto nativeBuf = std::make_shared<detail::OwnedBytesBuffer>(
std::vector<uint8_t>{5, 6, 7});
auto safe = AsyncArrayBuffer::wrap(nativeBuf);
auto jsVal = bridging::toJs(rt, std::move(safe), invoker);
EXPECT_TRUE(jsVal.asObject(rt).isArrayBuffer(rt));
auto jsBuf = jsVal.asObject(rt).getArrayBuffer(rt);
EXPECT_EQ(3, jsBuf.size(rt));
auto data = std::span(jsBuf.data(rt), jsBuf.size(rt));
EXPECT_EQ(5, data[0]);
EXPECT_EQ(7, data[2]);
}
// toJs with owned bytes: JS ArrayBuffer contains the correct data.
{
auto safe = AsyncArrayBuffer::wrap(std::vector<uint8_t>{100, 200});
auto jsVal = bridging::toJs(rt, std::move(safe), invoker);
EXPECT_TRUE(jsVal.asObject(rt).isArrayBuffer(rt));
auto jsBuf = jsVal.asObject(rt).getArrayBuffer(rt);
EXPECT_EQ(2, jsBuf.size(rt));
auto data = std::span(jsBuf.data(rt), jsBuf.size(rt));
EXPECT_EQ(100, data[0]);
EXPECT_EQ(200, data[1]);
}
}
TEST_F(BridgingTest, highResTimeStampTest) {
HighResTimeStamp timestamp = HighResTimeStamp::now();
EXPECT_EQ(
@@ -42,6 +42,14 @@ struct TestClass {
callback();
}
size_t byteLength(jsi::Runtime& rt, jsi::ArrayBuffer buffer) {
return buffer.size(rt);
}
jsi::ArrayBuffer echo(jsi::Runtime& /*unused*/, jsi::ArrayBuffer buffer) {
return buffer;
}
private:
std::shared_ptr<CallInvoker> invoker_;
};
@@ -99,6 +107,20 @@ TEST_F(BridgingTest, callFromJsTest) {
EXPECT_TRUE(called);
}
TEST_F(BridgingTest, arrayBufferCallFromJsTest) {
auto instance = TestClass(invoker);
auto buf = eval("new ArrayBuffer(5)").asObject(rt).getArrayBuffer(rt);
EXPECT_EQ(
5,
bridging::callFromJs<size_t>(
rt, &TestClass::byteLength, invoker, &instance, std::move(buf)));
auto buf2 = eval("new ArrayBuffer(9)").asObject(rt).getArrayBuffer(rt);
auto out = bridging::callFromJs<jsi::ArrayBuffer>(
rt, &TestClass::echo, invoker, &instance, std::move(buf2));
EXPECT_EQ(9, out.size(rt));
}
struct MethodReturnTypeCastingTestObject {
public:
explicit MethodReturnTypeCastingTestObject(int value) : value_(value) {}
@@ -6,10 +6,14 @@
*/
#include "NativeCxxModuleExample.h"
#include <react/bridging/ArrayBuffer.h>
#include <react/debug/react_native_assert.h>
#include <iomanip>
#include <numeric>
#include <ostream>
#include <span>
#include <sstream>
#include <thread>
#include <utility>
namespace facebook::react {
@@ -22,6 +26,22 @@ std::string to_string_with_precision(double value, int precision = 2) {
return oss.str();
}
struct IntegerSequence : jsi::MutableBuffer {
explicit IntegerSequence(int32_t size) : data_(size) {
std::iota(data_.begin(), data_.end(), 1);
}
size_t size() const override {
return data_.size();
}
uint8_t* data() override {
return data_.data();
}
std::vector<uint8_t> data_;
};
} // namespace
NativeCxxModuleExample::NativeCxxModuleExample(
@@ -52,6 +72,48 @@ std::vector<std::optional<ObjectStruct>> NativeCxxModuleExample::getArray(
return arg;
}
jsi::ArrayBuffer NativeCxxModuleExample::getArrayBuffer(
jsi::Runtime& /*rt*/,
jsi::ArrayBuffer arg) {
return arg;
}
jsi::ArrayBuffer NativeCxxModuleExample::createNativeBuffer(
jsi::Runtime& rt,
int32_t arg) {
return {rt, std::make_shared<IntegerSequence>(arg)};
}
AsyncPromise<double> NativeCxxModuleExample::processAsyncBuffer(
jsi::Runtime& rt,
jsi::ArrayBuffer arg) {
auto promise = AsyncPromise<double>(rt, jsInvoker_);
auto storage = AsyncArrayBuffer::acquire(rt, arg);
// NOLINTNEXTLINE(facebook-hte-BadCall-detach) — example/demo code
std::thread([promise, storage = std::move(storage)]() mutable {
auto sum = 0.0;
auto bytes = std::span(storage.data(), storage.size());
for (auto byte : bytes) {
sum += byte;
}
promise.resolve(sum);
}).detach();
return promise;
}
AsyncPromise<AsyncArrayBuffer> NativeCxxModuleExample::getAsyncBuffer(
jsi::Runtime& rt,
int32_t arg) {
auto promise = AsyncPromise<AsyncArrayBuffer>(rt, jsInvoker_);
// NOLINTNEXTLINE(facebook-hte-BadCall-detach) — example/demo code
std::thread([promise, arg]() mutable {
promise.resolve(
AsyncArrayBuffer::wrap(std::make_shared<IntegerSequence>(arg)));
}).detach();
return promise;
}
bool NativeCxxModuleExample::getBool(jsi::Runtime& /*rt*/, bool arg) {
return arg;
}
@@ -124,6 +124,14 @@ class NativeCxxModuleExample : public NativeCxxModuleExampleCxxSpec<NativeCxxMod
std::vector<std::optional<ObjectStruct>> getArray(jsi::Runtime &rt, std::vector<std::optional<ObjectStruct>> arg);
jsi::ArrayBuffer getArrayBuffer(jsi::Runtime &rt, jsi::ArrayBuffer arg);
jsi::ArrayBuffer createNativeBuffer(jsi::Runtime &rt, int32_t arg);
AsyncPromise<double> processAsyncBuffer(jsi::Runtime &rt, jsi::ArrayBuffer arg);
AsyncPromise<AsyncArrayBuffer> getAsyncBuffer(jsi::Runtime &rt, int32_t arg);
bool getBool(jsi::Runtime &rt, bool arg);
ConstantsStruct getConstants(jsi::Runtime &rt);
@@ -82,6 +82,10 @@ export interface Spec extends TurboModule {
+onSubmit: CodegenTypes.EventEmitter<ObjectStruct[]>;
+onEvent: CodegenTypes.EventEmitter<EnumNone>;
+getArray: (arg: Array<ObjectStruct | null>) => Array<ObjectStruct | null>;
+getArrayBuffer: (payload: ArrayBuffer) => ArrayBuffer;
+createNativeBuffer: (size: number) => ArrayBuffer;
+processAsyncBuffer: (payload: ArrayBuffer) => Promise<number>;
+getAsyncBuffer: (size: number) => Promise<ArrayBuffer>;
+getBool: (arg: boolean) => boolean;
+getConstants: () => ConstantsStruct;
+getCustomEnum: (arg: EnumInt) => EnumInt;
@@ -8,8 +8,10 @@
#include <NativeCxxModuleExample/NativeCxxModuleExample.h>
#include <ReactCommon/TurboModuleTestFixture.h>
#include <gtest/gtest.h>
#include <cstdint>
#include <memory>
#include <optional>
#include <span>
#include <vector>
namespace facebook::react {
@@ -31,6 +33,24 @@ TEST_F(NativeCxxModuleExampleTests, GetArrayReturnsCorrectValues) {
EXPECT_EQ(result[0]->b, "2");
}
TEST_F(NativeCxxModuleExampleTests, GetArrayBufferReturnsCorrectValues) {
auto eval = runtime_->global().getPropertyAsFunction(*runtime_, "eval");
jsi::ArrayBuffer buf = eval.call(*runtime_, "new Uint8Array([1,2,3]).buffer")
.getObject(*runtime_)
.getArrayBuffer(*runtime_);
jsi::ArrayBuffer out = module_->getArrayBuffer(*runtime_, std::move(buf));
EXPECT_EQ(out.size(*runtime_), 3);
auto bytes = std::span(out.data(*runtime_), out.size(*runtime_));
EXPECT_EQ(bytes[0], 1);
EXPECT_EQ(bytes[1], 2);
EXPECT_EQ(bytes[2], 3);
}
TEST_F(NativeCxxModuleExampleTests, CreateNativeBufferReturnsCorrectSize) {
jsi::ArrayBuffer buf = module_->createNativeBuffer(*runtime_, 42);
EXPECT_EQ(buf.size(*runtime_), 42);
}
TEST_F(NativeCxxModuleExampleTests, GetBoolReturnsCorrectValues) {
EXPECT_FALSE(module_->getBool(*runtime_, false));
EXPECT_TRUE(module_->getBool(*runtime_, true));
@@ -40,6 +40,9 @@ type Examples =
| 'callback'
| 'callbackWithSubscription'
| 'getArray'
| 'getArrayBuffer'
| 'processAsyncBuffer'
| 'getAsyncBuffer'
| 'getBool'
| 'getConstants'
| 'getCustomEnum'
@@ -102,6 +105,31 @@ class NativeCxxModuleExampleExample extends React.Component<{}, State> {
{a: 2, b: 'bar'},
null,
]),
getArrayBuffer: () => {
const view = new Uint8Array([1, 2, 3, 4, 5]);
const buffer = NativeCxxModuleExample?.getArrayBuffer(view.buffer);
return new Uint8Array(buffer || []).toString();
},
processAsyncBuffer: async () => {
const view = new Uint8Array([10, 20, 30, 40, 50]);
const nativeBuffer = NativeCxxModuleExample?.createNativeBuffer(10);
const [byteSum, zeroCopyByteSum] = await Promise.all([
NativeCxxModuleExample?.processAsyncBuffer(view.buffer),
nativeBuffer != null
? NativeCxxModuleExample?.processAsyncBuffer(nativeBuffer)
: Promise.resolve(0),
]);
this._setResult(
'processAsyncBuffer',
`sum=${(byteSum ?? 0) + (zeroCopyByteSum ?? 0)}`,
);
},
getAsyncBuffer: () =>
NativeCxxModuleExample?.getAsyncBuffer(10).then(buffer => {
this._setResult('getAsyncBuffer', new Uint8Array(buffer).toString());
}),
getBool: () => NativeCxxModuleExample?.getBool(true),
getConstants: () => NativeCxxModuleExample?.getConstants(),
getCustomEnum: () => NativeCxxModuleExample?.getCustomEnum(EnumInt.IB),
@@ -1613,6 +1613,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -9586,6 +9603,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -9597,6 +9619,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -9904,6 +9930,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -11618,11 +11650,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -1607,6 +1607,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -9224,6 +9241,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -9235,6 +9257,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -9542,6 +9568,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -11256,11 +11288,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -1611,6 +1611,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -9439,6 +9456,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -9450,6 +9472,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -9757,6 +9783,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -11471,11 +11503,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -4589,6 +4589,23 @@ class facebook::react::AppleEventBeat : public facebook::react::EventBeat, publi
public virtual void activityDidChange(const facebook::react::RunLoopObserver::Delegate* delegate, facebook::react::RunLoopObserver::Activity activity) const noexcept override;
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -11890,6 +11907,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -11901,6 +11923,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -12203,6 +12229,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -13851,11 +13883,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -4208,6 +4208,23 @@ class facebook::react::AppleEventBeat : public facebook::react::EventBeat, publi
public virtual void activityDidChange(const facebook::react::RunLoopObserver::Delegate* delegate, facebook::react::RunLoopObserver::Activity activity) const noexcept override;
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -11211,6 +11228,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -11222,6 +11244,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -11524,6 +11550,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -13172,11 +13204,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -4587,6 +4587,23 @@ class facebook::react::AppleEventBeat : public facebook::react::EventBeat, publi
public virtual void activityDidChange(const facebook::react::RunLoopObserver::Delegate* delegate, facebook::react::RunLoopObserver::Activity activity) const noexcept override;
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -11753,6 +11770,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -11764,6 +11786,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public facebook::react::NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -12066,6 +12092,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -13714,11 +13746,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -938,6 +938,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -6655,6 +6672,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -6666,6 +6688,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -6963,6 +6989,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -8604,11 +8636,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -933,6 +933,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -6495,6 +6512,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -6506,6 +6528,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -6803,6 +6829,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -8444,11 +8476,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();
@@ -936,6 +936,23 @@ class facebook::react::AppRegistryBinding {
public static void stopSurface(facebook::jsi::Runtime& runtime, facebook::react::SurfaceId surfaceId);
}
class facebook::react::AsyncArrayBuffer {
public AsyncArrayBuffer(const facebook::react::AsyncArrayBuffer&) = delete;
public AsyncArrayBuffer(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public const uint8_t* data() const noexcept;
public facebook::react::AsyncArrayBuffer& operator=(const facebook::react::AsyncArrayBuffer&) = delete;
public facebook::react::AsyncArrayBuffer& operator=(facebook::react::AsyncArrayBuffer&&) noexcept = default;
public size_t size() const noexcept;
public static facebook::react::AsyncArrayBuffer acquire(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer borrow(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer copy(facebook::jsi::Runtime& rt, const facebook::jsi::ArrayBuffer& buffer);
public static facebook::react::AsyncArrayBuffer wrap(std::shared_ptr<facebook::jsi::MutableBuffer> buffer) noexcept;
public static facebook::react::AsyncArrayBuffer wrap(std::vector<uint8_t> bytes);
public std::shared_ptr<facebook::jsi::MutableBuffer> getMutableBuffer() const noexcept;
public uint8_t* data() noexcept;
public ~AsyncArrayBuffer() = default;
}
class facebook::react::AttributedString : public facebook::react::Sealable, public facebook::react::DebugStringConvertible {
public bool compareTextAttributesWithoutFrame(const facebook::react::AttributedString& rhs) const;
public bool isContentEqual(const facebook::react::AttributedString& rhs) const;
@@ -6646,6 +6663,11 @@ template <typename... Types>
struct facebook::react::Bridging<std::tuple<Types...>> : public facebook::react::array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {
}
struct facebook::react::Bridging<facebook::jsi::ArrayBuffer> {
public static facebook::jsi::ArrayBuffer fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& obj);
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::jsi::ArrayBuffer buf);
}
struct facebook::react::Bridging<facebook::jsi::JSError> {
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Value& value);
public static facebook::jsi::JSError fromJs(facebook::jsi::Runtime& rt, facebook::jsi::Value&& value);
@@ -6657,6 +6679,10 @@ struct facebook::react::Bridging<facebook::jsi::WeakObject> {
public static facebook::jsi::WeakObject fromJs(facebook::jsi::Runtime& rt, const facebook::jsi::Object& value);
}
struct facebook::react::Bridging<facebook::react::AsyncArrayBuffer> {
public static facebook::jsi::Value toJs(facebook::jsi::Runtime& rt, facebook::react::AsyncArrayBuffer buffer);
}
struct facebook::react::Bridging<facebook::react::EndResult> : public NativeAnimatedTurboModuleEndResultBridging<facebook::react::EndResult> {
}
@@ -6954,6 +6980,12 @@ std::optional<facebook::react::CSSColor> facebook::react::detail::parseModernHsl
template <typename... ComponentT>
constexpr std::optional<float> facebook::react::detail::normalizeComponent(const std::variant<std::monostate, ComponentT...>& component, float baseValue);
class facebook::react::detail::OwnedBytesBuffer : public facebook::jsi::MutableBuffer {
public OwnedBytesBuffer(std::vector<uint8_t> bytes) noexcept;
public virtual size_t size() const override;
public virtual uint8_t* data() override;
}
enum facebook::react::detail::HexColorType {
Long,
Short,
@@ -8595,11 +8627,13 @@ struct facebook::react::bridging::is_optional<std::optional<T>> : public std::tr
struct facebook::react::bridging::Converter<facebook::jsi::Object> : public facebook::react::bridging::ConverterBase<facebook::jsi::Object> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
}
struct facebook::react::bridging::Converter<facebook::jsi::Value> : public facebook::react::bridging::ConverterBase<facebook::jsi::Value> {
public operator facebook::jsi::Array();
public operator facebook::jsi::ArrayBuffer();
public operator facebook::jsi::Function();
public operator facebook::jsi::Object();
public operator facebook::jsi::String();