From 67803a1d49f264b4bb3263b1c8d1c1091e74c648 Mon Sep 17 00:00:00 2001 From: lijuan Date: Mon, 11 Nov 2024 15:55:08 +0800 Subject: [PATCH 1/7] =?UTF-8?q?flutter=5Fjsbridge=5Fplugin=E5=BA=93ohos?= =?UTF-8?q?=E4=BE=A7=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijuan --- OAT.xml | 84 ++++++ ohos/.gitignore | 30 +++ ohos/.metadata | 30 +++ ohos/CHANGELOG.md | 3 + ohos/LICENSE | 27 ++ ohos/README.md | 70 +++++ ohos/analysis_options.yaml | 4 + ohos/example/.gitignore | 44 ++++ ohos/example/README.md | 16 ++ ohos/example/analysis_options.yaml | 29 +++ ohos/example/lib/main.dart | 105 ++++++++ ohos/example/ohos/.gitignore | 19 ++ ohos/example/ohos/AppScope/app.json5 | 10 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes ohos/example/ohos/build-profile.json5 | 27 ++ ohos/example/ohos/entry/.gitignore | 7 + ohos/example/ohos/entry/build-profile.json5 | 29 +++ ohos/example/ohos/entry/hvigorfile.ts | 17 ++ ohos/example/ohos/entry/oh-package.json5 | 12 + .../main/ets/entryability/EntryAbility.ets | 24 ++ .../ohos/entry/src/main/ets/pages/Index.ets | 38 +++ .../ets/plugins/GeneratedPluginRegistrant.ets | 28 ++ ohos/example/ohos/entry/src/main/module.json5 | 53 ++++ .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 ++ .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + .../main/resources/en_US/element/string.json | 16 ++ .../main/resources/zh_CN/element/string.json | 16 ++ .../src/ohosTest/ets/test/Ability.test.ets | 50 ++++ .../entry/src/ohosTest/ets/test/List.test.ets | 20 ++ .../ohosTest/ets/testability/TestAbility.ets | 63 +++++ .../ohosTest/ets/testability/pages/Index.ets | 49 ++++ .../ets/testrunner/OpenHarmonyTestRunner.ts | 64 +++++ .../ohos/entry/src/ohosTest/module.json5 | 51 ++++ .../resources/base/element/color.json | 8 + .../resources/base/element/string.json | 16 ++ .../ohosTest/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/test_pages.json | 5 + ohos/example/ohos/hvigor/hvigor-config.json5 | 23 ++ ohos/example/ohos/hvigorfile.ts | 21 ++ ohos/example/ohos/oh-package.json5 | 21 ++ ohos/example/pubspec.yaml | 87 +++++++ ohos/example/test/widget_test.dart | 27 ++ ohos/lib/flutterjsbridgeplugin.dart | 34 +++ ohos/lib/init_script.dart | 242 ++++++++++++++++++ ohos/lib/js_bridge.dart | 124 +++++++++ ohos/lib/js_obj.dart | 59 +++++ ohos/ohos/.gitignore | 9 + ohos/ohos/build-profile.json5 | 10 + ohos/ohos/hvigorfile.ts | 2 + ohos/ohos/index.ets | 17 ++ ohos/ohos/oh-package.json5 | 11 + .../FlutterJsbridgePluginOhosPlugin.ets | 59 +++++ ohos/ohos/src/main/module.json5 | 10 + ohos/pubspec.yaml | 76 ++++++ .../flutter_jsbridge_plugin_ohos_test.dart | 20 ++ 58 files changed, 1953 insertions(+) create mode 100644 OAT.xml create mode 100644 ohos/.gitignore create mode 100644 ohos/.metadata create mode 100644 ohos/CHANGELOG.md create mode 100644 ohos/LICENSE create mode 100644 ohos/README.md create mode 100644 ohos/analysis_options.yaml create mode 100644 ohos/example/.gitignore create mode 100644 ohos/example/README.md create mode 100644 ohos/example/analysis_options.yaml create mode 100644 ohos/example/lib/main.dart create mode 100644 ohos/example/ohos/.gitignore create mode 100644 ohos/example/ohos/AppScope/app.json5 create mode 100644 ohos/example/ohos/AppScope/resources/base/element/string.json create mode 100644 ohos/example/ohos/AppScope/resources/base/media/app_icon.png create mode 100644 ohos/example/ohos/build-profile.json5 create mode 100644 ohos/example/ohos/entry/.gitignore create mode 100644 ohos/example/ohos/entry/build-profile.json5 create mode 100644 ohos/example/ohos/entry/hvigorfile.ts create mode 100644 ohos/example/ohos/entry/oh-package.json5 create mode 100644 ohos/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 ohos/example/ohos/entry/src/main/ets/pages/Index.ets create mode 100644 ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets create mode 100644 ohos/example/ohos/entry/src/main/module.json5 create mode 100644 ohos/example/ohos/entry/src/main/resources/base/element/color.json create mode 100644 ohos/example/ohos/entry/src/main/resources/base/element/string.json create mode 100644 ohos/example/ohos/entry/src/main/resources/base/media/icon.png create mode 100644 ohos/example/ohos/entry/src/main/resources/base/profile/main_pages.json create mode 100644 ohos/example/ohos/entry/src/main/resources/en_US/element/string.json create mode 100644 ohos/example/ohos/entry/src/main/resources/zh_CN/element/string.json create mode 100644 ohos/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 ohos/example/ohos/entry/src/ohosTest/ets/test/List.test.ets create mode 100644 ohos/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets create mode 100644 ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets create mode 100644 ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts create mode 100644 ohos/example/ohos/entry/src/ohosTest/module.json5 create mode 100644 ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json create mode 100644 ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json create mode 100644 ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png create mode 100644 ohos/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 ohos/example/ohos/hvigor/hvigor-config.json5 create mode 100644 ohos/example/ohos/hvigorfile.ts create mode 100644 ohos/example/ohos/oh-package.json5 create mode 100644 ohos/example/pubspec.yaml create mode 100644 ohos/example/test/widget_test.dart create mode 100644 ohos/lib/flutterjsbridgeplugin.dart create mode 100644 ohos/lib/init_script.dart create mode 100644 ohos/lib/js_bridge.dart create mode 100644 ohos/lib/js_obj.dart create mode 100644 ohos/ohos/.gitignore create mode 100644 ohos/ohos/build-profile.json5 create mode 100644 ohos/ohos/hvigorfile.ts create mode 100644 ohos/ohos/index.ets create mode 100644 ohos/ohos/oh-package.json5 create mode 100644 ohos/ohos/src/main/ets/components/plugin/FlutterJsbridgePluginOhosPlugin.ets create mode 100644 ohos/ohos/src/main/module.json5 create mode 100644 ohos/pubspec.yaml create mode 100644 ohos/test/flutter_jsbridge_plugin_ohos_test.dart diff --git a/OAT.xml b/OAT.xml new file mode 100644 index 0000000..e6c6f55 --- /dev/null +++ b/OAT.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ohos/.gitignore b/ohos/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/ohos/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/ohos/.metadata b/ohos/.metadata new file mode 100644 index 0000000..f3ef596 --- /dev/null +++ b/ohos/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 6e880180d1be82672dba0917db429179217f1172 + channel: master + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 6e880180d1be82672dba0917db429179217f1172 + base_revision: 6e880180d1be82672dba0917db429179217f1172 + - platform: ohos + create_revision: 6e880180d1be82672dba0917db429179217f1172 + base_revision: 6e880180d1be82672dba0917db429179217f1172 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/ohos/CHANGELOG.md b/ohos/CHANGELOG.md new file mode 100644 index 0000000..abd84ca --- /dev/null +++ b/ohos/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Support OpenHarmony. \ No newline at end of file diff --git a/ohos/LICENSE b/ohos/LICENSE new file mode 100644 index 0000000..8940a4b --- /dev/null +++ b/ohos/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ohos/README.md b/ohos/README.md new file mode 100644 index 0000000..493be3c --- /dev/null +++ b/ohos/README.md @@ -0,0 +1,70 @@ +# flutter_jsbridge_plugin_ohos + +# Add JsBridge Plugin to the WebView + +[A Flutter plugin that provides a JsBridge on WebView widget.](https://pub.dev/packages/bridge_webview_flutter) + +This plugin must introduce [webview_flutter](https://pub.dev/packages/webview_flutter) + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Ohos. + +For help getting started with Flutter development, view the +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + +## Usage + +```yaml +dependencies: + flutter_jsbridge_plugin: 0.0.5 + flutter_jsbridge_plugin_ohos: 1.0.0 +``` + +### Init JsBridge and register handler + +``` +... +final JsBridge _jsBridge = JsBridge(); +... +WebView( + initialUrl: "https://www.baidu.com?timeStamp=${new DateTime.now().millisecondsSinceEpoch}", + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: (WebViewController webViewController) async { + _jsBridge.loadJs(webViewController); + _controller.complete(webViewController); + _jsBridge.registerHandler("getToken", onCallBack: (data, func) { + // return token to js + func({"token": "token"}); + }); + _jsBridge.registerHandler("IAPpayment", onCallBack: (data, func) { + print("js call flutter iap"); + }); + _jsBridge.registerHandler("back", onCallBack: (data, func) { + print("js call flutter back"); + }); + }, + navigationDelegate: (NavigationRequest request) { + if (_jsBridge.handlerUrl(request.url)) { + return NavigationDecision.navigate; + } + return NavigationDecision.prevent; + }, + onPageStarted: (url) { + _jsBridge.init(); + }, +)) + +``` + +## JS Usage +[js file](https://github.com/epoll-j/flutter_jsbridge_plugin/blob/master/JSBridge.js) + +## 支持格式 +| 格式 |android|ios| harmonyOS | +|:-----------------|:----:|:----:|:--------------:| +| getPlatformVersion|✅ | ✅ | ✅ | \ No newline at end of file diff --git a/ohos/analysis_options.yaml b/ohos/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/ohos/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/ohos/example/.gitignore b/ohos/example/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/ohos/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/ohos/example/README.md b/ohos/example/README.md new file mode 100644 index 0000000..a9f56a8 --- /dev/null +++ b/ohos/example/README.md @@ -0,0 +1,16 @@ +# flutter_jsbridge_plugin_ohos_example + +Demonstrates how to use the flutter_jsbridge_plugin_ohos plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/ohos/example/analysis_options.yaml b/ohos/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/ohos/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/ohos/example/lib/main.dart b/ohos/example/lib/main.dart new file mode 100644 index 0000000..d12eaef --- /dev/null +++ b/ohos/example/lib/main.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_jsbridge_plugin_ohos/flutterjsbridgeplugin.dart'; +import 'package:flutter_jsbridge_plugin_ohos/js_bridge.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + + final Completer _controller = Completer(); + final JsBridge _jsBridge = JsBridge(); + late final WebViewController _webcontroller; + + @override + void initState() { + super.initState(); + initPlatformState(); + + WidgetsBinding.instance.addPostFrameCallback((_) { + try{ + _jsBridge.loadJs(_webcontroller); + _controller.complete(_webcontroller); + _jsBridge.registerHandler("getToken", onCallBack: (data, func) { + // return token to js + func({"token": "token"}); + }); + _jsBridge.registerHandler("IAPpayment", onCallBack: (data, func) { + print("js call flutter iap"); + }); + _jsBridge.registerHandler("back", onCallBack: (data, func) { + print("js call flutter back"); + }); + }catch(error){ + print('main WidgetsBinding error:$error'); + } + }); + + _webcontroller = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setBackgroundColor(const Color(0x00000000)) + ..setNavigationDelegate( + NavigationDelegate( + onProgress: (int progress) { + // Update loading bar. + }, + onPageStarted: (String url) { + _jsBridge.init(); + }, + onPageFinished: (String url) {}, + onWebResourceError: (WebResourceError error) {}, + onNavigationRequest: (NavigationRequest request) { + if (_jsBridge.handlerUrl(request.url)) { + return NavigationDecision.navigate; + } + return NavigationDecision.prevent; + }, + ), + ) + ..loadRequest(Uri.parse('https://juejin.cn?timeStamp=${new DateTime.now().millisecondsSinceEpoch}')); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + try { + platformVersion = await Flutterjsbridgeplugin.platformVersion; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: WebViewWidget( + controller: _webcontroller, + )), + ); + } +} diff --git a/ohos/example/ohos/.gitignore b/ohos/example/ohos/.gitignore new file mode 100644 index 0000000..6ca13b3 --- /dev/null +++ b/ohos/example/ohos/.gitignore @@ -0,0 +1,19 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +*.har +**/BuildProfile.ets +**/oh-package-lock.json5 + +**/src/main/resources/rawfile/flutter_assets/ +**/libs/arm64-v8a/libapp.so +**/libs/arm64-v8a/libflutter.so +**/libs/arm64-v8a/libvmservice_snapshot.so diff --git a/ohos/example/ohos/AppScope/app.json5 b/ohos/example/ohos/AppScope/app.json5 new file mode 100644 index 0000000..c55462f --- /dev/null +++ b/ohos/example/ohos/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.flutter_jsbridge_plugin.flutter_jsbridge_plugin_ohos_example", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} \ No newline at end of file diff --git a/ohos/example/ohos/AppScope/resources/base/element/string.json b/ohos/example/ohos/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..e37bfea --- /dev/null +++ b/ohos/example/ohos/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "flutter_jsbridge_plugin_ohos_example" + } + ] +} diff --git a/ohos/example/ohos/AppScope/resources/base/media/app_icon.png b/ohos/example/ohos/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(Xn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n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets b/ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000..cef0447 --- /dev/null +++ b/ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000..1def08f --- /dev/null +++ b/ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/ohos/example/ohos/entry/src/ohosTest/module.json5 b/ohos/example/ohos/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..fab77ce --- /dev/null +++ b/ohos/example/ohos/entry/src/ohosTest/module.json5 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json b/ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000..3c71296 --- /dev/null +++ b/ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json b/ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000..65d8fa5 --- /dev/null +++ b/ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png b/ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+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@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y=2.19.6 <3.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + flutter_jsbridge_plugin_ohos: + # When depending on this package from a real application you should use: + # flutter_jsbridge_plugin_ohos: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + webview_flutter: + git: + url: "https://gitee.com/openharmony-sig/flutter_packages.git" + path: "packages/webview_flutter-v4.4.4/webview_flutter" + +dev_dependencies: + flutter_test: + sdk: flutter + espresso: ^0.2.0 + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/ohos/example/test/widget_test.dart b/ohos/example/test/widget_test.dart new file mode 100644 index 0000000..a600522 --- /dev/null +++ b/ohos/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_jsbridge_plugin_ohos_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/ohos/lib/flutterjsbridgeplugin.dart b/ohos/lib/flutterjsbridgeplugin.dart new file mode 100644 index 0000000..92fa795 --- /dev/null +++ b/ohos/lib/flutterjsbridgeplugin.dart @@ -0,0 +1,34 @@ +import 'dart:async'; +import 'package:flutter/services.dart'; + +class Flutterjsbridgeplugin { + static const MethodChannel _channel = + MethodChannel('flutterjsbridgeplugin'); + + Flutterjsbridgeplugin() { + _channel.setMethodCallHandler(_onMethodCall); + } + + static Future get platformVersion async { + final String version = await _channel.invokeMethod('getPlatformVersion'); + print('get platformVersion version: $version'); + return version; + } + + static Future get scrpit async { + final String initScript = await _channel.invokeMethod("getScript"); + return "javascript:$initScript"; + } + + Future isMainThread() async { + return await _channel.invokeMethod("isMainThread"); + } + + Future handlerReturnData(String url) async { + return await _channel.invokeMethod("handlerReturnData", url); + } + + Future _onMethodCall(MethodCall call) async { + return false; + } +} diff --git a/ohos/lib/init_script.dart b/ohos/lib/init_script.dart new file mode 100644 index 0000000..fcbd257 --- /dev/null +++ b/ohos/lib/init_script.dart @@ -0,0 +1,242 @@ +// ignore: non_constant_identifier_names +String init_script_android = ''' +(function() { + if (window.WebViewJavascriptBridge) { + return; + } + + var lastCallTime = 0; + var stoId = null; + var FETCH_QUEUE = 50; + + var messagingIframe; + var sendMessageQueue = []; + var receiveMessageQueue = []; + var messageHandlers = {}; + var timer = null; + + var CUSTOM_PROTOCOL_SCHEME = 'jsbridge'; + var QUEUE_HAS_MESSAGE = '__QUEUE_MESSAGE__/'; + + var responseCallbacks = {}; + var uniqueId = 1; + + var base64encodechars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + function base64encode(str) { + if (str === undefined) { + return str; + } + + var out, i, len; + var c1, c2, c3; + len = str.length; + i = 0; + out = ""; + while (i < len) { + c1 = str.charCodeAt(i++) & 0xff; + if (i == len) { + out += base64encodechars.charAt(c1 >> 2); + out += base64encodechars.charAt((c1 & 0x3) << 4); + out += "=="; + break; + } + c2 = str.charCodeAt(i++); + if (i == len) { + out += base64encodechars.charAt(c1 >> 2); + out += base64encodechars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); + out += base64encodechars.charAt((c2 & 0xf) << 2); + out += "="; + break; + } + c3 = str.charCodeAt(i++); + out += base64encodechars.charAt(c1 >> 2); + out += base64encodechars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); + out += base64encodechars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6)); + out += base64encodechars.charAt(c3 & 0x3f); + } + return out; + } + + + function _createQueueReadyIframe(doc) { +// messagingIframe = doc.createElement('iframe'); +// messagingIframe.style.display = 'none'; +// doc.documentElement.appendChild(messagingIframe); + } + + function isAndroid() { + var ua = navigator.userAgent.toLowerCase(); + var isA = ua.indexOf("android") > -1; + if (isA) { + return true; + } + return false; + } + + function isIphone() { + var ua = navigator.userAgent.toLowerCase(); + var isIph = ua.indexOf("iphone") > -1; + if (isIph) { + return true; + } + return false; + } + + //set default messageHandler + function init(messageHandler) { + if (WebViewJavascriptBridge._messageHandler) { + throw new Error('WebViewJavascriptBridge.init called twice'); + } + WebViewJavascriptBridge._messageHandler = messageHandler; + var receivedMessages = receiveMessageQueue; + receiveMessageQueue = null; + for (var i = 0; i < receivedMessages.length; i++) { + _dispatchMessageFromNative(receivedMessages[i]); + } + } + + function send(data, responseCallback) { + _doSend({ + data: data + }, responseCallback); + } + + function registerHandler(handlerName, handler) { + messageHandlers[handlerName] = handler; + } + + function callHandler(handlerName, data, responseCallback) { + console.log(handlerName); + _doSend({ + handlerName: handlerName, + data: data + }, responseCallback); + } + + //sendMessage add message, 触发native处理 sendMessage + function _doSend(message, responseCallback) { + console.log('send'); + if (responseCallback) { + var callbackId = 'cb_' + (uniqueId++) + '_' + new Date().getTime(); + responseCallbacks[callbackId] = responseCallback; + message.callbackId = callbackId; + } + sendMessageQueue.push(message); + if (!timer) { + timer = setTimeout(function() { + _getIframe().src = CUSTOM_PROTOCOL_SCHEME + '://return/sendMsg/' + encodeURIComponent(JSON.stringify(sendMessageQueue)); + sendMessageQueue = []; + timer = null; + }, 30); + } + } + + // 提供给native调用,该函数作用:获取sendMessageQueue返回给native,由于android不能直接获取返回的内容,所以使用url shouldOverrideUrlLoading 的方式返回内容 + function _fetchQueue() { + if (sendMessageQueue.length === 0) { + return; + } + + if (new Date().getTime() - lastCallTime < FETCH_QUEUE) { + if (!stoId) { + stoId = setTimeout(_fetchQueue, FETCH_QUEUE); + } + return; + } + + lastCallTime = new Date().getTime(); + stoId = null; + + var messageQueueString = JSON.stringify(sendMessageQueue); + sendMessageQueue = []; + if (messageQueueString === '[]') { + return; + } + + _getIframe().src = CUSTOM_PROTOCOL_SCHEME + '://return/sendMsg/' + encodeURIComponent(messageQueueString); + +// var messageQueueString = JSON.stringify(sendMessageQueue); +// sendMessageQueue = []; +// //add by hq +// if (isIphone()) { +// return messageQueueString; +// //android can't read directly the return data, so we can reload iframe src to communicate with java +// } else if (isAndroid()) { +// messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://return/sendMsg/' + encodeURIComponent(messageQueueString); +// } + } + + //提供给native使用, + function _dispatchMessageFromNative(messageJSON) { + setTimeout(function() { + var message = JSON.parse(messageJSON); + var responseCallback; + //java call finished, now need to call js callback function + if (message.responseId) { + responseCallback = responseCallbacks[message.responseId]; + if (!responseCallback) { + return; + } + responseCallback(message.responseData); + delete responseCallbacks[message.responseId]; + } else { + //直接发送 + if (message.callbackId) { + var callbackResponseId = message.callbackId; + responseCallback = function(responseData) { + _doSend({ + responseId: callbackResponseId, + responseData: responseData + }); + }; + } + var handler = WebViewJavascriptBridge._messageHandler; + if (message.handlerName) { + handler = messageHandlers[message.handlerName]; + } + //查找指定handler + try { + handler(message.data, responseCallback); + } catch (exception) { + if (typeof console != 'undefined') { + console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception); + } + } + } + }); + } + + //提供给native调用,receiveMessageQueue 在会在页面加载完后赋值为null,所以 + function _handleMessageFromNative(messageJSON) { +// if (receiveMessageQueue) { +// receiveMessageQueue.push(messageJSON); +// } else { + _dispatchMessageFromNative(messageJSON); +// } + } + + function _getIframe() { + if (typeof(messagingIframe) == 'undefined') { + messagingIframe = document.createElement('iframe'); + messagingIframe.style.display = 'none'; + document.documentElement.appendChild(messagingIframe); + } + return messagingIframe; + } + + var WebViewJavascriptBridge = window.WebViewJavascriptBridge = { + init: init, + send: send, + registerHandler: registerHandler, + callHandler: callHandler, + _handleMessageFromNative: _handleMessageFromNative, + _fetchQueue: _fetchQueue + }; + + var doc = document; +// _createQueueReadyIframe(doc); + var readyEvent = doc.createEvent('Events'); + readyEvent.initEvent('WebViewJavascriptBridgeReady'); + readyEvent.bridge = WebViewJavascriptBridge; + doc.dispatchEvent(readyEvent); +})();'''; \ No newline at end of file diff --git a/ohos/lib/js_bridge.dart b/ohos/lib/js_bridge.dart new file mode 100644 index 0000000..6668981 --- /dev/null +++ b/ohos/lib/js_bridge.dart @@ -0,0 +1,124 @@ +import 'dart:io'; + +import 'package:webview_flutter/webview_flutter.dart'; +import 'dart:convert' as convert; +import 'package:sprintf/sprintf.dart'; + +import 'init_script.dart'; +import 'js_obj.dart'; + +typedef CallBackFunction = void Function(dynamic data); +typedef BridgeHandler = void Function(dynamic data, CallBackFunction function); + +class JsBridge { + WebViewController _webViewController = WebViewController(); + Map _callbacks = Map(); + Map _handlers = Map(); + int _uniqueId = 0; + static final String _protocolScheme = "jsbridge://"; + final String _fetchData = "${_protocolScheme}return/fetch"; + final String _returnData = "${_protocolScheme}return/sendMsg/"; + String _dartToJs = + "javascript:WebViewJavascriptBridge._handleMessageFromNative('%s');"; + + void loadJs(WebViewController controller) { + _webViewController = controller; + init(); + } + + void init() { + if (_webViewController == null) { + throw "WebViewController must not null"; + } + + _loadJs(init_script_android); + } + + bool handlerUrl(String url) { + return _handlerReturnData(url); + } + + bool _handlerReturnData(String url) { + if (url.startsWith(_protocolScheme)) { + if (url == _fetchData) { + _fetchQueue(); + } else { + List list = JsMsg.fromList(convert + .jsonDecode(Uri.decodeComponent(url).replaceAll(_returnData, ""))); + print(list); + for (JsMsg msg in list) { + print(msg); + if (msg.responseId != null) { + + } else { + late CallBackFunction function; + if (msg.callbackId != null) { + if (msg.callbackId != null) { + function = (dynamic data) { + JsMsg callbackMsg = JsMsg(); + callbackMsg.responseId = msg.callbackId; + callbackMsg.responseData = convert.jsonEncode(data); + // 发送 + _loadJs(sprintf(_dartToJs, [_replaceJson(callbackMsg.toJson())])); + }; + } + } else { + function = (dynamic data) {}; + } + BridgeHandler? handler; + if (msg.handlerName != null) { + handler = _handlers[msg.handlerName]; + } + if (handler != null) { + handler.call(msg.data, function); + } + } + } + } + return false; + } + return true; + } + + void _fetchQueue() { + _loadJs("WebViewJavascriptBridge._fetchQueue()"); + } + + void callHandler(String handlerName, + {dynamic data, required CallBackFunction onCallBack}) { + JsRequest request = JsRequest(); + request.handlerName = handlerName; + if (data != null) { + if (data is String) { + request.data = data; + } else { + request.data = convert.jsonEncode(data); + } + } + request.callbackId = _generateId(); + if (onCallBack != null) { + _callbacks[request.callbackId] = onCallBack; + } + _loadJs(sprintf(_dartToJs, [_replaceJson(request.toJson())])); + } + + void registerHandler(String handlerName, + {dynamic data, required BridgeHandler onCallBack}) { + if (onCallBack != null) { + _handlers[handlerName] = onCallBack; + } + } + + String _generateId() { + return "flutter_cb_${_uniqueId++}"; + } + + String _replaceJson(String json) { + json = json.replaceAll("\\", "\\\\"); + return json; + } + + void _loadJs(String script) { + _webViewController.runJavaScript(script); + } +} diff --git a/ohos/lib/js_obj.dart b/ohos/lib/js_obj.dart new file mode 100644 index 0000000..8b0fdc0 --- /dev/null +++ b/ohos/lib/js_obj.dart @@ -0,0 +1,59 @@ +import 'dart:convert' as convert; + +class JsRequest { + late String callbackId; + late String data; + late String handlerName; + + String toJson() { + return convert.jsonEncode({ + "callbackId": callbackId ?? "", + "data": data ?? "", + "handlerName": handlerName ?? "" + }); + } +} + +class JsMsg { + late String callbackId; //callbackId + late String responseId; //responseId + late String responseData; //responseData + late String data; //data of message + late String handlerName; + + JsMsg(); + + static List fromList(List list) { + List msgList = []; + for (Map json in list) { + JsMsg msg = JsMsg(); + msg.callbackId = json["callbackId"]; + msg.responseId = json["responseId"]; + msg.responseData = convert.jsonEncode(json["responseData"]); + msg.data = convert.jsonEncode(json["data"]); + msg.handlerName = json["handlerName"]; + msgList.add(msg); + } + return msgList; + } + + factory JsMsg.formJson(Map json) { + JsMsg msg = JsMsg(); + msg.callbackId = json["callbackId"]; + msg.responseId = json["responseId"]; + msg.responseData = convert.jsonEncode(json["responseData"]); + msg.data = convert.jsonEncode(json["data"]); + msg.handlerName = json["handlerName"]; + return msg; + } + + String toJson() { + return convert.jsonEncode({ + "callbackId": callbackId ?? "", + "responseId": responseId ?? "", + "responseData": responseData ?? "", + "data": data ?? "", + "handlerName": handlerName ?? "" + }); + } +} diff --git a/ohos/ohos/.gitignore b/ohos/ohos/.gitignore new file mode 100644 index 0000000..c0f9ca4 --- /dev/null +++ b/ohos/ohos/.gitignore @@ -0,0 +1,9 @@ +/node_modules +/oh_modules +/.preview +/.idea +/build +/.cxx +/.test +/BuildProfile.ets +/oh-package-lock.json5 diff --git a/ohos/ohos/build-profile.json5 b/ohos/ohos/build-profile.json5 new file mode 100644 index 0000000..79961f9 --- /dev/null +++ b/ohos/ohos/build-profile.json5 @@ -0,0 +1,10 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/ohos/ohos/hvigorfile.ts b/ohos/ohos/hvigorfile.ts new file mode 100644 index 0000000..47e6e1f --- /dev/null +++ b/ohos/ohos/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/ohos/ohos/index.ets b/ohos/ohos/index.ets new file mode 100644 index 0000000..2097fef --- /dev/null +++ b/ohos/ohos/index.ets @@ -0,0 +1,17 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FlutterJsbridgePluginOhosPlugin from './src/main/ets/components/plugin/FlutterJsbridgePluginOhosPlugin'; +export default FlutterJsbridgePluginOhosPlugin; diff --git a/ohos/ohos/oh-package.json5 b/ohos/ohos/oh-package.json5 new file mode 100644 index 0000000..f089a4c --- /dev/null +++ b/ohos/ohos/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "flutter_jsbridge_plugin_ohos", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@ohos/flutter_ohos": "file:./har/flutter.har" + } +} diff --git a/ohos/ohos/src/main/ets/components/plugin/FlutterJsbridgePluginOhosPlugin.ets b/ohos/ohos/src/main/ets/components/plugin/FlutterJsbridgePluginOhosPlugin.ets new file mode 100644 index 0000000..56941ae --- /dev/null +++ b/ohos/ohos/src/main/ets/components/plugin/FlutterJsbridgePluginOhosPlugin.ets @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + FlutterPlugin, + FlutterPluginBinding, + MethodCall, + MethodCallHandler, + MethodChannel, + MethodResult, +} from '@ohos/flutter_ohos'; + +import { deviceInfo } from '@kit.BasicServicesKit'; + +/** FlutterJsbridgePluginOhosPlugin **/ +export default class FlutterJsbridgePluginOhosPlugin implements FlutterPlugin, MethodCallHandler { + private channel: MethodChannel | null = null; + + getUniqueClassName(): string { + return "FlutterJsbridgePluginOhosPlugin" + } + + onAttachedToEngine(binding: FlutterPluginBinding): void { + this.channel = new MethodChannel(binding.getBinaryMessenger(), "flutterjsbridgeplugin"); + this.channel.setMethodCallHandler(this) + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + if (this.channel != null) { + this.channel.setMethodCallHandler(null) + } + } + + onMethodCall(call: MethodCall, result: MethodResult): void { + if (call.method == "getPlatformVersion") { + result.success(this.getVersion()) + } else { + result.notImplemented() + } + } + + //手机系统版本号 + private getVersion(): string{ + let osFullNameInfo: string = deviceInfo.osFullName; + return osFullNameInfo; + } +} \ No newline at end of file diff --git a/ohos/ohos/src/main/module.json5 b/ohos/ohos/src/main/module.json5 new file mode 100644 index 0000000..b570c1a --- /dev/null +++ b/ohos/ohos/src/main/module.json5 @@ -0,0 +1,10 @@ +{ + "module": { + "name": "flutter_jsbridge_plugin_ohos", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/ohos/pubspec.yaml b/ohos/pubspec.yaml new file mode 100644 index 0000000..7d980ef --- /dev/null +++ b/ohos/pubspec.yaml @@ -0,0 +1,76 @@ +name: flutter_jsbridge_plugin_ohos +description: use jsbridge to webview in flutter. +version: 1.0.0 +homepage: + +environment: + sdk: '>=2.19.6 <3.0.0' + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + sprintf: ^7.0.0 + webview_flutter: + git: + url: "https://gitee.com/openharmony-sig/flutter_packages.git" + path: "packages/webview_flutter-v4.4.4/webview_flutter" + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + build_runner: ^2.1.4 + pigeon: ^9.2.4 +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + ohos: + package: com.flutter_jsbridge_plugin.flutter_jsbridge_plugin_ohos + pluginClass: FlutterJsbridgePluginOhosPlugin + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/ohos/test/flutter_jsbridge_plugin_ohos_test.dart b/ohos/test/flutter_jsbridge_plugin_ohos_test.dart new file mode 100644 index 0000000..91fb2bc --- /dev/null +++ b/ohos/test/flutter_jsbridge_plugin_ohos_test.dart @@ -0,0 +1,20 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_jsbridge_plugin_ohos/flutterjsbridgeplugin.dart'; + +void main() { + const MethodChannel channel = MethodChannel('flutterjsbridgeplugin'); + TestWidgetsFlutterBinding.ensureInitialized(); + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) async { + return '42'; + }); + }); + tearDown(() { + channel.setMockMethodCallHandler(null); + }); + test('getPlatformVersion', () async { + expect(await Flutterjsbridgeplugin.platformVersion, '42'); + }); +} + -- Gitee From 615546c33592c57c188edfca3128ce0d724c6244 Mon Sep 17 00:00:00 2001 From: megan Date: Mon, 11 Nov 2024 08:07:49 +0000 Subject: [PATCH 2/7] update ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets. Signed-off-by: megan --- .../ets/plugins/GeneratedPluginRegistrant.ets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets b/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets index c9b6724..b60bc59 100644 --- a/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets +++ b/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { FlutterEngine, Log } from '@ohos/flutter_ohos'; import FlutterJsbridgePluginOhosPlugin from 'flutter_jsbridge_plugin_ohos'; import WebViewFlutterPlugin from 'webview_flutter_ohos'; -- Gitee From d135df7e6b895a756950087c2efe4bb6d728df56 Mon Sep 17 00:00:00 2001 From: megan Date: Mon, 11 Nov 2024 08:13:23 +0000 Subject: [PATCH 3/7] update ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets. Signed-off-by: megan --- .../ets/plugins/GeneratedPluginRegistrant.ets | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets b/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets index b60bc59..bec4c45 100644 --- a/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets +++ b/ohos/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets @@ -1,17 +1,17 @@ -/** - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import { FlutterEngine, Log } from '@ohos/flutter_ohos'; import FlutterJsbridgePluginOhosPlugin from 'flutter_jsbridge_plugin_ohos'; -- Gitee From 61a108ef80155c90f0402671e955a0fb39d02273 Mon Sep 17 00:00:00 2001 From: megan Date: Mon, 11 Nov 2024 08:16:29 +0000 Subject: [PATCH 4/7] update ohos/pubspec.yaml. Signed-off-by: megan --- ohos/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ohos/pubspec.yaml b/ohos/pubspec.yaml index 7d980ef..9f2830c 100644 --- a/ohos/pubspec.yaml +++ b/ohos/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_jsbridge_plugin_ohos description: use jsbridge to webview in flutter. version: 1.0.0 -homepage: +homepage: https://github.com/epoll-j/flutter_jsbridge_plugin environment: sdk: '>=2.19.6 <3.0.0' -- Gitee From 7756a55535efcdda043bf87d3ce12234f8ada126 Mon Sep 17 00:00:00 2001 From: megan Date: Mon, 11 Nov 2024 08:38:58 +0000 Subject: [PATCH 5/7] update ohos/pubspec.yaml. Signed-off-by: megan --- ohos/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ohos/pubspec.yaml b/ohos/pubspec.yaml index 9f2830c..ac23159 100644 --- a/ohos/pubspec.yaml +++ b/ohos/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_jsbridge_plugin_ohos description: use jsbridge to webview in flutter. version: 1.0.0 -homepage: https://github.com/epoll-j/flutter_jsbridge_plugin +homepage: https://gitee.com/openharmony-sig/fluttertpc_flutter_jsbridge_plugin environment: sdk: '>=2.19.6 <3.0.0' -- Gitee From 91089ec6d611772847d85a84eb62546ea863175e Mon Sep 17 00:00:00 2001 From: megan Date: Fri, 15 Nov 2024 06:15:05 +0000 Subject: [PATCH 6/7] update OAT.xml. Signed-off-by: megan --- OAT.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OAT.xml b/OAT.xml index e6c6f55..9267803 100644 --- a/OAT.xml +++ b/OAT.xml @@ -53,9 +53,9 @@ - - - + + + @@ -70,9 +70,9 @@ - - - + + + -- Gitee From 9d16a6deb9213dd373838424a69656535e4c82af Mon Sep 17 00:00:00 2001 From: megan Date: Fri, 15 Nov 2024 06:49:10 +0000 Subject: [PATCH 7/7] update ohos/README.md. Signed-off-by: megan --- ohos/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ohos/README.md b/ohos/README.md index 493be3c..2546634 100644 --- a/ohos/README.md +++ b/ohos/README.md @@ -65,6 +65,6 @@ WebView( [js file](https://github.com/epoll-j/flutter_jsbridge_plugin/blob/master/JSBridge.js) ## 支持格式 -| 格式 |android|ios| harmonyOS | +| 格式 |android|ios| OpenHarmony | |:-----------------|:----:|:----:|:--------------:| | getPlatformVersion|✅ | ✅ | ✅ | \ No newline at end of file -- Gitee