@exodus/react-native-webview 9.4.0-no-android.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/ios/RNCWebView.xcodeproj/project.pbxproj +271 -0
- package/lib/WebView.android.js +1 -0
- package/lib/WebView.ios.js +217 -0
- package/lib/WebView.js +4 -0
- package/lib/WebView.styles.js +33 -0
- package/lib/WebViewShared.js +47 -0
- package/lib/WebViewTypes.js +18 -0
- package/package.json +87 -0
- package/react-native-webview.podspec +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# React Native WebView - a Modern, Cross-Platform WebView for React Native
|
|
2
|
+
|
|
3
|
+
[](https://github.com/react-native-community/react-native-webview)
|
|
4
|
+
[](http://makeapullrequest.com)
|
|
5
|
+
[](#contributors)
|
|
6
|
+
[](https://snyk.io/test/github/react-native-community/react-native-webview)
|
|
7
|
+
[](https://www.npmjs.com/package/react-native-webview)
|
|
8
|
+
[][lean-core-issue]
|
|
9
|
+
|
|
10
|
+
**React Native WebView** is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView (which will be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)).
|
|
11
|
+
|
|
12
|
+
## Core Maintainers - Sponsoring companies
|
|
13
|
+
|
|
14
|
+
_This project is maintained for free by these people using both their free time and their company work time._
|
|
15
|
+
|
|
16
|
+
- [Thibault Malbranche](https://github.com/Titozzz) ([Twitter @titozzz](https://twitter.com/titozzz)) from [Brigad](https://brigad.co/about)
|
|
17
|
+
- [Jamon Holmgren](https://github.com/jamonholmgren) ([Twitter @jamonholmgren](https://twitter.com/jamonholmgren)) from [Infinite Red](https://infinite.red/react-native)
|
|
18
|
+
|
|
19
|
+
## Platforms Supported
|
|
20
|
+
|
|
21
|
+
- [x] iOS
|
|
22
|
+
- [x] Android
|
|
23
|
+
- [x] macOS
|
|
24
|
+
- [x] Windows
|
|
25
|
+
|
|
26
|
+
_Note: Expo support for React Native WebView started with [Expo SDK v33.0.0](https://blog.expo.io/expo-sdk-v33-0-0-is-now-available-52d1c99dfe4c)._
|
|
27
|
+
|
|
28
|
+
## Getting Started
|
|
29
|
+
|
|
30
|
+
Read our [Getting Started Guide](docs/Getting-Started.md). If any step seems unclear, please create a detailed issue.
|
|
31
|
+
|
|
32
|
+
## Versioning
|
|
33
|
+
|
|
34
|
+
This project follows [semantic versioning](https://semver.org/). We do not hesitate to release breaking changes but they will be in a major version.
|
|
35
|
+
|
|
36
|
+
**Breaking History:**
|
|
37
|
+
|
|
38
|
+
Current Version: 
|
|
39
|
+
|
|
40
|
+
- [8.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v8.0.0) - onNavigationStateChange now triggers with hash url changes
|
|
41
|
+
|
|
42
|
+
- [7.0.1](https://github.com/react-native-community/react-native-webview/releases/tag/v7.0.1) - Removed UIWebView
|
|
43
|
+
|
|
44
|
+
- [6.0.**2**](https://github.com/react-native-community/react-native-webview/releases/tag/v6.0.2) - Update to AndroidX. Make sure to enable it in your project's `android/gradle.properties`. See [Getting Started Guide](docs/Getting-Started.md).
|
|
45
|
+
|
|
46
|
+
- [5.0.**1**](https://github.com/react-native-community/react-native-webview/releases/tag/v5.0.0) - Refactored the old postMessage implementation for communication from webview to native.
|
|
47
|
+
- [4.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v4.0.0) - Added cache (enabled by default).
|
|
48
|
+
- [3.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v3.0.0) - WKWebview: Add shared process pool so cookies and localStorage are shared across webviews in iOS (enabled by default).
|
|
49
|
+
- [2.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v2.0.0) - First release this is a replica of the core webview component
|
|
50
|
+
|
|
51
|
+
**Upcoming:**
|
|
52
|
+
|
|
53
|
+
- this.webView.postMessage() removal (never documented and less flexible than injectJavascript) -> [how to migrate](https://github.com/react-native-community/react-native-webview/issues/809)
|
|
54
|
+
- Kotlin rewrite
|
|
55
|
+
- Maybe Swift rewrite
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
Import the `WebView` component from `react-native-webview` and use it like so:
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import React, { Component } from 'react';
|
|
63
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
64
|
+
import { WebView } from 'react-native-webview';
|
|
65
|
+
|
|
66
|
+
// ...
|
|
67
|
+
class MyWebComponent extends Component {
|
|
68
|
+
render() {
|
|
69
|
+
return <WebView source={{ uri: 'https://reactnative.dev/' }} />;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For more, read the [API Reference](./docs/Reference.md) and [Guide](./docs/Guide.md). If you're interested in contributing, check out the [Contributing Guide](./docs/Contributing.md).
|
|
75
|
+
|
|
76
|
+
## Common issues
|
|
77
|
+
|
|
78
|
+
- If you're getting `Invariant Violation: Native component for "RNCWebView does not exist"` it likely means you forgot to run `react-native link` or there was some error with the linking process
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
See [Contributing.md](https://github.com/react-native-community/react-native-webview/blob/master/docs/Contributing.md)
|
|
83
|
+
|
|
84
|
+
## Contributors
|
|
85
|
+
|
|
86
|
+
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key-)):
|
|
87
|
+
|
|
88
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
89
|
+
<!-- prettier-ignore -->
|
|
90
|
+
<table><tr><td align="center"><a href="https://twitter.com/titozzz"><img src="https://avatars1.githubusercontent.com/u/6181446?v=4" width="100px;" alt="Thibault Malbranche"/><br /><sub><b>Thibault Malbranche</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Code">💻</a> <a href="#ideas-titozzz" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-titozzz" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Documentation">📖</a> <a href="#maintenance-titozzz" title="Maintenance">🚧</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Tests">⚠️</a> <a href="#infra-titozzz" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#question-titozzz" title="Answering Questions">💬</a></td><td align="center"><a href="https://jamonholmgren.com"><img src="https://avatars3.githubusercontent.com/u/1479215?v=4" width="100px;" alt="Jamon Holmgren"/><br /><sub><b>Jamon Holmgren</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Code">💻</a> <a href="#ideas-jamonholmgren" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-jamonholmgren" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Documentation">📖</a> <a href="#maintenance-jamonholmgren" title="Maintenance">🚧</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Tests">⚠️</a> <a href="#example-jamonholmgren" title="Examples">💡</a> <a href="#question-jamonholmgren" title="Answering Questions">💬</a></td><td align="center"><a href="https://github.com/andreipfeiffer"><img src="https://avatars1.githubusercontent.com/u/2570562?v=4" width="100px;" alt="Andrei Pfeiffer"/><br /><sub><b>Andrei Pfeiffer</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=andreipfeiffer" title="Code">💻</a> <a href="#review-andreipfeiffer" title="Reviewed Pull Requests">👀</a> <a href="#ideas-andreipfeiffer" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://twitter.com/mikediarmid"><img src="https://avatars0.githubusercontent.com/u/5347038?v=4" width="100px;" alt="Michael Diarmid"/><br /><sub><b>Michael Diarmid</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=Salakar" title="Code">💻</a> <a href="#review-Salakar" title="Reviewed Pull Requests">👀</a> <a href="#ideas-Salakar" title="Ideas, Planning, & Feedback">🤔</a> <a href="#tool-Salakar" title="Tools">🔧</a></td><td align="center"><a href="http://smathson.github.io"><img src="https://avatars3.githubusercontent.com/u/932981?v=4" width="100px;" alt="Scott Mathson"/><br /><sub><b>Scott Mathson</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=smathson" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=smathson" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/YangXiaomei"><img src="https://avatars0.githubusercontent.com/u/8221990?v=4" width="100px;" alt="Margaret"/><br /><sub><b>Margaret</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei" title="Documentation">📖</a></td><td align="center"><a href="https://stylisted.com"><img src="https://avatars2.githubusercontent.com/u/1173161?v=4" width="100px;" alt="Jordan Sexton"/><br /><sub><b>Jordan Sexton</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=jordansexton" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=jordansexton" title="Documentation">📖</a></td></tr><tr><td align="center"><a href="https://github.com/MalcolmScruggs"><img src="https://avatars1.githubusercontent.com/u/22333355?v=4" width="100px;" alt="Malcolm Scruggs"/><br /><sub><b>Malcolm Scruggs</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=MalcolmScruggs" title="Code">💻</a> <a href="#tool-MalcolmScruggs" title="Tools">🔧</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=MalcolmScruggs" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/Momazo7u7"><img src="https://avatars0.githubusercontent.com/u/42069617?v=4" width="100px;" alt="Momazo7u7"/><br /><sub><b>Momazo7u7</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=Momazo7u7" title="Documentation">📖</a></td><td align="center"><a href="https://marco-nett.de"><img src="https://avatars1.githubusercontent.com/u/3315507?v=4" width="100px;" alt="Marco"/><br /><sub><b>Marco</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=marconett" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/jeluard"><img src="https://avatars1.githubusercontent.com/u/359723?v=4" width="100px;" alt="Julien Eluard"/><br /><sub><b>Julien Eluard</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=jeluard" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/CubeSugar"><img src="https://avatars3.githubusercontent.com/u/3667305?v=4" width="100px;" alt="Jian Wei"/><br /><sub><b>Jian Wei</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=CubeSugar" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=CubeSugar" title="Documentation">📖</a></td><td align="center"><a href="https://www.linkedin.com/in/svbutko/"><img src="https://avatars2.githubusercontent.com/u/14828004?v=4" width="100px;" alt="Sergei Butko"/><br /><sub><b>Sergei Butko</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=svbutko" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/TMomemt"><img src="https://avatars3.githubusercontent.com/u/42024947?v=4" width="100px;" alt="TMomemt"/><br /><sub><b>TMomemt</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=TMomemt" title="Code">💻</a></td></tr><tr><td align="center"><a href="http://www.try.com"><img src="https://avatars0.githubusercontent.com/u/674503?v=4" width="100px;" alt="Eric Lewis"/><br /><sub><b>Eric Lewis</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=ericlewis" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=ericlewis" title="Documentation">📖</a></td><td align="center"><a href="https://bzfx.net"><img src="https://avatars2.githubusercontent.com/u/1542454?v=4" width="100px;" alt="Daniel Vicory"/><br /><sub><b>Daniel Vicory</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=dvicory" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=dvicory" title="Documentation">📖</a></td></tr></table>
|
|
91
|
+
|
|
92
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
93
|
+
|
|
94
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
|
99
|
+
|
|
100
|
+
## Traduções
|
|
101
|
+
|
|
102
|
+
This readme is available in:
|
|
103
|
+
|
|
104
|
+
- [Brazilian portuguese](docs/README.portuguese.md)
|
|
105
|
+
|
|
106
|
+
[lean-core-issue]: https://github.com/facebook/react-native/issues/23313
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */; };
|
|
11
|
+
E91B351D21446E6C00F9801F /* RNCWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351B21446E6C00F9801F /* RNCWebViewManager.m */; };
|
|
12
|
+
E91B351E21446E6C00F9801F /* RNCWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351C21446E6C00F9801F /* RNCWebView.m */; };
|
|
13
|
+
/* End PBXBuildFile section */
|
|
14
|
+
|
|
15
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
16
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
17
|
+
isa = PBXCopyFilesBuildPhase;
|
|
18
|
+
buildActionMask = 2147483647;
|
|
19
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
20
|
+
dstSubfolderSpec = 16;
|
|
21
|
+
files = (
|
|
22
|
+
);
|
|
23
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
24
|
+
};
|
|
25
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
26
|
+
|
|
27
|
+
/* Begin PBXFileReference section */
|
|
28
|
+
134814201AA4EA6300B7C361 /* libRNCWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
29
|
+
3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RNCWKProcessPoolManager.m; path = ../apple/RNCWKProcessPoolManager.m; sourceTree = "<group>"; };
|
|
30
|
+
3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNCWKProcessPoolManager.h; path = ../apple/RNCWKProcessPoolManager.h; sourceTree = "<group>"; };
|
|
31
|
+
E91B351921446E6C00F9801F /* RNCWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNCWebViewManager.h; path = ../apple/RNCWebViewManager.h; sourceTree = "<group>"; };
|
|
32
|
+
E91B351A21446E6C00F9801F /* RNCWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNCWebView.h; path = ../apple/RNCWebView.h; sourceTree = "<group>"; };
|
|
33
|
+
E91B351B21446E6C00F9801F /* RNCWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNCWebViewManager.m; path = ../apple/RNCWebViewManager.m; sourceTree = "<group>"; };
|
|
34
|
+
E91B351C21446E6C00F9801F /* RNCWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNCWebView.m; path = ../apple/RNCWebView.m; sourceTree = "<group>"; };
|
|
35
|
+
/* End PBXFileReference section */
|
|
36
|
+
|
|
37
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
38
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
39
|
+
isa = PBXFrameworksBuildPhase;
|
|
40
|
+
buildActionMask = 2147483647;
|
|
41
|
+
files = (
|
|
42
|
+
);
|
|
43
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
44
|
+
};
|
|
45
|
+
/* End PBXFrameworksBuildPhase section */
|
|
46
|
+
|
|
47
|
+
/* Begin PBXGroup section */
|
|
48
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
49
|
+
isa = PBXGroup;
|
|
50
|
+
children = (
|
|
51
|
+
134814201AA4EA6300B7C361 /* libRNCWebView.a */,
|
|
52
|
+
);
|
|
53
|
+
name = Products;
|
|
54
|
+
sourceTree = "<group>";
|
|
55
|
+
};
|
|
56
|
+
58B511D21A9E6C8500147676 = {
|
|
57
|
+
isa = PBXGroup;
|
|
58
|
+
children = (
|
|
59
|
+
E91B351A21446E6C00F9801F /* RNCWebView.h */,
|
|
60
|
+
E91B351C21446E6C00F9801F /* RNCWebView.m */,
|
|
61
|
+
E91B351921446E6C00F9801F /* RNCWebViewManager.h */,
|
|
62
|
+
E91B351B21446E6C00F9801F /* RNCWebViewManager.m */,
|
|
63
|
+
3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */,
|
|
64
|
+
3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */,
|
|
65
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
66
|
+
);
|
|
67
|
+
sourceTree = "<group>";
|
|
68
|
+
};
|
|
69
|
+
/* End PBXGroup section */
|
|
70
|
+
|
|
71
|
+
/* Begin PBXNativeTarget section */
|
|
72
|
+
58B511DA1A9E6C8500147676 /* RNCWebView */ = {
|
|
73
|
+
isa = PBXNativeTarget;
|
|
74
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCWebView" */;
|
|
75
|
+
buildPhases = (
|
|
76
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
77
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
78
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
79
|
+
);
|
|
80
|
+
buildRules = (
|
|
81
|
+
);
|
|
82
|
+
dependencies = (
|
|
83
|
+
);
|
|
84
|
+
name = RNCWebView;
|
|
85
|
+
productName = RCTDataManager;
|
|
86
|
+
productReference = 134814201AA4EA6300B7C361 /* libRNCWebView.a */;
|
|
87
|
+
productType = "com.apple.product-type.library.static";
|
|
88
|
+
};
|
|
89
|
+
/* End PBXNativeTarget section */
|
|
90
|
+
|
|
91
|
+
/* Begin PBXProject section */
|
|
92
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
93
|
+
isa = PBXProject;
|
|
94
|
+
attributes = {
|
|
95
|
+
LastUpgradeCheck = 0830;
|
|
96
|
+
ORGANIZATIONNAME = Facebook;
|
|
97
|
+
TargetAttributes = {
|
|
98
|
+
58B511DA1A9E6C8500147676 = {
|
|
99
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */;
|
|
104
|
+
compatibilityVersion = "Xcode 3.2";
|
|
105
|
+
developmentRegion = en;
|
|
106
|
+
hasScannedForEncodings = 0;
|
|
107
|
+
knownRegions = (
|
|
108
|
+
en,
|
|
109
|
+
);
|
|
110
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
111
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
112
|
+
projectDirPath = "";
|
|
113
|
+
projectRoot = "";
|
|
114
|
+
targets = (
|
|
115
|
+
58B511DA1A9E6C8500147676 /* RNCWebView */,
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
/* End PBXProject section */
|
|
119
|
+
|
|
120
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
121
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
122
|
+
isa = PBXSourcesBuildPhase;
|
|
123
|
+
buildActionMask = 2147483647;
|
|
124
|
+
files = (
|
|
125
|
+
E91B351D21446E6C00F9801F /* RNCWebViewManager.m in Sources */,
|
|
126
|
+
E91B351E21446E6C00F9801F /* RNCWebView.m in Sources */,
|
|
127
|
+
3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */,
|
|
128
|
+
);
|
|
129
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
130
|
+
};
|
|
131
|
+
/* End PBXSourcesBuildPhase section */
|
|
132
|
+
|
|
133
|
+
/* Begin XCBuildConfiguration section */
|
|
134
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
135
|
+
isa = XCBuildConfiguration;
|
|
136
|
+
buildSettings = {
|
|
137
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
138
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
139
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
140
|
+
CLANG_ENABLE_MODULES = YES;
|
|
141
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
142
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
143
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
144
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
145
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
146
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
147
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
148
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
149
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
150
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
151
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
152
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
153
|
+
COPY_PHASE_STRIP = NO;
|
|
154
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
155
|
+
ENABLE_TESTABILITY = YES;
|
|
156
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
157
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
158
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
159
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
160
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
161
|
+
"DEBUG=1",
|
|
162
|
+
"$(inherited)",
|
|
163
|
+
);
|
|
164
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
165
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
166
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
167
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
168
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
169
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
170
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
171
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
172
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
173
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
174
|
+
SDKROOT = iphoneos;
|
|
175
|
+
};
|
|
176
|
+
name = Debug;
|
|
177
|
+
};
|
|
178
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
179
|
+
isa = XCBuildConfiguration;
|
|
180
|
+
buildSettings = {
|
|
181
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
182
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
183
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
184
|
+
CLANG_ENABLE_MODULES = YES;
|
|
185
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
186
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
187
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
188
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
189
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
190
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
191
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
192
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
193
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
194
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
195
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
196
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
197
|
+
COPY_PHASE_STRIP = YES;
|
|
198
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
199
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
200
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
201
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
202
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
203
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
204
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
205
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
206
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
207
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
208
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
209
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
210
|
+
SDKROOT = iphoneos;
|
|
211
|
+
VALIDATE_PRODUCT = YES;
|
|
212
|
+
};
|
|
213
|
+
name = Release;
|
|
214
|
+
};
|
|
215
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
216
|
+
isa = XCBuildConfiguration;
|
|
217
|
+
buildSettings = {
|
|
218
|
+
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/**";
|
|
219
|
+
HEADER_SEARCH_PATHS = (
|
|
220
|
+
"$(inherited)",
|
|
221
|
+
"$(SRCROOT)/../node_modules/react-native/React/**",
|
|
222
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
223
|
+
);
|
|
224
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
225
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
226
|
+
PRODUCT_NAME = RNCWebView;
|
|
227
|
+
SKIP_INSTALL = YES;
|
|
228
|
+
};
|
|
229
|
+
name = Debug;
|
|
230
|
+
};
|
|
231
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
232
|
+
isa = XCBuildConfiguration;
|
|
233
|
+
buildSettings = {
|
|
234
|
+
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/**";
|
|
235
|
+
HEADER_SEARCH_PATHS = (
|
|
236
|
+
"$(inherited)",
|
|
237
|
+
"$(SRCROOT)/../node_modules/react-native/React/**",
|
|
238
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
239
|
+
);
|
|
240
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
241
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
242
|
+
PRODUCT_NAME = RNCWebView;
|
|
243
|
+
SKIP_INSTALL = YES;
|
|
244
|
+
};
|
|
245
|
+
name = Release;
|
|
246
|
+
};
|
|
247
|
+
/* End XCBuildConfiguration section */
|
|
248
|
+
|
|
249
|
+
/* Begin XCConfigurationList section */
|
|
250
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */ = {
|
|
251
|
+
isa = XCConfigurationList;
|
|
252
|
+
buildConfigurations = (
|
|
253
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
254
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
255
|
+
);
|
|
256
|
+
defaultConfigurationIsVisible = 0;
|
|
257
|
+
defaultConfigurationName = Release;
|
|
258
|
+
};
|
|
259
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCWebView" */ = {
|
|
260
|
+
isa = XCConfigurationList;
|
|
261
|
+
buildConfigurations = (
|
|
262
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
263
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
264
|
+
);
|
|
265
|
+
defaultConfigurationIsVisible = 0;
|
|
266
|
+
defaultConfigurationName = Release;
|
|
267
|
+
};
|
|
268
|
+
/* End XCConfigurationList section */
|
|
269
|
+
};
|
|
270
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
271
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => null;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UIManager as NotTypedUIManager, View, requireNativeComponent, NativeModules, Image, findNodeHandle, } from 'react-native';
|
|
3
|
+
import invariant from 'invariant';
|
|
4
|
+
import { defaultOriginWhitelist, createOnShouldStartLoadWithRequest, defaultRenderError, defaultRenderLoading, } from './WebViewShared';
|
|
5
|
+
import styles from './WebView.styles';
|
|
6
|
+
const UIManager = NotTypedUIManager;
|
|
7
|
+
const { resolveAssetSource } = Image;
|
|
8
|
+
const processDecelerationRate = (decelerationRate) => {
|
|
9
|
+
let newDecelerationRate = decelerationRate;
|
|
10
|
+
if (newDecelerationRate === 'normal') {
|
|
11
|
+
newDecelerationRate = 0.998;
|
|
12
|
+
}
|
|
13
|
+
else if (newDecelerationRate === 'fast') {
|
|
14
|
+
newDecelerationRate = 0.99;
|
|
15
|
+
}
|
|
16
|
+
return newDecelerationRate;
|
|
17
|
+
};
|
|
18
|
+
const RNCWebViewManager = NativeModules.RNCWebViewManager;
|
|
19
|
+
const RNCWebView = requireNativeComponent('RNCWebView');
|
|
20
|
+
class WebView extends React.Component {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.state = {
|
|
24
|
+
viewState: this.props.startInLoadingState ? 'LOADING' : 'IDLE',
|
|
25
|
+
lastErrorEvent: null,
|
|
26
|
+
};
|
|
27
|
+
this.webViewRef = React.createRef();
|
|
28
|
+
// eslint-disable-next-line react/sort-comp
|
|
29
|
+
this.getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
|
|
30
|
+
/**
|
|
31
|
+
* Go forward one page in the web view's history.
|
|
32
|
+
*/
|
|
33
|
+
this.goForward = () => {
|
|
34
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().goForward, undefined);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Go back one page in the web view's history.
|
|
38
|
+
*/
|
|
39
|
+
this.goBack = () => {
|
|
40
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().goBack, undefined);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Reloads the current page.
|
|
44
|
+
*/
|
|
45
|
+
this.reload = () => {
|
|
46
|
+
this.setState({ viewState: 'LOADING' });
|
|
47
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().reload, undefined);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Stop loading the current page.
|
|
51
|
+
*/
|
|
52
|
+
this.stopLoading = () => {
|
|
53
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().stopLoading, undefined);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Request focus on WebView rendered page.
|
|
57
|
+
*/
|
|
58
|
+
this.requestFocus = () => {
|
|
59
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().requestFocus, undefined);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Posts a message to the web view, which will emit a `message` event.
|
|
63
|
+
* Accepts one argument, `data`, which must be a string.
|
|
64
|
+
*
|
|
65
|
+
* In your webview, you'll need to something like the following.
|
|
66
|
+
*
|
|
67
|
+
* ```js
|
|
68
|
+
* document.addEventListener('message', e => { document.title = e.data; });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
this.postMessage = (data) => {
|
|
72
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().postMessage, [String(data)]);
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Injects a javascript string into the referenced WebView. Deliberately does not
|
|
76
|
+
* return a response because using eval() to return a response breaks this method
|
|
77
|
+
* on pages with a Content Security Policy that disallows eval(). If you need that
|
|
78
|
+
* functionality, look into postMessage/onMessage.
|
|
79
|
+
*/
|
|
80
|
+
this.injectJavaScript = (data) => {
|
|
81
|
+
UIManager.dispatchViewManagerCommand(this.getWebViewHandle(), this.getCommands().injectJavaScript, [data]);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* We return an event with a bunch of fields including:
|
|
85
|
+
* url, title, loading, canGoBack, canGoForward
|
|
86
|
+
*/
|
|
87
|
+
this.updateNavigationState = (event) => {
|
|
88
|
+
if (this.props.onNavigationStateChange) {
|
|
89
|
+
this.props.onNavigationStateChange(event.nativeEvent);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Returns the native `WebView` node.
|
|
94
|
+
*/
|
|
95
|
+
this.getWebViewHandle = () => {
|
|
96
|
+
const nodeHandle = findNodeHandle(this.webViewRef.current);
|
|
97
|
+
invariant(nodeHandle != null, 'nodeHandle expected to be non-null');
|
|
98
|
+
return nodeHandle;
|
|
99
|
+
};
|
|
100
|
+
this.onLoadingStart = (event) => {
|
|
101
|
+
const { onLoadStart } = this.props;
|
|
102
|
+
if (onLoadStart) {
|
|
103
|
+
onLoadStart(event);
|
|
104
|
+
}
|
|
105
|
+
this.updateNavigationState(event);
|
|
106
|
+
};
|
|
107
|
+
this.onLoadingError = (event) => {
|
|
108
|
+
event.persist(); // persist this event because we need to store it
|
|
109
|
+
const { onError, onLoadEnd } = this.props;
|
|
110
|
+
if (onLoadEnd) {
|
|
111
|
+
onLoadEnd(event);
|
|
112
|
+
}
|
|
113
|
+
if (onError) {
|
|
114
|
+
onError(event);
|
|
115
|
+
}
|
|
116
|
+
console.warn('Encountered an error loading page', event.nativeEvent);
|
|
117
|
+
this.setState({
|
|
118
|
+
lastErrorEvent: event.nativeEvent,
|
|
119
|
+
viewState: 'ERROR',
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
this.onHttpError = (event) => {
|
|
123
|
+
const { onHttpError } = this.props;
|
|
124
|
+
if (onHttpError) {
|
|
125
|
+
onHttpError(event);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
this.onLoadingFinish = (event) => {
|
|
129
|
+
const { onLoad, onLoadEnd } = this.props;
|
|
130
|
+
if (onLoad) {
|
|
131
|
+
onLoad(event);
|
|
132
|
+
}
|
|
133
|
+
if (onLoadEnd) {
|
|
134
|
+
onLoadEnd(event);
|
|
135
|
+
}
|
|
136
|
+
this.setState({
|
|
137
|
+
viewState: 'IDLE',
|
|
138
|
+
});
|
|
139
|
+
this.updateNavigationState(event);
|
|
140
|
+
};
|
|
141
|
+
this.onMessage = (event) => {
|
|
142
|
+
const { onMessage } = this.props;
|
|
143
|
+
if (onMessage) {
|
|
144
|
+
onMessage(event);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
this.onLoadingProgress = (event) => {
|
|
148
|
+
const { onLoadProgress } = this.props;
|
|
149
|
+
if (onLoadProgress) {
|
|
150
|
+
onLoadProgress(event);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
this.onShouldStartLoadWithRequestCallback = (shouldStart, _url, lockIdentifier) => {
|
|
154
|
+
const viewManager = (this.props.nativeConfig && this.props.nativeConfig.viewManager)
|
|
155
|
+
|| RNCWebViewManager;
|
|
156
|
+
viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
|
|
157
|
+
};
|
|
158
|
+
this.onContentProcessDidTerminate = (event) => {
|
|
159
|
+
const { onContentProcessDidTerminate } = this.props;
|
|
160
|
+
if (onContentProcessDidTerminate) {
|
|
161
|
+
onContentProcessDidTerminate(event);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
componentDidUpdate(prevProps) {
|
|
166
|
+
this.showRedboxOnPropChanges(prevProps, 'allowsInlineMediaPlayback');
|
|
167
|
+
this.showRedboxOnPropChanges(prevProps, 'incognito');
|
|
168
|
+
this.showRedboxOnPropChanges(prevProps, 'mediaPlaybackRequiresUserAction');
|
|
169
|
+
this.showRedboxOnPropChanges(prevProps, 'dataDetectorTypes');
|
|
170
|
+
}
|
|
171
|
+
showRedboxOnPropChanges(prevProps, propName) {
|
|
172
|
+
if (this.props[propName] !== prevProps[propName]) {
|
|
173
|
+
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
render() {
|
|
177
|
+
const { decelerationRate: decelerationRateProp, nativeConfig = {}, onMessage, onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp, originWhitelist, renderError, renderLoading, injectedJavaScriptForMainFrameOnly = true, injectedJavaScriptBeforeContentLoadedForMainFrameOnly = true, style, containerStyle, ...otherProps } = this.props;
|
|
178
|
+
let otherView = null;
|
|
179
|
+
if (this.state.viewState === 'LOADING') {
|
|
180
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
181
|
+
}
|
|
182
|
+
else if (this.state.viewState === 'ERROR') {
|
|
183
|
+
const errorEvent = this.state.lastErrorEvent;
|
|
184
|
+
invariant(errorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
185
|
+
otherView = (renderError || defaultRenderError)(errorEvent.domain, errorEvent.code, errorEvent.description);
|
|
186
|
+
}
|
|
187
|
+
else if (this.state.viewState !== 'IDLE') {
|
|
188
|
+
console.error(`RNCWebView invalid state encountered: ${this.state.viewState}`);
|
|
189
|
+
}
|
|
190
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
191
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
192
|
+
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(this.onShouldStartLoadWithRequestCallback,
|
|
193
|
+
// casting cause it's in the default props
|
|
194
|
+
originWhitelist, onShouldStartLoadWithRequestProp);
|
|
195
|
+
const decelerationRate = processDecelerationRate(decelerationRateProp);
|
|
196
|
+
const NativeWebView = nativeConfig.component
|
|
197
|
+
|| RNCWebView;
|
|
198
|
+
const webView = (<NativeWebView key="webViewKey" {...otherProps} decelerationRate={decelerationRate} messagingEnabled={typeof onMessage === 'function'} onLoadingError={this.onLoadingError} onLoadingFinish={this.onLoadingFinish} onLoadingProgress={this.onLoadingProgress} onFileDownload={this.props.onFileDownload} onLoadingStart={this.onLoadingStart} onHttpError={this.onHttpError} onMessage={this.onMessage} onScroll={this.props.onScroll} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} onContentProcessDidTerminate={this.onContentProcessDidTerminate} injectedJavaScript={this.props.injectedJavaScript} injectedJavaScriptBeforeContentLoaded={this.props.injectedJavaScriptBeforeContentLoaded} injectedJavaScriptForMainFrameOnly={injectedJavaScriptForMainFrameOnly} injectedJavaScriptBeforeContentLoadedForMainFrameOnly={injectedJavaScriptBeforeContentLoadedForMainFrameOnly} ref={this.webViewRef}
|
|
199
|
+
// TODO: find a better way to type this.
|
|
200
|
+
source={resolveAssetSource(this.props.source)} style={webViewStyles} {...nativeConfig.props}/>);
|
|
201
|
+
return (<View style={webViewContainerStyle}>
|
|
202
|
+
{webView}
|
|
203
|
+
{otherView}
|
|
204
|
+
</View>);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
WebView.defaultProps = {
|
|
208
|
+
javaScriptEnabled: true,
|
|
209
|
+
cacheEnabled: true,
|
|
210
|
+
originWhitelist: defaultOriginWhitelist,
|
|
211
|
+
useSharedProcessPool: true,
|
|
212
|
+
};
|
|
213
|
+
WebView.isFileUploadSupported = async () => {
|
|
214
|
+
// no native implementation for iOS, depends only on permissions
|
|
215
|
+
return true;
|
|
216
|
+
};
|
|
217
|
+
export default WebView;
|
package/lib/WebView.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
const styles = StyleSheet.create({
|
|
3
|
+
container: {
|
|
4
|
+
flex: 1,
|
|
5
|
+
overflow: 'hidden',
|
|
6
|
+
},
|
|
7
|
+
loadingOrErrorView: {
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
flex: 1,
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
height: '100%',
|
|
13
|
+
width: '100%',
|
|
14
|
+
backgroundColor: 'white'
|
|
15
|
+
},
|
|
16
|
+
loadingProgressBar: {
|
|
17
|
+
height: 20,
|
|
18
|
+
},
|
|
19
|
+
errorText: {
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
textAlign: 'center',
|
|
22
|
+
marginBottom: 2,
|
|
23
|
+
},
|
|
24
|
+
errorTextTitle: {
|
|
25
|
+
fontSize: 15,
|
|
26
|
+
fontWeight: '500',
|
|
27
|
+
marginBottom: 10,
|
|
28
|
+
},
|
|
29
|
+
webView: {
|
|
30
|
+
backgroundColor: '#ffffff',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export default styles;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import escapeStringRegexp from 'escape-string-regexp';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Linking, View, ActivityIndicator, Text } from 'react-native';
|
|
4
|
+
import styles from './WebView.styles';
|
|
5
|
+
const defaultOriginWhitelist = ['http://*', 'https://*'];
|
|
6
|
+
const extractOrigin = (url) => {
|
|
7
|
+
const result = /^[A-Za-z][A-Za-z0-9+\-.]+:(\/\/)?[^/]*/.exec(url);
|
|
8
|
+
return result === null ? '' : result[0];
|
|
9
|
+
};
|
|
10
|
+
const originWhitelistToRegex = (originWhitelist) => `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
|
|
11
|
+
const passesWhitelist = (compiledWhitelist, url) => {
|
|
12
|
+
const origin = extractOrigin(url);
|
|
13
|
+
return compiledWhitelist.some(x => new RegExp(x).test(origin));
|
|
14
|
+
};
|
|
15
|
+
const compileWhitelist = (originWhitelist) => ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
|
|
16
|
+
const createOnShouldStartLoadWithRequest = (loadRequest, originWhitelist, onShouldStartLoadWithRequest) => {
|
|
17
|
+
return ({ nativeEvent }) => {
|
|
18
|
+
let shouldStart = true;
|
|
19
|
+
const { url, lockIdentifier } = nativeEvent;
|
|
20
|
+
if (!passesWhitelist(compileWhitelist(originWhitelist), url)) {
|
|
21
|
+
Linking.canOpenURL(url).then((supported) => {
|
|
22
|
+
if (supported) {
|
|
23
|
+
return Linking.openURL(url);
|
|
24
|
+
}
|
|
25
|
+
console.warn(`Can't open url: ${url}`);
|
|
26
|
+
return undefined;
|
|
27
|
+
}).catch(e => {
|
|
28
|
+
console.warn('Error opening URL: ', e);
|
|
29
|
+
});
|
|
30
|
+
shouldStart = false;
|
|
31
|
+
}
|
|
32
|
+
else if (onShouldStartLoadWithRequest) {
|
|
33
|
+
shouldStart = onShouldStartLoadWithRequest(nativeEvent);
|
|
34
|
+
}
|
|
35
|
+
loadRequest(shouldStart, url, lockIdentifier);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const defaultRenderLoading = () => (<View style={styles.loadingOrErrorView}>
|
|
39
|
+
<ActivityIndicator />
|
|
40
|
+
</View>);
|
|
41
|
+
const defaultRenderError = (errorDomain, errorCode, errorDesc) => (<View style={styles.loadingOrErrorView}>
|
|
42
|
+
<Text style={styles.errorTextTitle}>Error loading page</Text>
|
|
43
|
+
<Text style={styles.errorText}>{`Domain: ${errorDomain}`}</Text>
|
|
44
|
+
<Text style={styles.errorText}>{`Error Code: ${errorCode}`}</Text>
|
|
45
|
+
<Text style={styles.errorText}>{`Description: ${errorDesc}`}</Text>
|
|
46
|
+
</View>);
|
|
47
|
+
export { defaultOriginWhitelist, createOnShouldStartLoadWithRequest, defaultRenderLoading, defaultRenderError, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp, max-classes-per-file */
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
export class NativeWebViewIOS extends NativeWebViewIOSBase {
|
|
4
|
+
}
|
|
5
|
+
export class NativeWebViewMacOS extends NativeWebViewMacOSBase {
|
|
6
|
+
}
|
|
7
|
+
export class NativeWebViewAndroid extends NativeWebViewAndroidBase {
|
|
8
|
+
}
|
|
9
|
+
export class NativeWebViewWindows extends NativeWebViewWindowsBase {
|
|
10
|
+
}
|
|
11
|
+
export var ContentInsetAdjustmentBehavior;
|
|
12
|
+
(function (ContentInsetAdjustmentBehavior) {
|
|
13
|
+
ContentInsetAdjustmentBehavior["automatic"] = "automatic";
|
|
14
|
+
ContentInsetAdjustmentBehavior["scrollableAxes"] = "scrollableAxes";
|
|
15
|
+
ContentInsetAdjustmentBehavior["never"] = "never";
|
|
16
|
+
ContentInsetAdjustmentBehavior["always"] = "always";
|
|
17
|
+
})(ContentInsetAdjustmentBehavior || (ContentInsetAdjustmentBehavior = {}));
|
|
18
|
+
;
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exodus/react-native-webview",
|
|
3
|
+
"description": "React Native WebView component for iOS, Android, macOS, and Windows",
|
|
4
|
+
"typings": "index.d.ts",
|
|
5
|
+
"author": "Jamon Holmgren <jamon@infinite.red>",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Thibault Malbranche <malbranche.thibault@gmail.com>"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"version": "9.4.0-no-android.0",
|
|
11
|
+
"homepage": "https://github.com/react-native-community/react-native-webview#readme",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start": "node node_modules/react-native/local-cli/cli.js start",
|
|
14
|
+
"start:android": "react-native run-android --root example/",
|
|
15
|
+
"start:ios": "react-native run-ios --project-path example/ios --scheme example",
|
|
16
|
+
"start:macos": "node node_modules/react-native-macos/local-cli/cli.js start --use-react-native-macos",
|
|
17
|
+
"start:windows": "react-native start --use-react-native-windows",
|
|
18
|
+
"ci": "CI=true && yarn lint",
|
|
19
|
+
"ci:publish": "yarn semantic-release",
|
|
20
|
+
"lint": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx",
|
|
21
|
+
"build": "yarn tsc",
|
|
22
|
+
"prepare": "yarn build",
|
|
23
|
+
"appium": "appium",
|
|
24
|
+
"test:windows": "yarn jest --setupFiles=./jest-setups/jest.setup.windows.js"
|
|
25
|
+
},
|
|
26
|
+
"rn-docs": {
|
|
27
|
+
"title": "Webview",
|
|
28
|
+
"type": "Component"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^16.9",
|
|
32
|
+
"react-native": ">=0.60 <0.62"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"escape-string-regexp": "2.0.0",
|
|
36
|
+
"invariant": "2.2.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "7.4.5",
|
|
40
|
+
"@babel/runtime": "7.4.5",
|
|
41
|
+
"@react-native-community/cli": "^3.2.0",
|
|
42
|
+
"@react-native-community/cli-platform-android": "^3.0.0",
|
|
43
|
+
"@react-native-community/cli-platform-ios": "^3.0.0",
|
|
44
|
+
"@semantic-release/git": "7.0.16",
|
|
45
|
+
"@types/invariant": "^2.2.30",
|
|
46
|
+
"@types/jest": "24.0.18",
|
|
47
|
+
"@types/react": "16.8.8",
|
|
48
|
+
"@types/react-native": "0.60.11",
|
|
49
|
+
"@types/selenium-webdriver": "4.0.9",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "2.1.0",
|
|
51
|
+
"@typescript-eslint/parser": "2.1.0",
|
|
52
|
+
"babel-eslint": "10.0.3",
|
|
53
|
+
"babel-jest": "24.8.0",
|
|
54
|
+
"babel-plugin-module-resolver": "3.1.3",
|
|
55
|
+
"eslint": "6.3.0",
|
|
56
|
+
"eslint-config-airbnb": "18.0.1",
|
|
57
|
+
"eslint-config-prettier": "6.2.0",
|
|
58
|
+
"eslint-plugin-import": "2.18.2",
|
|
59
|
+
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
60
|
+
"eslint-plugin-react": "7.14.3",
|
|
61
|
+
"eslint-plugin-react-native": "3.7.0",
|
|
62
|
+
"jest": "24.9.0",
|
|
63
|
+
"metro": "0.56.4",
|
|
64
|
+
"metro-react-native-babel-preset": "0.54.1",
|
|
65
|
+
"react": "16.9.0",
|
|
66
|
+
"react-native": "0.61.5",
|
|
67
|
+
"react-native-macos": "0.60.0-microsoft.73",
|
|
68
|
+
"react-native-windows": "0.61.5",
|
|
69
|
+
"semantic-release": "15.13.24",
|
|
70
|
+
"typescript": "3.6.2",
|
|
71
|
+
"appium": "1.17.0",
|
|
72
|
+
"selenium-appium": "0.0.15",
|
|
73
|
+
"selenium-webdriver": "4.0.0-alpha.7"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "https://github.com/react-native-community/react-native-webview.git"
|
|
78
|
+
},
|
|
79
|
+
"files": [
|
|
80
|
+
"ios",
|
|
81
|
+
"lib/*.js",
|
|
82
|
+
"!lib/*.windows.js",
|
|
83
|
+
"!lib/*.macos.js",
|
|
84
|
+
"!lib/*.apple.js",
|
|
85
|
+
"react-native-webview.podspec"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = package['name']
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
|
|
11
|
+
s.authors = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = { :ios => "9.0", :osx => "10.14" }
|
|
14
|
+
|
|
15
|
+
s.source = { :git => "https://github.com/react-native-community/react-native-webview.git", :tag => "v#{s.version}" }
|
|
16
|
+
s.source_files = "apple/**/*.{h,m}"
|
|
17
|
+
|
|
18
|
+
s.dependency 'React'
|
|
19
|
+
end
|