Skip to content

Commit 75785cb

Browse files
alexmoroz15Aleksey
and
Aleksey
authored
React Native Windows >=0.63.11 Initial Implementation PR (microsoft#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]>
1 parent b15a019 commit 75785cb

File tree

119 files changed

+22719
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+22719
-59
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
14+
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
20+
21+
[include]
22+
23+
[libs]
24+
node_modules/react-native/interface.js
25+
node_modules/react-native/flow/
26+
27+
[options]
28+
emoji=true
29+
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
32+
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
36+
37+
munge_underscores=true
38+
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
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'
41+
42+
suppress_type=$FlowIssue
43+
suppress_type=$FlowFixMe
44+
suppress_type=$FlowFixMeProps
45+
suppress_type=$FlowFixMeState
46+
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50+
51+
[lints]
52+
sketchy-null-number=warn
53+
sketchy-null-mixed=warn
54+
sketchy-number=warn
55+
untyped-type-import=warn
56+
nonstrict-import=warn
57+
deprecated-type=warn
58+
unsafe-getters-setters=warn
59+
unnecessary-invariant=warn
60+
signature-verification-failure=warn
61+
deprecated-utility=error
62+
63+
[strict]
64+
deprecated-type
65+
nonstrict-import
66+
sketchy-null
67+
unclear-type
68+
unsafe-getters-setters
69+
untyped-import
70+
untyped-type-import
71+
72+
[version]
73+
^0.122.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# Android/IntelliJ
25+
#
26+
build/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
32+
# Visual Studio Code
33+
#
34+
.vscode/
35+
36+
# node.js
37+
#
38+
node_modules/
39+
npm-debug.log
40+
yarn-error.log
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+
!debug.keystore
47+
48+
# fastlane
49+
#
50+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
51+
# screenshots whenever they are needed.
52+
# For more information about the recommended setup visit:
53+
# https://docs.fastlane.tools/best-practices/source-control/
54+
55+
*/fastlane/report.xml
56+
*/fastlane/Preview.html
57+
*/fastlane/screenshots
58+
59+
# Bundle artifact
60+
*.jsbundle
61+
62+
# CocoaPods
63+
/ios/Pods/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Examples/CodePushDemoAppCpp/App.js

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import React, { Component } from 'react';
2+
import {
3+
AppRegistry,
4+
Dimensions,
5+
Image,
6+
SafeAreaView,
7+
ScrollView,
8+
StyleSheet,
9+
Text,
10+
TouchableOpacity,
11+
View,
12+
} from 'react-native';
13+
14+
import CodePush from "react-native-code-push";
15+
16+
class App extends Component<{}> {
17+
constructor() {
18+
super();
19+
this.state = { restartAllowed: true };
20+
}
21+
22+
codePushStatusDidChange(syncStatus) {
23+
switch(syncStatus) {
24+
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
25+
this.setState({ syncMessage: "Checking for update." });
26+
break;
27+
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
28+
this.setState({ syncMessage: "Downloading package." });
29+
break;
30+
case CodePush.SyncStatus.AWAITING_USER_ACTION:
31+
this.setState({ syncMessage: "Awaiting user action." });
32+
break;
33+
case CodePush.SyncStatus.INSTALLING_UPDATE:
34+
this.setState({ syncMessage: "Installing update." });
35+
break;
36+
case CodePush.SyncStatus.UP_TO_DATE:
37+
this.setState({ syncMessage: "App up to date.", progress: false });
38+
break;
39+
case CodePush.SyncStatus.UPDATE_IGNORED:
40+
this.setState({ syncMessage: "Update cancelled by user.", progress: false });
41+
break;
42+
case CodePush.SyncStatus.UPDATE_INSTALLED:
43+
this.setState({ syncMessage: "Update installed and will be applied on restart.", progress: false });
44+
break;
45+
case CodePush.SyncStatus.UNKNOWN_ERROR:
46+
this.setState({ syncMessage: "An unknown error occurred.", progress: false });
47+
break;
48+
}
49+
}
50+
51+
codePushDownloadDidProgress(progress) {
52+
this.setState({ progress });
53+
}
54+
55+
toggleAllowRestart() {
56+
this.state.restartAllowed
57+
? CodePush.disallowRestart()
58+
: CodePush.allowRestart();
59+
60+
this.setState({ restartAllowed: !this.state.restartAllowed });
61+
}
62+
63+
getUpdateMetadata() {
64+
CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
65+
.then((metadata: LocalPackage) => {
66+
this.setState({ syncMessage: metadata ? JSON.stringify(metadata) : "Running binary version", progress: false });
67+
}, (error: any) => {
68+
this.setState({ syncMessage: "Error: " + error, progress: false });
69+
});
70+
}
71+
72+
/** Update is downloaded silently, and applied on restart (recommended) */
73+
sync() {
74+
CodePush.sync(
75+
{},
76+
this.codePushStatusDidChange.bind(this),
77+
this.codePushDownloadDidProgress.bind(this)
78+
);
79+
}
80+
81+
/** Update pops a confirmation dialog, and then immediately reboots the app */
82+
syncImmediate() {
83+
CodePush.sync(
84+
{ installMode: CodePush.InstallMode.IMMEDIATE, updateDialog: true },
85+
this.codePushStatusDidChange.bind(this),
86+
this.codePushDownloadDidProgress.bind(this)
87+
);
88+
}
89+
90+
restartApp() {
91+
CodePush.restartApp();
92+
}
93+
94+
render() {
95+
let progressView;
96+
97+
if (this.state.progress) {
98+
progressView = (
99+
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
100+
);
101+
}
102+
103+
return (
104+
<SafeAreaView>
105+
<ScrollView>
106+
<View style={styles.container}>
107+
<Text style={styles.welcome}>
108+
Welcome to CodePush!
109+
</Text>
110+
<Text style={styles.welcome}>
111+
Demo bundle
112+
</Text>
113+
<TouchableOpacity onPress={this.restartApp.bind(this)}>
114+
<Text style={styles.syncButton}>Press to restart</Text>
115+
</TouchableOpacity>
116+
<TouchableOpacity onPress={this.sync.bind(this)}>
117+
<Text style={styles.syncButton}>Press for background sync</Text>
118+
</TouchableOpacity>
119+
<TouchableOpacity onPress={this.syncImmediate.bind(this)}>
120+
<Text style={styles.syncButton}>Press for dialog-driven sync</Text>
121+
</TouchableOpacity>
122+
{progressView}
123+
<TouchableOpacity onPress={this.toggleAllowRestart.bind(this)}>
124+
<Text style={styles.restartToggleButton}>Restart { this.state.restartAllowed ? "allowed" : "forbidden"}</Text>
125+
</TouchableOpacity>
126+
<TouchableOpacity onPress={this.getUpdateMetadata.bind(this)}>
127+
<Text style={styles.syncButton}>Press for Update Metadata</Text>
128+
</TouchableOpacity>
129+
<Text style={styles.messages}>{this.state.syncMessage || ""}</Text>
130+
</View>
131+
</ScrollView>
132+
</SafeAreaView>
133+
);
134+
}
135+
}
136+
137+
const styles = StyleSheet.create({
138+
container: {
139+
flex: 1,
140+
alignItems: "center",
141+
backgroundColor: "#F5FCFF",
142+
paddingTop: 50
143+
},
144+
image: {
145+
margin: 30,
146+
width: Dimensions.get("window").width - 100,
147+
height: 365 * (Dimensions.get("window").width - 100) / 651,
148+
},
149+
messages: {
150+
marginTop: 30,
151+
textAlign: "center",
152+
},
153+
restartToggleButton: {
154+
color: "blue",
155+
fontSize: 17
156+
},
157+
syncButton: {
158+
color: "green",
159+
fontSize: 17
160+
},
161+
welcome: {
162+
fontSize: 20,
163+
textAlign: "center",
164+
margin: 20
165+
},
166+
});
167+
168+
/**
169+
* Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a
170+
* different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not
171+
* need to be explicitly called. All options of CodePush.sync() are also available in this decorator.
172+
*/
173+
let codePushOptions = { checkFrequency: CodePush.CheckFrequency.MANUAL };
174+
175+
App = CodePush(codePushOptions)(App);
176+
177+
export default App;

Examples/CodePushDemoAppCpp/app.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "CodePushDemoAppCpp",
3+
"displayName": "CodePushDemoAppCpp"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};
Loading

Examples/CodePushDemoAppCpp/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import {AppRegistry} from 'react-native';
6+
import App from './App';
7+
import {name as appName} from './app.json';
8+
9+
AppRegistry.registerComponent(appName, () => App);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Metro configuration for React Native
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
const path = require('path');
8+
const blacklist = require('metro-config/src/defaults/blacklist');
9+
10+
module.exports = {
11+
resolver: {
12+
blacklistRE: blacklist([
13+
// This stops "react-native run-windows" from causing the metro server to crash if its already running
14+
new RegExp(
15+
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
16+
),
17+
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip
18+
/.*\.ProjectImports\.zip/,
19+
]),
20+
},
21+
transformer: {
22+
getTransformOptions: async () => ({
23+
transform: {
24+
experimentalImportSupport: false,
25+
inlineRequires: false,
26+
},
27+
}),
28+
},
29+
};

0 commit comments

Comments
 (0)