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

35 Коммитов

Автор SHA1 Сообщение Дата
Riley Dulin 16e8a35d42 Remove groupCollapsed from list of unsupported polyfills
Summary:
Changelog: [Internal] Remove groupCollapsed from list of unsupported polyfills

`console.groupCollapsed` was always replaced with `originalConsole`'s implementation, but
the right behavior is to have it be a proxy (call both `console` and `originalConsole`).
So remove this key from a list of unsupported functions.

Reviewed By: yungsters

Differential Revision: D18820158

fbshipit-source-id: d83cffbc7e7939c2654fad2e0d681da7c3b5196a
2019-12-06 13:35:47 -08:00
Tim Yung b7ab922bb3 RN: Console Stub Parity
Summary:
Brings parity to the non-`__DEV__` stub polyfill for `console`.

Changelog:
[General][Added] - Added missing `console` polyfills in release builds.

Reviewed By: ejanzer, RSNara

Differential Revision: D18667335

fbshipit-source-id: 0307d04a136e5f7bb914f18b80441b7a7fae5e5b
2019-11-23 07:22:44 -08:00
Rick Hanlon 42ac240bce Don't wrap console methods for metro logging in Chrome debugger (#26883)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/26883

This diff fixes an issue reported in https://github.com/facebook/react-native/issues/26788 where logs in the Chrome console were showing a different location than previous versions.

In the change here, we stop wrapping the console functions to attach the metro websocket in any environment that isn't a native app environment. We do this by checking `global.nativeLoggingHook` which is bound only by native apps and not environments like the Chrome DevTools.

Changelog: [General][Fixed] - Fix wrong lines logging in Chrome debugger

Reviewed By: cpojer, gaearon

Differential Revision: D17951707

fbshipit-source-id: f045ea9abaa8aecc6afb8eca7db9842146a3d872
2019-10-21 10:05:40 -07:00
Brian Vaughn 92a3c9da0a React DevTools v4 integration
Summary:
This Diff is being posted for discussion purposes. It will not be ready to land until React DevTools v4 has been published to NPM.

