Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.
Reviewed By: yungsters
Differential Revision: D13195941
fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
Summary:
Instead of assigning all the constants exported by a NativeModule to the native module JavaScript object itself, we want to instead export a `getConstants()` method that can be used to access native module constants. This change simplifies the API of native modules. Eventually, we'll remove the ability to access constants as native module object properties alltogether, but that's comes later.
**Note**: I didn't need to make any cpp changes because `JSIExecutor::NativeModuleProxy::get` calls `JSINativeModules::getModule` (here: https://goo.gl/QwPDWF), which eventually calls `JSINativeModules::createModule`, which uses `global.__fbGenNativeModule` (here: https://goo.gl/pSxMgE), which is just an alias to `genModule` in `NativeModules` (here: https://goo.gl/u2wjCs).
Reviewed By: fkgozali
Differential Revision: D13207152
fbshipit-source-id: 375aab1346232819187a5d5b272b33c55992346a
Summary:
`new Date().getTime()` is equal to `Date.now()`.
`Date.now()` avoids an allocation, which can save some GC time.
This micro-optimization isn't worth it in most places, but since MessageQueue is one of the hottest pieces of JS in RN, it's worth it.
Reviewed By: javache
Differential Revision: D9972334
fbshipit-source-id: 05d78fd65304f0f27115d76b8b52db11a52c86a0
Summary:
They are bad :D
And they affect us when trying to migrate to the babel runtime helpers
Reviewed By: pvdz
Differential Revision: D9829462
fbshipit-source-id: 15240a56e707e13775d57714646e4960cfe202df
Summary:
NaN is not handled consistently by the bridge in all cases,
so detect it and complain. In order to make the complaint more
obvious, use JSON.stringify on the value, and a replacer so that some
of the censoring which normally takes place doesn't get in the way of
clarity.
Reviewed By: mmmulani
Differential Revision: D9779799
fbshipit-source-id: 6c1a6bfe05ecaa3aeb558acc49dfd54461e1ba74
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary:
ag -L --ignore __snapshots__ 'flow strict|noflow|generated|The controller you requested could not be found.' | ag '\.js$' | xargs ag -l 'flow' | sort > ~/temp
cat ~/temp | xargs ag -L 'flow strict' | xargs sed -i '' 's/flow$/flow strict-local/'
until flow check; do flow check --json | jq -r '.errors[].message[0].path' | sort | uniq | xargs hg revert; done
allow_many_files
The controller you requested could not be found.
The controller you requested could not be found.
Reviewed By: TheSavior
Differential Revision: D9004573
fbshipit-source-id: 936bd5741706b781be06bf08b6ad805a69407dfd
Summary:
This makes JSTimers actively register a callback for callImmediates.
Besides being generally tricky, circular dependency prevent compiling React Native code with bundlers that rely on concatenating module sources rather that evaluating code at the time of requiring, like Google Closure Compiler.
Sadly, Google Closure Compiler setup that prompted this change is complicated and brittle. And there are no good public tools to find circular dependencies among Haste-style modules (with unqualified require paths).
So some advice on a good test plan would be useful. Does Facebook have any tools to find circular dependencies with Haste-style requires?
FWIW, a check that worked for me was to replace all import paths in React Native from Haste style to normal relative paths (which I needed anyway) and then run [`madge`](https://www.npmjs.com/package/madge) on the code base:
```
$ ~/node_modules/.bin/madge --circular react-native/Libraries
Processed 390 files (7.4s) (81 warnings)
✖ Found 2 circular dependencies!
1) BatchedBridge/NativeModules.js > BatchedBridge/BatchedBridge.js > BatchedBridge/MessageQueue.js > Core/Timers/JSTimers.js
2) StyleSheet/flattenStyle.js > StyleSheet/StyleSheet.js
```
(The second cycle is already eliminated in a8e3c7f578).
[GENERAL] [MINOR] [MessageQueue] - MessageQueue implementation doesn't have a circular dependency on JSTimers.
Closes https://github.com/facebook/react-native/pull/19526
Reviewed By: hramos
Differential Revision: D8458755
Pulled By: yungsters
fbshipit-source-id: e753139b920ba1ad1a6db10f974c03ca195340c7
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.
It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)
* Checked the Flow configuration by running flow on the project root (no errors):
```
yarn flow
```
* Checked the Jest configuration by running the tests with a clean cache:
```
yarn jest --clearCache && yarn test
```
* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:
```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```
[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995
Reviewed By: mjesun
Differential Revision: D7729509
Pulled By: rubennorte
fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
Summary: JSON.stringify will convert a function to null, but folly::dynamic in the native code can't represent a JS function. Props do sometimes have functions, but don't permit them everywhere.
Reviewed By: johnislarry
Differential Revision: D6541878
fbshipit-source-id: b2a9d3ba7899dfb98a6a2ada3aa91a26549fdd94
Summary: The method is being used in a test, so if a private method name mangling happens, the name of the method changes and the test fails.
Reviewed By: cpojer
Differential Revision: D5347967
fbshipit-source-id: ee964c2876bcfea5253d2ce7f9f02d4dbeebeab3
Summary:
Looking to address a few new `FlowFixMe`s I had to do some minor refactoring of `MessageQueue`. Has the advantage of (IMO) making things clearer by removing a redundant counter and some gratuitous bitwise operations.
Previously `_callbacks` was an array of `?Function`s where even elements were failure callbacks and odd elements were successes. Each new call incremented `_callID` by one and `_callbackID` by two. I've changed this to use two arrays `_successCallbacks` and `_failureCallbacks` indexed by `callID`. That made the `_callbackID` counter unnecessary and reduced the need for computed indices.
Tested with flow and a quick play with UIExplorer.
Closes https://github.com/facebook/react-native/pull/11986
Differential Revision: D4962162
Pulled By: javache
fbshipit-source-id: 17dddfedc0cb5950dbdd9bd06fae6eb6de4c4a7d
Summary:
The stall watchdog is handy to detect stalls, but it doesn't really tell us what was
happening. This diff makes it easy to track React perf and bridge traffic during any stall, and
prints it out if the stall exceeds the threshold.
Reviewed By: yungsters
Differential Revision: D4479439
fbshipit-source-id: 87f94913ec341a648d7744249597dc30b29759ab