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

122 Коммитов

Автор SHA1 Сообщение Дата
Min ho Kim 84f5ebe4f9 Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:23:11 -07:00
Spencer Ahrens 1e45a41dc2 dev error for excessive pending callbacks
Summary:
We've seen some crashes from exceeding property limits (>200k) from storing callbacks, which is insane since callbacks should be called and cleaned up right away in most cases. Browsing around I never see more than about 50 pending callbacks when firing off a whole much of animations and measures and stuff.

In order to track down the leak, I added some code in `__DEV__` to provide more info - hopefully some developers will hit it and report the issue. Unfortunately it's not easy to get any useful information in prod because we strip all the useful debug info, but if this continues to be a problem we could try capturing that info in prod as well (and maybe other info, too).

Reviewed By: PeteTheHeat

Differential Revision: D16267702

fbshipit-source-id: 8185bb8ff0d646b307c98238616950086b1a608f
2019-07-17 14:15:54 -07:00
Spencer Ahrens 8dcee62be9 Use `Map`s instead of `Object`s for `MessageQueue` callbacks
Summary:
This lead to exceeding the Object property count limit in Hermes:
```
Unhandled JS Exception: Property storage can't accommodate 254464 properties, js engine: hermes
```

Reviewed By: PeteTheHeat

Differential Revision: D16212572

fbshipit-source-id: 8fcedb55ebd1f8b289ec759ea1ad4e81cf903dfd
2019-07-17 14:15:54 -07:00
Moti Zilberman 56f08fcf84 Pop bridge frames from errors thrown by sync host function calls
Summary:
When a synchronous call from JS to native code throws an error, it doesn't include a useful stack trace from the native side. To improve error attribution, this diff pops the frames in `MessageQueue.js` and `NativeModules.js` from the stack traces of such errors. This uses the `error.framesToPop` convention understood by RN's global error handler.

For now we limit this to errors converted from C++ exceptions in host functions, since those are not likely to ever contain further JavaScript frames at the point where we catch them; if they did, it would violate our assumption that the top two frames of the stack are in the JS bridge code.

Reviewed By: cwdick

Differential Revision: D15805054

fbshipit-source-id: 8c1dd7c81b00b6a88e31473271889af1f88f7263
2019-06-19 09:15:14 -07:00
Moti Zilberman 37bbfa663d Add test for sync methods (type=sync)
Summary: Adds a test for synchronous methods (`type === 'sync'`) in NativeModules. This doesn't modify any behaviour.

Reviewed By: amnn

Differential Revision: D15804757

fbshipit-source-id: 4db76dbd0b0b111ed9311d4b7ec35a077c377f01
2019-06-19 09:15:14 -07:00
Moti Zilberman 88e9098a64 Preserve the caller's JS stack trace when a type=promise method rejects
Summary: TSIA

Reviewed By: cwdick

Differential Revision: D15802451

fbshipit-source-id: db31ddf697afe54c22bc2c16254a6231497d5c3f
2019-06-19 09:15:14 -07:00
Moti Zilberman d216b55ef5 Add test for promise-returning methods (type=promise)
Summary: Adds a test for promise-returning methods (`type === 'promise'`) in `NativeModules`. This doesn't modify any behaviour.

Reviewed By: cwdick

Differential Revision: D15802452

fbshipit-source-id: 8dc1f862d33742ef4ba355ca36338e0dbabf8edb
2019-06-19 09:15:14 -07:00
Moti Zilberman 0f92984eba Strengthen ModuleConfig Flow typing
Summary:
Types the last 3 members of the `ModuleConfig` tuple (functions, promise method IDs, and sync method IDs) as nullable and immutable arrays. This is in line with how they are used in the code; one debug-only call site had to be fixed to account for nullability.

Also updates the test data in `MessageQueueTestConfig` to explicitly conform to this type.

Reviewed By: amnn

Differential Revision: D15899159

