Summary:
This moves the `src` directory one level up and removes the `react-packager` folder. Personally, I always disliked this indirection. I'm reorganizing some things in RNP, so this seems to make sense.
Not sure if I forgot to update any paths. Can anyone advice if there are more places that need change?
Reviewed By: jeanlauliac
Differential Revision: D4487867
fbshipit-source-id: d63f9c79d6238300df9632d2e6a4e6a4196d5ccb
Summary:
Introduces a new mechanism to build source maps that allows us to use real mapping segments instead of just mapping line-by-line.
This mechanism is only used when building development bundles to improve the debugging experience in Chrome.
The new mechanism takes advantage of a new feature in babel-generator that exposes raw mapping objects. These raw mapping objects are converted to arrays with 2, 4, or 5 for the most compact representation possible.
We no longer generate a source map for the bundle that maps each line to itself in conjunction with configuring babel generator to retain lines.
Instead, we create a source map with a large mappings object produced from the mappings of each individual file in conjunction with a “carry over” – the number of preceding lines in the bundle.
The implementation makes a couple of assumptions that hold true for babel transform results, e.g. mappings being in the order of the generated code, and that a block of mappings always belongs to the same source file. In addition, the implementation avoids allocation of objects and strings at all costs. All calculations are purely numeric, and base64 vlq produces numeric ascii character codes. These are written to a preallocated buffer objects, which is turned to a string only at the end of the building process. This implementation is ~5x faster than using the source-map library.
In addition to providing development source maps that work better, we can now also produce individual high-quality source maps for production builds and combine them to an “index source map”. This approach is unfeasable for development source maps, because index source map consistently crash Chrome.
Better production source maps are useful to get precise information about source location and symbol names when symbolicating stack traces from crashes in production.
Reviewed By: jeanlauliac
Differential Revision: D4382290
fbshipit-source-id: 365a176fa142729d0a4cef43edeb81084361e54d
Summary:
Currently the jest mock for `ListViewDataSource` has a property called `items` which returns the number of items of the data source. Example from a snapshot:
ListViewDataSource {
"items": 6,
}
If the datablob includes immutable Maps like:
const dataBlob = {
'alpha': immutable.Map({ name: 'Alpha' }),
'beta': immutable.Map({ name: 'Beta' }),
};
then the result is:
ListViewDataSource {
"items": NaN,
}
This PR checks if the properties of the `dataBlob` are immutable Maps and then checks whether they are empty.
The result for the above dataBlob would be:
ListViewDataSource {
"items": 2,
}
Closes https://github.com/facebook/react-native/pull/11567
Differential Revision: D4354977
Pulled By: cpojer
fbshipit-source-id: 9f6bd6ea9896eebd9373344a43ffe97deee5015b
Summary:
`Fake` components are simplified so snapshots are stable and reliable, and references are exported
so that interactions like `onRefresh` and `onScroll` can be called manually. Currently there is just
one global export for each class, but we may change this in the future if we need to manage multiple
`Fake`s of the same type in one render tree.
Right now these must be installed explicitly, but I might move them into `__mocks__` folders if it
seems reasonable to make them defaults.
Reviewed By: cpojer
Differential Revision: D4318207
fbshipit-source-id: 62802353a98b09ca1c80804ef7201ea63091f94a
Summary:
**Description:**
Jest tests that use that StatusBar failing because the status bar functions aren't mocked.
Errors I ran into:
`TypeError: StatusBarManager. setNetworkActivityIndicatorVisible is not a function`
`TypeError: StatusBarManager. setHidden is not a function`
`TypeError: StatusBarManager. setStyle is not a function`
**Fix:**
Added mocks for all the functions that the StatusBar offers according to the docs: https://facebook.github.io/react-native/docs/statusbar.html
**Test plan (required)**
Verify that the tests using StatusBar and its functions succeed.
Closes https://github.com/facebook/react-native/pull/11322
Differential Revision: D4284536
Pulled By: cpojer
fbshipit-source-id: b67be8c0595d91ee9aca4784f457c0959d7e45d5
Summary:
Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger.
**More info:**
In one of my files I have:
```
export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);
```
When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)
```
TypeError: Cannot read property 'HEIGHT' of undefined
at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)
```
**Test plan (required)**
Verify that with this change tests that use StatusBar pass.
Closes https://github.com/facebook/react-native/pull/11198
Differential Revision: D4246367
Pulled By: cpojer
fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a
Summary:
**Description**
In the same vein as https://github.com/facebook/react-native/pull/11198, this adds a mock for the native module `AppState`.
**Test plan**
Create a component that uses `AppState`, e.g.
```jsx
import React, { Component } from 'react';
import { AppState } from 'react-native';
class TestComponent extends Component {
componentDidMount() {
AppState.addEventListener('change', this.stateChangeListener);
}
}
```
Closes https://github.com/facebook/react-native/pull/11199
Differential Revision: D4246668
Pulled By: cpojer
fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
Summary:
Fixes warnings such as `Warning: Native component for "RCTView" does not exist` when you don't mock the native view class on `UIManager`.
**Test plan (required)**
Run `npm test` with it and without it, notice that warnings are gone and results are the same.
cc cpojer
Closes https://github.com/facebook/react-native/pull/10486
Differential Revision: D4063500
Pulled By: cpojer
fbshipit-source-id: f6bdda1fdd1ad87958f435071d353684cb812af4