├── entry
├── src
│ ├── mock
│ │ └── mock-config.json5
│ ├── main
│ │ ├── resources
│ │ │ ├── base
│ │ │ │ ├── profile
│ │ │ │ │ ├── backup_config.json
│ │ │ │ │ └── main_pages.json
│ │ │ │ ├── media
│ │ │ │ │ ├── background.png
│ │ │ │ │ ├── foreground.png
│ │ │ │ │ ├── startIcon.png
│ │ │ │ │ └── layered_image.json
│ │ │ │ └── element
│ │ │ │ │ ├── color.json
│ │ │ │ │ └── string.json
│ │ │ ├── zh_CN
│ │ │ │ └── element
│ │ │ │ │ └── string.json
│ │ │ ├── en_US
│ │ │ │ └── element
│ │ │ │ │ └── string.json
│ │ │ └── rawfile
│ │ │ │ └── index.html
│ │ ├── ets
│ │ │ ├── entrybackupability
│ │ │ │ └── EntryBackupAbility.ets
│ │ │ ├── entryability
│ │ │ │ └── EntryAbility.ets
│ │ │ └── pages
│ │ │ │ └── Index.ets
│ │ └── module.json5
│ ├── test
│ │ ├── List.test.ets
│ │ └── LocalUnit.test.ets
│ └── ohosTest
│ │ ├── ets
│ │ └── test
│ │ │ ├── List.test.ets
│ │ │ └── Ability.test.ets
│ │ └── module.json5
├── .gitignore
├── hvigorfile.ts
├── oh-package.json5
├── build-profile.json5
├── oh-package-lock.json5
└── obfuscation-rules.txt
├── webview_javascript_bridge
├── consumer-rules.txt
├── .gitignore
├── CHANGELOG.md
├── src
│ ├── test
│ │ ├── List.test.ets
│ │ └── LocalUnit.test.ets
│ ├── ohosTest
│ │ ├── ets
│ │ │ └── test
│ │ │ │ ├── List.test.ets
│ │ │ │ └── Ability.test.ets
│ │ └── module.json5
│ └── main
│ │ ├── resources
│ │ ├── base
│ │ │ └── element
│ │ │ │ └── string.json
│ │ ├── en_US
│ │ │ └── element
│ │ │ │ └── string.json
│ │ └── zh_CN
│ │ │ └── element
│ │ │ └── string.json
│ │ ├── module.json5
│ │ └── ets
│ │ ├── WebViewJavascriptBridge.ets
│ │ ├── WebViewJavascriptBridge_JS.ets
│ │ ├── WebViewJavascriptBridgeBase.ets
│ │ └── WebViewJavascriptBridgeTools.ets
├── hvigorfile.ts
├── Index.ets
├── oh-package.json5
├── BuildProfile.ets
├── build-profile.json5
├── obfuscation-rules.txt
├── LICENSE
└── README.md
├── wvjb_demo.gif
├── AppScope
├── resources
│ └── base
│ │ ├── media
│ │ └── app_icon.png
│ │ └── element
│ │ └── string.json
└── app.json5
├── .gitignore
├── oh-package.json5
├── hvigorfile.ts
├── oh-package-lock.json5
├── hvigor
└── hvigor-config.json5
└── README.md
/entry/src/mock/mock-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/consumer-rules.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/entry/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /oh_modules
3 | /.preview
4 | /build
5 | /.cxx
6 | /.test
--------------------------------------------------------------------------------
/entry/src/main/resources/base/profile/backup_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "allowToBackupRestore": true
3 | }
--------------------------------------------------------------------------------
/wvjb_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1ilI/WebViewJavascriptBridge_harmony/HEAD/wvjb_demo.gif
--------------------------------------------------------------------------------
/entry/src/main/resources/base/profile/main_pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "src": [
3 | "pages/Index"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /oh_modules
3 | /.preview
4 | /build
5 | /.cxx
6 | /.test
--------------------------------------------------------------------------------
/webview_javascript_bridge/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## 版本更新记录
3 |
4 | ### 2024/07/01 - 1.0.1
5 | 修改最低支持版本为 API 10
6 |
7 | ### 2024/06/28 - 1.0.0
8 | 初始发布
--------------------------------------------------------------------------------
/entry/src/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import localUnitTest from './LocalUnit.test';
2 |
3 | export default function testsuite() {
4 | localUnitTest();
5 | }
--------------------------------------------------------------------------------
/AppScope/resources/base/media/app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1ilI/WebViewJavascriptBridge_harmony/HEAD/AppScope/resources/base/media/app_icon.png
--------------------------------------------------------------------------------
/entry/src/ohosTest/ets/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import abilityTest from './Ability.test';
2 |
3 | export default function testsuite() {
4 | abilityTest();
5 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1ilI/WebViewJavascriptBridge_harmony/HEAD/entry/src/main/resources/base/media/background.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1ilI/WebViewJavascriptBridge_harmony/HEAD/entry/src/main/resources/base/media/foreground.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/startIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1ilI/WebViewJavascriptBridge_harmony/HEAD/entry/src/main/resources/base/media/startIcon.png
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import localUnitTest from './LocalUnit.test';
2 |
3 | export default function testsuite() {
4 | localUnitTest();
5 | }
--------------------------------------------------------------------------------
/AppScope/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "app_name",
5 | "value": "WebViewJavascriptBridge"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/entry/src/main/resources/base/element/color.json:
--------------------------------------------------------------------------------
1 | {
2 | "color": [
3 | {
4 | "name": "start_window_background",
5 | "value": "#FFFFFF"
6 | }
7 | ]
8 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/ohosTest/ets/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import abilityTest from './Ability.test';
2 |
3 | export default function testsuite() {
4 | abilityTest();
5 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/layered_image.json:
--------------------------------------------------------------------------------
1 | {
2 | "layered-image":
3 | {
4 | "background" : "$media:background",
5 | "foreground" : "$media:foreground"
6 | }
7 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "page_show",
5 | "value": "page from package"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/resources/en_US/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "page_show",
5 | "value": "page from package"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/resources/zh_CN/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "page_show",
5 | "value": "page from package"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /oh_modules
3 | /local.properties
4 | /.idea
5 | **/build
6 | /.hvigor
7 | .cxx
8 | /.clangd
9 | /.clang-format
10 | /.clang-tidy
11 | **/.test
12 | /.appanalyzer
13 | **/.DS_Store
--------------------------------------------------------------------------------
/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "description": "Please describe the basic information.",
4 | "dependencies": {
5 | },
6 | "devDependencies": {
7 | "@ohos/hypium": "1.0.18",
8 | "@ohos/hamock": "1.0.0"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { appTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/entry/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "webview_javascript_bridge",
4 | "type": "har",
5 | "deviceTypes": [
6 | "default",
7 | "tablet",
8 | "2in1",
9 | "car"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AppScope/app.json5:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "bundleName": "com.yue.WebViewJavascriptBridge",
4 | "vendor": "example",
5 | "versionCode": 1000000,
6 | "versionName": "1.0.0",
7 | "icon": "$media:app_icon",
8 | "label": "$string:app_name"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { harTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/entry/src/ohosTest/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "entry_test",
4 | "type": "feature",
5 | "deviceTypes": [
6 | "phone",
7 | "tablet",
8 | "2in1",
9 | "car"
10 | ],
11 | "deliveryWithInstall": true,
12 | "installationFree": false
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/entry/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "entry",
3 | "version": "1.0.0",
4 | "description": "Please describe the basic information.",
5 | "main": "",
6 | "author": "",
7 | "license": "",
8 | "dependencies": {
9 | '@yue/WebViewJavascriptBridge' : 'file:../webview_javascript_bridge'
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/entry/src/main/resources/zh_CN/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "模块描述"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/ohosTest/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "webview_javascript_bridge_test",
4 | "type": "feature",
5 | "deviceTypes": [
6 | "default",
7 | "tablet",
8 | "2in1",
9 | "car"
10 | ],
11 | "deliveryWithInstall": true,
12 | "installationFree": false
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/entry/src/main/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/en_US/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/Index.ets:
--------------------------------------------------------------------------------
1 |
2 |
3 | export { WVJBDelegate } from './src/main/ets/WebViewJavascriptBridgeBase'
4 |
5 | export { WVJBResponseCallback } from './src/main/ets/WebViewJavascriptBridgeBase'
6 |
7 | export { WebViewJavascriptBridge } from './src/main/ets/WebViewJavascriptBridge'
8 |
9 | export { WebViewJavascriptBridgeTools } from './src/main/ets/WebViewJavascriptBridgeTools'
--------------------------------------------------------------------------------
/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
3 |
4 | export default class EntryBackupAbility extends BackupExtensionAbility {
5 | async onBackup() {
6 | hilog.info(0x0000, 'testTag', 'onBackup ok');
7 | }
8 |
9 | async onRestore(bundleVersion: BundleVersion) {
10 | hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
11 | }
12 | }
--------------------------------------------------------------------------------
/entry/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | },
5 | "buildOptionSet": [
6 | {
7 | "name": "release",
8 | "arkOptions": {
9 | "obfuscation": {
10 | "ruleOptions": {
11 | "enable": true,
12 | "files": [
13 | "./obfuscation-rules.txt"
14 | ]
15 | }
16 | }
17 | }
18 | },
19 | ],
20 | "targets": [
21 | {
22 | "name": "default"
23 | },
24 | {
25 | "name": "ohosTest",
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@yue/webview_javascript_bridge",
3 | "version": "1.0.1",
4 | "description": "WebViewJavascriptBridge 在 HarmonyOS (API 10+)上的实现",
5 | "repository": "https://github.com/1ilI/WebViewJavascriptBridge_harmony.git",
6 | "homepage": "https://github.com/1ilI/WebViewJavascriptBridge_harmony",
7 | "main": "Index.ets",
8 | "author": "yue",
9 | "license": "Apache-2.0",
10 | "keywords": [
11 | "JSBridge",
12 | "WebView",
13 | "bridge loaded",
14 | "wvjb queue message",
15 | "桥接交互",
16 | ],
17 | "dependencies": {}
18 | }
19 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/BuildProfile.ets:
--------------------------------------------------------------------------------
1 | /**
2 | * Use these variables when you tailor your ArkTS code. They must be of the const type.
3 | */
4 | export const HAR_VERSION = '1.0.1';
5 | export const BUILD_MODE_NAME = 'debug';
6 | export const DEBUG = true;
7 | export const TARGET_NAME = 'default';
8 |
9 | /**
10 | * BuildProfile Class is used only for compatibility purposes.
11 | */
12 | export default class BuildProfile {
13 | static readonly HAR_VERSION = HAR_VERSION;
14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15 | static readonly DEBUG = DEBUG;
16 | static readonly TARGET_NAME = TARGET_NAME;
17 | }
--------------------------------------------------------------------------------
/entry/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "@yue/WebViewJavascriptBridge@../webview_javascript_bridge": "@yue/WebViewJavascriptBridge@../webview_javascript_bridge"
9 | },
10 | "packages": {
11 | "@yue/WebViewJavascriptBridge@../webview_javascript_bridge": {
12 | "name": "@yue/webview_javascript_bridge",
13 | "version": "1.0.1",
14 | "resolved": "../webview_javascript_bridge",
15 | "registryType": "local"
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | },
5 | "buildOptionSet": [
6 | {
7 | "name": "release",
8 | "arkOptions": {
9 | "obfuscation": {
10 | "ruleOptions": {
11 | "enable": true,
12 | "files": [
13 | "./obfuscation-rules.txt"
14 | ]
15 | },
16 | "consumerFiles": [
17 | "./consumer-rules.txt"
18 | ]
19 | }
20 | },
21 | },
22 | ],
23 | "targets": [
24 | {
25 | "name": "default"
26 | },
27 | {
28 | "name": "ohosTest"
29 | }
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/entry/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
--------------------------------------------------------------------------------
/webview_javascript_bridge/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
--------------------------------------------------------------------------------
/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
9 | "@ohos/hypium@1.0.18": "@ohos/hypium@1.0.18"
10 | },
11 | "packages": {
12 | "@ohos/hamock@1.0.0": {
13 | "name": "@ohos/hamock",
14 | "version": "1.0.0",
15 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==",
16 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har",
17 | "registryType": "ohpm"
18 | },
19 | "@ohos/hypium@1.0.18": {
20 | "name": "@ohos/hypium",
21 | "version": "1.0.18",
22 | "integrity": "sha512-RGe/iLGdeywdQilMWZsHKUoiE9OJ+9QxQsorF92R2ImLNVHVhbpSePNITGpW7TnvLgOIP/jscOqfIOhk6X7XRQ==",
23 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.18.har",
24 | "registryType": "ohpm"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/hvigor/hvigor-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "dependencies": {
4 | },
5 | "execution": {
6 | // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
7 | // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
8 | // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
9 | // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
10 | // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
11 | },
12 | "logging": {
13 | // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
14 | },
15 | "debugging": {
16 | // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
17 | },
18 | "nodeOptions": {
19 | // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
20 | // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/entry/src/main/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "entry",
4 | "type": "entry",
5 | "description": "$string:module_desc",
6 | "mainElement": "EntryAbility",
7 | "deviceTypes": [
8 | "phone",
9 | "tablet",
10 | "2in1",
11 | "car"
12 | ],
13 | "deliveryWithInstall": true,
14 | "installationFree": false,
15 | "pages": "$profile:main_pages",
16 | "abilities": [
17 | {
18 | "name": "EntryAbility",
19 | "srcEntry": "./ets/entryability/EntryAbility.ets",
20 | "description": "$string:EntryAbility_desc",
21 | "icon": "$media:layered_image",
22 | "label": "$string:EntryAbility_label",
23 | "startWindowIcon": "$media:startIcon",
24 | "startWindowBackground": "$color:start_window_background",
25 | "exported": true,
26 | "skills": [
27 | {
28 | "entities": [
29 | "entity.system.home"
30 | ],
31 | "actions": [
32 | "action.system.home"
33 | ]
34 | }
35 | ]
36 | }
37 | ],
38 | "extensionAbilities": [
39 | {
40 | "name": "EntryBackupAbility",
41 | "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
42 | "type": "backup",
43 | "exported": false,
44 | "metadata": [
45 | {
46 | "name": "ohos.extension.backup",
47 | "resource": "$profile:backup_config"
48 | }
49 | ],
50 | }
51 | ]
52 | }
53 | }
--------------------------------------------------------------------------------
/entry/src/main/ets/entryability/EntryAbility.ets:
--------------------------------------------------------------------------------
1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
2 | import { hilog } from '@kit.PerformanceAnalysisKit';
3 | import { window } from '@kit.ArkUI';
4 |
5 | export default class EntryAbility extends UIAbility {
6 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
7 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
8 | }
9 |
10 | onDestroy(): void {
11 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
12 | }
13 |
14 | onWindowStageCreate(windowStage: window.WindowStage): void {
15 | // Main window is created, set main page for this ability
16 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
17 |
18 | windowStage.loadContent('pages/Index', (err) => {
19 | if (err.code) {
20 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
21 | return;
22 | }
23 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
24 | });
25 | }
26 |
27 | onWindowStageDestroy(): void {
28 | // Main window is destroyed, release UI related resources
29 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
30 | }
31 |
32 | onForeground(): void {
33 | // Ability has brought to foreground
34 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
35 | }
36 |
37 | onBackground(): void {
38 | // Ability has back to background
39 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/entry/src/test/LocalUnit.test.ets:
--------------------------------------------------------------------------------
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 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/test/LocalUnit.test.ets:
--------------------------------------------------------------------------------
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 | }
--------------------------------------------------------------------------------
/entry/src/ohosTest/ets/test/Ability.test.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3 |
4 | export default function abilityTest() {
5 | describe('ActsAbilityTest', () => {
6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7 | beforeAll(() => {
8 | // Presets an action, which is performed only once before all test cases of the test suite start.
9 | // This API supports only one parameter: preset action function.
10 | })
11 | beforeEach(() => {
12 | // Presets an action, which is performed before each unit test case starts.
13 | // The number of execution times is the same as the number of test cases defined by **it**.
14 | // This API supports only one parameter: preset action function.
15 | })
16 | afterEach(() => {
17 | // Presets a clear action, which is performed after each unit test case ends.
18 | // The number of execution times is the same as the number of test cases defined by **it**.
19 | // This API supports only one parameter: clear action function.
20 | })
21 | afterAll(() => {
22 | // Presets a clear action, which is performed after all test cases of the test suite end.
23 | // This API supports only one parameter: clear action function.
24 | })
25 | it('assertContain', 0, () => {
26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28 | let a = 'abc';
29 | let b = 'b';
30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31 | expect(a).assertContain(b);
32 | expect(a).assertEqual(a);
33 | })
34 | })
35 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/ohosTest/ets/test/Ability.test.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3 |
4 | export default function abilityTest() {
5 | describe('ActsAbilityTest', () => {
6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7 | beforeAll(() => {
8 | // Presets an action, which is performed only once before all test cases of the test suite start.
9 | // This API supports only one parameter: preset action function.
10 | })
11 | beforeEach(() => {
12 | // Presets an action, which is performed before each unit test case starts.
13 | // The number of execution times is the same as the number of test cases defined by **it**.
14 | // This API supports only one parameter: preset action function.
15 | })
16 | afterEach(() => {
17 | // Presets a clear action, which is performed after each unit test case ends.
18 | // The number of execution times is the same as the number of test cases defined by **it**.
19 | // This API supports only one parameter: clear action function.
20 | })
21 | afterAll(() => {
22 | // Presets a clear action, which is performed after all test cases of the test suite end.
23 | // This API supports only one parameter: clear action function.
24 | })
25 | it('assertContain', 0, () => {
26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28 | let a = 'abc';
29 | let b = 'b';
30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31 | expect(a).assertContain(b);
32 | expect(a).assertEqual(a);
33 | })
34 | })
35 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/rawfile/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | WebViewJavascriptBridge
11 |
12 |
13 |
14 |
82 |
83 | WebViewJavascriptBridge
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/ets/WebViewJavascriptBridge.ets:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Yue 2024.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | *
15 | * Created by Yue on 2024/6/24.
16 | */
17 |
18 | import {
19 | WebViewJavascriptBridgeBase,
20 | WVJBDelegate,
21 | WVJBHandler,
22 | WVJBResponseCallback
23 | } from './WebViewJavascriptBridgeBase';
24 | import { FetchQueueJS } from './WebViewJavascriptBridge_JS';
25 |
26 | export interface SendParams {
27 | data: Object,
28 | responseCallback: WVJBResponseCallback,
29 | }
30 |
31 | export interface CallParams {
32 | data?: Object,
33 | handlerName: string,
34 | responseCallback?: WVJBResponseCallback,
35 | }
36 |
37 | export class WebViewJavascriptBridge implements WVJBDelegate {
38 | private _base: WebViewJavascriptBridgeBase = new WebViewJavascriptBridgeBase();
39 | private _webController: WebviewController | undefined;
40 |
41 | constructor(forWebController: WebviewController) {
42 | this._base.delegate = this;
43 | this._webController = forWebController;
44 | }
45 |
46 | public static enableLogging() {
47 | WebViewJavascriptBridgeBase.enableLogging();
48 | }
49 |
50 | public bridgeInterceptWithURL(url: string): boolean {
51 | if (this._base.isBridgeLoadedURL(url)) {
52 | this._base.injectJavascriptFile();
53 | return true;
54 | } else if (this._base.isQueueMessageURL(url)) {
55 | this._flushMessageQueue();
56 | return true;
57 | }
58 | return false;
59 | }
60 |
61 | public registerHandler(handlerName: string, handler: WVJBHandler) {
62 | this._base.messageHandlers.set(handlerName, handler);
63 | }
64 |
65 | public removeHandler(handlerName: string) {
66 | if (this._base.messageHandlers.has(handlerName)) {
67 | this._base.messageHandlers.delete(handlerName);
68 | }
69 | }
70 |
71 | public send(params: SendParams) {
72 | this._base.sendData(params?.data, params?.responseCallback, undefined);
73 | }
74 |
75 | public callHandler(params: CallParams) {
76 | this._base.sendData(params?.data, params?.responseCallback, params?.handlerName);
77 | }
78 |
79 | public reset() {
80 | this._base.reset();
81 | }
82 |
83 | evaluateJavascript(javascriptCommand: string): void {
84 | if (this._webController) {
85 | this._webController.runJavaScriptExt(javascriptCommand, (error, result) => {
86 | });
87 | } else {
88 | console.log('❌ WebViewJavascriptBridge 未初始化');
89 | }
90 | }
91 |
92 | private _flushMessageQueue() {
93 | if (this._webController) {
94 | this._webController.runJavaScriptExt(FetchQueueJS, (error, result) => {
95 | if (error) {
96 | console.log('❌执行 js 方法 _fetchQueue 出错' + error.message);
97 | }
98 | this._base.flushMessageQueue(result.getString());
99 | })
100 | } else {
101 | console.log('❌ WebViewJavascriptBridge 未初始化');
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/ets/WebViewJavascriptBridge_JS.ets:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Yue 2024.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | *
15 | * Created by Yue on 2024/6/11.
16 | */
17 |
18 | export const WebViewJavascriptBridge_JS = `
19 | ;(function() {
20 | if (window.WebViewJavascriptBridge) {
21 | return;
22 | }
23 |
24 | if (!window.onerror) {
25 | window.onerror = function(msg, url, line) {
26 | console.log("WebViewJavascriptBridge: ERROR:" + msg + "@" + url + ":" + line);
27 | }
28 | }
29 | window.WebViewJavascriptBridge = {
30 | registerHandler: registerHandler,
31 | callHandler: callHandler,
32 | disableJavscriptAlertBoxSafetyTimeout: disableJavscriptAlertBoxSafetyTimeout,
33 | _fetchQueue: _fetchQueue,
34 | _handleMessageFromHarmony: _handleMessageFromHarmony
35 | };
36 |
37 | var messagingIframe;
38 | var sendMessageQueue = [];
39 | var messageHandlers = {};
40 |
41 | var CUSTOM_PROTOCOL_SCHEME = 'https';
42 | var QUEUE_HAS_MESSAGE = '__wvjb_queue_message__';
43 |
44 | var responseCallbacks = {};
45 | var uniqueId = 1;
46 | var dispatchMessagesWithTimeoutSafety = true;
47 |
48 | function registerHandler(handlerName, handler) {
49 | messageHandlers[handlerName] = handler;
50 | }
51 |
52 | function callHandler(handlerName, data, responseCallback) {
53 | if (arguments.length == 2 && typeof data == 'function') {
54 | responseCallback = data;
55 | data = null;
56 | }
57 | _doSend({ handlerName:handlerName, data:data }, responseCallback);
58 | }
59 | function disableJavscriptAlertBoxSafetyTimeout() {
60 | dispatchMessagesWithTimeoutSafety = false;
61 | }
62 |
63 | function _doSend(message, responseCallback) {
64 | if (responseCallback) {
65 | var callbackId = 'cb_'+(uniqueId++)+'_'+new Date().getTime();
66 | responseCallbacks[callbackId] = responseCallback;
67 | message['callbackId'] = callbackId;
68 | }
69 | sendMessageQueue.push(message);
70 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE;
71 | }
72 |
73 | function _fetchQueue() {
74 | var messageQueueString = JSON.stringify(sendMessageQueue);
75 | sendMessageQueue = [];
76 | return messageQueueString;
77 | }
78 |
79 | function _dispatchMessageFromHarmony(messageJSON) {
80 | if (dispatchMessagesWithTimeoutSafety) {
81 | setTimeout(_doDispatchMessageFromHarmony);
82 | } else {
83 | _doDispatchMessageFromHarmony();
84 | }
85 |
86 | function _doDispatchMessageFromHarmony() {
87 | var message = JSON.parse(messageJSON);
88 | var messageHandler;
89 | var responseCallback;
90 |
91 | if (message.responseId) {
92 | responseCallback = responseCallbacks[message.responseId];
93 | if (!responseCallback) {
94 | return;
95 | }
96 | responseCallback(message.responseData);
97 | delete responseCallbacks[message.responseId];
98 | } else {
99 | if (message.callbackId) {
100 | var callbackResponseId = message.callbackId;
101 | responseCallback = function(responseData) {
102 | _doSend({ handlerName:message.handlerName, responseId:callbackResponseId, responseData:responseData });
103 | };
104 | }
105 |
106 | var handler = messageHandlers[message.handlerName];
107 | if (!handler) {
108 | console.log("WebViewJavascriptBridge: WARNING: no handler for message from Harmony:", JSON.stringify(message));
109 | } else {
110 | handler(message.data, responseCallback);
111 | }
112 | }
113 | }
114 | }
115 |
116 | function _handleMessageFromHarmony(messageJSON) {
117 | _dispatchMessageFromHarmony(messageJSON);
118 | }
119 |
120 | messagingIframe = document.createElement('iframe');
121 | messagingIframe.style.display = 'none';
122 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE;
123 | document.documentElement.appendChild(messagingIframe);
124 |
125 | registerHandler("_disableJavascriptAlertBoxSafetyTimeout", disableJavscriptAlertBoxSafetyTimeout);
126 |
127 | setTimeout(_callWVJBCallbacks, 0);
128 | function _callWVJBCallbacks() {
129 | var callbacks = window.WVJBCallbacks;
130 | if (callbacks) {
131 | delete window.WVJBCallbacks;
132 | for (var i=0; i {
41 | this.selectHasArgs = !this.selectHasArgs;
42 | })
43 | Checkbox({ name: '包含参数' }).select(this.selectHasArgs).onChange((value) => {
44 | this.selectHasArgs = value;
45 | })
46 | }.margin({ top: 10, bottom: 5 })
47 |
48 | Button('h5注册方法,原生从 h5 获取信息').onClick(() => {
49 | this._getH5Info();
50 | })
51 | }
52 | .width('100%')
53 | .height('30%')
54 | .backgroundColor(Color.Gray)
55 | }
56 |
57 | @Builder
58 | private webView() {
59 | Web({
60 | src: $rawfile('index.html'),
61 | controller: this._controller,
62 | })
63 | .width('100%')
64 | .height('70%')
65 | .zoomAccess(false)// 不允许缩放
66 | .domStorageAccess(true)
67 | .onControllerAttached(() => {
68 | // WebviewController 载入完成后,设置 WebViewJavascriptBridge
69 | this.setupWebViewJavascriptBridge();
70 | })
71 | .onAlert((event) => {
72 | AlertDialog.show({ message: event?.message })
73 | return false;
74 | })
75 | .onLoadIntercept((event) => {
76 | const url = event.data.getRequestUrl();
77 | // 符合 WebViewJavascriptBridge 的链接规则才拦截
78 | if (this._bridge?.bridgeInterceptWithURL(url)) {
79 | return true;
80 | }
81 | return false;
82 | });
83 | }
84 |
85 | /**
86 | * 设置 jsBridge
87 | */
88 | private setupWebViewJavascriptBridge() {
89 | // 开启调试,控制台打印信息,默认无调试
90 | WebViewJavascriptBridge.enableLogging();
91 | // 创建 WebViewJavascriptBridge
92 | this._bridge = new WebViewJavascriptBridge(this._controller);
93 | // 创建后,注册相关方法
94 | this._bridge.registerHandler('getNativeInfo', (data: Object, responseCallback: WVJBResponseCallback) => {
95 | if (data) {
96 | this._toast("JS 调用 getNativeInfo \n原生接收到参数:" + WebViewJavascriptBridgeTools.jsonStringify(data));
97 | } else {
98 | this._toast("JS 调用 getNativeInfo 没有向原生传递参数");
99 | }
100 |
101 | let map1 = new Map>([
102 | ["deviceInfo", new Map([
103 | ["types", "harmony"],
104 | ["debug", "1"],
105 | ])],
106 | ["userInfo", new Map([
107 | ["userId", "666666"],
108 | ["member_name", "用户名"],
109 | ])],
110 | ]);
111 | let map2: Record> = {
112 | "deviceInfo": {
113 | "types": "harmony",
114 | "debug": "1",
115 | },
116 | "userInfo": {
117 | "userId": "666666",
118 | "member_name": "用户名",
119 | }
120 | }
121 | // map1 和 map2 均可嵌套,生成 json 字符串,返回给 responseCallback
122 | const jsonStr: string = WebViewJavascriptBridgeTools.jsonStringify(map1);
123 | // const jsonStr: string = WebViewJavascriptBridgeTools.jsonStringify(map2);
124 | responseCallback(jsonStr);
125 | });
126 |
127 |
128 | // 原生主动调用 H5 方法,获取 H5 侧的信息
129 | this._bridge.callHandler({
130 | handlerName: 'getH5InfoOnStar', responseCallback: (responseData) => {
131 | this._toast("初始化时原生调用 getH5InfoOnStar \n接收到结果:" +
132 | WebViewJavascriptBridgeTools.jsonStringify(responseData));
133 | }
134 | })
135 |
136 | }
137 |
138 | private _getH5Info() {
139 | let arg1 = new Map>([
140 | ["key", "1"],
141 | ["h5Info", new Map([
142 | ["id", "1111"],
143 | ["k", "v"],
144 | ])],
145 | ]);
146 | let arg2: Record> = {
147 | "key": "2",
148 | "h5Info": { "id": "222", "k2": "v2" }
149 | }
150 |
151 | if (this.selectHasArgs) {
152 | this._bridge?.callHandler({
153 | handlerName: 'getH5Info',
154 | data: arg2,
155 | responseCallback: (responseData) => {
156 | this._toast(WebViewJavascriptBridgeTools.jsonStringify(responseData));
157 | }
158 | })
159 | }
160 | // 无参数传递
161 | else {
162 | this._bridge?.callHandler({
163 | handlerName: 'getH5Info',
164 | responseCallback: (responseData) => {
165 | this._toast(WebViewJavascriptBridgeTools.jsonStringify(responseData));
166 | }
167 | })
168 | }
169 | }
170 |
171 | private _toast(msg: string) {
172 | promptAction.showToast({
173 | message: msg,
174 | duration: 4000
175 | });
176 | }
177 | }
--------------------------------------------------------------------------------
/webview_javascript_bridge/src/main/ets/WebViewJavascriptBridgeBase.ets:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Yue 2024.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | *
15 | * Created by Yue on 2024/6/24.
16 | */
17 |
18 | import { WebViewJavascriptBridgeTools } from './WebViewJavascriptBridgeTools';
19 | import { JSON } from '@kit.ArkTS';
20 | import { WebViewJavascriptBridge_JS } from './WebViewJavascriptBridge_JS';
21 |
22 | const _LogTAG: string = "[WebViewJavascriptBridge]";
23 | let _logging: boolean = false;
24 | let _logMaxLength: number = 800;
25 |
26 | export type WVJBResponseCallback = (responseData: Object) => void;
27 |
28 | export type WVJBHandler = (data: Object, responseCallback: WVJBResponseCallback) => void;
29 |
30 | export interface WVJBDelegate {
31 | evaluateJavascript(javascriptCommand: string): void;
32 | }
33 |
34 | export class WebViewJavascriptBridgeBase {
35 | delegate?: WVJBDelegate;
36 | startupMessageQueue: Array