Update React Native to be compatible with the [new version 4 React DevTools extension](https://github.com/bvaughn/react-devtools-experimental).

**Note that this is a breaking change**, as the version 3 and version 4 backends are **not compatible**. Once this update ships (in React Native) users will be required to update their version of the [`react-devtools` NPM package](https://www.npmjs.com/package/react-devtools). The same will be true for IDEs like Nuclide as well as other developer tools like Flipper and [React Native Debugger](https://github.com/jhen0409/react-native-debugger).

Related changes also included in this diff are:
* Pass an explicit whitelist of style props for the React Native style editor (to improve developer experience when adding new styles).
* Update `YellowBox` console patching to coordinate with DevTools own console patching.
  * Also improved formatting slightly by not calling `stringifySafe` for strings (since this adds visible quotation marks).

Regarding the console patching- component stacks will be appended by default when there's no DevTools frontend open. The frontend will provide an option to turn this behavior off though:

{F168852162}

React DevTools will detect if the new version is used with an older version of React Native, and offer inline upgrade instructions:

{F169306863}

**Note that the change to the `RCTEnableTurboModule` will not be included in this Diff**. I've just turned those off temporarily so I can use v8+Chrome for debugging.

Reviewed By: rickhanlonii

Differential Revision: D15973709

fbshipit-source-id: bb9d83fc829af4693e7a10a622acc95a411a48e4
2019-08-26 23:56:59 -07:00
Moti Zilberman 9f85f1e39c Type ErrorUtils (error-guard.js)
Summary:
* Adds Flow types to `error-guard.js` and propagates them via the `ErrorUtils` module.
* Fixes some call sites to account for the stricter (correct) types.

Differential Revision: D16619538

fbshipit-source-id: c006ff2736ec380763956c4b89702cf44dd4deb0
2019-08-02 09:38:46 -07:00
Spencer Ahrens d7cbe3347b protect against hanging when logging nasty objects
Summary:
Logging nasty objects can cause RN to lockup as we try to format it nicely. The formatting code has some safegaurds against excessive recursion and some cycles, but it's not failsafe.

This adds a limit on the total number of times format can be called before we start to bail out. In my testing, this limit keeps the format time under ~100ms for huge objects, and logcat and other log readers start truncating it anyway so there is rarely any lost information.

I also considered using wall time, but this seemed a little cleaner. Open to suggestions.

Reviewed By: yungsters

Differential Revision: D15710157

fbshipit-source-id: b50261093270d6fb67b3473432d384ec51b98fd5
2019-06-21 07:43:52 -07:00
Spencer Ahrens a87af19d3f workaround T43930203 where originalConsole.assert doesn't properly check the condition and always fires
Summary: Workaround for bugs with originalConsole.assert firing when it shouldn't.

Reviewed By: Hypuk

Differential Revision: D15201459

fbshipit-source-id: d4cf648725cf42754561468b23ea8edd7c1b84b2
2019-05-03 12:27:21 -07:00
Janic Duplessis 5e36b0c6eb Add support for cancelling fetch requests with AbortController (#24419)
Summary:
This adds https://github.com/mysticatea/abort-controller to polyfill [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). This is used to cancel requests when using `fetch`.

This also updates `event-target-shim` to 5.0 to make sure we only have one version of this dependency. This updates required adding a polyfill for `console.assert` which is used by the new version. I made one based on https://github.com/gskinner/console-polyfill/blob/master/console.js#L74.

The polyfill is very small, especially since we already use `event-target-shim` so I think it makes sense to include in core.

Depends on #24418 so that the fetch polyfill supports the `signal` parameter.

Fixes #18115

[General] [Added] - Add support for cancelling fetch requests with AbortController
Pull Request resolved: https://github.com/facebook/react-native/pull/24419

Differential Revision: D14912858

Pulled By: cpojer

fbshipit-source-id: 8a6402910398db51e2f3e3262f07aabdf68fcf72
2019-04-15 12:02:36 -07:00
Christoph Nakazawa 06cf7face2 Remove Polyfills from RN Open Source
Summary:
We don't need these polyfills in RN Open Source any longer because JSC supports these features natively.

We also don't need these internally at FB, but I want the removal to be a step by step process and separate from the open source work.

Reviewed By: rickhanlonii

Differential Revision: D14762827

fbshipit-source-id: 114626bd18516c42ced43c3f7aa29d42d1d95335
2019-04-04 15:20:33 -07:00
Mido 638d672abc Added groupCollapsed polyfill (#21457)
Summary:
`groupCollapsed` is used to group logs but collapsed which is very useful when the console has many logs (e.g. when using `redux-logger`).

For developers who prefer to debug iOS apps using Safari JSC, the `groupCollapsed` was not polyfilled.

Fixes #21446
Pull Request resolved: https://github.com/facebook/react-native/pull/21457

Differential Revision: D13761796

Pulled By: cpojer

fbshipit-source-id: e7c4f1ff4728c6a7f6ffd6cc629f7fbc1aa67e87
2019-01-22 07:05:22 -08:00
Shen Junru 7de2f77d20 Fix expose originalConsole issue (#22844)
Summary:
The "originalConsole" expose is incorrect in the "polyfills/console.js"

Changelog:
----------

[GENERAL] [Fixed] - Fixed originalConsole expose issue
Pull Request resolved: https://github.com/facebook/react-native/pull/22844

Differential Revision: D13579480

Pulled By: cpojer

fbshipit-source-id: 1d3ad84d3560b757df23170924af9c7655738871
2019-01-04 00:04:05 -08:00
luckyzeng 3592122af3 Delete unused code in console.js (#20860)
Summary:
The isPrimitive method in [console.js](5c2720b089/Libraries/polyfills/console.js (L364)) is unused. It should be deleted.
Pull Request resolved: https://github.com/facebook/react-native/pull/20860

Differential Revision: D13396715

Pulled By: cpojer

fbshipit-source-id: ddfd828086106c997dcc77f5eae67adb6a0c1dfa
2018-12-10 05:48:32 -08:00
Nurzhan Bakibayev bccc4548e4 console polyfill: pass unsupported messages to original console
Summary: Some console methods (like `groupCollapsed` or `clear`) are not supported by console.js polyfill and are not passed to the original console objects.

Reviewed By: sahrens

Differential Revision: D12900996

fbshipit-source-id: 1b2f487028e418ae934f631996eaaf63abdced82
2018-11-07 11:21:55 -08:00
Ignacio Olaciregui ae8ec39397 Fix linting issues (#22062)
Summary:
Fixes lots of ESLint warnings. Many of them where in PR #20877 by janicduplessis which requested to split the linting fixes from configuration and package changes.

I solved only the issues that I was most certain about but I would love to get hands on all of them with a little bit of input.
Pull Request resolved: https://github.com/facebook/react-native/pull/22062

Differential Revision: D12889447

Pulled By: TheSavior

fbshipit-source-id: 35f7a08104a5b859c860afdde4af2b32c0685c50
2018-11-01 14:29: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
Simon Jensen 966bb63a80 make Object.assign polyfill conditional and spec compliant
Summary: Replace the non-compliant `Object.assign` with a spec compliant version from Mozilla. Since its spec compliant we can apply conditionally only when a native version is not available.

Reviewed By: yungsters

Differential Revision: D8896359

fbshipit-source-id: 4999fe3094eba2206293bbe28760a4e46cbee6aa
2018-08-23 14:02:10 -07:00
Tim Yung c1ecd8aefc RN: Polyfill `String#padEnd` and `String#padStart`
Summary: Adds polyfills for `String.prototype.padEnd` and `String.prototype.padStart`.

Reviewed By: mjesun

Differential Revision: D9233437

fbshipit-source-id: 3430450f28b4cec8f1c74af5f169e9bdef044ae8
2018-08-13 12:01:57 -07:00
gengjiawen fdce938455 fix missing prettier file (#20001)
Summary:
fix missing prettier file
pass all current ci.
https://github.com/facebook/react-native/pull/19987
 [GENERAL] [INTERNAL] [TOOL] - fix missing prettier file.
Closes https://github.com/facebook/react-native/pull/20001

Differential Revision: D8714374

Pulled By: hramos

fbshipit-source-id: acdcb5d84c56d26c55f6262a0a98aefe786de8cb
2018-07-02 10:48:06 -07:00
Andrew Goodale f7657eaf02 Implement console group APIs (#18555)
Summary:
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

React Native provides an implementation of the Web "Console" API, which is a powerful mechanism for debugging and analyzing RN apps. However, one subset of the Console API that RN does not provide is the "grouping" functions, namely `console.group` and `console.groupEnd`. These functions provide a useful way to see how an application behaves within a different parts of an application hierarchy.

I modified the "RNTester" app to create a console group each time an example is tapped, and the group is ended when the "Back" button is tapped. Here is an example of the grouping as seen in the Xcode console.

<img width="651" alt="console grouping" src="https://user-images.githubusercontent.com/445421/37882070-d2ae7860-306d-11e8-8cf4-be843a864f43.png">

https://github.com/facebook/react-native-website/pull/270

[GENERAL] [ENHANCEMENT] [console.js] - Add `console.group()` and `console.groupEnd()` APIs, matching the Web Console API.
Closes https://github.com/facebook/react-native/pull/18555

Differential Revision: D7992131

Pulled By: hramos

fbshipit-source-id: 0d28896292563922240ae2100ed49e35b6d1f102
2018-06-12 11:18:37 -07:00
Peter van der Zee 7014a30baa Upgrade babel to beta.47 across xplat
Summary:
Upgrade Babel from beta.40 to beta.47

There are two important breaking changes here.

- If you want an AST from the Babel `transform` functions you must pass on `ast:true` in the options.
- The `sourceType` is now the only source of truth on whether to parse with the Script or Module goal. It defaults to `script` and can also be `module` or `unambiguous`. In the `unambiguous` case it will first try to parse with the Module goal and only if it crashes it will try again with the Script goal.

Beyond that there were some fixes and some smaller changes that may affect you. See the Babel changelogs for details (https://github.com/babel/babel/tags).

Also updated the way we generate the babel helpers file.

Reviewed By: rubennorte

Differential Revision: D8075280

fbshipit-source-id: 2bb902690e8a4b19d9cada2b7b0c94812b3d4f0f
2018-05-23 06:16:01 -07:00
Peter van der Zee fbd1beaf66 Add automated script to update the babelHelpers file
Reviewed By: cpojer

Differential Revision: D8025371

fbshipit-source-id: 4811f16d882196bc32be7471b6a3ab4d834651c2
2018-05-18 06:09:26 -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
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
Peter van der Zee f8d6b97140 BREAKING CHANGE: UPGRADE REACT NATIVE TO BABEL 7!
Summary:
BREAKING CHANGE
This change upgrades the React Native build pipeline from Babel 6 to Babel 7

If you use a `.babelrc` then you'll need to update it to Babel 7 (note that some plugins are no longer relevant, some plugins are automatically upgraded, and some will need some manual love).

Note that you may also need to upgrade your dev env, tests etc, to make sure they work with Babel 7.

Reviewed By: mjesun

Differential Revision: D7591303

fbshipit-source-id: 29cef21f6466633a9c366d1f3c0d3cf874c714db
2018-04-11 16:47:18 -07:00
Matt Mahoney c9a6b8560f Revert D7097279: BREAKING CHANGE: UPGRADE REACT NATIVE TO BABEL 7!
Differential Revision:
D7097279

Original commit changeset: 9fb204cae733

fbshipit-source-id: bbbb20b5dbed5dc01ae5557686a07d987b9a6cc6
2018-04-11 08:25:17 -07:00
Peter van der Zee ebd12fa09f BREAKING CHANGE: UPGRADE REACT NATIVE TO BABEL 7!
Summary:
BREAKING CHANGE
This change upgrades the React Native build pipeline from Babel 6 to Babel 7

If you use a `.babelrc` then you'll need to update it to Babel 7 (note that some plugins are no longer relevant, some plugins are automatically upgraded, and some will need some manual love).

Note that you may also need to upgrade your dev env, tests etc, to make sure they work with Babel 7.

Reviewed By: cpojer

Differential Revision: D7097279

fbshipit-source-id: 9fb204cae733174a1c155669b7c17ddb70f7aecc
2018-04-10 21:02:43 -07:00
Peter van der Zee 88ba7ebcc7 Fix "function statements" in strict mode builds
Reviewed By: davidaurelio

Differential Revision: D7427473

fbshipit-source-id: 130d0653c100c4a12b2a01aa3489b780febf6d8e
2018-03-28 10:12:41 -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 11a495cb32 Fixing eslint-comments warnings
Reviewed By: yungsters

Differential Revision: D6678252

fbshipit-source-id: ee93b7ee52520b750ca11fcc625cccf3cd82d075
2018-01-08 17:04:29 -08:00
Naman Goel 5cdf5f3910 Use proper script way to clone Emoji files from www
Differential Revision: D5615872

fbshipit-source-id: 7f2c19f1a65f42b78136be7e6a608d0415c1a49f
2017-08-21 16:29:39 -07:00
Kashav Madan c404425d0f Improve spacing in polyfill error messages
Summary:
<!--
Thank you for sending the PR!

If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!

Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.

Happy contributing!
-->

Noticed a lack of spacing in the following error message:

```
In this environment the sources for assign MUST be an object.This error is a performance optimization and not spec compliant.
TypeError: In this environment the sources for assign MUST be an object.This error is a performance optimization and not spec compliant.
    at Object.assign (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:230:15)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:134559:46
    at Array.map (native)
    at GridComponent._callee$ (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:134554:58)
    at tryCatch (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7388:40)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7576:22)
    at Generator.prototype.(anonymous function) [as next] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7413:21)
    at tryCatch (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7388:40)
    at invoke (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7446:20)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7476:11
```

Tested by updating the message locally in `/path/to/rn-project/node_modules/react-native/packager/src/Resolver/polyfills/Object.es6.js`.
Closes https://github.com/facebook/react-native/pull/15166

Differential Revision: D5481475

Pulled By: javache

fbshipit-source-id: f3e4e482a8ee61d52e8c3e0c5f038b1109bd1113
2017-08-10 03:56:01 -07:00
Riley Dulin de4e51beaf Make console work with JS engines which use print
Reviewed By: javache

Differential Revision: D5586381

fbshipit-source-id: e40dea048129bef6755817297a7d9eb701f71d41
2017-08-09 18:03:39 -07:00
Miguel Jimenez Esun 7a4eda2f70 Remove default polyfills from metro-bundler
Reviewed By: davidaurelio

Differential Revision: D5423673

fbshipit-source-id: a66655cd72d56eb60a8a79a298ebfbc746b5ad10
2017-07-17 03:20:02 -07:00
Miguel Jimenez Esun ad0fe15e2e Move polyfills to react-native
Summary:
React Native bundler (aka Metro Bundler) was splitted from the main codebase some time ago (now it lives [[https://github.com/facebook/metro-bundler|here]]). To make it more agnostic, polyfills will be moved out from it, so people who doesn't need them does not include them. However, RN will still need them, so the first step is to copy them back to RN so that we can provide them to Metro Bundler later.

We also include a way of passing the list of polyfills to include, as an `Array<string>`. The field is called `polyfills`, and defaults to the traditional list that is currently included in the package manager [see here](be1843cddc/packages/metro-bundler/src/defaults.js (L27-L37)).

In future commits, `metro-bundler` will be able to manage the `polyfills` array passed to it, and use it, instead of the pre-defined ones.

Reviewed By: davidaurelio

Differential Revision: D5381614

fbshipit-source-id: 749d536b781843ecb3067803e44398cd6df941f1
2017-07-11 03:47:16 -07:00