fbshipit-source-id: b6955ba92efc73253de48e2ce7c3034fa91adce3
2019-06-19 09:15:13 -07:00
James Ide 33ee6f8b99 Add a lint rule to disallow Haste imports (#25058)
Summary:
This is an ESLint plugin that infers whether an import looks like a Haste module name. To keep the linter fast and simple, it does not look in the Haste map. Instead, it looks for uppercase characters in single-name import paths, since npm has disallowed uppercase letters in package names for a long time. There are some false negatives (e.g. "merge" is a Haste module and this linter rule would not pick it up) but those are about 1.1% of the module names in the RN repo, and unit tests and integration tests will fail anyway once Haste is turned off.

You can disable the lint rule on varying granular levels with ESLint's normal disabling/enabling mechanisms.

Also rewrote more Haste imports so that the linter passes (i.e. fixed lint errors as part of this PR).

## Changelog

[General] [Changed] - Add a lint rule to disallow Haste imports
Pull Request resolved: https://github.com/facebook/react-native/pull/25058

Differential Revision: D15515826

Pulled By: cpojer

fbshipit-source-id: d58a3c30dfe0887f8a530e3393af4af5a1ec1cac
2019-05-30 07:45:16 -07:00
Rubén Norte edb07c1f64 Fallback to empty object when native module constants are not defined
Summary: Force `getConstants` in native modules to return an empty object when they're not defined in their native implementations.

Reviewed By: fkgozali

Differential Revision: D15393585

fbshipit-source-id: cdda9df0d0f0a98ba226340d3cee67fec63e106c
2019-05-17 10:04:49 -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
Spencer Ahrens 3155ddf2e8 Support callbacks in synchronous native functions
Summary:
We need to move animated native module calls to synchronous so we can properly thread them in with mounting instructions in Fabric. Some of them take callbacks so we need to add support for that when switching to synchronous.

A side benefit is that we can unify codepaths a little more with async callbacks.

Reviewed By: shergin

Differential Revision: D14790898

fbshipit-source-id: dc222b9e74375e046e8a9b1b19d72f652dc6722c
2019-04-08 09:15:13 -07:00
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
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
2018-12-03 00:07:02 -08:00
Ramanpreet Nara db43aa8fc3 Implement getConstants()
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
2018-11-27 16:28:20 -08:00
Riley Dulin bbb2d9a5b3 Change new Date() to Date.now() to save on date allocations
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
2018-09-21 11:11:33 -07:00
Rafael Oleza c58fb3b73a Remove some automocks from tests
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
2018-09-18 04:18:11 -07:00
Marc Horowitz 7f1fcb67e5 Improve the bridge params validator, and its invariant string
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
2018-09-12 19:10:16 -07:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Wayne Cheng f536a0c268 Adding flow strict local to remaining possible files in xplat/JS
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
2018-08-09 08:54:44 -07:00
Kirill Nikolaev 52f431b4bb Eliminate circular dependency between MessageQueue and JSTimers modules. (#19526)
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
2018-06-15 17:06:29 -07:00
Nurzhan Bakibayev 10814e2e61 Remove __fbUninstallRNGlobalErrorHandler
Reviewed By: pakoito

Differential Revision: D7831179

fbshipit-source-id: 6db9fe617d5a1a23a4aa46c9c3028db13a7a52a0
2018-05-21 11:12:46 -07:00
Dmitry Zakharov a93e281428 Detach RN Bridge and CS
Reviewed By: danzimm

Differential Revision: D7833851

fbshipit-source-id: 14533c519f08bd39d69f5203040ad54415228f9f
2018-05-11 10:57:53 -07:00
Eli White d01ab66b47 Prettier React Native Libraries
Reviewed By: sahrens

Differential Revision: D7961488

fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
2018-05-10 19:10:38 -07:00
Eli White cd7c91f35d Convert react-native-github/Libraries to let/const
Reviewed By: sahrens

Differential Revision: D7961763

fbshipit-source-id: ff7dd1d2c7101c8019e0b4f844d8c377b4d13a13
2018-05-10 19:10:38 -07:00
Eli White 8f5ebe5952 Convert react-native-github/Libraries to let/const
Reviewed By: sahrens

Differential Revision: D7956042

fbshipit-source-id: 221851aa311f3cdd6326497352b366048db0a1bb
2018-05-10 16:16:35 -07:00
Riley Dulin d4d515cdc3 MessageQueue not initializing inCall
Reviewed By: yungsters

Differential Revision: D7898700

fbshipit-source-id: c2b4d6e75e7f5871cd40b00bd173e6f1a929b26a
2018-05-10 11:02:45 -07:00
Spencer Ahrens 5b923e0eaf Add args to bridge function call systrace markers
Reviewed By: yungsters

Differential Revision: D7797728

fbshipit-source-id: 615affc57e658d4dd08a88f829d38be930804372
2018-04-30 09:55:49 -07:00
Rubén Norte d5e9e55fa3 Remove @providesModule from all modules
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
2018-04-25 07:37:10 -07:00
Paco Estevez Garcia 976712afa3 Replace RN exception handling override with new version
Reviewed By: Hypuk

Differential Revision: D7385541

fbshipit-source-id: 287d3f4d681046f740ed0552e00a2249c3803a0b
2018-04-03 06:01:37 -07:00
Charles Dick aabd5d1458 Use map instead of array
Reviewed By: dcaspi

Differential Revision: D7327839

fbshipit-source-id: e48d2b9f34e337d14f9519eac16b6a15fa56deb5
2018-03-20 04:17:55 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
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
2018-02-16 18:31:53 -08:00
Semen Zhydenko d2c569795c Typos in comments and log messages
Summary:
No code changes, no testing required.

alligned -> aligned
allignment -> alignment
completly -> completely
conseptually -> conceptually
decendents -> descendants
indefinetly -> indefinitely
dimention -> dimension
doesnt -> doesn't
safegaurd -> safeguard
intialization -> initialization
hierachy -> hierarchy
happend -> happened
gaurd -> guard
programatically -> programmatically
initalized -> initialized
immidiately -> immediately
occured -> occurred
unkown -> unknown
neccessary -> necessary
neccesarily -> necessarily
occuring -> occurring
comoponent -> component
propogate -> propagate
recieved -> received
referece -> reference
perfomance -> performance
recieving -> receiving
subsquently -> subsequently
scoll -> scroll
suprisingly -> surprisingly
targetting -> targeting
tranform -> transform
symetrical -> symmetrical
wtih -> with
Closes https://github.com/facebook/react-native/pull/17578

Differential Revision: D6718791

Pulled By: shergin

fbshipit-source-id: 4ab79c1131ec5971d35a0c7199eba7ec0a0918ad
2018-01-12 22:18:45 -08:00
Eli White 79902f99b8 Finish migration from jasmine to jest
Reviewed By: cpojer

Differential Revision: D6671373

fbshipit-source-id: e9570b9a9da6063576905719f7ffc5465cda737a
2018-01-08 14:17:55 -08:00
Marc Horowitz ea2e2c54cb Make the __DEV__ argument check more robust
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
2017-12-14 11:17:39 -08:00
Paco Estevez Garcia 1d16923063 Add remote API to uninstall the global error handler in RN
Reviewed By: fromcelticpark

Differential Revision: D6426209

fbshipit-source-id: 804e73e0dc4e4b85b336e3627c00840d2ff3c9d6
2017-12-11 08:06:24 -08:00
Miguel Jimenez Esun 834b9d4e6e Adding @email tags to most of the tests
Reviewed By: rafeca

Differential Revision: D6185623

fbshipit-source-id: 30df83288fe85516d8d5a1617a4fb8fea826ed6f
2017-11-02 06:25:03 -07:00
Riley Dulin 7b575d669d Improve flow typing and linting for MessageQueue
Differential Revision: D5987892

fbshipit-source-id: 8b9218875944decc5e21863e3c3f3a659ff2e2e4
2017-10-10 16:32:28 -07:00
Riley Dulin 089add4de7 Add @format to MessageQueue
Reviewed By: javache

Differential Revision: D5925489

fbshipit-source-id: 799b530a2540850722ad1910263030afb951c4c5
2017-09-28 13:16:00 -07:00
Jonathan Lee 182874d972 Reverting changes to MessageQueue
Reviewed By: zjj010104

Differential Revision: D5785916

fbshipit-source-id: ed30e3d2763d16c5a1f550f05d2b9f0997b83fbe
2017-09-07 14:30:59 -07:00
Pieter De Baets cb313569e5 Increase information logged to MessageQueue.spy
Reviewed By: dulinriley

Differential Revision: D5517734

fbshipit-source-id: de7ba08130d229882256bcb1496d6efc708bdce7
2017-07-31 06:16:41 -07:00
Kody Greenbaum 26764d4179 Revert D5470356: [react-native] Increase information logged to MessageQueue.spy
Differential Revision: D5470356

fbshipit-source-id: 27b247ac3c538f801c1f9a86f74fb3098064e92e
2017-07-25 11:53:20 -07:00
Pieter De Baets f445ac8ef1 Increase information logged to MessageQueue.spy
Reviewed By: dulinriley

Differential Revision: D5470356

fbshipit-source-id: 663dfa4e0c8cc5292e27f607111fc35a565a0bd8
2017-07-25 08:01:28 -07:00
Arnold Noronha 2639e7f123 Revert D5446953: [react-native] Conditionally export JSTimers
Differential Revision: D5446953

fbshipit-source-id: 8275e1b71b8fac9b120c8ddff486f9cd88b7939d
2017-07-19 13:06:02 -07:00
Pieter De Baets a68f6fab0f Conditionally export JSTimers
Reviewed By: fkgozali

Differential Revision: D5446953

fbshipit-source-id: c08bd873024d591f5186a3a6767f319de3b6b6d8
2017-07-19 05:45:08 -07:00
Miguel Jimenez Esun 1d7c990424 Make a method used externaly (in a test) public
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
2017-07-03 07:53:58 -07:00
Pieter De Baets b6cfad27f8 Allow no args to be passed to rejection callback
Reviewed By: davidaurelio

Differential Revision:
D5301417

Tags: accept2ship

fbshipit-source-id: a4fb74dd50eb63579e7b69a6d48d4020f718b81c
2017-06-22 10:04:09 -07:00
Pieter De Baets 0ae11f12f3 Merge JSTimers and JSTimersExecution
Reviewed By: mmmulani

Differential Revision: D5292923

fbshipit-source-id: d8331cbac28ba3bbf47c9746238a755b707903ea
2017-06-22 09:52:33 -07:00
Pieter De Baets 534bbfac8f Report Java stack from errors from sync native module calls
Reviewed By: mhorowitz

Differential Revision: D5069794

fbshipit-source-id: ede314034a2eb6b063a22dbd6e5d13c8ad66e20c
2017-06-14 09:32:37 -07:00
James Burnett 51c0e81557 remove disableAutomock from jest tests (new default) @bypass-lint
Reviewed By: cpojer

Differential Revision: D5237192

fbshipit-source-id: dccca52a91259d7fea27931f92bca94184a82d4a
2017-06-13 15:04:09 -07:00
Alex Dvornikov e38641cd73 Fixed error in _getCallableModule method in MessageQueue
Reviewed By: javache

Differential Revision: D5208462

fbshipit-source-id: 13f71e2b7988305eccfa91c349ff120fad9129f0
2017-06-08 12:49:37 -07:00