diff --git a/docs/Guide.md b/docs/Guide.md
index c7f022d..8d2a842 100644
--- a/docs/Guide.md
+++ b/docs/Guide.md
@@ -55,7 +55,7 @@ class MyWeb extends Component {
### Loading local HTML files
-Sometimes you would have bundled an HTML file along with the app and would like to load the HTML asset into your WebView. To do this on iOS, you can just import the html file like any other asset as shown below.
+Sometimes you would have bundled an HTML file along with the app and would like to load the HTML asset into your WebView. To do this on iOS and Windows, you can just import the html file like any other asset as shown below.
```js
import React, { Component } from 'react';
diff --git a/example/App.tsx b/example/App.tsx
index 796420f..6322382 100644
--- a/example/App.tsx
+++ b/example/App.tsx
@@ -16,6 +16,7 @@ import Background from './examples/Background';
import Downloads from './examples/Downloads';
import Uploads from './examples/Uploads';
import Injection from './examples/Injection';
+import LocalPageLoad from './examples/LocalPageLoad';
const TESTS = {
Alerts: {
@@ -66,6 +67,14 @@ const TESTS = {
return ;
},
},
+ PageLoad: {
+ title: 'LocalPageLoad',
+ testId: 'LocalPageLoad',
+ description: 'Local Page load test',
+ render() {
+ return ;
+ },
+ },
};
type Props = {};
@@ -124,6 +133,11 @@ export default class App extends Component {
title="Injection"
onPress={() => this._changeTest('Injection')}
/>
+ this._changeTest('PageLoad')}
+ />
{Platform.OS == "ios" &&
+
+
+ Test
+
+
+ Local page test
+
+
\ No newline at end of file
diff --git a/example/examples/LocalPageLoad.tsx b/example/examples/LocalPageLoad.tsx
new file mode 100644
index 0000000..780e6e6
--- /dev/null
+++ b/example/examples/LocalPageLoad.tsx
@@ -0,0 +1,16 @@
+import React, {Component} from 'react';
+import {View, Text, Alert, TextInput, Button} from 'react-native';
+import WebView from 'react-native-webview';
+const localHtmlFile = require('../assets/test.html');
+
+export default class LocalPageLoad extends Component {
+ render() {
+ return (
+
+
+
+
+
+ );
+ }
+ }
\ No newline at end of file
diff --git a/windows/ReactNativeWebView/ReactWebViewManager.cpp b/windows/ReactNativeWebView/ReactWebViewManager.cpp
index 8b04fe2..a12a3e0 100644
--- a/windows/ReactNativeWebView/ReactWebViewManager.cpp
+++ b/windows/ReactNativeWebView/ReactWebViewManager.cpp
@@ -58,7 +58,6 @@ namespace winrt::ReactNativeWebView::implementation {
auto const& srcMap = propertyValue.AsObject();
if (srcMap.find("uri") != srcMap.end()) {
auto uriString = srcMap.at("uri").AsString();
- // non-uri sources not yet supported
if (uriString.length() == 0) {
continue;
}
@@ -67,9 +66,9 @@ namespace winrt::ReactNativeWebView::implementation {
if (srcMap.find("__packager_asset") != srcMap.end()) {
isPackagerAsset = srcMap.at("__packager_asset").AsBoolean();
}
-
- if (isPackagerAsset && uriString.find("assets") == 0) {
- uriString.replace(0, 6, "ms-appx://");
+ if (isPackagerAsset && uriString.find("file://") == 0) {
+ auto bundleRootPath = winrt::to_string(ReactNativeHost().InstanceSettings().BundleRootPath());
+ uriString.replace(0, 7, bundleRootPath.empty() ? "ms-appx-web:///Bundle/" : bundleRootPath);
}
webView.Navigate(winrt::Uri(to_hstring(uriString)));
@@ -94,10 +93,10 @@ namespace winrt::ReactNativeWebView::implementation {
ConstantProviderDelegate ReactWebViewManager::ExportedCustomDirectEventTypeConstants() noexcept {
return [](winrt::IJSValueWriter const& constantWriter) {
- WriteCustomDirectEventTypeConstant(constantWriter, "onLoadingStart");
- WriteCustomDirectEventTypeConstant(constantWriter, "onLoadingFinish");
- WriteCustomDirectEventTypeConstant(constantWriter, "onLoadingError");
- WriteCustomDirectEventTypeConstant(constantWriter, "onMessage");
+ WriteCustomDirectEventTypeConstant(constantWriter, "LoadingStart");
+ WriteCustomDirectEventTypeConstant(constantWriter, "LoadingFinish");
+ WriteCustomDirectEventTypeConstant(constantWriter, "LoadingError");
+ WriteCustomDirectEventTypeConstant(constantWriter, "Message");
};
}
diff --git a/yarn.lock b/yarn.lock
index 6b1f318..9d0c059 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5233,7 +5233,7 @@ debug@^3.1.0, debug@^3.2.6:
dependencies:
ms "^2.1.1"
-debuglog@*, debuglog@^1.0.1:
+debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -7225,7 +7225,7 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"
-imurmurhash@*, imurmurhash@^0.1.4:
+imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -8733,11 +8733,6 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"
-lodash._baseindexof@*:
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
- integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
-
lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -8746,33 +8741,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"
-lodash._bindcallback@*:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
- integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
-
-lodash._cacheindexof@*:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
- integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
-
-lodash._createcache@*:
- version "3.1.2"
- resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
- integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
- dependencies:
- lodash._getnative "^3.0.0"
-
lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
-lodash._getnative@*, lodash._getnative@^3.0.0:
- version "3.9.1"
- resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
- integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
-
lodash._root@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
@@ -8843,11 +8816,6 @@ lodash.merge@^4.6.1:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
-lodash.restparam@*:
- version "3.6.1"
- resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
- integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
-
lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"