-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React Native Windows >=0.63.11 Initial Implementation PR (#1994)
* Add React Native Windows 0.63.5+ support * modify windows/.npmignore * Update setup-windows.md * Revert package.json changes * Add newline at the end of added files * Update demo app package.json to show minimum version * Update setup-windows.md * Update setup-windows.md Co-authored-by: Aleksey <[email protected]>
- Loading branch information
1 parent
b15a019
commit 75785cb
Showing
119 changed files
with
22,719 additions
and
59 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
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,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@react-native-community', | ||
}; |
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,73 @@ | ||
[ignore] | ||
; We fork some components by platform | ||
.*/*[.]android.js | ||
|
||
; Ignore "BUCK" generated dirs | ||
<PROJECT_ROOT>/\.buckd/ | ||
|
||
; Ignore polyfills | ||
node_modules/react-native/Libraries/polyfills/.* | ||
|
||
; These should not be required directly | ||
; require from fbjs/lib instead: require('fbjs/lib/warning') | ||
node_modules/warning/.* | ||
|
||
; Flow doesn't support platforms | ||
.*/Libraries/Utilities/LoadingView.js | ||
|
||
[untyped] | ||
.*/node_modules/@react-native-community/cli/.*/.* | ||
|
||
[include] | ||
|
||
[libs] | ||
node_modules/react-native/interface.js | ||
node_modules/react-native/flow/ | ||
|
||
[options] | ||
emoji=true | ||
|
||
esproposal.optional_chaining=enable | ||
esproposal.nullish_coalescing=enable | ||
|
||
module.file_ext=.js | ||
module.file_ext=.json | ||
module.file_ext=.ios.js | ||
|
||
munge_underscores=true | ||
|
||
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1' | ||
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub' | ||
|
||
suppress_type=$FlowIssue | ||
suppress_type=$FlowFixMe | ||
suppress_type=$FlowFixMeProps | ||
suppress_type=$FlowFixMeState | ||
|
||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError | ||
|
||
[lints] | ||
sketchy-null-number=warn | ||
sketchy-null-mixed=warn | ||
sketchy-number=warn | ||
untyped-type-import=warn | ||
nonstrict-import=warn | ||
deprecated-type=warn | ||
unsafe-getters-setters=warn | ||
unnecessary-invariant=warn | ||
signature-verification-failure=warn | ||
deprecated-utility=error | ||
|
||
[strict] | ||
deprecated-type | ||
nonstrict-import | ||
sketchy-null | ||
unclear-type | ||
unsafe-getters-setters | ||
untyped-import | ||
untyped-type-import | ||
|
||
[version] | ||
^0.122.0 |
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 @@ | ||
*.pbxproj -text |
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,63 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
|
||
# Android/IntelliJ | ||
# | ||
build/ | ||
.idea | ||
.gradle | ||
local.properties | ||
*.iml | ||
|
||
# Visual Studio Code | ||
# | ||
.vscode/ | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
*.keystore | ||
!debug.keystore | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/ | ||
|
||
*/fastlane/report.xml | ||
*/fastlane/Preview.html | ||
*/fastlane/screenshots | ||
|
||
# Bundle artifact | ||
*.jsbundle | ||
|
||
# CocoaPods | ||
/ios/Pods/ |
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,6 @@ | ||
module.exports = { | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}; |
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 @@ | ||
{} |
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,177 @@ | ||
import React, { Component } from 'react'; | ||
import { | ||
AppRegistry, | ||
Dimensions, | ||
Image, | ||
SafeAreaView, | ||
ScrollView, | ||
StyleSheet, | ||
Text, | ||
TouchableOpacity, | ||
View, | ||
} from 'react-native'; | ||
|
||
import CodePush from "react-native-code-push"; | ||
|
||
class App extends Component<{}> { | ||
constructor() { | ||
super(); | ||
this.state = { restartAllowed: true }; | ||
} | ||
|
||
codePushStatusDidChange(syncStatus) { | ||
switch(syncStatus) { | ||
case CodePush.SyncStatus.CHECKING_FOR_UPDATE: | ||
this.setState({ syncMessage: "Checking for update." }); | ||
break; | ||
case CodePush.SyncStatus.DOWNLOADING_PACKAGE: | ||
this.setState({ syncMessage: "Downloading package." }); | ||
break; | ||
case CodePush.SyncStatus.AWAITING_USER_ACTION: | ||
this.setState({ syncMessage: "Awaiting user action." }); | ||
break; | ||
case CodePush.SyncStatus.INSTALLING_UPDATE: | ||
this.setState({ syncMessage: "Installing update." }); | ||
break; | ||
case CodePush.SyncStatus.UP_TO_DATE: | ||
this.setState({ syncMessage: "App up to date.", progress: false }); | ||
break; | ||
case CodePush.SyncStatus.UPDATE_IGNORED: | ||
this.setState({ syncMessage: "Update cancelled by user.", progress: false }); | ||
break; | ||
case CodePush.SyncStatus.UPDATE_INSTALLED: | ||
this.setState({ syncMessage: "Update installed and will be applied on restart.", progress: false }); | ||
break; | ||
case CodePush.SyncStatus.UNKNOWN_ERROR: | ||
this.setState({ syncMessage: "An unknown error occurred.", progress: false }); | ||
break; | ||
} | ||
} | ||
|
||
codePushDownloadDidProgress(progress) { | ||
this.setState({ progress }); | ||
} | ||
|
||
toggleAllowRestart() { | ||
this.state.restartAllowed | ||
? CodePush.disallowRestart() | ||
: CodePush.allowRestart(); | ||
|
||
this.setState({ restartAllowed: !this.state.restartAllowed }); | ||
} | ||
|
||
getUpdateMetadata() { | ||
CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING) | ||
.then((metadata: LocalPackage) => { | ||
this.setState({ syncMessage: metadata ? JSON.stringify(metadata) : "Running binary version", progress: false }); | ||
}, (error: any) => { | ||
this.setState({ syncMessage: "Error: " + error, progress: false }); | ||
}); | ||
} | ||
|
||
/** Update is downloaded silently, and applied on restart (recommended) */ | ||
sync() { | ||
CodePush.sync( | ||
{}, | ||
this.codePushStatusDidChange.bind(this), | ||
this.codePushDownloadDidProgress.bind(this) | ||
); | ||
} | ||
|
||
/** Update pops a confirmation dialog, and then immediately reboots the app */ | ||
syncImmediate() { | ||
CodePush.sync( | ||
{ installMode: CodePush.InstallMode.IMMEDIATE, updateDialog: true }, | ||
this.codePushStatusDidChange.bind(this), | ||
this.codePushDownloadDidProgress.bind(this) | ||
); | ||
} | ||
|
||
restartApp() { | ||
CodePush.restartApp(); | ||
} | ||
|
||
render() { | ||
let progressView; | ||
|
||
if (this.state.progress) { | ||
progressView = ( | ||
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text> | ||
); | ||
} | ||
|
||
return ( | ||
<SafeAreaView> | ||
<ScrollView> | ||
<View style={styles.container}> | ||
<Text style={styles.welcome}> | ||
Welcome to CodePush! | ||
</Text> | ||
<Text style={styles.welcome}> | ||
Demo bundle | ||
</Text> | ||
<TouchableOpacity onPress={this.restartApp.bind(this)}> | ||
<Text style={styles.syncButton}>Press to restart</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity onPress={this.sync.bind(this)}> | ||
<Text style={styles.syncButton}>Press for background sync</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity onPress={this.syncImmediate.bind(this)}> | ||
<Text style={styles.syncButton}>Press for dialog-driven sync</Text> | ||
</TouchableOpacity> | ||
{progressView} | ||
<TouchableOpacity onPress={this.toggleAllowRestart.bind(this)}> | ||
<Text style={styles.restartToggleButton}>Restart { this.state.restartAllowed ? "allowed" : "forbidden"}</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity onPress={this.getUpdateMetadata.bind(this)}> | ||
<Text style={styles.syncButton}>Press for Update Metadata</Text> | ||
</TouchableOpacity> | ||
<Text style={styles.messages}>{this.state.syncMessage || ""}</Text> | ||
</View> | ||
</ScrollView> | ||
</SafeAreaView> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: "center", | ||
backgroundColor: "#F5FCFF", | ||
paddingTop: 50 | ||
}, | ||
image: { | ||
margin: 30, | ||
width: Dimensions.get("window").width - 100, | ||
height: 365 * (Dimensions.get("window").width - 100) / 651, | ||
}, | ||
messages: { | ||
marginTop: 30, | ||
textAlign: "center", | ||
}, | ||
restartToggleButton: { | ||
color: "blue", | ||
fontSize: 17 | ||
}, | ||
syncButton: { | ||
color: "green", | ||
fontSize: 17 | ||
}, | ||
welcome: { | ||
fontSize: 20, | ||
textAlign: "center", | ||
margin: 20 | ||
}, | ||
}); | ||
|
||
/** | ||
* Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a | ||
* different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not | ||
* need to be explicitly called. All options of CodePush.sync() are also available in this decorator. | ||
*/ | ||
let codePushOptions = { checkFrequency: CodePush.CheckFrequency.MANUAL }; | ||
|
||
App = CodePush(codePushOptions)(App); | ||
|
||
export default App; |
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,4 @@ | ||
{ | ||
"name": "CodePushDemoAppCpp", | ||
"displayName": "CodePushDemoAppCpp" | ||
} |
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,3 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import {AppRegistry} from 'react-native'; | ||
import App from './App'; | ||
import {name as appName} from './app.json'; | ||
|
||
AppRegistry.registerComponent(appName, () => App); |
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,29 @@ | ||
/** | ||
* Metro configuration for React Native | ||
* https://github.com/facebook/react-native | ||
* | ||
* @format | ||
*/ | ||
const path = require('path'); | ||
const blacklist = require('metro-config/src/defaults/blacklist'); | ||
|
||
module.exports = { | ||
resolver: { | ||
blacklistRE: blacklist([ | ||
// This stops "react-native run-windows" from causing the metro server to crash if its already running | ||
new RegExp( | ||
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, | ||
), | ||
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip | ||
/.*\.ProjectImports\.zip/, | ||
]), | ||
}, | ||
transformer: { | ||
getTransformOptions: async () => ({ | ||
transform: { | ||
experimentalImportSupport: false, | ||
inlineRequires: false, | ||
}, | ||
}), | ||
}, | ||
}; |
Oops, something went wrong.