@react-native-ohos/react-native-webview 13.15.1-rc.1
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.OpenSource +11 -0
- package/README.md +13 -0
- package/harmony/rn_webview/BuildProfile.ets +17 -0
- package/harmony/rn_webview/OAT.xml +45 -0
- package/harmony/rn_webview/build-profile.json5 +28 -0
- package/harmony/rn_webview/hvigorfile.ts +1 -0
- package/harmony/rn_webview/index.ets +13 -0
- package/harmony/rn_webview/oh-package.json5 +13 -0
- package/harmony/rn_webview/src/main/cpp/CMakeLists.txt +9 -0
- package/harmony/rn_webview/src/main/cpp/WebViewPackage.h +17 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/BaseReactNativeWebviewPackage.h +95 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +119 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.cpp +18 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.h +16 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.cpp +17 -0
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.h +16 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ComponentDescriptors.h +24 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.cpp +241 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.h +263 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +103 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +509 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.cpp +17 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.h +32 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.cpp +16 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.h +29 -0
- package/harmony/rn_webview/src/main/ets/CutomReference.ts +30 -0
- package/harmony/rn_webview/src/main/ets/Logger.ts +44 -0
- package/harmony/rn_webview/src/main/ets/Magic.ets +184 -0
- package/harmony/rn_webview/src/main/ets/RNCWebView.ets +571 -0
- package/harmony/rn_webview/src/main/ets/RNCWebViewPackage.ets +38 -0
- package/harmony/rn_webview/src/main/ets/ShouldRequestUrl.ts +48 -0
- package/harmony/rn_webview/src/main/ets/WebViewBaseOperate.ets +443 -0
- package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +58 -0
- package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +524 -0
- package/harmony/rn_webview/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/rn_webview/src/main/ets/generated/index.ets +5 -0
- package/harmony/rn_webview/src/main/ets/generated/ts.ts +6 -0
- package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebView.ts +18 -0
- package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebViewModule.ts +16 -0
- package/harmony/rn_webview/src/main/ets/generated/turboModules/ts.ts +6 -0
- package/harmony/rn_webview/src/main/module.json5 +11 -0
- package/harmony/rn_webview/src/main/resources/base/element/string.json +40 -0
- package/harmony/rn_webview/src/main/resources/en_US/element/string.json +40 -0
- package/harmony/rn_webview/src/main/resources/zh_CN/element/string.json +40 -0
- package/harmony/rn_webview/src/test/List.test.ets +5 -0
- package/harmony/rn_webview/src/test/LocalUnit.test.ets +33 -0
- package/harmony/rn_webview/ts.ets +9 -0
- package/harmony/rn_webview.har +0 -0
- package/package.json +99 -0
- package/src/NativeRNCWebView.ts +22 -0
- package/src/NativeRNCWebViewModule.ts +19 -0
- package/src/RNCWebViewNativeComponent.ts +354 -0
- package/src/WebView.harmony.tsx +343 -0
- package/src/WebView.tsx +10 -0
- package/src/codegenUtils.ts +11 -0
- package/src/index.ts +10 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"string": [
|
|
3
|
+
{
|
|
4
|
+
"name": "page_show",
|
|
5
|
+
"value": "page from npm package"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "deny",
|
|
9
|
+
"value": "不允许"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "on_confirm",
|
|
13
|
+
"value": "允许"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "use_your_camera",
|
|
17
|
+
"value": "使用你的摄像头?"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "use_your_microphone",
|
|
21
|
+
"value": "使用你的麦克风?"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "use_your_camera_and_microphone",
|
|
25
|
+
"value": "使用你的摄像头和麦克风?"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "midi_sysex_resources",
|
|
29
|
+
"value": "访问 MIDI SYSEX 资源?"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "determined",
|
|
33
|
+
"value": "确认"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "cancel",
|
|
37
|
+
"value": "取消"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
2
|
+
|
|
3
|
+
export default function localUnitTest() {
|
|
4
|
+
describe('localUnitTest',() => {
|
|
5
|
+
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
// Presets an action, which is performed only once before all test cases of the test suite start.
|
|
8
|
+
// This API supports only one parameter: preset action function.
|
|
9
|
+
});
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// Presets an action, which is performed before each unit test case starts.
|
|
12
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
13
|
+
// This API supports only one parameter: preset action function.
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
// Presets a clear action, which is performed after each unit test case ends.
|
|
17
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
18
|
+
// This API supports only one parameter: clear action function.
|
|
19
|
+
});
|
|
20
|
+
afterAll(() => {
|
|
21
|
+
// Presets a clear action, which is performed after all test cases of the test suite end.
|
|
22
|
+
// This API supports only one parameter: clear action function.
|
|
23
|
+
});
|
|
24
|
+
it('assertContain', 0, () => {
|
|
25
|
+
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
|
26
|
+
let a = 'abc';
|
|
27
|
+
let b = 'b';
|
|
28
|
+
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
|
29
|
+
expect(a).assertContain(b);
|
|
30
|
+
expect(a).assertEqual(a);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import {RNCWebViewPackage as WebViewPackage} from './src/main/ets/RNCWebViewPackage'
|
|
6
|
+
|
|
7
|
+
export {WebViewPackage};
|
|
8
|
+
|
|
9
|
+
export * from './src/main/ets/RNCWebViewPackage'
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-webview",
|
|
3
|
+
"description": "React Native WebView component for harmony",
|
|
4
|
+
"react-native": "src/index",
|
|
5
|
+
"source": "src/index",
|
|
6
|
+
"typings": "index.d.ts",
|
|
7
|
+
"author": "Jamon Holmgren <jamon@infinite.red>",
|
|
8
|
+
"contributors": [
|
|
9
|
+
"Thibault Malbranche <malbranche.thibault@gmail.com>"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"version": "13.15.1-rc.1",
|
|
13
|
+
"homepage": "https://github.com/react-native-oh-library/react-native-webview#readme",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"macos": "react-native run-macos --scheme WebviewExample --project-path example/macos",
|
|
16
|
+
"start": "react-native start",
|
|
17
|
+
"windows": "install-windows-test-app --project-directory example/windows && react-native run-windows --root example --arch x64",
|
|
18
|
+
"ci": "CI=true && yarn lint",
|
|
19
|
+
"ci:publish": "yarn semantic-release",
|
|
20
|
+
"lint": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx,.js,.jsx",
|
|
21
|
+
"build": "babel --extensions \".ts,.tsx\" --out-dir lib src",
|
|
22
|
+
"prepare:types": "tsc --noEmit false --emitDeclarationOnly --declaration --rootDir src --outDir lib",
|
|
23
|
+
"prepare": "yarn prepare:types && yarn build",
|
|
24
|
+
"appium": "appium",
|
|
25
|
+
"test:windows": "yarn jest --setupFiles=./jest-setups/jest.setup.js",
|
|
26
|
+
"add:macos": "yarn add react-native-macos@0.73.17",
|
|
27
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-webview --cpp-output-path ./harmony/rn_webview/src/main/cpp/generated --ets-output-path ./harmony/rn_webview/src/main/ets/generated --turbo-modules-spec-paths ./src --arkts-components-spec-paths ./src"
|
|
28
|
+
},
|
|
29
|
+
"rn-docs": {
|
|
30
|
+
"title": "Webview",
|
|
31
|
+
"type": "Component"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "*",
|
|
35
|
+
"react-native": "*"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"escape-string-regexp": "^4.0.0",
|
|
39
|
+
"invariant": "2.2.4",
|
|
40
|
+
"react-native-webview": "13.15.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@babel/cli": "^7.20.0",
|
|
44
|
+
"@babel/core": "^7.20.0",
|
|
45
|
+
"@babel/runtime": "^7.20.0",
|
|
46
|
+
"@callstack/react-native-visionos": "0.73.8",
|
|
47
|
+
"@react-native/babel-preset": "0.73.21",
|
|
48
|
+
"@react-native/eslint-config": "0.73.2",
|
|
49
|
+
"@react-native/metro-config": "0.73.5",
|
|
50
|
+
"@react-native/typescript-config": "0.73.1",
|
|
51
|
+
"@react-native-oh/react-native-harmony-cli": "file:./packages/rnoh-react-native-harmony-cli-0.77.10.tgz",
|
|
52
|
+
"@rnx-kit/metro-config": "1.3.15",
|
|
53
|
+
"@semantic-release/git": "7.0.16",
|
|
54
|
+
"@types/invariant": "^2.2.30",
|
|
55
|
+
"@types/jest": "^29.5.12",
|
|
56
|
+
"@types/react": "18.2.61",
|
|
57
|
+
"@types/selenium-webdriver": "4.0.9",
|
|
58
|
+
"@types/minimatch": "^5.1.2",
|
|
59
|
+
"appium": "1.17.0",
|
|
60
|
+
"eslint": "8.57.0",
|
|
61
|
+
"jest": "^29.6.3",
|
|
62
|
+
"metro-react-native-babel-preset": "0.73.7",
|
|
63
|
+
"prettier": "2.8.8",
|
|
64
|
+
"react": "18.3.1",
|
|
65
|
+
"react-native": "0.77.1",
|
|
66
|
+
"react-native-macos": "0.73.17",
|
|
67
|
+
"react-native-test-app": "3.7.2",
|
|
68
|
+
"react-native-windows": "0.73.8",
|
|
69
|
+
"selenium-appium": "1.0.2",
|
|
70
|
+
"selenium-webdriver": "4.0.0-alpha.7",
|
|
71
|
+
"semantic-release": "15.13.24",
|
|
72
|
+
"typescript": "5.1.3",
|
|
73
|
+
"winappdriver": "^0.0.7"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git://github.com/react-native-oh-library/react-native-webview.git"
|
|
78
|
+
},
|
|
79
|
+
"files": [
|
|
80
|
+
"src",
|
|
81
|
+
"harmony",
|
|
82
|
+
"react-native-webview.podspec",
|
|
83
|
+
"!**/__tests__",
|
|
84
|
+
"!**/__fixtures__",
|
|
85
|
+
"!**/__mocks__"
|
|
86
|
+
],
|
|
87
|
+
"keywords": [
|
|
88
|
+
"react-native",
|
|
89
|
+
"harmony"
|
|
90
|
+
],
|
|
91
|
+
"publishConfig": {
|
|
92
|
+
"registry": "https://registry.npmjs.org/",
|
|
93
|
+
"access": "public"
|
|
94
|
+
},
|
|
95
|
+
"harmony": {
|
|
96
|
+
"alias": "react-native-webview"
|
|
97
|
+
},
|
|
98
|
+
"packageManager": "yarn@1.22.19"
|
|
99
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TurboModule } from 'react-native';
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
10
|
+
|
|
11
|
+
export interface Spec extends TurboModule {
|
|
12
|
+
readonly getConstants: () => {};
|
|
13
|
+
|
|
14
|
+
// your module methods go here, for example:
|
|
15
|
+
isFileUploadSupported(): Promise<boolean>;
|
|
16
|
+
shouldStartLoadWithLockIdentifier(
|
|
17
|
+
shouldStart: boolean,
|
|
18
|
+
lockIdentifier: Double
|
|
19
|
+
): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNCWebView');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { TurboModule } from 'react-native';
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
10
|
+
|
|
11
|
+
export interface Spec extends TurboModule {
|
|
12
|
+
isFileUploadSupported(): Promise<boolean>;
|
|
13
|
+
shouldStartLoadWithLockIdentifier(
|
|
14
|
+
shouldStart: boolean,
|
|
15
|
+
lockIdentifier: Double
|
|
16
|
+
): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNCWebViewModule');
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
8
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
9
|
+
import {
|
|
10
|
+
DirectEventHandler,
|
|
11
|
+
Double,
|
|
12
|
+
Int32,
|
|
13
|
+
WithDefault,
|
|
14
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
15
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
16
|
+
|
|
17
|
+
export type WebViewNativeEvent = Readonly<{
|
|
18
|
+
url: string;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
title: string;
|
|
21
|
+
canGoBack: boolean;
|
|
22
|
+
canGoForward: boolean;
|
|
23
|
+
lockIdentifier: Double;
|
|
24
|
+
}>;
|
|
25
|
+
export type WebViewCustomMenuSelectionEvent = Readonly<{
|
|
26
|
+
label: string;
|
|
27
|
+
key: string;
|
|
28
|
+
selectedText: string;
|
|
29
|
+
}>;
|
|
30
|
+
export type WebViewMessageEvent = Readonly<{
|
|
31
|
+
url: string;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
title: string;
|
|
34
|
+
canGoBack: boolean;
|
|
35
|
+
canGoForward: boolean;
|
|
36
|
+
lockIdentifier: Double;
|
|
37
|
+
data: string;
|
|
38
|
+
}>;
|
|
39
|
+
export type WebViewOpenWindowEvent = Readonly<{
|
|
40
|
+
targetUrl: string;
|
|
41
|
+
}>;
|
|
42
|
+
export type WebViewHttpErrorEvent = Readonly<{
|
|
43
|
+
url: string;
|
|
44
|
+
loading: boolean;
|
|
45
|
+
title: string;
|
|
46
|
+
canGoBack: boolean;
|
|
47
|
+
canGoForward: boolean;
|
|
48
|
+
lockIdentifier: Double;
|
|
49
|
+
description: string;
|
|
50
|
+
statusCode: Int32;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type WebViewErrorEvent = Readonly<{
|
|
54
|
+
url: string;
|
|
55
|
+
loading: boolean;
|
|
56
|
+
title: string;
|
|
57
|
+
canGoBack: boolean;
|
|
58
|
+
canGoForward: boolean;
|
|
59
|
+
lockIdentifier: Double;
|
|
60
|
+
domain?: string;
|
|
61
|
+
code: Int32;
|
|
62
|
+
description: string;
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
export type WebViewNativeProgressEvent = Readonly<{
|
|
66
|
+
url: string;
|
|
67
|
+
loading: boolean;
|
|
68
|
+
title: string;
|
|
69
|
+
canGoBack: boolean;
|
|
70
|
+
canGoForward: boolean;
|
|
71
|
+
lockIdentifier: Double;
|
|
72
|
+
progress: Double;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export type WebViewNavigationEvent = Readonly<{
|
|
76
|
+
url: string;
|
|
77
|
+
loading: boolean;
|
|
78
|
+
title: string;
|
|
79
|
+
canGoBack: boolean;
|
|
80
|
+
canGoForward: boolean;
|
|
81
|
+
lockIdentifier: Double;
|
|
82
|
+
navigationType:
|
|
83
|
+
| 'click'
|
|
84
|
+
| 'formsubmit'
|
|
85
|
+
| 'backforward'
|
|
86
|
+
| 'reload'
|
|
87
|
+
| 'formresubmit'
|
|
88
|
+
| 'other';
|
|
89
|
+
mainDocumentURL?: string;
|
|
90
|
+
}>;
|
|
91
|
+
|
|
92
|
+
export type ShouldStartLoadRequestEvent = Readonly<{
|
|
93
|
+
url: string;
|
|
94
|
+
loading: boolean;
|
|
95
|
+
title: string;
|
|
96
|
+
canGoBack: boolean;
|
|
97
|
+
canGoForward: boolean;
|
|
98
|
+
lockIdentifier: Double;
|
|
99
|
+
navigationType:
|
|
100
|
+
| 'click'
|
|
101
|
+
| 'formsubmit'
|
|
102
|
+
| 'backforward'
|
|
103
|
+
| 'reload'
|
|
104
|
+
| 'formresubmit'
|
|
105
|
+
| 'other';
|
|
106
|
+
mainDocumentURL?: string;
|
|
107
|
+
isTopFrame: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
|
|
110
|
+
type ScrollEvent = Readonly<{
|
|
111
|
+
contentInset: {
|
|
112
|
+
bottom: Double;
|
|
113
|
+
left: Double;
|
|
114
|
+
right: Double;
|
|
115
|
+
top: Double;
|
|
116
|
+
};
|
|
117
|
+
contentOffset: {
|
|
118
|
+
y: Double;
|
|
119
|
+
x: Double;
|
|
120
|
+
};
|
|
121
|
+
contentSize: {
|
|
122
|
+
height: Double;
|
|
123
|
+
width: Double;
|
|
124
|
+
};
|
|
125
|
+
layoutMeasurement: {
|
|
126
|
+
height: Double;
|
|
127
|
+
width: Double;
|
|
128
|
+
};
|
|
129
|
+
targetContentOffset?: {
|
|
130
|
+
y: Double;
|
|
131
|
+
x: Double;
|
|
132
|
+
};
|
|
133
|
+
velocity?: {
|
|
134
|
+
y: Double;
|
|
135
|
+
x: Double;
|
|
136
|
+
};
|
|
137
|
+
zoomScale?: Double;
|
|
138
|
+
responderIgnoreScroll?: boolean;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
type WebViewRenderProcessGoneEvent = Readonly<{
|
|
142
|
+
didCrash: boolean;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
type WebViewDownloadEvent = Readonly<{
|
|
146
|
+
downloadUrl: string;
|
|
147
|
+
}>;
|
|
148
|
+
|
|
149
|
+
// type MenuItem = Readonly<{label: string, key: string}>;
|
|
150
|
+
|
|
151
|
+
export interface NativeProps extends ViewProps {
|
|
152
|
+
// Android only
|
|
153
|
+
allowFileAccess?: boolean;
|
|
154
|
+
allowsProtectedMedia?: boolean;
|
|
155
|
+
allowsFullscreenVideo?: boolean;
|
|
156
|
+
androidLayerType?: WithDefault<'none' | 'software' | 'hardware', 'none'>;
|
|
157
|
+
cacheMode?: WithDefault<
|
|
158
|
+
| 'LOAD_DEFAULT'
|
|
159
|
+
| 'LOAD_CACHE_ELSE_NETWORK'
|
|
160
|
+
| 'LOAD_NO_CACHE'
|
|
161
|
+
| 'LOAD_CACHE_ONLY',
|
|
162
|
+
'LOAD_DEFAULT'
|
|
163
|
+
>;
|
|
164
|
+
domStorageEnabled?: boolean;
|
|
165
|
+
downloadingMessage?: string;
|
|
166
|
+
forceDarkOn?: boolean;
|
|
167
|
+
geolocationEnabled?: boolean;
|
|
168
|
+
lackPermissionToDownloadMessage?: string;
|
|
169
|
+
messagingModuleName: string;
|
|
170
|
+
minimumFontSize?: Int32;
|
|
171
|
+
mixedContentMode?: WithDefault<'never' | 'always' | 'compatibility', 'never'>;
|
|
172
|
+
nestedScrollEnabled?: boolean;
|
|
173
|
+
onContentSizeChange?: DirectEventHandler<WebViewNativeEvent>;
|
|
174
|
+
onRenderProcessGone?: DirectEventHandler<WebViewRenderProcessGoneEvent>;
|
|
175
|
+
overScrollMode?: string;
|
|
176
|
+
saveFormDataDisabled?: boolean;
|
|
177
|
+
scalesPageToFit?: WithDefault<boolean, true>;
|
|
178
|
+
setBuiltInZoomControls?: WithDefault<boolean, true>;
|
|
179
|
+
setDisplayZoomControls?: boolean;
|
|
180
|
+
setSupportMultipleWindows?: WithDefault<boolean, true>;
|
|
181
|
+
textZoom?: Int32;
|
|
182
|
+
thirdPartyCookiesEnabled?: WithDefault<boolean, true>;
|
|
183
|
+
// Workaround to watch if listener if defined
|
|
184
|
+
hasOnScroll?: boolean;
|
|
185
|
+
injectedJavaScriptObject?: string;
|
|
186
|
+
// !Android only
|
|
187
|
+
paymentRequestEnabled?: boolean;
|
|
188
|
+
// iOS only
|
|
189
|
+
allowingReadAccessToURL?: string;
|
|
190
|
+
allowsBackForwardNavigationGestures?: boolean;
|
|
191
|
+
allowsInlineMediaPlayback?: boolean;
|
|
192
|
+
allowsPictureInPictureMediaPlayback?: boolean;
|
|
193
|
+
allowsAirPlayForMediaPlayback?: boolean;
|
|
194
|
+
allowsLinkPreview?: WithDefault<boolean, true>;
|
|
195
|
+
automaticallyAdjustContentInsets?: WithDefault<boolean, true>;
|
|
196
|
+
ignoreSilentHardwareSwitch?:boolean;
|
|
197
|
+
autoManageStatusBarEnabled?: WithDefault<boolean, true>;
|
|
198
|
+
bounces?: WithDefault<boolean, true>;
|
|
199
|
+
contentInset?: Readonly<{
|
|
200
|
+
top?: Double;
|
|
201
|
+
left?: Double;
|
|
202
|
+
bottom?: Double;
|
|
203
|
+
right?: Double;
|
|
204
|
+
}>;
|
|
205
|
+
contentInsetAdjustmentBehavior?: WithDefault<
|
|
206
|
+
'never' | 'automatic' | 'scrollableAxes' | 'always',
|
|
207
|
+
'never'
|
|
208
|
+
>;
|
|
209
|
+
contentMode?: WithDefault<
|
|
210
|
+
'recommended' | 'mobile' | 'desktop',
|
|
211
|
+
'recommended'
|
|
212
|
+
>;
|
|
213
|
+
dataDetectorTypes?: WithDefault<
|
|
214
|
+
ReadonlyArray<
|
|
215
|
+
| 'address'
|
|
216
|
+
| 'link'
|
|
217
|
+
| 'calendarEvent'
|
|
218
|
+
| 'trackingNumber'
|
|
219
|
+
| 'flightNumber'
|
|
220
|
+
| 'lookupSuggestion'
|
|
221
|
+
| 'phoneNumber'
|
|
222
|
+
| 'all'
|
|
223
|
+
| 'none'
|
|
224
|
+
>,
|
|
225
|
+
'phoneNumber'
|
|
226
|
+
>;
|
|
227
|
+
decelerationRate?: Double;
|
|
228
|
+
directionalLockEnabled?: WithDefault<boolean, true>;
|
|
229
|
+
enableApplePay?: boolean;
|
|
230
|
+
hideKeyboardAccessoryView?: boolean;
|
|
231
|
+
keyboardDisplayRequiresUserAction?: WithDefault<boolean, true>;
|
|
232
|
+
limitsNavigationsToAppBoundDomains?: boolean;
|
|
233
|
+
mediaCapturePermissionGrantType?: WithDefault<
|
|
234
|
+
| 'prompt'
|
|
235
|
+
| 'grant'
|
|
236
|
+
| 'deny'
|
|
237
|
+
| 'grantIfSameHostElsePrompt'
|
|
238
|
+
| 'grantIfSameHostElseDeny',
|
|
239
|
+
'prompt'
|
|
240
|
+
>;
|
|
241
|
+
pagingEnabled?: boolean;
|
|
242
|
+
pullToRefreshEnabled?: boolean;
|
|
243
|
+
refreshControlLightMode?: boolean;
|
|
244
|
+
scrollEnabled?: WithDefault<boolean, true>;
|
|
245
|
+
sharedCookiesEnabled?: boolean;
|
|
246
|
+
textInteractionEnabled?: WithDefault<boolean, true>;
|
|
247
|
+
useSharedProcessPool?: WithDefault<boolean, true>;
|
|
248
|
+
onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
|
|
249
|
+
onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
|
|
250
|
+
onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
|
|
251
|
+
|
|
252
|
+
menuItems?: ReadonlyArray<Readonly<{ label: string; key: string }>>;
|
|
253
|
+
suppressMenuItems?: Readonly<string>[];
|
|
254
|
+
// Workaround to watch if listener if defined
|
|
255
|
+
hasOnFileDownload?: boolean;
|
|
256
|
+
fraudulentWebsiteWarningEnabled?: WithDefault<boolean, true>;
|
|
257
|
+
// !iOS only
|
|
258
|
+
|
|
259
|
+
allowFileAccessFromFileURLs?: boolean;
|
|
260
|
+
allowUniversalAccessFromFileURLs?: boolean;
|
|
261
|
+
applicationNameForUserAgent?: string;
|
|
262
|
+
basicAuthCredential?: Readonly<{
|
|
263
|
+
username: string;
|
|
264
|
+
password: string;
|
|
265
|
+
}>;
|
|
266
|
+
cacheEnabled?: WithDefault<boolean, true>;
|
|
267
|
+
incognito?: boolean;
|
|
268
|
+
injectedJavaScript?: string;
|
|
269
|
+
injectedJavaScriptBeforeContentLoaded?: string;
|
|
270
|
+
injectedJavaScriptForMainFrameOnly?: WithDefault<boolean, true>;
|
|
271
|
+
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: WithDefault<
|
|
272
|
+
boolean,
|
|
273
|
+
true
|
|
274
|
+
>;
|
|
275
|
+
javaScriptCanOpenWindowsAutomatically?: boolean;
|
|
276
|
+
javaScriptEnabled?: WithDefault<boolean, true>;
|
|
277
|
+
webviewDebuggingEnabled?: boolean;
|
|
278
|
+
mediaPlaybackRequiresUserAction?: WithDefault<boolean, true>;
|
|
279
|
+
messagingEnabled: boolean;
|
|
280
|
+
shouldStartLoadWithRequestEnabled: boolean;
|
|
281
|
+
onLoadingError: DirectEventHandler<WebViewErrorEvent>;
|
|
282
|
+
onLoadingFinish: DirectEventHandler<WebViewNavigationEvent>;
|
|
283
|
+
onLoadingProgress: DirectEventHandler<WebViewNativeProgressEvent>;
|
|
284
|
+
onLoadingStart: DirectEventHandler<WebViewNavigationEvent>;
|
|
285
|
+
onHttpError: DirectEventHandler<WebViewHttpErrorEvent>;
|
|
286
|
+
onMessage: DirectEventHandler<WebViewMessageEvent>;
|
|
287
|
+
onOpenWindow?: DirectEventHandler<WebViewOpenWindowEvent>;
|
|
288
|
+
hasOnOpenWindowEvent?: boolean;
|
|
289
|
+
onScroll?: DirectEventHandler<ScrollEvent>;
|
|
290
|
+
onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
|
|
291
|
+
showsHorizontalScrollIndicator?: WithDefault<boolean, true>;
|
|
292
|
+
showsVerticalScrollIndicator?: WithDefault<boolean, true>;
|
|
293
|
+
indicatorStyle?: WithDefault<'default' | 'black' | 'white', 'default'>;
|
|
294
|
+
newSource: Readonly<{
|
|
295
|
+
uri?: string;
|
|
296
|
+
method?: string;
|
|
297
|
+
body?: string;
|
|
298
|
+
|
|
299
|
+
headers?: ReadonlyArray<Readonly<{ name: string; value: string }>>;
|
|
300
|
+
html?: string;
|
|
301
|
+
baseUrl?: string;
|
|
302
|
+
}>;
|
|
303
|
+
userAgent?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface NativeCommands {
|
|
307
|
+
goBack: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
308
|
+
goForward: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
309
|
+
reload: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
310
|
+
stopLoading: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
311
|
+
injectJavaScript: (
|
|
312
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
313
|
+
javascript: string
|
|
314
|
+
) => void;
|
|
315
|
+
requestFocus: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
316
|
+
postMessage: (
|
|
317
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
318
|
+
data: string
|
|
319
|
+
) => void;
|
|
320
|
+
// Android Only
|
|
321
|
+
loadUrl: (
|
|
322
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
323
|
+
url: string
|
|
324
|
+
) => void;
|
|
325
|
+
clearFormData: (
|
|
326
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
327
|
+
) => void;
|
|
328
|
+
clearCache: (
|
|
329
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
330
|
+
includeDiskFiles: boolean
|
|
331
|
+
) => void;
|
|
332
|
+
clearHistory: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
333
|
+
// !Android Only
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
337
|
+
supportedCommands: [
|
|
338
|
+
'goBack',
|
|
339
|
+
'goForward',
|
|
340
|
+
'reload',
|
|
341
|
+
'stopLoading',
|
|
342
|
+
'injectJavaScript',
|
|
343
|
+
'requestFocus',
|
|
344
|
+
'postMessage',
|
|
345
|
+
'loadUrl',
|
|
346
|
+
'clearFormData',
|
|
347
|
+
'clearCache',
|
|
348
|
+
'clearHistory',
|
|
349
|
+
],
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
export default codegenNativeComponent<NativeProps>(
|
|
353
|
+
'RNCWebView'
|
|
354
|
+
) as HostComponent<NativeProps>;
|