forked from microsoft/react-native-test-app
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
Anastasia Orishchenko
committed
Jul 16, 2020
1 parent
15ab648
commit a6b522d
Showing
12 changed files
with
437 additions
and
362 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 |
---|---|---|
|
@@ -15,3 +15,4 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | |
xcuserdata/ | ||
yarn-error.log* | ||
.vs/ | ||
msbuild.binlog |
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,18 +1,17 @@ | ||
if (process.argv.includes("--config=metro.config.macos.js")) { | ||
module.exports = { | ||
reactNativePath: "node_modules/react-native-macos", | ||
}; | ||
} | ||
else if (process.argv.includes("--config=metro.config.windows.js")) { | ||
module.exports = { | ||
reactNativePath: "node_modules/react-native-windows", | ||
}; | ||
module.exports = { | ||
reactNativePath: "node_modules/react-native-macos", | ||
}; | ||
} else if (process.argv.includes("--config=metro.config.windows.js")) { | ||
module.exports = { | ||
reactNativePath: "node_modules/react-native-windows", | ||
}; | ||
} else { | ||
module.exports = { | ||
project: { | ||
ios: { | ||
project: "ios/ReactTestApp-Dummy.xcodeproj", | ||
}, | ||
}, | ||
}; | ||
module.exports = { | ||
project: { | ||
ios: { | ||
project: "ios/ReactTestApp-Dummy.xcodeproj", | ||
}, | ||
}, | ||
}; | ||
} |
Binary file not shown.
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
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,53 @@ | ||
#include "pch.h" | ||
|
||
#include "ReactInstance.h" | ||
|
||
#include <filesystem> | ||
|
||
namespace ReactTestApp | ||
{ | ||
void ReactInstance::LoadJSBundleFrom(JSBundleSource source) | ||
{ | ||
auto instanceSettings = reactNativeHost_.InstanceSettings(); | ||
instanceSettings.UseLiveReload(source == JSBundleSource::DevServer); | ||
instanceSettings.UseWebDebugger(source == JSBundleSource::DevServer); | ||
instanceSettings.UseFastRefresh(source == JSBundleSource::DevServer); | ||
|
||
switch (source) { | ||
case JSBundleSource::DevServer: | ||
instanceSettings.JavaScriptMainModuleName(L"index"); | ||
instanceSettings.JavaScriptBundleFile(L""); | ||
break; | ||
case JSBundleSource::Embedded: | ||
winrt::hstring bundleFileName = winrt::to_hstring(GetBundleName()); | ||
instanceSettings.JavaScriptBundleFile(bundleFileName); | ||
break; | ||
} | ||
|
||
reactNativeHost_.ReloadInstance(); | ||
} | ||
|
||
winrt::Microsoft::ReactNative::ReactNativeHost &ReactInstance::ReactHost() | ||
{ | ||
return reactNativeHost_; | ||
} | ||
|
||
std::string GetBundleName() | ||
{ | ||
std::vector entryFileNames = {"index.windows", | ||
"main.windows", | ||
"index.native", | ||
"main.native", | ||
"index" | ||
"main"}; | ||
|
||
for (std::string &&n : entryFileNames) { | ||
std::string path = "Bundle\\" + n + ".bundle"; | ||
if (std::filesystem::exists(path)) { | ||
return n; | ||
} | ||
} | ||
|
||
return ""; // TODO handle bundle not present | ||
} | ||
} // namespace ReactTestApp |
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,23 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
namespace ReactTestApp | ||
{ | ||
enum class JSBundleSource { | ||
DevServer, | ||
Embedded, | ||
}; | ||
|
||
class ReactInstance | ||
{ | ||
public: | ||
winrt::Microsoft::ReactNative::ReactNativeHost &ReactHost(); | ||
void LoadJSBundleFrom(JSBundleSource source); | ||
|
||
private: | ||
winrt::Microsoft::ReactNative::ReactNativeHost reactNativeHost_; | ||
}; | ||
|
||
std::string GetBundleName(); | ||
|
||
} // namespace ReactTestApp |
Oops, something went wrong.