@momo-kits/webview 0.0.60-beta.5 → 0.0.60-beta.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.
- package/index.js +1 -2
- package/package.json +2 -4
- package/index.d.ts +0 -47
- package/lib/WebView.android.d.ts +0 -75
- package/lib/WebView.android.d.ts.map +0 -1
- package/lib/WebView.android.js +0 -318
- package/lib/WebView.d.ts +0 -7
- package/lib/WebView.d.ts.map +0 -1
- package/lib/WebView.ios.d.ts +0 -83
- package/lib/WebView.ios.d.ts.map +0 -1
- package/lib/WebView.ios.js +0 -284
- package/lib/WebView.js +0 -16
- package/lib/WebView.macos.d.ts +0 -83
- package/lib/WebView.macos.d.ts.map +0 -1
- package/lib/WebView.macos.js +0 -272
- package/lib/WebView.styles.d.ts +0 -12
- package/lib/WebView.styles.d.ts.map +0 -1
- package/lib/WebView.styles.js +0 -35
- package/lib/WebView.windows.d.ts +0 -39
- package/lib/WebView.windows.d.ts.map +0 -1
- package/lib/WebView.windows.js +0 -189
- package/lib/WebViewShared.d.ts +0 -7
- package/lib/WebViewShared.d.ts.map +0 -1
- package/lib/WebViewShared.js +0 -61
- package/lib/WebViewTypes.d.ts +0 -850
- package/lib/WebViewTypes.d.ts.map +0 -1
- package/lib/WebViewTypes.js +0 -48
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/webview",
|
|
3
|
-
"version": "0.0.60-beta.
|
|
3
|
+
"version": "0.0.60-beta.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"
|
|
8
|
-
"prop-types": "^15.7.2",
|
|
9
|
-
"react": "16.9.0"
|
|
7
|
+
"react-native-webview": "11.26.1"
|
|
10
8
|
},
|
|
11
9
|
"peerDependencies": {
|
|
12
10
|
"react": "16.9.0",
|
package/index.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
// eslint-disable-next-line
|
|
3
|
-
import { IOSWebViewProps, AndroidWebViewProps } from './lib/WebViewTypes';
|
|
4
|
-
|
|
5
|
-
export { FileDownload, WebViewMessageEvent, WebViewNavigation } from './lib/WebViewTypes';
|
|
6
|
-
|
|
7
|
-
export type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
|
|
8
|
-
|
|
9
|
-
declare class WebView extends Component<WebViewProps> {
|
|
10
|
-
/**
|
|
11
|
-
* Go back one page in the webview's history.
|
|
12
|
-
*/
|
|
13
|
-
goBack: () => void;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Go forward one page in the webview's history.
|
|
17
|
-
*/
|
|
18
|
-
goForward: () => void;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Reloads the current page.
|
|
22
|
-
*/
|
|
23
|
-
reload: () => void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Stop loading the current page.
|
|
27
|
-
*/
|
|
28
|
-
stopLoading(): void;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Extra Native Component Config.
|
|
32
|
-
*/
|
|
33
|
-
extraNativeComponentConfig: () => any;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Executes the JavaScript string.
|
|
37
|
-
*/
|
|
38
|
-
injectJavaScript: (script: string) => void;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Focuses on WebView redered page.
|
|
42
|
-
*/
|
|
43
|
-
requestFocus: () => void;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { WebView };
|
|
47
|
-
export default WebView;
|
package/lib/WebView.android.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { WebViewRenderProcessGoneEvent, WebViewErrorEvent, WebViewHttpErrorEvent, WebViewMessageEvent, WebViewNavigationEvent, WebViewProgressEvent, AndroidWebViewProps, NativeWebViewAndroid, State } from './WebViewTypes';
|
|
3
|
-
/**
|
|
4
|
-
* Renders a native WebView.
|
|
5
|
-
*/
|
|
6
|
-
declare class WebView extends React.Component<AndroidWebViewProps, State> {
|
|
7
|
-
static defaultProps: {
|
|
8
|
-
overScrollMode: string;
|
|
9
|
-
javaScriptEnabled: boolean;
|
|
10
|
-
thirdPartyCookiesEnabled: boolean;
|
|
11
|
-
scalesPageToFit: boolean;
|
|
12
|
-
allowsFullscreenVideo: boolean;
|
|
13
|
-
allowFileAccess: boolean;
|
|
14
|
-
saveFormDataDisabled: boolean;
|
|
15
|
-
cacheEnabled: boolean;
|
|
16
|
-
androidHardwareAccelerationDisabled: boolean;
|
|
17
|
-
androidLayerType: string;
|
|
18
|
-
originWhitelist: string[];
|
|
19
|
-
};
|
|
20
|
-
static isFileUploadSupported: () => Promise<any>;
|
|
21
|
-
startUrl: string | null;
|
|
22
|
-
state: State;
|
|
23
|
-
webViewRef: React.RefObject<NativeWebViewAndroid>;
|
|
24
|
-
messagingModuleName: string;
|
|
25
|
-
componentDidMount: () => void;
|
|
26
|
-
getCommands: () => {
|
|
27
|
-
goForward: number;
|
|
28
|
-
goBack: number;
|
|
29
|
-
reload: number;
|
|
30
|
-
stopLoading: number;
|
|
31
|
-
postMessage: number;
|
|
32
|
-
injectJavaScript: number;
|
|
33
|
-
loadUrl: number;
|
|
34
|
-
requestFocus: number;
|
|
35
|
-
clearHistory: number;
|
|
36
|
-
clearCache: number;
|
|
37
|
-
clearFormData: number;
|
|
38
|
-
};
|
|
39
|
-
goForward: () => void;
|
|
40
|
-
goBack: () => void;
|
|
41
|
-
reload: () => void;
|
|
42
|
-
stopLoading: () => void;
|
|
43
|
-
requestFocus: () => void;
|
|
44
|
-
postMessage: (data: string) => void;
|
|
45
|
-
clearFormData: () => void;
|
|
46
|
-
clearCache: (includeDiskFiles: boolean) => void;
|
|
47
|
-
clearHistory: () => void;
|
|
48
|
-
/**
|
|
49
|
-
* Injects a javascript string into the referenced WebView. Deliberately does not
|
|
50
|
-
* return a response because using eval() to return a response breaks this method
|
|
51
|
-
* on pages with a Content Security Policy that disallows eval(). If you need that
|
|
52
|
-
* functionality, look into postMessage/onMessage.
|
|
53
|
-
*/
|
|
54
|
-
injectJavaScript: (data: string) => void;
|
|
55
|
-
/**
|
|
56
|
-
* We return an event with a bunch of fields including:
|
|
57
|
-
* url, title, loading, canGoBack, canGoForward
|
|
58
|
-
*/
|
|
59
|
-
updateNavigationState: (event: WebViewNavigationEvent) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Returns the native `WebView` node.
|
|
62
|
-
*/
|
|
63
|
-
getWebViewHandle: () => number;
|
|
64
|
-
onLoadingStart: (event: WebViewNavigationEvent) => void;
|
|
65
|
-
onLoadingError: (event: WebViewErrorEvent) => void;
|
|
66
|
-
onHttpError: (event: WebViewHttpErrorEvent) => void;
|
|
67
|
-
onRenderProcessGone: (event: WebViewRenderProcessGoneEvent) => void;
|
|
68
|
-
onLoadingFinish: (event: WebViewNavigationEvent) => void;
|
|
69
|
-
onMessage: (event: WebViewMessageEvent) => void;
|
|
70
|
-
onLoadingProgress: (event: WebViewProgressEvent) => void;
|
|
71
|
-
onShouldStartLoadWithRequestCallback: (shouldStart: boolean, url: string) => void;
|
|
72
|
-
render(): JSX.Element;
|
|
73
|
-
}
|
|
74
|
-
export default WebView;
|
|
75
|
-
//# sourceMappingURL=WebView.android.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebView.android.d.ts","sourceRoot":"","sources":["../src/WebView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAsB1B,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAgBxB;;GAEG;AACH,cAAM,OAAQ,SAAQ,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,CAAC;IAC/D,MAAM,CAAC,YAAY;;;;;;;;;;;;MAYjB;IAEF,MAAM,CAAC,qBAAqB,qBAG1B;IAEF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,KAAK,EAAE,KAAK,CAGV;IAGF,UAAU,wCAA2C;IAErD,mBAAmB,SAA0C;IAE7D,iBAAiB,aAEf;IAEF,WAAW;;;;;;;;;;;;MAA+D;IAE1E,SAAS,aAMP;IAEF,MAAM,aAMJ;IAEF,MAAM,aASJ;IAEF,WAAW,aAMT;IAEF,YAAY,aAMV;IAEF,WAAW,yBAMT;IAEF,aAAa,aAMZ;IAED,UAAU,sCAMR;IAEF,YAAY,aAMV;IAEF;;;;;OAKG;IACH,gBAAgB,yBAMd;IAEF;;;OAGG;IACH,qBAAqB,0CAInB;IAEF;;OAEG;IACH,gBAAgB,eAId;IAEF,cAAc,0CAQZ;IAEF,cAAc,qCAeZ;IAEF,WAAW,yCAKV;IAED,mBAAmB,iDAKlB;IAED,eAAe,0CAeb;IAEF,SAAS,uCAKP;IAEF,iBAAiB,wCAcf;IAEF,oCAAoC,8CAWlC;IAEF,MAAM;CAoFP;AAED,eAAe,OAAO,CAAC"}
|
package/lib/WebView.android.js
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
Image, requireNativeComponent, UIManager as NotTypedUIManager, View, NativeModules, findNodeHandle,
|
|
5
|
-
} from 'react-native';
|
|
6
|
-
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
|
|
7
|
-
import invariant from 'invariant';
|
|
8
|
-
import {
|
|
9
|
-
defaultOriginWhitelist, createOnShouldStartLoadWithRequest, defaultRenderError, defaultRenderLoading,
|
|
10
|
-
} from './WebViewShared';
|
|
11
|
-
import styles from './WebView.styles';
|
|
12
|
-
|
|
13
|
-
const __extends = (this && this.__extends) || (function () {
|
|
14
|
-
var extendStatics = function (d, b) {
|
|
15
|
-
extendStatics = Object.setPrototypeOf
|
|
16
|
-
|| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; })
|
|
17
|
-
|| function (d, b) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
18
|
-
return extendStatics(d, b);
|
|
19
|
-
};
|
|
20
|
-
return function (d, b) {
|
|
21
|
-
extendStatics(d, b);
|
|
22
|
-
function __() { this.constructor = d; }
|
|
23
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
24
|
-
};
|
|
25
|
-
}());
|
|
26
|
-
const __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
-
function adopt(value) { return value instanceof P ? value : new P(((resolve) => { resolve(value); })); }
|
|
28
|
-
return new (P || (P = Promise))(((resolve, reject) => {
|
|
29
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
-
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
|
31
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
-
}));
|
|
34
|
-
};
|
|
35
|
-
const __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
|
-
let _ = {
|
|
37
|
-
label: 0, sent() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: []
|
|
38
|
-
}; let f; let y; let t; let
|
|
39
|
-
g;
|
|
40
|
-
return g = { next: verb(0), throw: verb(1), return: verb(2) }, typeof Symbol === 'function' && (g[Symbol.iterator] = function () { return this; }), g;
|
|
41
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42
|
-
function step(op) {
|
|
43
|
-
if (f) throw new TypeError('Generator is already executing.');
|
|
44
|
-
while (_) {
|
|
45
|
-
try {
|
|
46
|
-
if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
47
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
48
|
-
switch (op[0]) {
|
|
49
|
-
case 0: case 1: t = op; break;
|
|
50
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
51
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
52
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
53
|
-
default:
|
|
54
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
55
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
56
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
57
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
58
|
-
if (t[2]) _.ops.pop();
|
|
59
|
-
_.trys.pop(); continue;
|
|
60
|
-
}
|
|
61
|
-
op = body.call(thisArg, _);
|
|
62
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
63
|
-
}
|
|
64
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const __rest = (this && this.__rest) || function (s, e) {
|
|
68
|
-
const t = {};
|
|
69
|
-
for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; }
|
|
70
|
-
if (s != null && typeof Object.getOwnPropertySymbols === 'function') {
|
|
71
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
72
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return t;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const UIManager = NotTypedUIManager;
|
|
79
|
-
const RNCWebView = requireNativeComponent('RNCWebView');
|
|
80
|
-
const { resolveAssetSource } = Image;
|
|
81
|
-
/**
|
|
82
|
-
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
83
|
-
*/
|
|
84
|
-
let uniqueRef = 0;
|
|
85
|
-
/**
|
|
86
|
-
* Renders a native WebView.
|
|
87
|
-
*/
|
|
88
|
-
const WebView = /** @class */ (function (_super) {
|
|
89
|
-
__extends(WebView, _super);
|
|
90
|
-
function WebView() {
|
|
91
|
-
const _this = _super !== null && _super.apply(this, arguments) || this;
|
|
92
|
-
_this.startUrl = null;
|
|
93
|
-
_this.state = {
|
|
94
|
-
viewState: _this.props.startInLoadingState ? 'LOADING' : 'IDLE',
|
|
95
|
-
lastErrorEvent: null
|
|
96
|
-
};
|
|
97
|
-
_this.webViewRef = React.createRef();
|
|
98
|
-
_this.messagingModuleName = `WebViewMessageHandler${uniqueRef += 1}`;
|
|
99
|
-
_this.componentDidMount = function () {
|
|
100
|
-
BatchedBridge.registerCallableModule(_this.messagingModuleName, _this);
|
|
101
|
-
};
|
|
102
|
-
_this.getCommands = function () { return UIManager.getViewManagerConfig('RNCWebView').Commands; };
|
|
103
|
-
_this.goForward = function () {
|
|
104
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().goForward, undefined);
|
|
105
|
-
};
|
|
106
|
-
_this.goBack = function () {
|
|
107
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().goBack, undefined);
|
|
108
|
-
};
|
|
109
|
-
_this.reload = function () {
|
|
110
|
-
_this.setState({
|
|
111
|
-
viewState: 'LOADING'
|
|
112
|
-
});
|
|
113
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().reload, undefined);
|
|
114
|
-
};
|
|
115
|
-
_this.stopLoading = function () {
|
|
116
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().stopLoading, undefined);
|
|
117
|
-
};
|
|
118
|
-
_this.requestFocus = function () {
|
|
119
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().requestFocus, undefined);
|
|
120
|
-
};
|
|
121
|
-
_this.postMessage = function (data) {
|
|
122
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().postMessage, [String(data)]);
|
|
123
|
-
};
|
|
124
|
-
_this.clearFormData = function () {
|
|
125
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().clearFormData, undefined);
|
|
126
|
-
};
|
|
127
|
-
_this.clearCache = function (includeDiskFiles) {
|
|
128
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().clearCache, [includeDiskFiles]);
|
|
129
|
-
};
|
|
130
|
-
_this.clearHistory = function () {
|
|
131
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().clearHistory, undefined);
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Injects a javascript string into the referenced WebView. Deliberately does not
|
|
135
|
-
* return a response because using eval() to return a response breaks this method
|
|
136
|
-
* on pages with a Content Security Policy that disallows eval(). If you need that
|
|
137
|
-
* functionality, look into postMessage/onMessage.
|
|
138
|
-
*/
|
|
139
|
-
_this.injectJavaScript = function (data) {
|
|
140
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().injectJavaScript, [data]);
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* We return an event with a bunch of fields including:
|
|
144
|
-
* url, title, loading, canGoBack, canGoForward
|
|
145
|
-
*/
|
|
146
|
-
_this.updateNavigationState = function (event) {
|
|
147
|
-
if (_this.props.onNavigationStateChange) {
|
|
148
|
-
_this.props.onNavigationStateChange(event.nativeEvent);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Returns the native `WebView` node.
|
|
153
|
-
*/
|
|
154
|
-
_this.getWebViewHandle = function () {
|
|
155
|
-
const nodeHandle = findNodeHandle(_this.webViewRef.current);
|
|
156
|
-
invariant(nodeHandle != null, 'nodeHandle expected to be non-null');
|
|
157
|
-
return nodeHandle;
|
|
158
|
-
};
|
|
159
|
-
_this.onLoadingStart = function (event) {
|
|
160
|
-
const { onLoadStart } = _this.props;
|
|
161
|
-
const { url } = event.nativeEvent;
|
|
162
|
-
_this.startUrl = url;
|
|
163
|
-
if (onLoadStart) {
|
|
164
|
-
onLoadStart(event);
|
|
165
|
-
}
|
|
166
|
-
_this.updateNavigationState(event);
|
|
167
|
-
};
|
|
168
|
-
_this.onLoadingError = function (event) {
|
|
169
|
-
event.persist(); // persist this event because we need to store it
|
|
170
|
-
const _a = _this.props; const { onError } = _a; const
|
|
171
|
-
{ onLoadEnd } = _a;
|
|
172
|
-
if (onError) {
|
|
173
|
-
onError(event);
|
|
174
|
-
}
|
|
175
|
-
if (onLoadEnd) {
|
|
176
|
-
onLoadEnd(event);
|
|
177
|
-
}
|
|
178
|
-
console.warn('Encountered an error loading page', event.nativeEvent);
|
|
179
|
-
_this.setState({
|
|
180
|
-
lastErrorEvent: event.nativeEvent,
|
|
181
|
-
viewState: 'ERROR'
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
_this.onHttpError = function (event) {
|
|
185
|
-
const { onHttpError } = _this.props;
|
|
186
|
-
if (onHttpError) {
|
|
187
|
-
onHttpError(event);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
_this.onRenderProcessGone = function (event) {
|
|
191
|
-
const { onRenderProcessGone } = _this.props;
|
|
192
|
-
if (onRenderProcessGone) {
|
|
193
|
-
onRenderProcessGone(event);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
_this.onLoadingFinish = function (event) {
|
|
197
|
-
const _a = _this.props; const { onLoad } = _a; const
|
|
198
|
-
{ onLoadEnd } = _a;
|
|
199
|
-
const { url } = event.nativeEvent;
|
|
200
|
-
if (onLoad) {
|
|
201
|
-
onLoad(event);
|
|
202
|
-
}
|
|
203
|
-
if (onLoadEnd) {
|
|
204
|
-
onLoadEnd(event);
|
|
205
|
-
}
|
|
206
|
-
if (url === _this.startUrl) {
|
|
207
|
-
_this.setState({
|
|
208
|
-
viewState: 'IDLE'
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
_this.updateNavigationState(event);
|
|
212
|
-
};
|
|
213
|
-
_this.onMessage = function (event) {
|
|
214
|
-
const { onMessage } = _this.props;
|
|
215
|
-
if (onMessage) {
|
|
216
|
-
onMessage(event);
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
_this.onLoadingProgress = function (event) {
|
|
220
|
-
const { onLoadProgress } = _this.props;
|
|
221
|
-
const { progress } = event.nativeEvent;
|
|
222
|
-
if (progress === 1) {
|
|
223
|
-
_this.setState((state) => {
|
|
224
|
-
if (state.viewState === 'LOADING') {
|
|
225
|
-
return { viewState: 'IDLE' };
|
|
226
|
-
}
|
|
227
|
-
return null;
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
if (onLoadProgress) {
|
|
231
|
-
onLoadProgress(event);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
_this.onShouldStartLoadWithRequestCallback = function (shouldStart, url) {
|
|
235
|
-
if (shouldStart) {
|
|
236
|
-
UIManager.dispatchViewManagerCommand(_this.getWebViewHandle(), _this.getCommands().loadUrl, [String(url)]);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
return _this;
|
|
240
|
-
}
|
|
241
|
-
WebView.prototype.render = function () {
|
|
242
|
-
const _a = this.props; const { onMessage } = _a; const onShouldStartLoadWithRequestProp = _a.onShouldStartLoadWithRequest; const { originWhitelist } = _a; const { renderError } = _a; const { renderLoading } = _a; const { source } = _a; const { style } = _a; const { containerStyle } = _a; const _b = _a.nativeConfig; const nativeConfig = _b === void 0 ? {} : _b; const
|
|
243
|
-
otherProps = __rest(_a, ['onMessage', 'onShouldStartLoadWithRequest', 'originWhitelist', 'renderError', 'renderLoading', 'source', 'style', 'containerStyle', 'nativeConfig']);
|
|
244
|
-
let otherView = null;
|
|
245
|
-
if (this.state.viewState === 'LOADING') {
|
|
246
|
-
otherView = (renderLoading || defaultRenderLoading)();
|
|
247
|
-
} else if (this.state.viewState === 'ERROR') {
|
|
248
|
-
const errorEvent = this.state.lastErrorEvent;
|
|
249
|
-
invariant(errorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
250
|
-
otherView = (renderError || defaultRenderError)(errorEvent.domain, errorEvent.code, errorEvent.description);
|
|
251
|
-
} else if (this.state.viewState !== 'IDLE') {
|
|
252
|
-
console.error(`RNCWebView invalid state encountered: ${this.state.viewState}`);
|
|
253
|
-
}
|
|
254
|
-
const webViewStyles = [styles.container, styles.webView, style];
|
|
255
|
-
const webViewContainerStyle = [styles.container, containerStyle];
|
|
256
|
-
if (typeof source !== 'number' && source && 'method' in source) {
|
|
257
|
-
if (source.method === 'POST' && source.headers) {
|
|
258
|
-
console.warn('WebView: `source.headers` is not supported when using POST.');
|
|
259
|
-
} else if (source.method === 'GET' && source.body) {
|
|
260
|
-
console.warn('WebView: `source.body` is not supported when using GET.');
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
const NativeWebView = nativeConfig.component || RNCWebView;
|
|
264
|
-
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(this.onShouldStartLoadWithRequestCallback,
|
|
265
|
-
// casting cause it's in the default props
|
|
266
|
-
originWhitelist, onShouldStartLoadWithRequestProp);
|
|
267
|
-
const webView = (
|
|
268
|
-
<NativeWebView
|
|
269
|
-
key="webViewKey"
|
|
270
|
-
{...otherProps}
|
|
271
|
-
messagingEnabled={typeof onMessage === 'function'}
|
|
272
|
-
messagingModuleName={this.messagingModuleName}
|
|
273
|
-
onLoadingError={this.onLoadingError}
|
|
274
|
-
onLoadingFinish={this.onLoadingFinish}
|
|
275
|
-
onLoadingProgress={this.onLoadingProgress}
|
|
276
|
-
onLoadingStart={this.onLoadingStart}
|
|
277
|
-
onHttpError={this.onHttpError}
|
|
278
|
-
onRenderProcessGone={this.onRenderProcessGone}
|
|
279
|
-
onMessage={this.onMessage}
|
|
280
|
-
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
281
|
-
ref={this.webViewRef}
|
|
282
|
-
// TODO: find a better way to type this.
|
|
283
|
-
source={resolveAssetSource(source)}
|
|
284
|
-
style={webViewStyles}
|
|
285
|
-
{...nativeConfig.props}
|
|
286
|
-
/>
|
|
287
|
-
);
|
|
288
|
-
return (
|
|
289
|
-
<View style={webViewContainerStyle}>
|
|
290
|
-
{webView}
|
|
291
|
-
{otherView}
|
|
292
|
-
</View>
|
|
293
|
-
);
|
|
294
|
-
};
|
|
295
|
-
WebView.defaultProps = {
|
|
296
|
-
overScrollMode: 'always',
|
|
297
|
-
javaScriptEnabled: true,
|
|
298
|
-
thirdPartyCookiesEnabled: true,
|
|
299
|
-
scalesPageToFit: true,
|
|
300
|
-
allowsFullscreenVideo: false,
|
|
301
|
-
allowFileAccess: false,
|
|
302
|
-
saveFormDataDisabled: false,
|
|
303
|
-
cacheEnabled: true,
|
|
304
|
-
androidHardwareAccelerationDisabled: false,
|
|
305
|
-
androidLayerType: 'none',
|
|
306
|
-
originWhitelist: defaultOriginWhitelist
|
|
307
|
-
};
|
|
308
|
-
WebView.isFileUploadSupported = function () {
|
|
309
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
310
|
-
return __generator(this, (_a) =>
|
|
311
|
-
// native implementation should return "true" only for Android 5+
|
|
312
|
-
[2 /* return */, NativeModules.RNCWebView.isFileUploadSupported()]
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
return WebView;
|
|
317
|
-
}(React.Component));
|
|
318
|
-
export default WebView;
|
package/lib/WebView.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IOSWebViewProps, AndroidWebViewProps } from './WebViewTypes';
|
|
3
|
-
export declare type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
|
|
4
|
-
declare const WebView: React.FunctionComponent<WebViewProps>;
|
|
5
|
-
export { WebView };
|
|
6
|
-
export default WebView;
|
|
7
|
-
//# sourceMappingURL=WebView.d.ts.map
|
package/lib/WebView.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebView.d.ts","sourceRoot":"","sources":["../src/WebView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,oBAAY,YAAY,GAAG,eAAe,GAAG,mBAAmB,CAAC;AAMjE,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAMlD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|
package/lib/WebView.ios.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { WebViewErrorEvent, WebViewHttpErrorEvent, WebViewMessageEvent, WebViewNavigationEvent, WebViewProgressEvent, WebViewTerminatedEvent, IOSWebViewProps, NativeWebViewIOS, State } from './WebViewTypes';
|
|
3
|
-
declare class WebView extends React.Component<IOSWebViewProps, State> {
|
|
4
|
-
static defaultProps: {
|
|
5
|
-
javaScriptEnabled: boolean;
|
|
6
|
-
cacheEnabled: boolean;
|
|
7
|
-
originWhitelist: string[];
|
|
8
|
-
useSharedProcessPool: boolean;
|
|
9
|
-
};
|
|
10
|
-
static isFileUploadSupported: () => Promise<boolean>;
|
|
11
|
-
state: State;
|
|
12
|
-
webViewRef: React.RefObject<NativeWebViewIOS>;
|
|
13
|
-
getCommands: () => {
|
|
14
|
-
goForward: number;
|
|
15
|
-
goBack: number;
|
|
16
|
-
reload: number;
|
|
17
|
-
stopLoading: number;
|
|
18
|
-
postMessage: number;
|
|
19
|
-
injectJavaScript: number;
|
|
20
|
-
loadUrl: number;
|
|
21
|
-
requestFocus: number;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Go forward one page in the web view's history.
|
|
25
|
-
*/
|
|
26
|
-
goForward: () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Go back one page in the web view's history.
|
|
29
|
-
*/
|
|
30
|
-
goBack: () => void;
|
|
31
|
-
/**
|
|
32
|
-
* Reloads the current page.
|
|
33
|
-
*/
|
|
34
|
-
reload: () => void;
|
|
35
|
-
/**
|
|
36
|
-
* Stop loading the current page.
|
|
37
|
-
*/
|
|
38
|
-
stopLoading: () => void;
|
|
39
|
-
/**
|
|
40
|
-
* Request focus on WebView rendered page.
|
|
41
|
-
*/
|
|
42
|
-
requestFocus: () => void;
|
|
43
|
-
/**
|
|
44
|
-
* Posts a message to the web view, which will emit a `message` event.
|
|
45
|
-
* Accepts one argument, `data`, which must be a string.
|
|
46
|
-
*
|
|
47
|
-
* In your webview, you'll need to something like the following.
|
|
48
|
-
*
|
|
49
|
-
* ```js
|
|
50
|
-
* document.addEventListener('message', e => { document.title = e.data; });
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
postMessage: (data: string) => void;
|
|
54
|
-
/**
|
|
55
|
-
* Injects a javascript string into the referenced WebView. Deliberately does not
|
|
56
|
-
* return a response because using eval() to return a response breaks this method
|
|
57
|
-
* on pages with a Content Security Policy that disallows eval(). If you need that
|
|
58
|
-
* functionality, look into postMessage/onMessage.
|
|
59
|
-
*/
|
|
60
|
-
injectJavaScript: (data: string) => void;
|
|
61
|
-
/**
|
|
62
|
-
* We return an event with a bunch of fields including:
|
|
63
|
-
* url, title, loading, canGoBack, canGoForward
|
|
64
|
-
*/
|
|
65
|
-
updateNavigationState: (event: WebViewNavigationEvent) => void;
|
|
66
|
-
/**
|
|
67
|
-
* Returns the native `WebView` node.
|
|
68
|
-
*/
|
|
69
|
-
getWebViewHandle: () => number;
|
|
70
|
-
onLoadingStart: (event: WebViewNavigationEvent) => void;
|
|
71
|
-
onLoadingError: (event: WebViewErrorEvent) => void;
|
|
72
|
-
onHttpError: (event: WebViewHttpErrorEvent) => void;
|
|
73
|
-
onLoadingFinish: (event: WebViewNavigationEvent) => void;
|
|
74
|
-
onMessage: (event: WebViewMessageEvent) => void;
|
|
75
|
-
onLoadingProgress: (event: WebViewProgressEvent) => void;
|
|
76
|
-
onShouldStartLoadWithRequestCallback: (shouldStart: boolean, _url: string, lockIdentifier: number) => void;
|
|
77
|
-
onContentProcessDidTerminate: (event: WebViewTerminatedEvent) => void;
|
|
78
|
-
componentDidUpdate(prevProps: IOSWebViewProps): void;
|
|
79
|
-
showRedboxOnPropChanges(prevProps: IOSWebViewProps, propName: keyof IOSWebViewProps): void;
|
|
80
|
-
render(): JSX.Element;
|
|
81
|
-
}
|
|
82
|
-
export default WebView;
|
|
83
|
-
//# sourceMappingURL=WebView.ios.d.ts.map
|
package/lib/WebView.ios.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebView.ios.d.ts","sourceRoot":"","sources":["../src/WebView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EAEf,gBAAgB,EAEhB,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAyBxB,cAAM,OAAQ,SAAQ,KAAK,CAAC,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC;IAC3D,MAAM,CAAC,YAAY;;;;;MAKjB;IAEF,MAAM,CAAC,qBAAqB,yBAG1B;IAEF,KAAK,EAAE,KAAK,CAGV;IAEF,UAAU,oCAAuC;IAGjD,WAAW;;;;;;;;;MAA+D;IAE1E;;OAEG;IACH,SAAS,aAMP;IAEF;;OAEG;IACH,MAAM,aAMJ;IAEF;;OAEG;IACH,MAAM,aAOJ;IAEF;;OAEG;IACH,WAAW,aAMT;IAEF;;OAEG;IACH,YAAY,aAMV;IAEF;;;;;;;;;OASG;IACH,WAAW,yBAMT;IAEF;;;;;OAKG;IACH,gBAAgB,yBAMd;IAEF;;;OAGG;IACH,qBAAqB,0CAInB;IAEF;;OAEG;IACH,gBAAgB,eAId;IAEF,cAAc,0CAMZ;IAEF,cAAc,qCAeZ;IAEF,WAAW,yCAKV;IAED,eAAe,0CAYb;IAEF,SAAS,uCAKP;IAEF,iBAAiB,wCAKf;IAEF,oCAAoC,uEAUlC;IAEF,4BAA4B,0CAK1B;IAEF,kBAAkB,CAAC,SAAS,EAAE,eAAe;IAO7C,uBAAuB,CACrB,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,MAAM,eAAe;IASjC,MAAM;CAqFP;AAED,eAAe,OAAO,CAAC"}
|