参数具有 `index` 属性,表示切换后显示内容的 index | |
48 |
49 |
50 |
51 | ### 组件方法
52 |
53 | ```javascript
54 | /**
55 | * 使 SwiperView 滚动到指定内容
56 | * @param {number} index 需要显示的内容 index
57 | * @param {number} duration 移动到指定内容的耗时
58 | */
59 | swipeTo(index: number, duration?: number)
60 | ```
61 |
62 |
--------------------------------------------------------------------------------
/Documentation/打包说明.md:
--------------------------------------------------------------------------------
1 | # 打包说明
2 |
3 | ### JS 脚本打包
4 |
5 | JS 打包依赖 webpack,在项目根目录下的 /webpack 目录即为打包目录。目前打包目录下分为 3 部分,分别是:
6 |
7 | 1. weback 打包脚本;
8 | 2. 打包配置项;
9 | 3. webpack loaders.
10 |
11 | 通过执行 `yarn build` 命令可以对业务代码进行打包,打包后的文件会存在于项目根目录下的 /dist 目录中。
12 |
13 |
14 |
15 | #### Webpack loaders
16 |
17 | Loaders 分为两块:
18 |
19 | 1. 为 js 业务代码中的所有函数添加异常捕获;
20 | 2. 将图片转换为对应环境下的 url 链接以保证图片的正确显示。
21 |
22 | 一般情况下请勿改动 loader 目录下的任何内容!
23 |
24 |
25 |
26 | #### 打包配置项
27 |
28 | 打包配置项在 /webpack/config.js 中,目前一共包含 3 个可配置项:
29 |
30 | 1. host: 项目启动 ip,默认 0.0.0.0,一般情况下不需要修改;
31 | 2. port: 项目启用端口,默认 12345,一般情况下不需要修改;
32 | 3. imageProxyHost: 该参数默认情况下被注释或与 host 值相同,当使用安卓设备进行调试时,需要开启代理,此时会导致项目中的静态资源图片因为默认端口被代理无法正常显示图片。通过添加或修改该值为代理 ip 后可以保证图片正常显示。
33 |
34 |
35 |
36 | #### Webpack 打包脚本
37 |
38 | 打包脚本中的各项参数请参考 webpack 官方文档。在绝大多数情况下可以不对打包脚本进行任何修改,除非存在其他特殊的打包需求。
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 AMH Group
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 AMH Group
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/ROADMAP.md:
--------------------------------------------------------------------------------
1 | # 未来RoadMap
2 |
3 | - **性能优化**
4 |
5 | 1、首帧加载时长
6 |
7 |
8 |
9 | - **稳定性**
10 |
11 | 1、Flutter 已有线上异常问题逐步推进解决,主要集中在低端机型so异常
12 |
13 | 2、端可用性指标提升
14 |
15 | - **完善组件以及开发文档**
16 |
17 | - **开发工具链以及Debug模式建设**
18 |
19 | - **5+ 业务线接入支持【目前接入页面70+】**
20 |
21 | - **技术扩展**
22 |
23 | 1、Android端支持 JS引擎切换,降低安装包大小【v8 or jsc】
24 |
25 | 2、支持Flutter新版本切换,目前支持 v1.5.4-Hotfix2 \ v1.9.1-Hotfix6\v1.22.5 \ v2.2.2
26 |
27 | 3、支持动画
28 |
29 | 4、混合模式工程化链路优化
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.class
3 | .gradle
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | /captures
10 | GeneratedPluginRegistrant.java
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'io.manbang.frontend.thresh'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext{
6 | kotlin_version = '1.3.72'
7 | }
8 | repositories {
9 | maven {url 'https://maven.aliyun.com/repository/google'}
10 | maven {url 'http://maven.aliyun.com/mvn/repository/'}
11 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
12 | google()
13 | jcenter()
14 | maven {url "https://jitpack.io"}
15 | }
16 |
17 | dependencies {
18 | classpath 'com.android.tools.build:gradle:3.2.1'
19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20 | }
21 | }
22 |
23 | rootProject.allprojects {
24 | repositories {
25 | maven {url 'https://maven.aliyun.com/repository/google'}
26 | maven {url 'http://maven.aliyun.com/mvn/repository/'}
27 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
28 | google()
29 | jcenter()
30 | maven {url "https://jitpack.io"}
31 | }
32 |
33 | configurations.all {
34 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
35 | }
36 | }
37 |
38 | apply plugin: 'com.android.library'
39 | apply plugin: 'kotlin-android-extensions'
40 | apply plugin: 'kotlin-android'
41 |
42 | android {
43 | compileSdkVersion 28
44 | buildToolsVersion '28.0.3'
45 | defaultConfig {
46 | minSdkVersion 16
47 | targetSdkVersion 28
48 | }
49 | lintOptions {
50 | disable 'InvalidPackage'
51 | }
52 | }
53 |
54 | dependencies {
55 | implementation 'androidx.appcompat:appcompat:1.0.0'
56 | implementation 'androidx.annotation:annotation:1.0.0'
57 | implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
58 | implementation'com.squareup.retrofit2:retrofit:2.3.0'
59 | implementation 'com.eclipsesource.j2v8:j2v8:6.2.0@aar'
60 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
61 | implementation 'com.google.code.gson:gson:2.6.2'
62 | // api "com.ymm.lib:flutter-sdk:1.22.5-SNAPSHOT"
63 | }
64 |
65 | ext {
66 | groupId = 'io.manbang.frontend.thresh'
67 | artifactId = "Thresh"
68 | }
69 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
5 | v_lib_jscore=1.1.6-SNAPSHOT
6 |
7 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'thresh'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/ThreshPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 | package io.manbang.frontend.thresh;
24 |
25 | import io.flutter.plugin.common.MethodCall;
26 | import io.flutter.plugin.common.MethodChannel;
27 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
28 | import io.flutter.plugin.common.MethodChannel.Result;
29 | import io.flutter.plugin.common.PluginRegistry.Registrar;
30 |
31 | /** ThreshPlugin */
32 | public class ThreshPlugin implements MethodCallHandler {
33 | /** Plugin registration. */
34 | public static void registerWith(Registrar registrar) {
35 | final MethodChannel channel = new MethodChannel(registrar.messenger(), "thresh_demo");
36 | channel.setMethodCallHandler(new ThreshPlugin());
37 | }
38 |
39 | @Override
40 | public void onMethodCall(MethodCall call, Result result) {
41 | if (call.method.equals("getPlatformVersion")) {
42 | result.success("Android " + android.os.Build.VERSION.RELEASE);
43 | } else {
44 | result.notImplemented();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/channel/BridgeCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.channel;
25 |
26 | import java.util.Map;
27 |
28 | public interface BridgeCallback {
29 | /**
30 | *
31 | * @param code 0
32 | * 0 : success
33 | * @param reason callback message
34 | * @param bridgeResult result
35 | */
36 | void onResult(int code, String reason, Map bridgeResult);
37 | }
38 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/channel/MethodChannelProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.channel;
25 |
26 | import java.util.Map;
27 |
28 | import io.flutter.plugin.common.MethodChannel;
29 |
30 | /** An interface for classes that initialize MethodChannel using {@link io.manbang.frontend.thresh.channel.MethodChannelModule} */
31 | public interface MethodChannelProvider {
32 |
33 | /**
34 | * invoke flutter method
35 | *
36 | * @param method dart method
37 | * @param params params
38 | */
39 | void invokeMethod(String method,Map params);
40 |
41 | /**
42 | * dispatch MethodChannel event
43 | *
44 | * @param module
45 | * @param method
46 | * @param params
47 | * @param result
48 | */
49 | Object dispatchModuleChannelEvent(String module, String method, Object params, MethodChannel.Result result);
50 | }
51 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/channel/nativemodule/SendResultInvoke.java:
--------------------------------------------------------------------------------
1 | package io.manbang.frontend.thresh.channel.nativemodule;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 |
6 | import com.google.gson.Gson;
7 |
8 | import org.json.JSONObject;
9 |
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | import io.flutter.plugin.common.JSONUtil;
14 | import io.manbang.frontend.thresh.runtime.ThreshEngine;
15 |
16 | public class SendResultInvoke implements NativeModule.INativeInvoke {
17 |
18 | private Activity activity;
19 |
20 | SendResultInvoke(Activity activity) {
21 |
22 | this.activity = activity;
23 | }
24 |
25 | @Override
26 | public void invoke(ThreshEngine engine, Map params) {
27 | Intent intent = new Intent();
28 | final String PARAM_KEY = "params";
29 | if(params!=null&¶ms.size()>0&¶ms.containsKey(PARAM_KEY)){
30 | Object resultParam = params.get(PARAM_KEY);
31 | if(resultParam instanceof String){
32 | intent.putExtra(PARAM_KEY,(String) resultParam);
33 | }else if(resultParam instanceof Map){
34 | intent.putExtra(PARAM_KEY,new JSONObject((Map) resultParam).toString());
35 | }
36 | }
37 | activity.setResult(Activity.RESULT_OK, intent);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/AssetConfigParse.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.manager.config.configparse
25 |
26 | import io.manbang.frontend.thresh.manager.config.IParseConfig
27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig
28 |
29 | /**
30 | * 通过将asset文件,转化为配置项
31 | */
32 | class AssetConfigParse(val assetName: String) :IParseConfig {
33 |
34 | override fun parse(): ThreshConfig {
35 | TODO("Not yet implemented")
36 | }
37 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/CommonConfigParse.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.manager.config.configparse
25 |
26 | import io.manbang.frontend.thresh.manager.config.IParseConfig
27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig
28 |
29 |
30 | /**
31 | * 通用配置解析器
32 | * 仅仅直接将配置返回
33 | */
34 | class CommonConfigParse(val config: ThreshConfig) : IParseConfig {
35 |
36 | override fun parse(): ThreshConfig {
37 | return config
38 | }
39 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/FileAssetConfigParse.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.manager.config.configparse
25 |
26 | import io.manbang.frontend.thresh.manager.config.IParseConfig
27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig
28 | import java.io.File
29 |
30 | /**
31 | * 通过将文件转化为配置项目
32 | */
33 | class FileAssetConfigParse(val file: File) : IParseConfig {
34 | override fun parse(): ThreshConfig {
35 | TODO("Not yet implemented")
36 | }
37 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/IFlutterEngineExecute.java:
--------------------------------------------------------------------------------
1 | package io.manbang.frontend.thresh.manager.flutterengine;
2 |
3 | public interface IFlutterEngineExecute {
4 |
5 | interface IFlutterContainer {
6 | void putEngineId(String key, String engineId);
7 |
8 | String getInitialRoute();
9 |
10 | String engineIdKey();
11 |
12 | String dartEntryPointFunctionName();
13 |
14 | }
15 |
16 | void initFlutterEngine(IFlutterContainer flutterContainer) ;
17 |
18 | void loadFlutterPage();
19 | }
20 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshActivityFlutterContainer.java:
--------------------------------------------------------------------------------
1 | package io.manbang.frontend.thresh.manager.flutterengine;
2 |
3 | import io.manbang.frontend.thresh.containers.ThreshActivity;
4 | import io.manbang.frontend.thresh.manager.ContextIdManager;
5 |
6 | public class ThreshActivityFlutterContainer implements FlutterEngineExecute.IFlutterContainer {
7 |
8 | private ThreshActivity activity;
9 | private String dartEntryPointFunctionName;
10 |
11 | public ThreshActivityFlutterContainer(ThreshActivity activity){
12 |
13 | this(activity,"main");
14 | }
15 |
16 | public ThreshActivityFlutterContainer(ThreshActivity activity,String dartEntryPointFunctionName){
17 |
18 | this.activity = activity;
19 | this.dartEntryPointFunctionName = dartEntryPointFunctionName;
20 | }
21 |
22 | @Override
23 | public void putEngineId(String key, String engineId) {
24 | activity.getIntent().putExtra(key,engineId);
25 | }
26 |
27 | @Override
28 | public String getInitialRoute() {
29 | return activity.getInitialRoute();
30 | }
31 |
32 | @Override
33 | public String engineIdKey() {
34 |
35 | return ContextIdManager.INSTANCE.getContextId(activity);
36 | }
37 |
38 | @Override
39 | public String dartEntryPointFunctionName() {
40 | return dartEntryPointFunctionName;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshFragmentContainer.java:
--------------------------------------------------------------------------------
1 | package io.manbang.frontend.thresh.manager.flutterengine;
2 |
3 | import io.manbang.frontend.thresh.containers.ThreshFragment;
4 | import io.manbang.frontend.thresh.manager.ContextIdManager;
5 |
6 | public class ThreshFragmentContainer implements FlutterEngineExecute.IFlutterContainer {
7 |
8 | private ThreshFragment fragment;
9 | private String dartEntryPointFunctionName ;
10 |
11 | public ThreshFragmentContainer(ThreshFragment fragment) {
12 |
13 | this(fragment,"main");
14 | }
15 |
16 | public ThreshFragmentContainer(ThreshFragment fragment,String dartEntryPointFunctionName) {
17 | this.fragment = fragment;
18 | this.dartEntryPointFunctionName = dartEntryPointFunctionName;
19 | }
20 |
21 | @Override
22 | public void putEngineId(String key, String engineId) {
23 | if (fragment.getArguments() != null) {
24 | fragment.getArguments().putString(key, engineId);
25 | }
26 | }
27 |
28 | @Override
29 | public String getInitialRoute() {
30 | return fragment.getInitialRoute();
31 | }
32 |
33 | @Override
34 | public String engineIdKey() {
35 | return ContextIdManager.INSTANCE.getContextId(fragment);
36 | }
37 |
38 | @Override
39 | public String dartEntryPointFunctionName() {
40 | return dartEntryPointFunctionName;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshIntentContainer.java:
--------------------------------------------------------------------------------
1 | package io.manbang.frontend.thresh.manager.flutterengine;
2 |
3 | import android.content.Intent;
4 |
5 | public class ThreshIntentContainer implements FlutterEngineExecute.IFlutterContainer {
6 |
7 | private final Intent intent;
8 | private final String route;
9 | private String engineId;
10 | private String dartEntryPointFunctionName;
11 |
12 | public ThreshIntentContainer(Intent intent, String route,String engineId,String dartEntryPointFunctionName){
13 |
14 | this.intent = intent;
15 | this.route = route;
16 | this.engineId = engineId;
17 | this.dartEntryPointFunctionName = dartEntryPointFunctionName;
18 | }
19 |
20 | public ThreshIntentContainer(Intent intent, String route,String engineId){
21 |
22 | this(intent,route,engineId,"main");
23 | }
24 |
25 | @Override
26 | public void putEngineId(String key, String engineId) {
27 | intent.putExtra(key,engineId);
28 | }
29 |
30 | @Override
31 | public String getInitialRoute() {
32 | return route;
33 | }
34 |
35 | @Override
36 | public String engineIdKey() {
37 | return engineId;
38 | }
39 |
40 | @Override
41 | public String dartEntryPointFunctionName() {
42 | return dartEntryPointFunctionName;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/handler/ThreshHandlerManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.manager.handler
25 |
26 | import io.manbang.frontend.thresh.manager.handler.interfaces.IReportHandler
27 | import java.lang.reflect.Proxy
28 |
29 | object ThreshHandlerManager {
30 |
31 | private var reportHandler: IReportHandler? = null
32 |
33 | fun setReportHandler(reportHandler: IReportHandler){
34 | this.reportHandler = reportHandler
35 | }
36 |
37 | /**
38 | * 上报数据功能
39 | */
40 | fun reportHandler(): IReportHandler {
41 | return returnProxyIfEmpty(reportHandler, IReportHandler::class.java)
42 | }
43 |
44 | //如果空返回代理对象,否则原对象返回
45 | private fun returnProxyIfEmpty(handler: T?, clazz: Class): T {
46 | return handler ?: emptyProxy(clazz)
47 | }
48 |
49 | private fun emptyProxy(clazz: Class): T {
50 |
51 | return Proxy.newProxyInstance(clazz.classLoader, arrayOf(clazz)) { _, _, _ -> null } as T
52 |
53 | }
54 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/manager/handler/interfaces/IReportHandler.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.manager.handler.interfaces
25 |
26 | /**
27 | * 上报数据的能力
28 | */
29 | interface IReportHandler {
30 | fun log(level: Int, tag: String?, message: String?, tr: Throwable?)
31 |
32 | /**
33 | * Report performance management data
34 | *
35 | * @param params
36 | */
37 | fun reportPerformance(params: Map<*, *>?)
38 |
39 | /**
40 | * Report exception log
41 | *
42 | * @param errorMessage
43 | * @param errorDetails
44 | */
45 | fun reportException(errorMessage: String?, errorDetails: Any?)
46 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/ThreshException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime;
25 |
26 | /**
27 | * Signals that a method has been invoked at a thresh exception time.
28 | */
29 | public class ThreshException extends RuntimeException {
30 |
31 | public ThreshException() {
32 | }
33 |
34 |
35 | public ThreshException(String exceptionMessage) {
36 | super(exceptionMessage);
37 | }
38 |
39 | public ThreshException(String exceptionMessage, Throwable reason) {
40 | super(exceptionMessage, reason);
41 | }
42 |
43 | public ThreshException(Throwable cause) {
44 | super(cause);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/MBJSExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore;
25 |
26 | import io.manbang.frontend.thresh.runtime.jscore.bundle.BundleOptions;
27 | import io.manbang.frontend.thresh.runtime.jscore.runtime.JSExecutor;
28 |
29 | /**
30 | * js执行器
31 | */
32 | public final class MBJSExecutor extends JSExecutor {
33 |
34 | private BundleOptions bundleOptions;
35 |
36 | public MBJSExecutor(BundleOptions bundleOptions) {
37 | this.bundleOptions= bundleOptions;
38 | }
39 |
40 | public BundleOptions getBundleOptions(){
41 | return bundleOptions;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/BundleCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore.bundle;
25 |
26 | /**
27 | * bundle callback
28 | */
29 | public interface BundleCallback {
30 |
31 | /**
32 | *
33 | * @param code 0 成功
34 | * @param reason 错误原因
35 | * @param data 文件流
36 | */
37 | void onResult(int code, String reason, String data);
38 | }
39 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/BundleType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore.bundle;
25 |
26 | /**
27 | * bundle包运行类型
28 | *
29 | * 101: 本地内置包
30 | * 102: 宿主,加载本地Assets内置包
31 | * -100:js服务器
32 | */
33 | public enum BundleType {
34 |
35 | /**
36 | * 宿主,加载本地内置包
37 | */
38 | LOCAL_FILE(101),
39 | /**
40 | * 宿主,加载本地Assets内置包
41 | */
42 | ASSETS_FILE(102),
43 | /**
44 | * 本地调试模式,连接js服务器端口
45 | */
46 | JS_SERVER(-100);
47 |
48 | private final int type;
49 |
50 | BundleType(int type) {
51 | this.type = type;
52 | }
53 |
54 | public int getType(){
55 | return type;
56 | }
57 |
58 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/ContainerType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore.bundle;
25 |
26 | /**
27 | * 容器方
28 | */
29 | public enum ContainerType {
30 |
31 | /**
32 | * Thresh - 动态flutter
33 | */
34 | Thresh("Thresh"),
35 | /**
36 | * 达芬奇 - 配置化平台
37 | */
38 | Davinci("Davinci");
39 |
40 | private final String type;
41 |
42 | ContainerType(String type) {
43 | this.type = type;
44 | }
45 |
46 | public String getType(){
47 | return type;
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/runtime/CompatInjectJS.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore.runtime;
25 |
26 | import io.manbang.frontend.thresh.util.ThreshLogger;
27 |
28 | /**
29 | * 自定义函数注入 解决V8兼容性问题
30 | */
31 | public class CompatInjectJS {
32 |
33 | public CompatInjectJS() {
34 | }
35 |
36 | public void log(Object obj) {
37 | ThreshLogger.d("native-log", obj.toString());
38 | }
39 |
40 | public void group(Object obj) {
41 | ThreshLogger.d("native-group", obj.toString());
42 | }
43 |
44 | public void groupEnd(Object obj) {
45 | ThreshLogger.d("native-groupEnd", obj.toString());
46 | }
47 |
48 | public void groupEnd() {
49 | ThreshLogger.d("native-groupEnd");
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/runtime/JSCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 | package io.manbang.frontend.thresh.runtime.jscore.runtime;
25 |
26 | import androidx.annotation.Nullable;
27 |
28 | /**
29 | * Method call result callback.
30 | *
31 | *
All methods of this class must be called on the platform thread (Android main thread).
65 | )
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/example/js/src/widgets/Title.tsx:
--------------------------------------------------------------------------------
1 | import Thresh, { basicWidgets } from 'thresh-lib'
2 | import { Colors } from '../config'
3 |
4 | interface ITitle {
5 | title: string
6 | }
7 |
8 | const { Text } = basicWidgets
9 |
10 | export default class Title extends Thresh.Widget {
11 | render () {
12 | return (
13 |
19 | {this.props.title}
20 |
21 | )
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/example/js/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "experimentalDecorators": true,
4 | "jsx": "react",
5 | "jsxFactory": "Thresh.createElement",
6 | "lib": [ "es5", "es6" ],
7 | "target": "es5",
8 | },
9 | "include": [ "src" ]
10 | }
--------------------------------------------------------------------------------
/example/js/webpack/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | server: {
3 | host: '0.0.0.0',
4 | // 远程调试时如果本地图片未显示,可以通过修改该字段为你的网络ip后,重新启动服务,本地图片即可显示
5 | // imageProxyHost: '10.190.22.92',
6 | port: 12345,
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/example/js/webpack/loader/image-loader.js:
--------------------------------------------------------------------------------
1 | const os = require('os')
2 | const path = require('path')
3 | const { readFileSync } = require('fs')
4 | const loaderUtils = require('loader-utils')
5 |
6 | const rootPath = path.resolve(__dirname, '../../')
7 | const networkInterfaces = os.networkInterfaces()
8 | let internalIp = '127.0.0.1'
9 | if (networkInterfaces && networkInterfaces.en0) {
10 | for (let i in networkInterfaces.en0) {
11 | const interface = networkInterfaces.en0[i]
12 | if (interface.family === 'IPv6') continue
13 | internalIp = interface.address
14 | }
15 | }
16 |
17 | module.exports = function() {
18 | const loaderOptions = loaderUtils.getOptions(this)
19 | const devMode = loaderOptions.localImageUseHttpRequestEnvs.indexOf(process.env.NODE_ENV) > -1
20 | const imagePath = this.resource
21 |
22 | let src = imagePath.split(path.join('/', 'src'))[1]
23 | if (!src) throw new Error('Static assets must include by "src" folder.')
24 | if (!devMode) {
25 | this.emitFile(src, readFileSync(imagePath))
26 | } else {
27 | src = imagePath.split(rootPath)[1]
28 | }
29 |
30 | return `export default '${
31 | !devMode
32 | ? src
33 | : `http://${loaderOptions.imageHost || internalIp}:${loaderOptions.port || '12345'}${src}`
34 | }'`
35 | }
36 |
--------------------------------------------------------------------------------
/example/js/webpack/loader/try-catch-loader/index.js:
--------------------------------------------------------------------------------
1 | const babel = require('@babel/core')
2 | const loaderUtils = require("loader-utils")
3 | const tryCatchWrapper = require('./plugin').default
4 |
5 | module.exports = function (source, inputMap) {
6 | let fileName = ''
7 | if (this.resource.indexOf('/node_modules') > -1) {
8 | fileName = this.resource.split('/node_modules')[1]
9 | } else {
10 | fileName = this.resource.split('/src')[1]
11 | }
12 | const loaderOptions = loaderUtils.getOptions(this)
13 | const transOpts = {
14 | plugins: [
15 | [
16 | tryCatchWrapper,
17 | {
18 | reportError: loaderOptions.reporter,
19 | rethrow: loaderOptions.rethrow,
20 | noCatchFuncNames: loaderOptions.noCatchFuncNames || [],
21 | fileName
22 | }
23 | ]
24 | ]
25 | }
26 | try {
27 | const result = babel.transform(source, transOpts)
28 | this.callback(null, result.code, result.map)
29 | } catch (e) {
30 | throw e
31 | }
32 | }
--------------------------------------------------------------------------------
/example/lib/assets/icon_back_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/icon_back_black.png
--------------------------------------------------------------------------------
/example/lib/assets/icon_back_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/icon_back_white.png
--------------------------------------------------------------------------------
/example/lib/assets/on_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/on_error.png
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flutter/rendering.dart';
4 | import 'package:flutter/services.dart';
5 | import 'package:flutter/widgets.dart';
6 |
7 | import 'thresh.dart' as thresh;
8 |
9 | // 本地调试入口
10 | void main() async {
11 | WidgetsFlutterBinding.ensureInitialized();
12 | window.onSemanticsEnabledChanged = () {};
13 | RendererBinding.instance.setSemanticsEnabled(false);
14 | if (window.defaultRouteName.isNotEmpty
15 | && window.defaultRouteName.startsWith('thresh/thresh-page')) {
16 | thresh.initPlugin(window.defaultRouteName);
17 | return;
18 | }
19 | // 默认测试页面
20 | thresh.main();
21 |
22 | MethodChannel('io.manbang.frontend/method_channel')
23 | .setMethodCallHandler((call) async {
24 | switch (call.method) {
25 | case 'setInitRoute':
26 | print("setInitRoute==>" + call.arguments);
27 | thresh.initPlugin(call.arguments);
28 | break;
29 | }
30 | });
31 | }
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: thresh_example
2 | description: Demonstrates how to use the thresh plugin.
3 |
4 | version: 0.0.1
5 |
6 | environment:
7 | sdk: ">=2.10.0 <3.0.0"
8 | flutter: ">=2.2.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 |
18 | thresh:
19 | path: ../
20 |
21 | # For information on the generic Dart part of this file, see the
22 | # following page: https://dart.dev/tools/pub/pubspec
23 |
24 | # The following section is specific to Flutter.
25 | flutter:
26 |
27 | # The following line ensures that the Material Icons font is
28 | # included with your application, so that you can use the icons in
29 | # the material Icons class.
30 | uses-material-design: true
31 |
32 | # To add assets to your application, add an assets section, like this:
33 | # assets:
34 | # - images/a_dot_burr.jpeg
35 | # - images/a_dot_ham.jpeg
36 |
37 | # An image asset can refer to one or more resolution-specific "variants", see
38 | # https://flutter.dev/assets-and-images/#resolution-aware.
39 |
40 | # For details regarding adding assets from package dependencies, see
41 | # https://flutter.dev/assets-and-images/#from-packages
42 |
43 | # To add custom fonts to your application, add a fonts section here,
44 | # in this "flutter" section. Each entry in this list should have a
45 | # "family" key with the font family name, and a "fonts" key with a
46 | # list giving the asset and other descriptors for the font. For
47 | # example:
48 | # fonts:
49 | # - family: Schyler
50 | # fonts:
51 | # - asset: fonts/Schyler-Regular.ttf
52 | # - asset: fonts/Schyler-Italic.ttf
53 | # style: italic
54 | # - family: Trajan Pro
55 | # fonts:
56 | # - asset: fonts/TrajanPro.ttf
57 | # - asset: fonts/TrajanPro_Bold.ttf
58 | # weight: 700
59 | #
60 | # For details regarding fonts from package dependencies,
61 | # see https://flutter.dev/custom-fonts/#from-packages
62 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter_test/flutter_test.dart';
9 |
10 | void main() {
11 | testWidgets('Verify Platform version', (WidgetTester tester) async {
12 | // Build our app and trigger a frame.
13 | });
14 | }
15 |
--------------------------------------------------------------------------------
/images/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image1.png
--------------------------------------------------------------------------------
/images/image10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image10.png
--------------------------------------------------------------------------------
/images/image11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image11.png
--------------------------------------------------------------------------------
/images/image12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image12.png
--------------------------------------------------------------------------------
/images/image13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image13.png
--------------------------------------------------------------------------------
/images/image14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image14.png
--------------------------------------------------------------------------------
/images/image15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image15.png
--------------------------------------------------------------------------------
/images/image16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image16.png
--------------------------------------------------------------------------------
/images/image17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image17.png
--------------------------------------------------------------------------------
/images/image18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image18.png
--------------------------------------------------------------------------------
/images/image19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image19.png
--------------------------------------------------------------------------------
/images/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image2.png
--------------------------------------------------------------------------------
/images/image20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image20.png
--------------------------------------------------------------------------------
/images/image21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image21.png
--------------------------------------------------------------------------------
/images/image22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image22.png
--------------------------------------------------------------------------------
/images/image23.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image23.png
--------------------------------------------------------------------------------
/images/image24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image24.png
--------------------------------------------------------------------------------
/images/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image3.png
--------------------------------------------------------------------------------
/images/image4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image4.png
--------------------------------------------------------------------------------
/images/image5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image5.png
--------------------------------------------------------------------------------
/images/image6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image6.png
--------------------------------------------------------------------------------
/images/image7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image7.png
--------------------------------------------------------------------------------
/images/image8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image8.png
--------------------------------------------------------------------------------
/images/image9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image9.png
--------------------------------------------------------------------------------
/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/logo.png
--------------------------------------------------------------------------------
/images/qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/qrcode.jpg
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshDataLoader.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | typedef NS_ENUM(NSInteger, ThreshLoadType) {
28 | LoadWithURL,
29 | LoadWithCustomized
30 | };
31 |
32 | @protocol ThreshDataLoader
33 |
34 | @optional
35 | // 加载选项,默认走自定义方式,通过 getJSDataWithModuleName:callback: 获取
36 | - (ThreshLoadType)loadType;
37 | // 通过远程地址加载时可手动传地址,默认本机地址
38 | - (NSString *)serverAddress;
39 | // 选择自定义数据获取方式
40 | - (void)getJSDataWithModuleName:(NSString *)moduleName callback:(void (^)(NSData *data))callback;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshInfoExport.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | typedef NS_ENUM(NSInteger, ThreshLifeCycle) {
30 | ThreshPageInit = 1,
31 | ThreshBeforeLoadBundle,
32 | ThreshAfterLoadBundle,
33 | ThreshBeforeEvalJS,
34 | ThreshAfterEvalJS,
35 | ThreshPageDidLoad,
36 | ThreshPageDidShow,
37 | ThreshFlutterFirstFrame,
38 | };
39 |
40 | typedef NS_ENUM(NSInteger, ThreshExceptionType) {
41 | ThreshExceptionJS,
42 | };
43 |
44 | @protocol ThreshInfoExport
45 |
46 | @optional
47 |
48 | // 不同状态及扩展字段
49 | - (void)lifeCycle:(ThreshLifeCycle)lifeCycle ext:(NSDictionary *)ext;
50 | // 异常信息
51 | - (void)exceptionType:(ThreshExceptionType)exceptionType msg:(NSString *)msg;
52 |
53 | @end
54 |
55 | NS_ASSUME_NONNULL_END
56 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshLogger.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | typedef NS_ENUM(NSInteger, ThreshLogLevel) {
30 | ThreshLogDebug = 1,
31 | ThreshLogInfo = 2,
32 | ThreshLogWarn = 3,
33 | ThreshLogError = 4,
34 | ThreshLogFatal = 5,
35 | };
36 |
37 | @protocol ThreshLogger
38 |
39 | @optional
40 | // log等级及信息
41 | - (void)log:(ThreshLogLevel)level msg:(NSString *)msg;
42 |
43 | @end
44 |
45 | NS_ASSUME_NONNULL_END
46 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshNativeBridge.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 | #import "ThreshDef.h"
27 |
28 | NS_ASSUME_NONNULL_BEGIN
29 |
30 | @protocol ThreshNativeBridge
31 |
32 | @optional
33 | - (void)performBridge:(NSDictionary *)bridgeInfo callBack:(ThreshBridgeCallBack)callBack;
34 |
35 | - (void)transferThreshData:(id)data;
36 |
37 | @end
38 |
39 | NS_ASSUME_NONNULL_END
40 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshNativePlatformView.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @protocol ThreshNativePlatformView
30 |
31 | /**
32 | * { <#viewId#>: <#className#>, ... }
33 | * viewId string flutter和native双方约定的自定义视图id
34 | * className string 自定义视图的className
35 | */
36 | @property (nonatomic, strong) NSDictionary *platformViewConfig;
37 |
38 | - (void)invokeInstanceMethodWithArgs:(NSDictionary *)args;
39 |
40 | @end
41 |
42 | NS_ASSUME_NONNULL_END
43 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshOptions.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @protocol ThreshDefaultViewOptions
30 | // 加载重试
31 | - (void)triggerRetry:(void (^)(void))retry;
32 |
33 | @end
34 |
35 | @protocol ThreshOptions
36 |
37 | @optional
38 | // 提供容器缺省页
39 | - (UIView *)defaultViewForContainer;
40 | // 是否需要splash 默认 false
41 | @property (nonatomic, assign) BOOL needDefaultSplashScreenView;
42 | // 自定义splashView
43 | @property (nonatomic, strong) UIView *splashScreenView;
44 | // 页面是否透明 默认 不透明
45 | @property (nonatomic, assign) BOOL opaque;
46 |
47 | @end
48 |
49 | NS_ASSUME_NONNULL_END
50 |
--------------------------------------------------------------------------------
/ios/Classes/Interface/ThreshRouterParams.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @protocol ThreshRouterParams
30 |
31 | @optional
32 | @property (nonatomic, strong) NSString *pageName;
33 | @property (nonatomic, strong) NSString *moduleName;
34 | @property (nonatomic, strong) NSString *referPageName;
35 | @property (nonatomic, strong) NSString *routerString;
36 | @property (nonatomic, strong) NSString *entrypoint;
37 |
38 | @end
39 |
40 | NS_ASSUME_NONNULL_END
41 |
--------------------------------------------------------------------------------
/ios/Classes/Thresh.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #ifndef Thresh_h
26 | #define Thresh_h
27 |
28 | #import "ThreshAppDelegate.h"
29 | #import "ThreshViewController.h"
30 | #import "ThreshPlatformViewFactory.h"
31 |
32 | #endif /* Thresh_h */
33 |
--------------------------------------------------------------------------------
/ios/Classes/ThreshAppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 | #import "ThreshLogger.h"
27 | #import "ThreshNativeBridge.h"
28 | #import "ThreshDataLoader.h"
29 | #import
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | @interface ThreshAppDelegate : NSObject
34 |
35 | + (instancetype)sharedInstance;
36 |
37 | - (void)startThreshWithLogger:(id)logger engineGroup:(FlutterEngineGroup *)engineGroup;
38 |
39 | @property (nonatomic, strong, readonly) id logger;
40 |
41 | @property (nonatomic, strong, readonly) FlutterEngineGroup *engineGroup;
42 |
43 | @end
44 |
45 | NS_ASSUME_NONNULL_END
46 |
--------------------------------------------------------------------------------
/ios/Classes/ThreshAppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import "ThreshAppDelegate.h"
26 |
27 | @interface ThreshAppDelegate ()
28 |
29 | @property (nonatomic, strong) id loader;
30 |
31 | @property (nonatomic, strong) id logger;
32 |
33 | @property (nonatomic, strong) id nativeBridge;
34 |
35 | @property (nonatomic, strong) FlutterEngineGroup *engineGroup;
36 |
37 | @end
38 |
39 | @implementation ThreshAppDelegate
40 |
41 | + (instancetype)sharedInstance {
42 |
43 | static ThreshAppDelegate *instance = nil;
44 | static dispatch_once_t onceToken;
45 | dispatch_once(&onceToken, ^{
46 | instance = [ThreshAppDelegate new];
47 | });
48 | return instance;
49 | }
50 |
51 | - (void)startThreshWithLogger:(id)logger engineGroup:(nonnull FlutterEngineGroup *)engineGroup {
52 | if (logger) {
53 | _logger = logger;
54 | }
55 | if (engineGroup) {
56 | _engineGroup = engineGroup;
57 | }
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/ios/Classes/ThreshPlugin.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | @interface ThreshPlugin : NSObject
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/ios/Classes/ThreshPlugin.m:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import "ThreshPlugin.h"
26 |
27 | @interface ThreshPlugin ()
28 |
29 | @end
30 |
31 | @implementation ThreshPlugin
32 |
33 | + (void)registerWithRegistrar:(NSObject*)registrar {}
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/ios/Classes/platformView/ThreshPlatformViewFactory.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 | #import
27 | #import "ThreshPlatformViewProtocol.h"
28 |
29 | NS_ASSUME_NONNULL_BEGIN
30 |
31 | @interface ThreshPlatformViewFactory : NSObject
32 |
33 | - (instancetype)initWithRegistrar:(NSObject *)registrar objClassName:(NSString *)objClassName;
34 |
35 | @end
36 |
37 | NS_ASSUME_NONNULL_END
38 |
--------------------------------------------------------------------------------
/ios/Classes/platformView/ThreshPlatformViewProtocol.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @protocol ThreshPlatformViewProtocol
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame
32 | viewIdentifier:(int64_t)viewId
33 | arguments:(id _Nullable)args
34 | registrar:(NSObject *)registrar;
35 |
36 | @end
37 |
38 | NS_ASSUME_NONNULL_END
39 |
--------------------------------------------------------------------------------
/ios/Classes/runtime/dartModule/ThreshPlatformUniqueChannelKeyGenerator.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @interface ThreshPlatformUniqueChannelKeyGenerator : NSObject
30 |
31 | - (instancetype)initWithPageName:(NSString *)pageName moduleName:(NSString *)moduleName channelName:(NSString *)channelName;
32 |
33 | - (NSString *)uniqueChannelID;
34 |
35 | - (NSString *)getChannelName;
36 |
37 | @end
38 |
39 | NS_ASSUME_NONNULL_END
40 |
--------------------------------------------------------------------------------
/ios/Classes/runtime/jsCore/ThreshJSCoreDef.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #ifndef ThreshJSCoreDef_h
26 | #define ThreshJSCoreDef_h
27 |
28 | typedef void(^ThreshJSLoaderResponse)(NSData *response, NSError *err);
29 |
30 | typedef void(^ThreshJSInvokeMethodResponse)(NSDictionary *params, NSError *err);
31 |
32 | typedef void(^ThreshJSCompleteResponse)(void);
33 |
34 | #endif /* ThreshJSCoreDef_h */
35 |
--------------------------------------------------------------------------------
/ios/Classes/runtime/jsCore/ThreshJSLoader.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 | #import "ThreshJSCoreDef.h"
27 |
28 | @class ThreshJSLoaderOptions;
29 |
30 | extern NSString *getRemoteSourceFailNotification;
31 | extern NSString *getRemoteSourceSuccessNotification;
32 |
33 |
34 | @interface ThreshJSLoader : NSObject
35 |
36 | + (ThreshJSLoader *)sharedLoader;
37 |
38 | - (void)loadJSWithAddress:(NSString *)address response:(ThreshJSLoaderResponse)response;
39 |
40 | @end
41 |
42 |
--------------------------------------------------------------------------------
/ios/Classes/runtime/jsModule/ThreshJSChannelManager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | /**
26 | * 管理 jsCoreChannel
27 | * 按照js包拆分纬度对channel进行管理
28 | */
29 |
30 | #import
31 | #import "ThreshJSCoreChannel.h"
32 | #import "ThreshProtocol.h"
33 |
34 | NS_ASSUME_NONNULL_BEGIN
35 |
36 | @interface ThreshJSChannelManager : NSObject
37 |
38 | + (ThreshJSChannelManager *)sharedMgr;
39 |
40 | - (BOOL)loadedWithModule:(NSString *)moduleName;
41 |
42 | - (void)haveLoadedWithModule:(NSString *)moduleName;
43 |
44 | - (ThreshJSCoreChannel *)channelWithModule:(NSString *)moduleName;
45 |
46 | - (void)removeChannelWithModule:(NSString *)moduleName;
47 |
48 | @end
49 |
50 | NS_ASSUME_NONNULL_END
51 |
--------------------------------------------------------------------------------
/ios/Classes/runtime/jsModule/ThreshJSTimerManager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | typedef void(^timerFire)(NSString *timerId);
30 |
31 | @interface ThreshJSTimerManager : NSObject
32 |
33 | + (void)operateTimer:(NSDictionary *)args block:(timerFire)block;
34 |
35 | @end
36 |
37 | NS_ASSUME_NONNULL_END
38 |
--------------------------------------------------------------------------------
/ios/Classes/util/NSTimer+Thresh.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 |
27 | NS_ASSUME_NONNULL_BEGIN
28 |
29 | @interface NSTimer (Thresh)
30 |
31 | + (NSTimer *)thresh_scheduledTimerWithTimeInterval:(NSTimeInterval)interval
32 | repeats:(BOOL)repeats
33 | block:(void (^)(NSTimer *timer))block;
34 |
35 | @end
36 |
37 | NS_ASSUME_NONNULL_END
38 |
--------------------------------------------------------------------------------
/ios/Classes/util/NSTimer+Thresh.m:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2021 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import "NSTimer+Thresh.h"
26 |
27 | @implementation NSTimer (Thresh)
28 |
29 | + (NSTimer *)thresh_scheduledTimerWithTimeInterval:(NSTimeInterval)interval
30 | repeats:(BOOL)repeats
31 | block:(void (^)(NSTimer *))block {
32 | return [self scheduledTimerWithTimeInterval:interval
33 | target:self
34 | selector:@selector(thresh_blockInvoke:)
35 | userInfo:[block copy]
36 | repeats:repeats];
37 | }
38 |
39 | + (void)thresh_blockInvoke:(NSTimer *)timer {
40 | void(^block)(NSTimer *timer) = timer.userInfo;
41 | if (block) {
42 | block(timer);
43 | }
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/ios/Classes/util/ThreshLogHandler.h:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
24 |
25 | #import
26 | #import "ThreshLogger.h"
27 |
28 | #define ThreshDebug(...) ThreshLog(ThreshLogDebug, __VA_ARGS__)
29 | #define ThreshInfo(...) ThreshLog(ThreshLogInfo, __VA_ARGS__)
30 | #define ThreshWarn(...) ThreshLog(ThreshLogWarn, __VA_ARGS__)
31 | #define ThreshError(...) ThreshLog(ThreshLogError, __VA_ARGS__)
32 | #define ThreshFatal(...) ThreshLog(ThreshLogFatal, __VA_ARGS__)
33 |
34 | #define ThreshLog(level, ...) [ThreshLogHandler log:level msg:[NSString stringWithFormat:__VA_ARGS__, nil] function:__FUNCTION__]
35 |
36 | @interface ThreshLogHandler : NSObject
37 |
38 | + (void)log:(ThreshLogLevel)level msg:(NSString *)msg function:(const char *)func;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/ios/thresh.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
3 | #
4 | Pod::Spec.new do |s|
5 | s.name = 'thresh'
6 | s.version = '0.0.1'
7 | s.summary = 'A new Flutter plugin.'
8 | s.description = <<-DESC
9 | A new Flutter plugin.
10 | DESC
11 | s.homepage = 'https://github.com/ymm-tech/thresh'
12 | s.license = { :file => '../LICENSE' }
13 | s.author = { 'Your Company' => 'email@example.com' }
14 | s.source = { :path => '.' }
15 | s.source_files = 'Classes/**/*'
16 | s.public_header_files = 'Classes/**/*.h'
17 | s.dependency 'Flutter'
18 | s.dependency 'AFNetworking', '4.0.1'
19 |
20 | s.ios.deployment_target = '8.0'
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/js-core/LICENSE:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 ManBang Group
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | *
23 | */
--------------------------------------------------------------------------------
/js-core/README.md:
--------------------------------------------------------------------------------
1 | # Thresh
2 |
3 | > What is Thresh?
4 | > A dynamic flutter framework.
5 |
6 | [如何使用 Thresh 进行动态 flutter 项目的开发?](https://wiki.amh-group.com/pages/viewpage.action?pageId=60425354)
--------------------------------------------------------------------------------
/js-core/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thresh-lib",
3 | "version": "1.3.33",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@types/node": {
8 | "version": "13.7.7",
9 | "resolved": "http://npm.ymmoa.com/@types%2fnode/-/node-13.7.7.tgz",
10 | "integrity": "sha1-FijmRhuozJtTGW3+rux7B/pu6pk=",
11 | "dev": true
12 | },
13 | "typescript": {
14 | "version": "4.1.3",
15 | "resolved": "http://npm.amh-group.com/typescript/-/typescript-4.1.3.tgz",
16 | "integrity": "sha1-UZ1YK9lMugz4k0x9joRn5HP1O7c=",
17 | "dev": true
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/js-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thresh-lib",
3 | "version": "1.3.55",
4 | "description": "Front-end framework for Thresh",
5 | "main": "index.ts",
6 | "author": "weishun.xu",
7 | "license": "MIT",
8 | "files": [
9 | "index.ts",
10 | "src/**/*"
11 | ],
12 | "devDependencies": {
13 | "@types/node": "^13.1.1",
14 | "typescript": "^4.1.3"
15 | },
16 | "scripts": {}
17 | }
--------------------------------------------------------------------------------
/js-core/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "jsxFactory": "Thresh.createElement",
5 | "lib": [ "es5", "es6", "es2017", "dom" ],
6 | "target": "es5"
7 | },
8 | "exclude": [ "node_modules/**/*" ]
9 | }
--------------------------------------------------------------------------------
/js-core/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@types/node@^13.1.1":
6 | version "13.13.34"
7 | resolved "http://npm.amh-group.com/@types%2fnode/-/node-13.13.34.tgz#c9300a1b6560d90817fb2bba650e250116a575f9"
8 | integrity sha1-yTAKG2Vg2QgX+yu6ZQ4lARaldfk=
9 |
10 | typescript@^4.1.3:
11 | version "4.1.3"
12 | resolved "http://npm.amh-group.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
13 | integrity sha1-UZ1YK9lMugz4k0x9joRn5HP1O7c=
14 |
--------------------------------------------------------------------------------
/lib/basic/bus.dart:
--------------------------------------------------------------------------------
1 | /// MIT License
2 | ///
3 | /// Copyright (c) 2020 ManBang Group
4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
5 | /// of this software and associated documentation files (the "Software"), to deal
6 | /// in the Software without restriction, including without limitation the rights
7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | /// copies of the Software, and to permit persons to whom the Software is
9 | /// furnished to do so, subject to the following conditions:
10 | ///
11 | /// The above copyright notice and this permission notice shall be included in all
12 | /// copies or substantial portions of the Software.
13 | ///
14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | /// SOFTWARE.
21 |
22 | class _Bus {
23 | Map pool = {};
24 | int busId = 0;
25 |
26 | dynamic register(Function callback, [String name]) {
27 | dynamic busName = name ?? (++busId).toString();
28 | if (!has(busName)) {
29 | pool[busName] = callback;
30 | return busName;
31 | }
32 | }
33 |
34 | fire(String name, {dynamic args}) {
35 | if (!has(name)) return;
36 | Function cb = pool[name];
37 | if (args == null)
38 | cb();
39 | else
40 | cb(args);
41 | }
42 |
43 | has(String name) {
44 | return !!(name != null && pool[name] != null);
45 | }
46 |
47 | remove(String name) {
48 | if (!has(name)) return;
49 | pool.remove(name);
50 | }
51 | }
52 |
53 | _Bus bus = _Bus();
54 |
--------------------------------------------------------------------------------
/lib/basic/device_info.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'dart:io';
3 |
4 | import 'package:device_info/device_info.dart';
5 |
6 | class Device {
7 |
8 | static AndroidDeviceInfo androidDeviceInfo;
9 |
10 | static IosDeviceInfo iosDeviceInfo;
11 |
12 | static initDeviceInfo() async {
13 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
14 | if(Platform.isAndroid){
15 | androidDeviceInfo = await deviceInfo.androidInfo;
16 | }else if(Platform.isIOS){
17 | iosDeviceInfo = await deviceInfo.iosInfo;
18 | }
19 | }
20 |
21 | static bool isAndroidQ(){
22 | if(Platform.isAndroid && Device.androidDeviceInfo != null && Device.androidDeviceInfo.version != null){
23 | return Device.androidDeviceInfo.version.sdkInt > 28;
24 | }
25 | return false;
26 | }
27 | }
--------------------------------------------------------------------------------
/lib/framework/channel/bridge.dart:
--------------------------------------------------------------------------------
1 | /// MIT License
2 | ///
3 | /// Copyright (c) 2020 ManBang Group
4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
5 | /// of this software and associated documentation files (the "Software"), to deal
6 | /// in the Software without restriction, including without limitation the rights
7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | /// copies of the Software, and to permit persons to whom the Software is
9 | /// furnished to do so, subject to the following conditions:
10 | ///
11 | /// The above copyright notice and this permission notice shall be included in all
12 | /// copies or substantial portions of the Software.
13 | ///
14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | /// SOFTWARE.
21 |
22 | import 'dart:convert';
23 | import 'package:thresh/basic/util.dart';
24 | import 'package:thresh/framework/core/dynamic_app.dart';
25 | import 'package:thresh/framework/channel/basic.dart';
26 |
27 | /// 注册渲染相关 channel 方法
28 | void registerBridgeChannelMethods () {
29 | DynamicChannel.register({
30 | 'bridgeRequest': (params) async {
31 | String methodId = Util.getString(params['methodId']);
32 | Map request = jsonDecode(params['request']);
33 | Map res = await Util.request(request['params']);
34 | dynamicApp?.call(
35 | method: ChannelMethod.bridgeResponse,
36 | params: {
37 | 'methodId': methodId,
38 | 'response': res
39 | }
40 | );
41 | },
42 | });
43 | }
44 |
--------------------------------------------------------------------------------
/lib/framework/channel/dev.dart:
--------------------------------------------------------------------------------
1 | /// MIT License
2 | ///
3 | /// Copyright (c) 2020 ManBang Group
4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
5 | /// of this software and associated documentation files (the "Software"), to deal
6 | /// in the Software without restriction, including without limitation the rights
7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | /// copies of the Software, and to permit persons to whom the Software is
9 | /// furnished to do so, subject to the following conditions:
10 | ///
11 | /// The above copyright notice and this permission notice shall be included in all
12 | /// copies or substantial portions of the Software.
13 | ///
14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | /// SOFTWARE.
21 |
22 | import 'package:thresh/basic/util.dart';
23 | import 'package:thresh/framework/channel/basic.dart';
24 | import 'package:thresh/devtools/dev_tools.dart';
25 |
26 | /// 注册渲染相关 channel 方法
27 | void registerDevtoolsChannelMethods () {
28 | DynamicChannel.register({
29 | 'devtools': (params) {
30 | String type = Util.getString(params['type']);
31 | String title = Util.getString(params['title']);
32 | String content = Util.getString(params['content']);
33 | if (type == null) return;
34 | InfoType infoType = InfoType.getType(type);
35 | if (infoType == null) return;
36 | devtools.insert(infoType, DevInfo(
37 | title: title,
38 | content: content
39 | ));
40 | },
41 | });
42 | }
43 |
--------------------------------------------------------------------------------
/lib/thresh.dart:
--------------------------------------------------------------------------------
1 | /// MIT License
2 | ///
3 | /// Copyright (c) 2020 ManBang Group
4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
5 | /// of this software and associated documentation files (the "Software"), to deal
6 | /// in the Software without restriction, including without limitation the rights
7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | /// copies of the Software, and to permit persons to whom the Software is
9 | /// furnished to do so, subject to the following conditions:
10 | ///
11 | /// The above copyright notice and this permission notice shall be included in all
12 | /// copies or substantial portions of the Software.
13 | ///
14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | /// SOFTWARE.
21 |
22 | library thresh;
23 |
24 | export 'framework/main.dart';
25 |
--------------------------------------------------------------------------------