@exodus/react-native-webview 11.26.1-exodus.5 → 11.26.1-exodus.7

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.
Files changed (126) hide show
  1. package/.all-contributorsrc +185 -0
  2. package/.circleci/config.yml +66 -0
  3. package/.eslintignore +2 -0
  4. package/.eslintrc.js +94 -0
  5. package/.flowconfig +88 -0
  6. package/.flowconfig.android +88 -0
  7. package/.gitattributes +12 -0
  8. package/.github/CODEOWNERS +1 -0
  9. package/.github/ISSUE_TEMPLATE/bug-report.md +42 -0
  10. package/.github/ISSUE_TEMPLATE/feature_request.md +30 -0
  11. package/.github/workflows/android-ci.yml +35 -0
  12. package/.github/workflows/detox.yml +20 -0
  13. package/.github/workflows/ios-ci.yml +31 -0
  14. package/.github/workflows/scripts/install-vs-features.ps1 +108 -0
  15. package/.github/workflows/stale.yml +17 -0
  16. package/.gitignore +62 -0
  17. package/.prettierrc.js +10 -0
  18. package/.releaserc +15 -0
  19. package/.vscode/settings.json +9 -0
  20. package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
  21. package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  22. package/android/.gradle/7.4.2/dependencies-accessors/gc.properties +0 -0
  23. package/android/.gradle/7.4.2/executionHistory/executionHistory.lock +0 -0
  24. package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
  25. package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
  26. package/android/.gradle/7.4.2/gc.properties +0 -0
  27. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  28. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  29. package/android/.gradle/vcs-1/gc.properties +0 -0
  30. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +25 -0
  31. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewUtils.java +51 -0
  32. package/babel.config.js +11 -0
  33. package/bin/setup +26 -0
  34. package/docs/Contributing.md +102 -0
  35. package/docs/Custom-Android.md +222 -0
  36. package/docs/Custom-iOS.md +236 -0
  37. package/docs/Debugging.md +101 -0
  38. package/docs/Getting-Started.md +142 -0
  39. package/docs/Guide.md +613 -0
  40. package/docs/Reference.md +1629 -0
  41. package/example/.gitignore +14 -0
  42. package/example/.watchmanconfig +1 -0
  43. package/example/App.tsx +262 -0
  44. package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
  45. package/example/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
  46. package/example/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
  47. package/example/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
  48. package/example/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
  49. package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
  50. package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
  51. package/example/android/.gradle/7.3.3/gc.properties +0 -0
  52. package/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  53. package/example/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  54. package/example/android/.gradle/vcs-1/gc.properties +0 -0
  55. package/example/android/build.gradle +15 -0
  56. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  57. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  58. package/example/android/gradle.properties +34 -0
  59. package/example/android/gradlew +234 -0
  60. package/example/android/gradlew.bat +89 -0
  61. package/example/android/settings.gradle +12 -0
  62. package/example/app.json +20 -0
  63. package/example/assets/test.html +9 -0
  64. package/example/babel.config.js +3 -0
  65. package/example/examples/Alerts.tsx +72 -0
  66. package/example/examples/ApplePay.tsx +23 -0
  67. package/example/examples/Background.tsx +54 -0
  68. package/example/examples/Downloads.tsx +57 -0
  69. package/example/examples/Injection.tsx +161 -0
  70. package/example/examples/LocalPageLoad.tsx +16 -0
  71. package/example/examples/Messaging.tsx +63 -0
  72. package/example/examples/NativeWebpage.tsx +22 -0
  73. package/example/examples/Scrolling.tsx +68 -0
  74. package/example/examples/Uploads.tsx +69 -0
  75. package/example/index.js +9 -0
  76. package/example/ios/Podfile +8 -0
  77. package/example/ios/Podfile.lock +445 -0
  78. package/index.js +5 -2
  79. package/ios/Podfile +10 -0
  80. package/ios/Podfile.lock +3 -0
  81. package/ios/Pods/Manifest.lock +3 -0
  82. package/ios/Pods/Pods.xcodeproj/project.pbxproj +397 -0
  83. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/Pods-RNCWebView.xcscheme +58 -0
  84. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
  85. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-Info.plist +26 -0
  86. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.markdown +3 -0
  87. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.plist +29 -0
  88. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-dummy.m +5 -0
  89. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-umbrella.h +16 -0
  90. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.debug.xcconfig +8 -0
  91. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.modulemap +6 -0
  92. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.release.xcconfig +8 -0
  93. package/ios/RNCWebView.xcworkspace/contents.xcworkspacedata +32 -0
  94. package/jest-setups/jest.setup.js +8 -0
  95. package/jest.config.js +184 -0
  96. package/lib/UpdateOS.d.ts +6 -0
  97. package/lib/UpdateOS.d.ts.map +1 -0
  98. package/lib/UpdateOS.js +49 -0
  99. package/lib/WebView.android.d.ts.map +1 -0
  100. package/lib/WebView.android.js +19 -3
  101. package/lib/WebView.d.ts.map +1 -0
  102. package/lib/WebView.ios.d.ts.map +1 -0
  103. package/lib/WebView.ios.js +5 -2
  104. package/lib/WebView.styles.d.ts.map +1 -0
  105. package/lib/WebViewNativeComponent.android.d.ts.map +1 -0
  106. package/lib/WebViewNativeComponent.ios.d.ts.map +1 -0
  107. package/lib/WebViewShared.d.ts.map +1 -0
  108. package/lib/WebViewTypes.d.ts +5 -1
  109. package/lib/WebViewTypes.d.ts.map +1 -0
  110. package/lib/index.d.ts.map +1 -0
  111. package/metro.config.js +57 -0
  112. package/package.json +1 -1
  113. package/src/WebView.android.tsx +246 -0
  114. package/src/WebView.ios.tsx +221 -0
  115. package/src/WebView.styles.ts +44 -0
  116. package/src/WebView.tsx +18 -0
  117. package/src/WebViewNativeComponent.android.ts +8 -0
  118. package/src/WebViewNativeComponent.ios.ts +8 -0
  119. package/src/WebViewShared.tsx +257 -0
  120. package/src/WebViewTypes.ts +914 -0
  121. package/src/__tests__/WebViewShared-test.js +208 -0
  122. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
  123. package/src/index.ts +4 -0
  124. package/tsconfig.json +24 -0
  125. package/yarn.lock +13895 -0
  126. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.kt +0 -15
