-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,214 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,12 @@ on: | |
push: | ||
branches: | ||
- master | ||
- next | ||
|
||
pull_request: | ||
branches: | ||
- master | ||
- next | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Improving Performance | ||
|
||
By default, UI Kitten is configured with processing Eva mapping packages during the runtime. This may lead to performance issues when using [mapping customization](design-system/customize-mapping) or React Native Navigation by Wix. By following this guide, you will know how to get rid of this and save time your application takes on loading. | ||
|
||
## Configuration | ||
|
||
Install the additional metro configuration: | ||
|
||
```bash | ||
npm i -D @ui-kitten/metro-config | ||
``` | ||
|
||
Create **metro.config.js** at the root of your project if you don't have this file yet and place the following code: | ||
|
||
```js | ||
const MetroConfig = require('@ui-kitten/metro-config'); | ||
|
||
const evaConfig = { | ||
evaPackage: '@eva-design/eva', | ||
// Optional, but may be useful when using mapping customization feature. | ||
// customMappingPath: './custom-mapping.json', | ||
}; | ||
|
||
module.exports = MetroConfig.create(evaConfig, { | ||
// Whatever was previously specified | ||
}); | ||
``` | ||
|
||
Modify props passed to ApplicationProvider: | ||
|
||
```jsx | ||
import React from 'react'; | ||
import { ApplicationProvider } from '@ui-kitten/components'; | ||
import * as eva from '@eva-design/eva'; | ||
|
||
export default () => ( | ||
<ApplicationProvider {...eva} theme={eva.light}> | ||
// ... | ||
</ApplicationProvider> | ||
); | ||
``` | ||
Restart Metro Bundler if it is running to apply the changes. | ||
|
||
<hr> | ||
|
||
## Definition | ||
|
||
Let's take a look on the **evaConfig** we define: | ||
|
||
**evaPackage** represents the name of Eva Design System package installed. | ||
|
||
In this example, we use `@eva-design/eva`. | ||
It may be one of the valid Eva Design System packages. | ||
|
||
**customMappingPath** represents a path to custom mapping if you use [mapping customization](design-system/customize-mapping) feature. You may omit it if you do not customize Eva. | ||
|
||
The second argument of `create` function is a standard configuration of Metro Bundler. In case you had `metro.config.js` previously, pass the object you had to merge it with UI Kitten configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ui-kitten", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"private": true, | ||
"license": "MIT", | ||
"author": "akveo <[email protected]>", | ||
|
@@ -65,4 +65,4 @@ | |
"react-native": "~0.61.4", | ||
"react-native-svg": "~9.13.3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@ui-kitten/components", | ||
"description": "React Native components based on Eva Design System", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"author": "akveo <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/akveo/react-native-ui-kitten#readme", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@ui-kitten/date-fns", | ||
"description": "date-fns services for UI Kitten", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"author": "akveo <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/akveo/react-native-ui-kitten#readme", | ||
|
@@ -24,7 +24,7 @@ | |
"date-fns": "^1.30.1" | ||
}, | ||
"peerDependencies": { | ||
"@ui-kitten/components": "4.4.0", | ||
"@ui-kitten/components": "4.4.1", | ||
"date-fns": "^1.30.1" | ||
}, | ||
"sideEffects": false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@ui-kitten/eva-icons", | ||
"description": "Eva Icons for React Native", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"author": "akveo <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/akveo/react-native-ui-kitten#readme", | ||
|
@@ -27,7 +27,7 @@ | |
"react-native-svg": "^9.4.0" | ||
}, | ||
"peerDependencies": { | ||
"@ui-kitten/components": "4.4.0", | ||
"@ui-kitten/components": "4.4.1", | ||
"react-native-svg": "^9.4.0" | ||
}, | ||
"sideEffects": false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import Fs from 'fs'; | ||
import LodashMerge from 'lodash.merge'; | ||
import MetroConfig from 'metro-config/src/defaults'; | ||
import BootstrapService from './services/bootstrap.service'; | ||
import { EvaConfig } from './services/eva-config.service'; | ||
import ProjectService from './services/project.service'; | ||
|
||
// TS definitions for metro config? | ||
type MetroConfigType = any; | ||
|
||
const defaultMetroConfig = MetroConfig.getDefaultValues(); | ||
const customMappingWatchOptions = { | ||
/* | ||
* How often the custom mapping should be polled in milliseconds | ||
*/ | ||
interval: 100, | ||
}; | ||
|
||
/** | ||
* Creates custom Metro config for bootstrapping Eva packages. | ||
* | ||
* @param {EvaConfig} evaConfig - configuration of Eva Design System used in project. | ||
* @see {EvaConfig} | ||
* | ||
* @param metroConfig - configuration of Metro Bundler used in project. | ||
* @link https://facebook.github.io/metro/docs/configuration | ||
* | ||
* @returns a combination of two metro configurations. | ||
* | ||
* @example Usage | ||
* | ||
* ```metro.config.js | ||
* const MetroConfig = require('@ui-kitten/metro-config'); | ||
* | ||
* const evaConfig = { | ||
* evaPackage: '@eva-design/eva', // Required. | ||
* customMappingPath: './custom-mapping.json', // Optional. | ||
* }; | ||
* | ||
* module.exports = MetroConfig.create(evaConfig, { | ||
* // Whatever was previously specified | ||
* }); | ||
* ``` | ||
*/ | ||
export const create = (evaConfig: EvaConfig, metroConfig?: MetroConfigType): MetroConfigType => { | ||
|
||
const handleMetroEvent = (event): void => { | ||
const reporter = metroConfig && metroConfig.reporter || defaultMetroConfig.reporter; | ||
|
||
if (reporter && reporter.update) { | ||
reporter.update(event); | ||
} | ||
|
||
if (event.type === 'initialize_started') { | ||
BootstrapService.run(evaConfig); | ||
|
||
const customMappingPath: string = ProjectService.resolvePath(evaConfig.customMappingPath); | ||
const customMappingExists: boolean = Fs.existsSync(customMappingPath); | ||
|
||
if (customMappingExists) { | ||
Fs.watchFile(customMappingPath, customMappingWatchOptions, () => { | ||
BootstrapService.run(evaConfig); | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
const libConfig: MetroConfigType = { | ||
reporter: { | ||
update: handleMetroEvent, | ||
}, | ||
}; | ||
|
||
return LodashMerge({}, libConfig, metroConfig); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "@ui-kitten/metro-config", | ||
"description": "UI Kitten config for Metro Bundler", | ||
"version": "4.4.1", | ||
"author": "akveo <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/akveo/react-native-ui-kitten#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/akveo/react-native-ui-kitten.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/akveo/react-native-ui-kitten/issues" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@eva-design/dss": "^1.4.0", | ||
"@eva-design/processor": "^1.4.0", | ||
"@types/lodash.merge": "ts3.7", | ||
"chalk": "^3.0.0", | ||
"lodash.merge": "^4.6.1" | ||
}, | ||
"peerDependencies": { | ||
"metro-config": "^0.58.0" | ||
} | ||
} |
Oops, something went wrong.