-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(functions): turbo modules implementation #8603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
russellwheatley
wants to merge
106
commits into
main
Choose a base branch
from
functions-turbo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,054
−825
Open
Changes from 84 commits
Commits
Show all changes
106 commits
Select commit
Hold shift + click to select a range
3dfaa1c
feat(storage): move to turbomodules
russellwheatley 9d896d2
chore: convert to TS
russellwheatley b80b1a7
format
russellwheatley 1431fbf
chore: ignore some things for now
russellwheatley cff1c5f
chore: update package.json main & types
russellwheatley abd0073
init with bob builder
russellwheatley 9f30fa8
yarn.lock
russellwheatley 18c0fdf
chore: rm rootDir from tsconfig.json
russellwheatley 800bf1a
test: import as type for tests
russellwheatley 1962777
chore: fix types
russellwheatley 4dd309f
update types
russellwheatley 193aa9b
rm type test
russellwheatley a49cf27
chore: fix path of type definitions
russellwheatley 6b52129
chore: moving functions to TS
russellwheatley 1214b3e
fix: imports
russellwheatley 34138fa
fix some types
russellwheatley 6802209
update types
russellwheatley a1cd58a
port over remaining types and delete js files
russellwheatley bd27a05
remove functions declaration
russellwheatley 3b645b1
chore: create spec for turbomodules
russellwheatley 909b963
rename spec
russellwheatley 98f387c
rm old version of cli
russellwheatley 7bad518
fix: need react-native as dependency for codegen to work
russellwheatley 3ba3a76
update scripts for generating code
russellwheatley d3ca750
generated code for android & ios
russellwheatley 7eda482
update podspec & config file as per RN docs
russellwheatley e714ad8
rm generated code
russellwheatley 9f17910
rename to Native prefix otherwise ignored by codegen
russellwheatley d8ffb33
updated generic types for spec
russellwheatley 4bd4607
latest generated code based on updated spec
russellwheatley 90bbbed
update naming of generated code
russellwheatley 938d1c3
update RNFB functions module
russellwheatley d4b2541
make file `.mm` & update podspec for functions
russellwheatley fba772e
podfile.lock
russellwheatley 88eeda8
Merge branch 'main' into functions-turbo
russellwheatley 3218d4d
yarn.lock
russellwheatley 30f5d35
chore: update version
russellwheatley cdfee94
chore: reverse order of prepare script
russellwheatley a04eb09
feat(android): make NativeFunctionsModule compatible with existing code
russellwheatley 1ca5cbb
update path
russellwheatley 1ca1da2
move modular/namespaced to same directory to fix TS
russellwheatley f4014d0
exclude jni from compilation
russellwheatley 459f936
fix: retreive if turbomodule
russellwheatley 471b285
fix: rename native module name
russellwheatley 1bb2088
setup example app
russellwheatley 72ce7a7
update functions spec
russellwheatley 468cdce
regenerated code with args
russellwheatley 6884aee
update android code handling
russellwheatley 65a9dd4
fix: iOS turbomodules implementation
russellwheatley 9b64eac
chore: regenerate code
russellwheatley b966ffe
attempt at fixing iOS issue
russellwheatley e75a23f
Merge branch 'main' into functions-turbo
russellwheatley c01d1ed
yarn.lock
russellwheatley e657017
podlock
russellwheatley 0b9a679
fix: ios
russellwheatley 771e7cb
fix: ios correct types
russellwheatley 831f2fb
chore: config for turbomodules
russellwheatley 2500468
fix: ios implementation
russellwheatley 3012669
chore: move types
russellwheatley 5751dee
chore: move types back
russellwheatley 184450e
chore: fix lint
russellwheatley c6a1182
fix: use get for TurboModules
russellwheatley 3a2d634
fix: move back types
russellwheatley 434393e
chore: remove unused js file
russellwheatley a661db6
chore: finally fix types
russellwheatley 4b8c892
update to typescript
russellwheatley b8b969d
try updating tsconfig.json
russellwheatley 3380bc9
fix(ios): pass nsnull if no data
russellwheatley 9437462
chore: make var for allArgs, easier to debug
russellwheatley 50bda8a
chore: remove unneeded package
russellwheatley 44c9206
chore: make note about podspec updates
russellwheatley bcc522f
chore: update android code
russellwheatley fe6816b
chore: reinsert code comments
russellwheatley b8c7db7
chore: remove todo
russellwheatley 67cce20
chore: typing improvement
russellwheatley c8b2683
chore: types
russellwheatley cf18e11
chore: improve details typing
russellwheatley 699c96b
chore: we now expose everything via index (now modular)
russellwheatley 3bf85d8
chore: improve web typing
russellwheatley c83c945
yarn.lock
russellwheatley ba19d1b
fix: allow details to be null
russellwheatley d44e244
Merge branch 'main' into functions-turbo
russellwheatley 6de6521
yarn.lock
russellwheatley 4d57bb6
fix(ios): update core logic to use sentinel value for preserving `nul…
russellwheatley 84641c1
refactor: rename turbo functions spec
russellwheatley ab024ee
refactor: remove previous generated code
russellwheatley 665a34a
refactor: generate code for new naming technique
russellwheatley 9222948
refactor: need spec file to be prefixed with "Native"
russellwheatley ff59bae
refactor: re-run codegen with new name
russellwheatley 2b9571e
refactor: ios renaming types
russellwheatley e23e657
refactor: need to prefix with Native
russellwheatley 4b4b8ab
refactor: prefix with "Native"
russellwheatley e41ffee
refactor: android naming
russellwheatley a107fa9
chore: format build.gradle
russellwheatley 0943a95
fix: improve the pattern matching for the turbo modules methods
russellwheatley 27e6b0e
Merge branch 'main' into functions-turbo
russellwheatley d5e5df8
chore: lock files
russellwheatley eb8a458
chore: format
russellwheatley d7b2646
test: skipping onConfigUpdate tests until they're fixed
russellwheatley 928e2df
fix: storage e2e test breaking because it was being encoded
russellwheatley b480d6d
chore: format
russellwheatley ebc2c97
chore: improve TS config and point to universal TS
russellwheatley a9d220c
Merge branch 'main' into functions-turbo
russellwheatley a36253a
refactor: remove code duplication
russellwheatley 402052f
refactor: JS encoding implementation to remove duplication
russellwheatley 0698610
chore: format
russellwheatley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * Copyright (c) 2016-present Invertase Limited & Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this library except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef RNFBNullSentinelInterceptor_h | ||
| #define RNFBNullSentinelInterceptor_h | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| /** | ||
| * Intercepts TurboModule conversions to automatically decode null sentinels. | ||
| * | ||
| * iOS TurboModules strip null values from object properties during serialization. | ||
| * See: https://github.com/facebook/react-native/issues/52802 | ||
| * The JavaScript side encodes nulls as sentinel objects, | ||
| * and this interceptor automatically converts them back to NSNull before they | ||
| * reach module implementation methods. | ||
| * | ||
| * This class uses method swizzling on RCTCxxConvert to intercept all TurboModule | ||
| * data conversion methods (JS_*Module_Spec*Data:), decoding sentinels before the | ||
| * data reaches the C++ bridging layer and ultimately your module methods. | ||
| */ | ||
| @interface RNFBNullSentinelInterceptor : NSObject | ||
|
|
||
| /** | ||
| * Initializes the null sentinel interceptor. | ||
| * This swizzles RCTCxxConvert (TurboModule converter) to automatically decode null sentinels. | ||
| * Called automatically when the class is loaded via +load. | ||
| */ | ||
| + (void)initialize; | ||
|
|
||
| @end | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * Copyright (c) 2016-present Invertase Limited & Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this library except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| #import "RNFBNullSentinelInterceptor.h" | ||
| #import <objc/runtime.h> | ||
| #import "RNFBSharedUtils.h" | ||
|
|
||
| @implementation RNFBNullSentinelInterceptor | ||
|
|
||
| + (void)load { | ||
| static dispatch_once_t onceToken; | ||
| dispatch_once(&onceToken, ^{ | ||
| [self swizzleRCTConvertMethods]; | ||
| }); | ||
| } | ||
|
|
||
| + (void)swizzleRCTConvertMethods { | ||
| // For TurboModules: Swizzle RCTCxxConvert to intercept all conversion methods | ||
| Class cxxConvertClass = NSClassFromString(@"RCTCxxConvert"); | ||
| if (cxxConvertClass) { | ||
| [self swizzleTurboModuleConversions:cxxConvertClass]; | ||
| } | ||
| } | ||
|
|
||
| + (void)swizzleTurboModuleConversions:(Class)cxxConvertClass { | ||
| // Get all methods from RCTCxxConvert | ||
| unsigned int methodCount = 0; | ||
| Method *methods = class_copyMethodList(object_getClass(cxxConvertClass), &methodCount); | ||
|
|
||
| for (unsigned int i = 0; i < methodCount; i++) { | ||
| Method method = methods[i]; | ||
| SEL selector = method_getName(method); | ||
| NSString *selectorName = NSStringFromSelector(selector); | ||
|
|
||
| // Intercept TurboModule data conversion methods (they follow pattern: JS_*Module_Spec*Data:) | ||
| if ([selectorName hasPrefix:@"JS_"] && [selectorName containsString:@"Module_Spec"] && | ||
| ([selectorName hasSuffix:@"Data:"] || [selectorName containsString:@"Data:"])) { | ||
| // Create a swizzled version using IMP | ||
| IMP originalIMP = method_getImplementation(method); | ||
| const char *typeEncoding = method_getTypeEncoding(method); | ||
|
|
||
| // Replace with our wrapper that decodes nulls | ||
| IMP newIMP = imp_implementationWithBlock(^id(id self, id json) { | ||
| // Decode null sentinels before passing to original conversion | ||
| id decoded = [RNFBSharedUtils decodeNullSentinels:json]; | ||
|
|
||
| // Call original implementation with decoded data | ||
| typedef id (*OriginalFunc)(id, SEL, id); | ||
| OriginalFunc originalFunc = (OriginalFunc)originalIMP; | ||
| return originalFunc(self, selector, decoded); | ||
| }); | ||
|
|
||
| method_setImplementation(method, newIMP); | ||
| } | ||
| } | ||
|
|
||
| free(methods); | ||
| } | ||
|
|
||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.