@@ -0,0 +1,208 @@
1
+ import { Linking } from 'react-native';
2
+
3
+ import {
4
+ defaultOriginWhitelist,
5
+ createOnShouldStartLoadWithRequest,
6
+ } from '../WebViewShared';
7
+
8
+ Linking.openURL.mockResolvedValue(undefined);
9
+ Linking.canOpenURL.mockResolvedValue(true);
10
+
11
+ // The tests that call createOnShouldStartLoadWithRequest will cause a promise
12
+ // to get kicked off (by calling the mocked `Linking.canOpenURL`) that the tests
13
+ // _need_ to get run to completion _before_ doing any `expect`ing. The reason
14
+ // is: once that promise is resolved another function should get run which will
15
+ // call `Linking.openURL`, and we want to test that.
16
+ //
17
+ // Normally we would probably do something like `await
18
+ // createShouldStartLoadWithRequest(...)` in the tests, but that doesn't work
19
+ // here because the promise that gets kicked off is not returned (because
20
+ // non-test code doesn't need to know about it).
21
+ //
22
+ // The tests thus need a way to "flush any pending promises" (to make sure
23
+ // pending promises run to completion) before doing any `expect`ing. `jest`
24
+ // doesn't provide a way to do this out of the box, but we can use this function
25
+ // to do it.
26
+ //
27
+ // See this issue for more discussion: https://github.com/facebook/jest/issues/2157
28
+ function flushPromises() {
29
+ return new Promise(resolve => setImmediate(resolve));
30
+ }
31
+
32
+
33
+ describe('WebViewShared', () => {
34
+ test('exports defaultOriginWhitelist', () => {
35
+ expect(defaultOriginWhitelist).toMatchSnapshot();
36
+ });
37
+
38
+ describe('createOnShouldStartLoadWithRequest', () => {
39
+ const alwaysTrueOnShouldStartLoadWithRequest = (nativeEvent) => {
40
+ return true;
41
+ };
42
+
43
+ const alwaysFalseOnShouldStartLoadWithRequest = (nativeEvent) => {
44
+ return false;
45
+ };
46
+
47
+ const loadRequest = jest.fn();
48
+
49
+ test('loadRequest is called without onShouldStartLoadWithRequest override', async () => {
50
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
51
+ loadRequest,
52
+ defaultOriginWhitelist,
53
+ );
54
+
55
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
56
+
57
+ await flushPromises();
58
+
59
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
60
+ expect(loadRequest).toHaveBeenCalledWith(true, 'https://www.example.com/', 1);
61
+ });
62
+
63
+ test('Linking.openURL is called without onShouldStartLoadWithRequest override', async () => {
64
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
65
+ loadRequest,
66
+ defaultOriginWhitelist,
67
+ );
68
+
69
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 2 } });
70
+
71
+ await flushPromises();
72
+
73
+ expect(Linking.openURL).toHaveBeenCalledWith('invalid://example.com/');
74
+ expect(loadRequest).toHaveBeenCalledWith(false, 'invalid://example.com/', 2);
75
+ });
76
+
77
+ test('loadRequest with true onShouldStartLoadWithRequest override is called', async () => {
78
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
79
+ loadRequest,
80
+ defaultOriginWhitelist,
81
+ alwaysTrueOnShouldStartLoadWithRequest,
82
+ );
83
+
84
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
85
+
86
+ await flushPromises();
87
+
88
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
89
+ expect(loadRequest).toHaveBeenLastCalledWith(true, 'https://www.example.com/', 1);
90
+ });
91
+
92
+ test('Linking.openURL with true onShouldStartLoadWithRequest override is called for links not passing the whitelist', async () => {
93
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
94
+ loadRequest,
95
+ defaultOriginWhitelist,
96
+ alwaysTrueOnShouldStartLoadWithRequest,
97
+ );
98
+
99
+ var a = 10;
100
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 1 } });
101
+
102
+ await flushPromises();
103
+
104
+ expect(Linking.openURL).toHaveBeenLastCalledWith('invalid://example.com/');
105
+ // We don't expect the URL to have been loaded in the WebView because it
106
+ // is not in the origin whitelist
107
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'invalid://example.com/', 1);
108
+ });
109
+
110
+ test('loadRequest with false onShouldStartLoadWithRequest override is called', async () => {
111
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
112
+ loadRequest,
113
+ defaultOriginWhitelist,
114
+ alwaysFalseOnShouldStartLoadWithRequest,
115
+ );
116
+
117
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
118
+
119
+ await flushPromises();
120
+
121
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
122
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'https://www.example.com/', 1);
123
+ });
124
+
125
+ test('loadRequest with limited whitelist', async () => {
126
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
127
+ loadRequest,
128
+ ['https://*'],
129
+ );
130
+
131
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
132
+
133
+ await flushPromises();
134
+
135
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
136
+ expect(loadRequest).toHaveBeenLastCalledWith(true, 'https://www.example.com/', 1);
137
+
138
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'http://insecure.com/', lockIdentifier: 2 } });
139
+
140
+ await flushPromises();
141
+
142
+ expect(Linking.openURL).toHaveBeenLastCalledWith('http://insecure.com/');
143
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'http://insecure.com/', 2);
144
+
145
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'git+https://insecure.com/', lockIdentifier: 3 } });
146
+
147
+ await flushPromises();
148
+
149
+ expect(Linking.openURL).toHaveBeenLastCalledWith('git+https://insecure.com/');
150
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'git+https://insecure.com/', 3);
151
+
152
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'fakehttps://insecure.com/', lockIdentifier: 4 } });
153
+
154
+ await flushPromises();
155
+
156
+ expect(Linking.openURL).toHaveBeenLastCalledWith('fakehttps://insecure.com/');
157
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'fakehttps://insecure.com/', 4);
158
+ });
159
+
160
+ test('loadRequest allows for valid URIs', async () => {
161
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
162
+ loadRequest,
163
+ ['plus+https://*', 'DOT.https://*', 'dash-https://*', '0invalid://*', '+invalid://*'],
164
+ );
165
+
166
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'plus+https://www.example.com/', lockIdentifier: 1 } });
167
+
168
+ await flushPromises();
169
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
170
+ expect(loadRequest).toHaveBeenLastCalledWith(true, 'plus+https://www.example.com/', 1);
171
+
172
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'DOT.https://www.example.com/', lockIdentifier: 2 } });
173
+
174
+ await flushPromises();
175
+
176
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
177
+ expect(loadRequest).toHaveBeenLastCalledWith(true, 'DOT.https://www.example.com/', 2);
178
+
179
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'dash-https://www.example.com/', lockIdentifier: 3 } });
180
+
181
+ await flushPromises();
182
+
183
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
184
+ expect(loadRequest).toHaveBeenLastCalledWith(true, 'dash-https://www.example.com/', 3);
185
+
186
+ onShouldStartLoadWithRequest({ nativeEvent: { url: '0invalid://www.example.com/', lockIdentifier: 4 } });
187
+
188
+ await flushPromises();
189
+
190
+ expect(Linking.openURL).toHaveBeenLastCalledWith('0invalid://www.example.com/');
191
+ expect(loadRequest).toHaveBeenLastCalledWith(false, '0invalid://www.example.com/', 4);
192
+
193
+ onShouldStartLoadWithRequest({ nativeEvent: { url: '+invalid://www.example.com/', lockIdentifier: 5 } });
194
+
195
+ await flushPromises();
196
+
197
+ expect(Linking.openURL).toHaveBeenLastCalledWith('+invalid://www.example.com/');
198
+ expect(loadRequest).toHaveBeenLastCalledWith(false, '+invalid://www.example.com/', 5);
199
+
200
+ onShouldStartLoadWithRequest({ nativeEvent: { url: 'FAKE+plus+https://www.example.com/', lockIdentifier: 6 } });
201
+
202
+ await flushPromises();
203
+
204
+ expect(Linking.openURL).toHaveBeenLastCalledWith('FAKE+plus+https://www.example.com/');
205
+ expect(loadRequest).toHaveBeenLastCalledWith(false, 'FAKE+plus+https://www.example.com/', 6);
206
+ });
207
+ });
208
+ });
@@ -0,0 +1,8 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`WebViewShared exports defaultOriginWhitelist 1`] = `
4
+ Array [
5
+ "http://*",
6
+ "https://*",
7
+ ]
8
+ `;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import WebView from './WebView';
2
+
3
+ export { WebView };
4
+ export default WebView;
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "include": ["src/*"],
3
+ "compilerOptions": {
4
+ "baseUrl": "./src/",
5
+ "jsx": "react-native",
6
+ "module": "esnext",
7
+ "moduleResolution": "node",
8
+ "target": "es2019",
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "outDir": "lib",
12
+ "allowSyntheticDefaultImports": true,
13
+ "esModuleInterop": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noImplicitReturns": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "pretty": true,
20
+ "resolveJsonModule": true,
21
+ "skipLibCheck": true,
22
+ "strict": true
23
+ }
24
+ }