Граф коммитов

35 Коммитов

Автор SHA1 Сообщение Дата
Paige Sun 9ebdf74708 Remove Unable to get TurboModule for DialogManagerAndroid warning for iOS
Summary:
The import of DialogManagerAndroid in [Alert.js](https://fburl.com/diffusion/n57e4l50) causes "Unable to get iOS TurboModule for DialogManagerAndroid" log.

Don't call ` TurboModuleRegistry.get` on DialogManagerAndroid when the Platform is iOS.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D27376204

fbshipit-source-id: 948da5c162100ffe196d5e0a54dc8b85659239ae
2021-03-26 23:48:28 -07:00
Paige Sun 3c4363d822 Clarify TurboModule cannot be found log
Reviewed By: JoshuaGross

Differential Revision: D27376177

fbshipit-source-id: 3e1a91ca7c11963874c029237bc2f45839fbbf6d
2021-03-26 21:11:47 -07:00
Paige Sun bfe3cd01bc Log info when TurboModule cannot be found
Summary:
There are a surprisingly large number of nil modules in both bridge and bridgeless. So far, features may silently fail if a module is nil.

We can't log with with console.error or console.warn because many tests will break even though modules aren't used in the test.

Differential Revision: D27285601

fbshipit-source-id: 1467100f2a4c48e97de5dd6e846c26981c14f099
2021-03-25 16:08:38 -07:00
Micha Reiser 93377ff508 Remove "use strict" directive from ES Modules
Summary:
ES Modules implicitly enable strict mode. Adding the "use strict" directive is, therefore, not required.

This diff removes all "use strict" directives from ES modules.

Changelog:

[Internal]

Reviewed By: motiz88

Differential Revision: D26172715

fbshipit-source-id: 57957bcbb672c4c3e62b1db633cf425c1c9d6430
2021-02-02 11:12:56 -08:00
Ramanpreet Nara 1f017617ac Stop passing in the schema from JavaScript
Summary:
This concludes the JavaScript clean for TurboModule JavaScript codegen teardown.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25915168

fbshipit-source-id: 1decc394ff63b1d39d270fc048e817501ea388ea
2021-01-14 19:14:23 -08:00
Rubén Norte e088a4fe9c Add support for UnsafeObject to allow using Flow strict in native modules
Summary:
This new type will be valid in Flow strict mode and can be used by native modules and components to replace `Object`, with the same semantics.

This unblocks the migration of the most modules in the React Native package to Flow strict.

Changelog: [Internal] Add UnsafeObject type compatible with Flow strict mode to use in native modules and components

Reviewed By: RSNara

Differential Revision: D25540631

fbshipit-source-id: 60b80bbc84a53aecc747e3a1799cdf551e1859cd
2021-01-04 03:56:57 -08:00
Mike Vitousek 7f53bb95f7 Suppress errors and switch to new-generics in xplat
Summary:
The Flow team has been building a new implementation of the system that typechecks the body of generic functions and classes. This system is more sound than the previous approach and detects errors that were uncaught previously. This diff turns on the new generic system by setting generate_tests=false in the .flowconfig, and suppresses newly discovered errors.

This diff modifies and re-signs some generated modules, because syncing from www pulled in a ton of other changes that have runtime differences, and I'm not equipped to verify that the changes are safe to land.

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D24801184

fbshipit-source-id: bb31fe4c5a4107d183649b436a548df5ff42e217
2020-11-20 00:50:30 -08:00
Ramanpreet Nara 09d4cb7b9f Remove @react-native/codegen lint ignores
Summary:
There's no reason for us to have lint ignores for `react-native/codegen/react-native-modules`. This diff removes all such ignores. I'll address any actual problems with the specs in subsequent diffs.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24529238

fbshipit-source-id: bbd2f4fb5dace65d803a8f93bd0d9a1c5a1cfb34
2020-10-26 16:23:03 -07:00
Ramanpreet Nara 3a6327a5d9 Open source react-native-modules ESLint rule
Summary:
Open source this ESLint rule so that we can lint our open source NativeModule specs.

Changelog: [Internal]

Reviewed By: shergin, cpojer

Differential Revision: D23791748

fbshipit-source-id: e44444bc87eaa9dc9b7f2b3ed03151798a35e8a5
2020-09-22 11:32:37 -07:00
Ramanpreet Nara 9728d04f96 Fix "[TM][JS] Forward NativeModule schema to __turboModuleProxy"
Summary: Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22888030

fbshipit-source-id: cb2b47f51f6ad5a7397045ffe5b81c9e1e396250
2020-08-04 15:49:52 -07:00
Ramanpreet Nara b5097c8dcd Back out "Back out "[TM][JS] Forward NativeModule schema to __turboModuleProxy""
Summary:
**Note:** This is a carbon copy of D22832730 (3df6f5fb2c). The fixes are stacked on top of this diff, in D22888030.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D22888032

fbshipit-source-id: 2f1b7ecd39437a3c5ee9c3214419716fde2bbdff
2020-08-04 15:49:52 -07:00
Gijs Weterings f8f53e595c Back out "Forward NativeModule schema to __turboModuleProxy"
Summary:
Original commit changeset: aecaf9943f9b

Changelog: [Internal]

Reviewed By: jimmy623

Differential Revision: D22885708

fbshipit-source-id: 6839266653ad33ea8fb53c9f4664ed773c57443d
2020-08-01 06:25:26 -07:00
Ramanpreet Nara 3df6f5fb2c Forward NativeModule schema to __turboModuleProxy
Summary:
`babel-plugin-codegen` will run the NativeModules codegen on each NativeModule spec, and inline the generated schema into the spec's `TurboModuleRegistry.get(Enforcing)?` call. This diff will forward that schema to `__turboModuleProxy` function (i.e: the TurboModule C++ infra).

**Note:** Both this and D2280384 can't be landed until D22743294 (650c0f64f1) hits production (1-2 weeks).

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D22832730

fbshipit-source-id: aecaf9943f9b01be805ff6b90249a6cbc6abdd20
2020-07-31 18:29:53 -07:00
Rubén Norte 4409642811 Migrate large amount of modules to flow strict and strict-local
Summary:
| Group | Before | After | Change |
| Untyped | 50 | 49 | -1 |
| flow | 197 | 155 | -42 |
| flow strict-local | 226 | 185 | -41 |
| flow strict | 33 | 117 | +84

Changelog: [Changed] Improved Flow typing of multiple modules (with migrations to `flow strict` and `flow strict-local`

Reviewed By: motiz88

Differential Revision: D22549140

fbshipit-source-id: ed29415332cfce15b244ee4dea9e13d035543175
2020-07-22 09:46:16 -07:00
Tim Yung 5242ad931b RN: Add `RootTag` Type to TurboModule
Summary:
Adds `RootTag` as a valid type for arguments and return types in TurboModules (on both Android and iOS).

This will enable us to change `RootTag` into an opaque type. There are two compelling reasons to do this:

- JavaScript will no longer be able to safely depend on `RootTag` being a number (which means we can change this in the future).
- Call sites using `unstable_RootTagContext` will can get a `RootTag`, but call sites using the legacy `context.rootTag` will not. This means the opaque type will give us a strategy for migrating away from legacy context and eventually making `unstable_RootTagContext` the only way to access `RootTag`.

Changelog:
[Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: RSNara

Differential Revision: D21127170

fbshipit-source-id: baec9d7ad17b2f8c4527f1a84f604fc0d28b97eb
2020-04-21 19:15:54 -07:00
Jesse Katsumata 42c1957aff chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 15:37:33 -07:00
Jesse Katsumata 5b8f4ef195 Clear some lint warnings (#27893)
Summary:
Applied linting for warnings that seemed trivial.

## Changelog

[Internal] [Fixed] - clear lint warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/27893

Test Plan: yarn lint

Differential Revision: D19619569

Pulled By: cpojer

fbshipit-source-id: f9f02838c56e94abc1590686c8443c6c6e6f44ca
2020-01-29 04:36:28 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Kevin Gozali fb627dac6a TM JS: Revert to import from TurboModuleRegistry.js
Summary:
Changelog: [Internal]

Reverting the import to the previous local module style since importing from react-native seems to introduce some perf regression. We'll revisit this later in the future.

Reviewed By: yungsters

Differential Revision: D18383893

fbshipit-source-id: f11d46a4545768f39199fd6fd22fcf14905d0a74
2019-11-08 11:44:16 -08:00
Kevin Gozali dd06f85bd0 TM JS: cleaned up TurboModuleRegistry types [2]
Summary:
Changelog: [Internal]

Moved the imports for `TurboModuleRegistry` and `TurboModule` from `react-native`. This was a jscodeshift with the script: P120688078

Reviewed By: yungsters

Differential Revision: D18262538

fbshipit-source-id: 48fac15229c897408928511c5ecbb42f17ec7b42
2019-11-04 18:51:05 -08:00
Logan Daniels 91f139b941 xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16657770

fbshipit-source-id: 4e260842c838a35317515044c54ccf55a083da33
2019-08-09 10:11:15 -07:00
Ramanpreet Nara b771e20ee9 Deprecate RCTExport
Summary: This diff renames `RCTExport` to `DEPRECATED_RCTExport`. I'll deal with the repercussions of this change in subsequent diffs.

Reviewed By: fkgozali

Differential Revision: D16468382

fbshipit-source-id: 571abbefbf68b03e351327cb52835cce2dfbc8bb
2019-07-25 15:04:04 -07:00
Emily Janzer c19c6cef3f Disable legacy native modules in bridgeless mode
Summary: Requiring legacy native modules fails in bridgeless mode because they use the batched bridge, so we need to check for turbomodules first to avoid crashing. In D15703655 I reversed the order of this check for everyone, but this had some unintended side effects (everyone got turbomodules). This time I'm just using my flag to check for bridgeless mode so we can bail out of legacy native modules instead.

Reviewed By: fkgozali

Differential Revision: D15857106

fbshipit-source-id: 9d33161ae059e7a357f135c82b6865f4d2a57add
2019-06-17 15:13:49 -07:00
Logan Daniels 7c005629ad Back out "[TM] Check TurboModules first in TurboModuleRegistry"
Summary:
`hg backout  D15703655`

possible cause of S180976

Reviewed By: shergin

Differential Revision: D15831550

fbshipit-source-id: 9080222c51e39f4432f4c081a8863dea2dcadec3
2019-06-14 13:57:30 -07:00
Emily Janzer bd2c57569b Use require for NativeModules
Summary:
Not totally sure if this is the best way to handle this. In Venice if a native module is missing I try to log the name of the module, but I noticed that the error I was getting was getting this:

{F161460962}

Presumably this is because importing from NativeModules looks for `__esModule`, but NativeModules uses `module.export`. So it's trying to access that property on my cpp proxy object, which doesn't exist...? Changing TurboModuleProxy to use `require` seems to fix the problem.

Reviewed By: fkgozali

Differential Revision: D15787508

fbshipit-source-id: 4b9df4e3c179117999fe6de6363edbef427a8263
2019-06-12 16:18:36 -07:00
Emily Janzer 20102ef5b1 Check TurboModules first in TurboModuleRegistry
Summary:
Reverse the order in which we look for modules in TurboModuleRegistry to check TurboModules first, and then fall back to legacy native modules. The main motivation for this is Venice, since requiring NativeModules.js fatals because there's no batched bridge. But we'll probably want to do this eventually anyway.

I ran a mobilelab for Marketplace home and am not seeing any significant difference in TTI.

Reviewed By: fkgozali

Differential Revision: D15703655

fbshipit-source-id: d65a4d7e09077474c30fb3938e38aee63bfa4eca
2019-06-10 12:05:01 -07:00
Tim Yung 8a014cdfb3 TurboModules: Improve Error Message
Summary: More verbose but descriptive error message when `TurboModule.getEnforcing` fails to find a native module.

Reviewed By: cpojer, gaearon

Differential Revision: D15619293

fbshipit-source-id: 0e8af4986d6ce9002966bb062766218ce9f89a13
2019-06-05 17:35:01 -07:00
Tim Yung fc6bbe62b5 TurboModules: ES Module Cleanup
Summary: Minor cleanup of module conventions in `TurboModuleRegistry`.

Reviewed By: cpojer

Differential Revision: D15619210

fbshipit-source-id: 90a926f992333260eb8806b5708594c4a12e68fb
2019-06-04 02:08:20 -07:00
James Ide 0ee5f68929 Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749)
Summary:
This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change.

See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

[General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24749

Differential Revision: D15258017

Pulled By: cpojer

fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
2019-05-08 08:48:59 -07:00
Kevin Gozali 0e72137c99 TM JS: Unify import syntax for TurboModuleRegistry
Summary:
For now, we use:

```
import * as TurboModuleRegistry from 'TurboModuleRegistry';

...

TurboModuleRegistry.getEnforcing<Spec>('Foo');
```

Reviewed By: RSNara

Differential Revision: D15020752

fbshipit-source-id: c4e8efaeb978e8f36e5ada998070923c3ed26d21
2019-04-19 21:04:16 -07:00
Kevin Gozali a2aba45067 TM iOS: Move SampleTurboModule to OSS
Summary:
This provides various versions of SampleTurboModule, that are:
* compatible with existing NativeModule
* TurboModule compliant

Variants:
* RCTSampleTurboModule (traditional objc module)
* RCTSampleTurboCxxModule (objc++ module using CxxModule)
* SampleTurboModule (pure C++ impl of a TurboModule, no ObjC)

As noted in some files, they need to be codegen'ed based on the `NativeSampleTurboModule.js` (Flow type). The codegen script is not yet usable in OSS (we'll work on it some time in H2 2019). For now, these files need to be manually synced with Flow type.

Reviewed By: cpojer

Differential Revision: D14932539

fbshipit-source-id: fb887192384e5e6e4dff4cac68b4e037a4783cd9
2019-04-15 12:25:47 -07:00
Ramanpreet Nara e1451caddd Only call __turboModuleProxy when it exists
Summary: `__turboModuleProxy` doesn't exist if you're not in the TurboModules QE. If such is the case, then we should just return null when `TurboModuleRegistry.get` is called.

Reviewed By: fkgozali

Differential Revision: D13937143

fbshipit-source-id: d3f11c52b7cbecaefba675d714f0d67236071389
2019-02-04 11:08:10 -08:00
Kevin Gozali 1bbb69355c TM: trimming down module dependencies when getting NativeModules
Summary: For now, do `require('NativeModules')` instead of `import {NativeModules} from 'react-native'`.

Reviewed By: mdvacca

Differential Revision: D13934066

fbshipit-source-id: 5188b11428a4dca8cecd1934e593d89a6e3fde2e
2019-02-01 17:43:09 -08:00
Kevin Gozali 1e6f5344d6 avoid double lookup of a nativemodule when resolving turbomodule
Summary: A simple optimization to not access `NativeModules` property twice.

Reviewed By: RSNara

Differential Revision: D13908128

fbshipit-source-id: d41cd5f855fb0176170d6bdc3ac93df5593eeca5
2019-01-31 16:58:58 -08:00
Kevin Gozali a3df286247 Move TurboModuleRegistry (JS) to github
Summary:
Moved the JS wrapper function to github. To access a TurboModule from JS:

```
export interface Spec extends TurboModule {
  +func1: () => number,
}

const module = TurboModuleRegistry.get<Spec>('SampleTurboModule');
```

This assumes:
* the binding on the native side has been installed properly, i.e. `global.__turboModuleProxy` needs to be installed properly.
* the module `SampleTurboModule` is registered properly in native.

More instructions will be provided later.

Reviewed By: yungsters

Differential Revision: D13584561

fbshipit-source-id: 50d29d88787f8d9caa7a3ee0d54d378db866515c
2019-01-04 16:19:43 -08:00