@kbapp/js-bridge 1.0.2-alpha.0 → 1.0.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +92 -64
- package/dist/index.es.js +179 -177
- package/dist/index.umd.js +1 -1
- package/dist/lib/open-post-editor.d.ts +68 -69
- package/dist/lib/trigger-login.d.ts +4 -5
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -87,7 +87,7 @@ async function saveImageHandle() {
|
|
|
87
87
|
| 62 | `saveImageToLocal` | 保存图片到本地 |
|
|
88
88
|
| 63 | `saveVideoToLocal` | 保存视频到本地 |
|
|
89
89
|
| 69 | `reportDAEvent` | 上报数据埋点 |
|
|
90
|
-
| - | `
|
|
90
|
+
| - | `onLoopCheckAppLogin` | 监听登录成功回调 |
|
|
91
91
|
| 31 | `getAppLoginInfo` | 获取 app 登录信息 |
|
|
92
92
|
| 31 | `triggerAppLogin` | 触发 app 登录 |
|
|
93
93
|
| 71 | `setScreenOrientation` | 设置屏幕方向 |
|
|
@@ -95,13 +95,13 @@ async function saveImageHandle() {
|
|
|
95
95
|
| 73 | `openAppSubscribeNotifySettings` | 前往/打开 app订阅管理页面 |
|
|
96
96
|
| 1001 | `runAction` | 执行 action |
|
|
97
97
|
|
|
98
|
-
| 类/枚举
|
|
99
|
-
|
|
|
100
|
-
| `BridgeCode`
|
|
101
|
-
| `IS_KB_APP_ENV`
|
|
102
|
-
| `AppLoginInfo`
|
|
103
|
-
| `AppShareModel`
|
|
104
|
-
| `AppBaseInfo`
|
|
98
|
+
| 类/枚举 | 说明 |
|
|
99
|
+
| --------------- | --------------------- |
|
|
100
|
+
| `BridgeCode` | kbapp 桥接状态码 |
|
|
101
|
+
| `IS_KB_APP_ENV` | 是否在开吧 APP 环境中 |
|
|
102
|
+
| `AppLoginInfo` | 登录信息模型 |
|
|
103
|
+
| `AppShareModel` | 应用分享模型 |
|
|
104
|
+
| `AppBaseInfo` | 设备信息模型 |
|
|
105
105
|
|
|
106
106
|
### checkForNewVersion
|
|
107
107
|
|
|
@@ -389,7 +389,7 @@ generateKBSign({
|
|
|
389
389
|
|
|
390
390
|
| 参数 | 类型 | 必填 | 说明 |
|
|
391
391
|
| ---------- | ----------------------------- | -------------- | -------- | -------- |
|
|
392
|
-
| `success` | `(res: AppLoginInfo
|
|
392
|
+
| `success` | `(res: AppLoginInfo | null) => void` | 否 | 成功回调 |
|
|
393
393
|
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
394
394
|
| `complete` | `() => void` | 否 | 完成回调 |
|
|
395
395
|
|
|
@@ -546,14 +546,42 @@ Promise<{
|
|
|
546
546
|
|
|
547
547
|
#### 示例代码
|
|
548
548
|
|
|
549
|
+
推荐使用 `createPostEditorParamsByThreadPostRule` 构造参数
|
|
550
|
+
|
|
549
551
|
```js
|
|
550
|
-
import { openPostEditor } from '@kbapp/js-bridge'
|
|
552
|
+
import { createPostEditorParamsByThreadPostRule, openPostEditor, KbRequirement } from '@kbapp/js-bridge'
|
|
553
|
+
|
|
554
|
+
openPostEditor({
|
|
555
|
+
postRule: createPostEditorParamsByThreadPostRule({
|
|
556
|
+
textMin: 0,
|
|
557
|
+
textMax: 1000,
|
|
558
|
+
/** 帖子中, 图片的最大张数 */
|
|
559
|
+
imageMax = 9,
|
|
560
|
+
|
|
561
|
+
/** 帖子中, 图片的最小张数 */
|
|
562
|
+
imageMin = 0,
|
|
563
|
+
|
|
564
|
+
/** 音频限制 */
|
|
565
|
+
audioRqr: KbRequirement.FREE,
|
|
566
|
+
|
|
567
|
+
/** 视频限制 */
|
|
568
|
+
videoRqr: KbRequirement.FREE,
|
|
569
|
+
|
|
570
|
+
/** 媒资限制 */
|
|
571
|
+
mediaRqr: KbRequirement.FORBID,
|
|
572
|
+
|
|
573
|
+
/** 位置-逆地理信息限制 */
|
|
574
|
+
streetRqr: KbRequirement.FREE
|
|
575
|
+
}),
|
|
576
|
+
})
|
|
551
577
|
|
|
552
578
|
openPostEditor({
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
579
|
+
postRule: {
|
|
580
|
+
hint: '请输入内容',
|
|
581
|
+
initialText: '默认内容',
|
|
582
|
+
image: true,
|
|
583
|
+
max_image_count: 9,
|
|
584
|
+
},
|
|
557
585
|
success(result) {
|
|
558
586
|
console.log('发帖内容', result)
|
|
559
587
|
},
|
|
@@ -598,14 +626,58 @@ const stopHandle = onAppSharePanelShow(() => {
|
|
|
598
626
|
|
|
599
627
|
---
|
|
600
628
|
|
|
601
|
-
###
|
|
629
|
+
### triggerAppLogin
|
|
630
|
+
|
|
631
|
+
> 触发 app 登录
|
|
632
|
+
|
|
633
|
+
#### 请求参数
|
|
634
|
+
|
|
635
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
636
|
+
| ---------- | ----------------------------- | ---- | -------- |
|
|
637
|
+
| `success` | `() => void` | 否 | 成功回调 |
|
|
638
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
639
|
+
| `complete` | `() => void` | 否 | 完成回调 |
|
|
640
|
+
|
|
641
|
+
#### 返回值
|
|
642
|
+
|
|
643
|
+
```js
|
|
644
|
+
Promise<void>
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
#### 示例代码
|
|
648
|
+
|
|
649
|
+
```js
|
|
650
|
+
import { triggerAppLogin, onLoopCheckAppLogin } from '@kbapp/js-bridge'
|
|
651
|
+
|
|
652
|
+
// 监听登录成功
|
|
653
|
+
const handle = onLoopCheckAppLogin((loginInfo) => {
|
|
654
|
+
console.log('登录成功', loginInfo)
|
|
655
|
+
handle() // 停止监听
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
// 触发登录
|
|
659
|
+
triggerAppLogin({
|
|
660
|
+
success() {
|
|
661
|
+
console.log('触发登录成功')
|
|
662
|
+
},
|
|
663
|
+
fail(error) {
|
|
664
|
+
console.log('触发登录失败', error)
|
|
665
|
+
},
|
|
666
|
+
})
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
> 支持 Promise 风格调用
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
673
|
+
### onLoopCheckAppLogin
|
|
602
674
|
|
|
603
|
-
>
|
|
675
|
+
> 启动轮询检查 APP 登录状态,查询到已登录后立即触发回调并自动回收回调函数(支持主动取消监听)
|
|
604
676
|
|
|
605
677
|
#### 请求参数
|
|
606
678
|
|
|
607
|
-
| 参数 | 类型
|
|
608
|
-
| ---------- |
|
|
679
|
+
| 参数 | 类型 | 说明 |
|
|
680
|
+
| ---------- | ----------------------------------- | ------------ |
|
|
609
681
|
| `callback` | `(loginInfo: AppLoginInfo) => void` | 登录成功回调 |
|
|
610
682
|
|
|
611
683
|
#### 返回值
|
|
@@ -618,9 +690,9 @@ const stopHandle = onAppSharePanelShow(() => {
|
|
|
618
690
|
#### 示例代码
|
|
619
691
|
|
|
620
692
|
```js
|
|
621
|
-
import {
|
|
693
|
+
import { onLoopCheckAppLogin } from '@kbapp/js-bridge'
|
|
622
694
|
|
|
623
|
-
const handle =
|
|
695
|
+
const handle = onLoopCheckAppLogin((loginInfo) => {
|
|
624
696
|
console.log('登录成功', loginInfo)
|
|
625
697
|
})
|
|
626
698
|
|
|
@@ -1023,50 +1095,6 @@ subscribeNotify({
|
|
|
1023
1095
|
|
|
1024
1096
|
---
|
|
1025
1097
|
|
|
1026
|
-
### triggerAppLogin
|
|
1027
|
-
|
|
1028
|
-
> 触发 app 登录
|
|
1029
|
-
|
|
1030
|
-
#### 请求参数
|
|
1031
|
-
|
|
1032
|
-
| 参数 | 类型 | 必填 | 说明 |
|
|
1033
|
-
| ---------- | ----------------------------- | ---- | -------- |
|
|
1034
|
-
| `success` | `() => void` | 否 | 成功回调 |
|
|
1035
|
-
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
1036
|
-
| `complete` | `() => void` | 否 | 完成回调 |
|
|
1037
|
-
|
|
1038
|
-
#### 返回值
|
|
1039
|
-
|
|
1040
|
-
```js
|
|
1041
|
-
Promise<void>
|
|
1042
|
-
```
|
|
1043
|
-
|
|
1044
|
-
#### 示例代码
|
|
1045
|
-
|
|
1046
|
-
```js
|
|
1047
|
-
import { triggerAppLogin, onAppLoginSuccess } from '@kbapp/js-bridge'
|
|
1048
|
-
|
|
1049
|
-
// 监听登录成功
|
|
1050
|
-
const handle = onAppLoginSuccess((loginInfo) => {
|
|
1051
|
-
console.log('登录成功', loginInfo)
|
|
1052
|
-
handle() // 停止监听
|
|
1053
|
-
})
|
|
1054
|
-
|
|
1055
|
-
// 触发登录
|
|
1056
|
-
triggerAppLogin({
|
|
1057
|
-
success() {
|
|
1058
|
-
console.log('触发登录成功')
|
|
1059
|
-
},
|
|
1060
|
-
fail(error) {
|
|
1061
|
-
console.log('触发登录失败', error)
|
|
1062
|
-
},
|
|
1063
|
-
})
|
|
1064
|
-
```
|
|
1065
|
-
|
|
1066
|
-
> 支持 Promise 风格调用
|
|
1067
|
-
|
|
1068
|
-
---
|
|
1069
|
-
|
|
1070
1098
|
### isAppVersionSupport
|
|
1071
1099
|
|
|
1072
1100
|
> 判断当前版本号是否支持
|
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function N(e) {
|
|
2
2
|
if (Object.prototype.toString.call(e) !== "[object Object]")
|
|
3
3
|
return e;
|
|
4
4
|
const t = {};
|
|
5
5
|
return Object.keys(e).forEach((r) => {
|
|
6
6
|
const i = e[r];
|
|
7
|
-
i != null && (t[r] = Object.prototype.toString.call(i) === "[object Object]" ?
|
|
7
|
+
i != null && (t[r] = Object.prototype.toString.call(i) === "[object Object]" ? N(i) : i);
|
|
8
8
|
}), t;
|
|
9
9
|
}
|
|
10
10
|
const l = class l {
|
|
@@ -25,52 +25,52 @@ l.UNKNOWN = new l({
|
|
|
25
25
|
errorCode: 1003,
|
|
26
26
|
errorMsg: "请在开吧app内执行"
|
|
27
27
|
});
|
|
28
|
-
let
|
|
29
|
-
const
|
|
30
|
-
const e = (
|
|
31
|
-
var
|
|
32
|
-
typeof
|
|
33
|
-
var d = { data:
|
|
28
|
+
let f = l;
|
|
29
|
+
const V = () => {
|
|
30
|
+
const e = (s, o, n) => {
|
|
31
|
+
var c = "";
|
|
32
|
+
typeof o == "function" && (n = o, o = {});
|
|
33
|
+
var d = { data: o === void 0 ? null : o };
|
|
34
34
|
if (typeof n == "function") {
|
|
35
|
-
var
|
|
36
|
-
window[
|
|
35
|
+
var p = "dscb" + window.dscb++;
|
|
36
|
+
window[p] = n, d._dscbstub = p;
|
|
37
37
|
}
|
|
38
|
-
if (d = JSON.stringify(d), window.flutter_inappwebview ? window.flutter_inappwebview.callHandler && (
|
|
39
|
-
return
|
|
38
|
+
if (d = JSON.stringify(d), window.flutter_inappwebview ? window.flutter_inappwebview.callHandler && (c = window.flutter_inappwebview.callHandler("" + s, d)) : (window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1) && (c = prompt("_flutterDsbridge=" + s, d)), c instanceof Promise)
|
|
39
|
+
return c;
|
|
40
40
|
try {
|
|
41
|
-
return JSON.parse(
|
|
41
|
+
return JSON.parse(c || "{}").data;
|
|
42
42
|
} catch {
|
|
43
43
|
console.error("callHandle异常,JSON.parse错误");
|
|
44
44
|
}
|
|
45
45
|
}, t = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, r = (() => {
|
|
46
|
-
const
|
|
47
|
-
t() && (clearInterval(
|
|
46
|
+
const s = [], o = setInterval(() => {
|
|
47
|
+
t() && (clearInterval(o), s.forEach((n) => {
|
|
48
48
|
e.apply(window, n);
|
|
49
|
-
}),
|
|
49
|
+
}), s.length = 0);
|
|
50
50
|
}, 500);
|
|
51
51
|
return (...n) => {
|
|
52
|
-
|
|
52
|
+
s.push(n);
|
|
53
53
|
};
|
|
54
54
|
})();
|
|
55
55
|
var i = {
|
|
56
56
|
default: void 0,
|
|
57
57
|
// for typescript
|
|
58
|
-
callHandler: function(
|
|
59
|
-
return t() ? e(
|
|
58
|
+
callHandler: function(s, o, n) {
|
|
59
|
+
return t() ? e(s, o, n) : r(s, o, n);
|
|
60
60
|
},
|
|
61
|
-
register: function(
|
|
62
|
-
var
|
|
61
|
+
register: function(s, o, n) {
|
|
62
|
+
var c = n ? window._dsaf : window._dsf;
|
|
63
63
|
window._dsInit || (window._dsInit = !0, setTimeout(function() {
|
|
64
64
|
i.callHandler("_dsb.dsinit");
|
|
65
|
-
}, 0)), typeof
|
|
65
|
+
}, 0)), typeof o == "object" ? c._obs[s] = o : c[s] = o;
|
|
66
66
|
},
|
|
67
|
-
registerHandler: function(
|
|
68
|
-
this.register(
|
|
67
|
+
registerHandler: function(s, o) {
|
|
68
|
+
this.register(s, o, !0);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
return function() {
|
|
72
72
|
if (!window._dsf) {
|
|
73
|
-
var
|
|
73
|
+
var s = {
|
|
74
74
|
//保存JS同步方法
|
|
75
75
|
_dsf: {
|
|
76
76
|
_obs: {}
|
|
@@ -82,123 +82,123 @@ const C = () => {
|
|
|
82
82
|
dscb: 0,
|
|
83
83
|
jsBridge: i,
|
|
84
84
|
_handleMessageFromNative: function(n) {
|
|
85
|
-
var
|
|
85
|
+
var c = JSON.parse(n.data), d = {
|
|
86
86
|
id: n.callbackId,
|
|
87
87
|
complete: !0
|
|
88
|
-
},
|
|
89
|
-
d.data =
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
d.data =
|
|
93
|
-
}),
|
|
88
|
+
}, p = this._dsf[n.method], y = this._dsaf[n.method], T = function(E, O) {
|
|
89
|
+
d.data = E.apply(O, c), i.callHandler("_dsb.returnValue", d);
|
|
90
|
+
}, k = function(E, O) {
|
|
91
|
+
c.push(function(M, U) {
|
|
92
|
+
d.data = M, d.complete = U !== !1, i.callHandler("_dsb.returnValue", d);
|
|
93
|
+
}), E.apply(O, c);
|
|
94
94
|
};
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
else if (
|
|
98
|
-
|
|
95
|
+
if (p)
|
|
96
|
+
T(p, this._dsf);
|
|
97
|
+
else if (y)
|
|
98
|
+
k(y, this._dsaf);
|
|
99
99
|
else {
|
|
100
|
-
var
|
|
101
|
-
if (
|
|
102
|
-
var
|
|
103
|
-
if (
|
|
104
|
-
|
|
100
|
+
var A = n.method.split(".");
|
|
101
|
+
if (A.length < 2) return;
|
|
102
|
+
var P = A.pop(), b = A.join("."), R = this._dsf._obs, g = R[b] || {}, w = g[P];
|
|
103
|
+
if (w && typeof w == "function") {
|
|
104
|
+
T(w, g);
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
107
|
+
if (R = this._dsaf._obs, g = R[b] || {}, w = g[P], w && typeof w == "function") {
|
|
108
|
+
k(w, g);
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
for (var
|
|
115
|
-
window[
|
|
114
|
+
for (var o in s)
|
|
115
|
+
window[o] = s[o];
|
|
116
116
|
}
|
|
117
117
|
}(), i;
|
|
118
118
|
};
|
|
119
119
|
var I;
|
|
120
|
-
const
|
|
120
|
+
const S = ((e) => /(kb)/i.test(e) ? V() : {
|
|
121
121
|
registerHandler(t, r) {
|
|
122
|
-
throw
|
|
122
|
+
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
123
123
|
},
|
|
124
124
|
callHandler(t, r, i) {
|
|
125
|
-
throw
|
|
125
|
+
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
126
126
|
}
|
|
127
|
-
})((I = window == null ? void 0 : window.navigator) == null ? void 0 : I.userAgent),
|
|
128
|
-
var i,
|
|
127
|
+
})((I = window == null ? void 0 : window.navigator) == null ? void 0 : I.userAgent), q = (e) => new Promise((t, r) => {
|
|
128
|
+
var i, s, o;
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
S.registerHandler(e.name, e.handler), (i = e.success) == null || i.call(e), t();
|
|
131
131
|
} catch (n) {
|
|
132
|
-
(
|
|
132
|
+
(s = e.fail) == null || s.call(e, n), r(n);
|
|
133
133
|
} finally {
|
|
134
|
-
(
|
|
134
|
+
(o = e.complete) == null || o.call(e);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
|
-
function
|
|
137
|
+
function h(e) {
|
|
138
138
|
const t = (r) => {
|
|
139
139
|
let i;
|
|
140
|
-
const
|
|
141
|
-
var
|
|
142
|
-
(!i || i === "success") && (i = "success", (
|
|
143
|
-
},
|
|
144
|
-
var
|
|
145
|
-
(!i || i === "error") && (i = "error", (
|
|
140
|
+
const s = (n) => {
|
|
141
|
+
var c;
|
|
142
|
+
(!i || i === "success") && (i = "success", (c = r.success) == null || c.call(r, n));
|
|
143
|
+
}, o = (n) => {
|
|
144
|
+
var c;
|
|
145
|
+
(!i || i === "error") && (i = "error", (c = r.fail) == null || c.call(r, n));
|
|
146
146
|
};
|
|
147
147
|
r.timeout && setTimeout(() => {
|
|
148
|
-
|
|
148
|
+
o(f.TIMEOUT);
|
|
149
149
|
}, r.timeout);
|
|
150
150
|
try {
|
|
151
|
-
|
|
152
|
-
let
|
|
151
|
+
S.callHandler(r.name, r.params, (n) => {
|
|
152
|
+
let c;
|
|
153
153
|
try {
|
|
154
|
-
typeof n == "string" && /^\s*(\{|\[).*(\}|\])\s*$/.test(n) ?
|
|
154
|
+
typeof n == "string" && /^\s*(\{|\[).*(\}|\])\s*$/.test(n) ? c = JSON.parse(n.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : c = n;
|
|
155
155
|
} catch {
|
|
156
|
-
|
|
156
|
+
c = n;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
s(c);
|
|
159
159
|
});
|
|
160
160
|
} catch (n) {
|
|
161
|
-
|
|
161
|
+
o(n);
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
return new Promise((r, i) => {
|
|
165
165
|
t({
|
|
166
166
|
name: e.name,
|
|
167
|
-
params:
|
|
167
|
+
params: N(e.params),
|
|
168
168
|
timeout: e.timeout,
|
|
169
|
-
success: (
|
|
170
|
-
var
|
|
171
|
-
(
|
|
169
|
+
success: (s) => {
|
|
170
|
+
var o, n;
|
|
171
|
+
(o = e.success) == null || o.call(e, s), (n = e.complete) == null || n.call(e), r(s);
|
|
172
172
|
},
|
|
173
|
-
fail: (
|
|
174
|
-
var
|
|
175
|
-
(
|
|
173
|
+
fail: (s) => {
|
|
174
|
+
var o, n;
|
|
175
|
+
(o = e.fail) == null || o.call(e, s), (n = e.complete) == null || n.call(e), i(s);
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
function u(e) {
|
|
181
|
-
|
|
181
|
+
S.callHandler(e.name, e.params, (t) => {
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function a(e) {
|
|
185
185
|
return async function(...r) {
|
|
186
|
-
const i = r[0] || {}, { success:
|
|
186
|
+
const i = r[0] || {}, { success: s, fail: o, complete: n, ...c } = i;
|
|
187
187
|
try {
|
|
188
|
-
const d = await Promise.resolve(e(
|
|
189
|
-
return
|
|
188
|
+
const d = await Promise.resolve(e(c));
|
|
189
|
+
return s == null || s(d), d;
|
|
190
190
|
} catch (d) {
|
|
191
|
-
const
|
|
192
|
-
errorCode:
|
|
191
|
+
const p = d != null && d.errorCode ? d : new f({
|
|
192
|
+
errorCode: f.UNKNOWN.errorCode,
|
|
193
193
|
errorMsg: String(d)
|
|
194
194
|
});
|
|
195
|
-
throw
|
|
195
|
+
throw o == null || o(p), p;
|
|
196
196
|
} finally {
|
|
197
197
|
n == null || n();
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function D(e) {
|
|
202
202
|
let t;
|
|
203
203
|
return function(...r) {
|
|
204
204
|
return t || (t = e(...r), Promise.resolve(t).catch(() => {
|
|
@@ -206,28 +206,28 @@ function M(e) {
|
|
|
206
206
|
}), t);
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
class
|
|
209
|
+
class B {
|
|
210
210
|
}
|
|
211
|
-
const H =
|
|
212
|
-
|
|
211
|
+
const H = a(
|
|
212
|
+
D(() => h({
|
|
213
213
|
name: "OpenActRequest",
|
|
214
214
|
params: {
|
|
215
215
|
type: 35,
|
|
216
216
|
data: {}
|
|
217
217
|
}
|
|
218
218
|
}))
|
|
219
|
-
),
|
|
220
|
-
function
|
|
221
|
-
return (...r) =>
|
|
219
|
+
), C = a(async (e) => (await H()).vcode >= e.minVersion);
|
|
220
|
+
function F(e, t) {
|
|
221
|
+
return (...r) => C({
|
|
222
222
|
minVersion: e.minVersion
|
|
223
223
|
}).then((i) => i ? t(...r) : Promise.reject(
|
|
224
|
-
new
|
|
225
|
-
errorCode:
|
|
224
|
+
new f({
|
|
225
|
+
errorCode: f.UNSUPPORTED_VERSION.errorCode,
|
|
226
226
|
errorMsg: `最低版本要求${e.minVersion}`
|
|
227
227
|
})
|
|
228
228
|
));
|
|
229
229
|
}
|
|
230
|
-
const J =
|
|
230
|
+
const J = a(() => {
|
|
231
231
|
u({
|
|
232
232
|
name: "OpenActRequest",
|
|
233
233
|
params: {
|
|
@@ -235,7 +235,7 @@ const J = c(() => {
|
|
|
235
235
|
data: null
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
|
-
}),
|
|
238
|
+
}), W = a(() => {
|
|
239
239
|
u({
|
|
240
240
|
name: "OpenActRequest",
|
|
241
241
|
params: {
|
|
@@ -243,17 +243,17 @@ const J = c(() => {
|
|
|
243
243
|
data: {}
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
|
-
}),
|
|
246
|
+
}), m = {
|
|
247
247
|
microphone: { description: "用于发帖上传音频" },
|
|
248
248
|
location: { description: "获取你选择的位置信息,用于线下导航服务" },
|
|
249
249
|
camera: { description: "收集你选中的照片或视频信息 ,用于 发表评论、分享视频" }
|
|
250
|
-
},
|
|
250
|
+
}, G = a((e) => (Object.assign(m, e), q({
|
|
251
251
|
name: "getPermissionUsage",
|
|
252
252
|
handler(t, r) {
|
|
253
|
-
r(
|
|
253
|
+
r(m[t.permission]);
|
|
254
254
|
}
|
|
255
|
-
}))),
|
|
256
|
-
const { kbKey: t, ...r } = e, { data: i } = await
|
|
255
|
+
}))), Q = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent), $ = a(async (e) => {
|
|
256
|
+
const { kbKey: t, ...r } = e, { data: i } = await h({
|
|
257
257
|
name: "OpenActRequest",
|
|
258
258
|
params: {
|
|
259
259
|
type: 51,
|
|
@@ -262,43 +262,44 @@ const J = c(() => {
|
|
|
262
262
|
});
|
|
263
263
|
return i;
|
|
264
264
|
});
|
|
265
|
-
|
|
265
|
+
var x = /* @__PURE__ */ ((e) => (e[e.FREE = 1] = "FREE", e[e.FORBID = 2] = "FORBID", e[e.REQUIRED = 3] = "REQUIRED", e))(x || {});
|
|
266
|
+
class L {
|
|
266
267
|
constructor() {
|
|
267
|
-
this.
|
|
268
|
+
this.textMin = 0, this.textMax = 1e3, this.imageMax = 9, this.imageMin = 0, this.audioRqr = 1, this.videoRqr = 1, this.mediaRqr = 2, this.streetRqr = 1;
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
function
|
|
271
|
-
const t = new
|
|
272
|
-
return e && Object.keys(e).forEach((
|
|
273
|
-
t[
|
|
271
|
+
function z(e) {
|
|
272
|
+
const t = new L();
|
|
273
|
+
return e && Object.keys(e).forEach((r) => {
|
|
274
|
+
t[r] = e[r];
|
|
274
275
|
}), {
|
|
275
|
-
hint:
|
|
276
|
-
initialText:
|
|
277
|
-
audio: t.
|
|
278
|
-
image: t.
|
|
279
|
-
video: t.
|
|
280
|
-
address: t.
|
|
281
|
-
asset_video: t.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
min_image_count: t.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
276
|
+
hint: e == null ? void 0 : e.placeholder,
|
|
277
|
+
initialText: e == null ? void 0 : e.initialText,
|
|
278
|
+
audio: t.audioRqr !== 2,
|
|
279
|
+
image: t.imageMax !== 0,
|
|
280
|
+
video: t.videoRqr !== 2,
|
|
281
|
+
address: t.streetRqr !== 2,
|
|
282
|
+
asset_video: t.mediaRqr !== 2,
|
|
283
|
+
audio_must: t.audioRqr === 3,
|
|
284
|
+
image_must: t.imageMin > 0,
|
|
285
|
+
asset_video_must: t.mediaRqr === 3,
|
|
286
|
+
max_image_count: t.imageMax,
|
|
287
|
+
min_image_count: t.imageMin,
|
|
288
|
+
video_must: t.videoRqr === 3,
|
|
289
|
+
text_must: t.textMin > 0,
|
|
290
|
+
content_max_length: t.textMax,
|
|
291
|
+
content_min_length: t.textMin
|
|
291
292
|
};
|
|
292
293
|
}
|
|
293
|
-
const
|
|
294
|
-
async (e
|
|
294
|
+
const K = a(
|
|
295
|
+
async (e) => h({
|
|
295
296
|
name: "OpenActRequest",
|
|
296
|
-
params: { type: 13, data: e }
|
|
297
|
+
params: { type: 13, data: (e == null ? void 0 : e.postRule) ?? {} }
|
|
297
298
|
}).then(({ data: t }) => {
|
|
298
299
|
const { pic: r, ...i } = t;
|
|
299
300
|
return { images: r, ...i };
|
|
300
301
|
})
|
|
301
|
-
),
|
|
302
|
+
), X = a(
|
|
302
303
|
(e) => {
|
|
303
304
|
u({
|
|
304
305
|
name: "OpenActRequest",
|
|
@@ -315,7 +316,7 @@ const z = c(
|
|
|
315
316
|
}
|
|
316
317
|
});
|
|
317
318
|
}
|
|
318
|
-
),
|
|
319
|
+
), Y = a((e) => {
|
|
319
320
|
u({
|
|
320
321
|
name: "OpenActRequest",
|
|
321
322
|
params: {
|
|
@@ -323,7 +324,7 @@ const z = c(
|
|
|
323
324
|
data: e
|
|
324
325
|
}
|
|
325
326
|
});
|
|
326
|
-
}),
|
|
327
|
+
}), Z = a(
|
|
327
328
|
(e) => {
|
|
328
329
|
u({
|
|
329
330
|
name: "OpenActRequest",
|
|
@@ -333,7 +334,7 @@ const z = c(
|
|
|
333
334
|
}
|
|
334
335
|
});
|
|
335
336
|
}
|
|
336
|
-
),
|
|
337
|
+
), ee = a(
|
|
337
338
|
(e) => {
|
|
338
339
|
u({
|
|
339
340
|
name: "OpenActRequest",
|
|
@@ -343,13 +344,13 @@ const z = c(
|
|
|
343
344
|
}
|
|
344
345
|
});
|
|
345
346
|
}
|
|
346
|
-
),
|
|
347
|
+
), te = a(() => h({
|
|
347
348
|
name: "OpenActRequest",
|
|
348
349
|
params: {
|
|
349
350
|
type: 26,
|
|
350
351
|
data: {}
|
|
351
352
|
}
|
|
352
|
-
})),
|
|
353
|
+
})), ne = a(
|
|
353
354
|
(e) => {
|
|
354
355
|
u({
|
|
355
356
|
name: "OpenActRequest",
|
|
@@ -359,7 +360,7 @@ const z = c(
|
|
|
359
360
|
}
|
|
360
361
|
});
|
|
361
362
|
}
|
|
362
|
-
),
|
|
363
|
+
), re = a(
|
|
363
364
|
(e) => {
|
|
364
365
|
u({
|
|
365
366
|
name: "OpenActRequest",
|
|
@@ -369,7 +370,7 @@ const z = c(
|
|
|
369
370
|
}
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
|
-
),
|
|
373
|
+
), oe = a(
|
|
373
374
|
(e) => {
|
|
374
375
|
u({
|
|
375
376
|
name: "OpenActRequest",
|
|
@@ -382,12 +383,12 @@ const z = c(
|
|
|
382
383
|
), _ = "SHARE_EVENT_NAME";
|
|
383
384
|
class ie {
|
|
384
385
|
}
|
|
385
|
-
const se =
|
|
386
|
+
const se = a((e) => q({
|
|
386
387
|
name: "CommonShare",
|
|
387
388
|
handler(t, r) {
|
|
388
389
|
window.dispatchEvent(new Event(_)), "onShareApp" in e && e.onShareApp ? r({ type: 12, data: e.onShareApp() }) : r({ type: 12, data: e });
|
|
389
390
|
}
|
|
390
|
-
})),
|
|
391
|
+
})), ce = a(async (e) => {
|
|
391
392
|
window.dispatchEvent(new Event(_)), u({
|
|
392
393
|
name: "OpenActRequest",
|
|
393
394
|
params: {
|
|
@@ -401,7 +402,7 @@ function ae(e) {
|
|
|
401
402
|
window.removeEventListener(_, e);
|
|
402
403
|
};
|
|
403
404
|
}
|
|
404
|
-
const
|
|
405
|
+
const de = a(
|
|
405
406
|
(e) => {
|
|
406
407
|
u({
|
|
407
408
|
name: "OpenActRequest",
|
|
@@ -414,12 +415,12 @@ const ce = c(
|
|
|
414
415
|
}
|
|
415
416
|
});
|
|
416
417
|
}
|
|
417
|
-
),
|
|
418
|
+
), ue = a(() => h({
|
|
418
419
|
name: "OpenActRequest",
|
|
419
420
|
params: {
|
|
420
421
|
type: 72
|
|
421
422
|
}
|
|
422
|
-
})),
|
|
423
|
+
})), le = a(async () => {
|
|
423
424
|
u({
|
|
424
425
|
name: "OpenActRequest",
|
|
425
426
|
params: {
|
|
@@ -427,21 +428,21 @@ const ce = c(
|
|
|
427
428
|
}
|
|
428
429
|
});
|
|
429
430
|
});
|
|
430
|
-
class
|
|
431
|
+
class fe {
|
|
431
432
|
}
|
|
432
|
-
const
|
|
433
|
+
const j = a(async () => (await h({
|
|
433
434
|
name: "OpenActRequest",
|
|
434
435
|
params: { type: 31, data: { requireLogin: !1 } }
|
|
435
|
-
})).data || null),
|
|
436
|
+
})).data || null), v = /* @__PURE__ */ (() => {
|
|
436
437
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ (() => {
|
|
437
438
|
let r;
|
|
438
|
-
const i = (
|
|
439
|
+
const i = (s) => {
|
|
439
440
|
r = setTimeout(async () => {
|
|
440
|
-
const n = await
|
|
441
|
+
const n = await j();
|
|
441
442
|
if (!n)
|
|
442
|
-
return i(++
|
|
443
|
-
e.forEach((
|
|
444
|
-
}, ((n) => n === 0 ? 0 : n < 50 ? 600 : n < 80 ? 1e3 : 5e3)(
|
|
443
|
+
return i(++s);
|
|
444
|
+
e.forEach((c) => c(n)), e.clear();
|
|
445
|
+
}, ((n) => n === 0 ? 0 : n < 50 ? 600 : n < 80 ? 1e3 : 5e3)(s));
|
|
445
446
|
};
|
|
446
447
|
return {
|
|
447
448
|
start() {
|
|
@@ -466,52 +467,53 @@ const x = c(async () => (await w({
|
|
|
466
467
|
t.start();
|
|
467
468
|
}
|
|
468
469
|
};
|
|
469
|
-
})(), pe =
|
|
470
|
-
|
|
470
|
+
})(), pe = a(async () => {
|
|
471
|
+
v.triggerCheckTask(), h({
|
|
471
472
|
name: "OpenActRequest",
|
|
472
473
|
params: { type: 31, data: { requireLogin: !0 } },
|
|
473
474
|
success(e) {
|
|
474
475
|
var t;
|
|
475
|
-
(t = e.data) != null && t.userId &&
|
|
476
|
+
(t = e.data) != null && t.userId && v.triggerCheckTask();
|
|
476
477
|
}
|
|
477
478
|
});
|
|
478
|
-
}),
|
|
479
|
-
|
|
479
|
+
}), we = (e) => (v.addTask(e), v.triggerCheckTask(), () => {
|
|
480
|
+
v.removeTask(e);
|
|
480
481
|
});
|
|
481
482
|
export {
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
B as AppBaseInfo,
|
|
484
|
+
fe as AppLoginInfo,
|
|
484
485
|
ie as AppShareModel,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
f as BridgeCode,
|
|
487
|
+
Q as IS_KB_APP_ENV,
|
|
488
|
+
x as KbRequirement,
|
|
489
|
+
L as NoteThreadPostRule,
|
|
488
490
|
J as checkForNewVersion,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
491
|
+
W as closeWebView,
|
|
492
|
+
z as createPostEditorParamsByThreadPostRule,
|
|
493
|
+
F as decorateAppVersionSupport,
|
|
492
494
|
se as defineAppShareModel,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
495
|
+
de as defineAppSharePanelState,
|
|
496
|
+
q as defineBridgeCallback,
|
|
497
|
+
G as definePermissionUsage,
|
|
498
|
+
$ as generateKBSign,
|
|
497
499
|
H as getAppBaseInfo,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
fe as onAppLoginSuccess,
|
|
500
|
+
j as getAppLoginInfo,
|
|
501
|
+
ue as getAppSubscribeNotifyStatus,
|
|
502
|
+
C as isAppVersionSupport,
|
|
502
503
|
ae as onAppSharePanelShow,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
X as
|
|
504
|
+
we as onLoopCheckAppLogin,
|
|
505
|
+
ce as openAppSharePanel,
|
|
506
|
+
le as openAppSubscribeNotifySettings,
|
|
507
|
+
K as openPostEditor,
|
|
508
|
+
X as reportDAEvent,
|
|
509
|
+
Y as runAction,
|
|
508
510
|
u as runBridgeApi,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
511
|
+
h as runBridgeApiResponse,
|
|
512
|
+
Z as saveImageToLocal,
|
|
513
|
+
ee as saveVideoToLocal,
|
|
514
|
+
te as scanQRCode,
|
|
515
|
+
ne as setScreenOrientation,
|
|
516
|
+
re as setWebViewTitle,
|
|
517
|
+
oe as shareImage,
|
|
516
518
|
pe as triggerAppLogin
|
|
517
519
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(r=typeof globalThis<"u"?globalThis:r||self,A(r.kbBridge={}))})(this,function(r){"use strict";var
|
|
1
|
+
(function(r,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(r=typeof globalThis<"u"?globalThis:r||self,A(r.kbBridge={}))})(this,function(r){"use strict";var V;function A(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const t={};return Object.keys(e).forEach(i=>{const s=e[i];s!=null&&(t[i]=Object.prototype.toString.call(s)==="[object Object]"?A(s):s)}),t}const p=class p{constructor(t){this.errorCode=t.errorCode,this.errorMsg=t.errorMsg}};p.UNKNOWN=new p({errorCode:1e3,errorMsg:"未知错误"}),p.UNSUPPORTED_VERSION=new p({errorCode:1001,errorMsg:"当前开吧版本不支持"}),p.TIMEOUT=new p({errorCode:1002,errorMsg:"执行超时"}),p.UNSUPPORTED_BRIDGE_ENV=new p({errorCode:1003,errorMsg:"请在开吧app内执行"});let f=p;const L=()=>{const e=(a,o,n)=>{var c="";typeof o=="function"&&(n=o,o={});var u={data:o===void 0?null:o};if(typeof n=="function"){var h="dscb"+window.dscb++;window[h]=n,u._dscbstub=h}if(u=JSON.stringify(u),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(c=window.flutter_inappwebview.callHandler(""+a,u)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(c=prompt("_flutterDsbridge="+a,u)),c instanceof Promise)return c;try{return JSON.parse(c||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},t=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,i=(()=>{const a=[],o=setInterval(()=>{t()&&(clearInterval(o),a.forEach(n=>{e.apply(window,n)}),a.length=0)},500);return(...n)=>{a.push(n)}})();var s={default:void 0,callHandler:function(a,o,n){return t()?e(a,o,n):i(a,o,n)},register:function(a,o,n){var c=n?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){s.callHandler("_dsb.dsinit")},0)),typeof o=="object"?c._obs[a]=o:c[a]=o},registerHandler:function(a,o){this.register(a,o,!0)}};return function(){if(!window._dsf){var a={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:s,_handleMessageFromNative:function(n){var c=JSON.parse(n.data),u={id:n.callbackId,complete:!0},h=this._dsf[n.method],E=this._dsaf[n.method],C=function(P,b){u.data=P.apply(b,c),s.callHandler("_dsb.returnValue",u)},U=function(P,b){c.push(function(ge,he){u.data=ge,u.complete=he!==!1,s.callHandler("_dsb.returnValue",u)}),P.apply(b,c)};if(h)C(h,this._dsf);else if(E)U(E,this._dsaf);else{var O=n.method.split(".");if(O.length<2)return;var B=O.pop(),D=O.join("."),T=this._dsf._obs,v=T[D]||{},w=v[B];if(w&&typeof w=="function"){C(w,v);return}if(T=this._dsaf._obs,v=T[D]||{},w=v[B],w&&typeof w=="function"){U(w,v);return}}}};for(var o in a)window[o]=a[o]}}(),s},S=(e=>/(kb)/i.test(e)?L():{registerHandler(t,i){throw f.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,s){throw f.UNSUPPORTED_BRIDGE_ENV}})((V=window==null?void 0:window.navigator)==null?void 0:V.userAgent),R=e=>new Promise((t,i)=>{var s,a,o;try{S.registerHandler(e.name,e.handler),(s=e.success)==null||s.call(e),t()}catch(n){(a=e.fail)==null||a.call(e,n),i(n)}finally{(o=e.complete)==null||o.call(e)}});function g(e){const t=i=>{let s;const a=n=>{var c;(!s||s==="success")&&(s="success",(c=i.success)==null||c.call(i,n))},o=n=>{var c;(!s||s==="error")&&(s="error",(c=i.fail)==null||c.call(i,n))};i.timeout&&setTimeout(()=>{o(f.TIMEOUT)},i.timeout);try{S.callHandler(i.name,i.params,n=>{let c;try{typeof n=="string"&&/^\s*(\{|\[).*(\}|\])\s*$/.test(n)?c=JSON.parse(n.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):c=n}catch{c=n}a(c)})}catch(n){o(n)}};return new Promise((i,s)=>{t({name:e.name,params:A(e.params),timeout:e.timeout,success:a=>{var o,n;(o=e.success)==null||o.call(e,a),(n=e.complete)==null||n.call(e),i(a)},fail:a=>{var o,n;(o=e.fail)==null||o.call(e,a),(n=e.complete)==null||n.call(e),s(a)}})})}function l(e){S.callHandler(e.name,e.params,t=>{})}function d(e){return async function(...i){const s=i[0]||{},{success:a,fail:o,complete:n,...c}=s;try{const u=await Promise.resolve(e(c));return a==null||a(u),u}catch(u){const h=u!=null&&u.errorCode?u:new f({errorCode:f.UNKNOWN.errorCode,errorMsg:String(u)});throw o==null||o(h),h}finally{n==null||n()}}}function H(e){let t;return function(...i){return t||(t=e(...i),Promise.resolve(t).catch(()=>{t=void 0}),t)}}class j{}const k=d(H(()=>g({name:"OpenActRequest",params:{type:35,data:{}}}))),m=d(async e=>(await k()).vcode>=e.minVersion);function F(e,t){return(...i)=>m({minVersion:e.minVersion}).then(s=>s?t(...i):Promise.reject(new f({errorCode:f.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}const W=d(()=>{l({name:"OpenActRequest",params:{type:56,data:null}})}),J=d(()=>{l({name:"OpenActRequest",params:{type:-1,data:{}}})}),I={microphone:{description:"用于发帖上传音频"},location:{description:"获取你选择的位置信息,用于线下导航服务"},camera:{description:"收集你选中的照片或视频信息 ,用于 发表评论、分享视频"}},Q=d(e=>(Object.assign(I,e),R({name:"getPermissionUsage",handler(t,i){i(I[t.permission])}}))),G=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent),K=d(async e=>{const{kbKey:t,...i}=e,{data:s}=await g({name:"OpenActRequest",params:{type:51,data:i}});return s});var N=(e=>(e[e.FREE=1]="FREE",e[e.FORBID=2]="FORBID",e[e.REQUIRED=3]="REQUIRED",e))(N||{});class M{constructor(){this.textMin=0,this.textMax=1e3,this.imageMax=9,this.imageMin=0,this.audioRqr=1,this.videoRqr=1,this.mediaRqr=2,this.streetRqr=1}}function $(e){const t=new M;return e&&Object.keys(e).forEach(i=>{t[i]=e[i]}),{hint:e==null?void 0:e.placeholder,initialText:e==null?void 0:e.initialText,audio:t.audioRqr!==2,image:t.imageMax!==0,video:t.videoRqr!==2,address:t.streetRqr!==2,asset_video:t.mediaRqr!==2,audio_must:t.audioRqr===3,image_must:t.imageMin>0,asset_video_must:t.mediaRqr===3,max_image_count:t.imageMax,min_image_count:t.imageMin,video_must:t.videoRqr===3,text_must:t.textMin>0,content_max_length:t.textMax,content_min_length:t.textMin}}const z=d(async e=>g({name:"OpenActRequest",params:{type:13,data:(e==null?void 0:e.postRule)??{}}}).then(({data:t})=>{const{pic:i,...s}=t;return{images:i,...s}})),X=d(e=>{l({name:"OpenActRequest",params:{type:69,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})}),Y=d(e=>{l({name:"OpenActRequest",params:{type:1001,data:e}})}),Z=d(e=>{l({name:"OpenActRequest",params:{type:62,data:e}})}),x=d(e=>{l({name:"OpenActRequest",params:{type:63,data:e}})}),ee=d(()=>g({name:"OpenActRequest",params:{type:26,data:{}}})),te=d(e=>{l({name:"OpenActRequest",params:{type:71,data:e}})}),ne=d(e=>{l({name:"OpenActRequest",params:{type:64,data:e}})}),ie=d(e=>{l({name:"OpenActRequest",params:{type:58,data:e}})}),_="SHARE_EVENT_NAME";class re{}const oe=d(e=>R({name:"CommonShare",handler(t,i){window.dispatchEvent(new Event(_)),"onShareApp"in e&&e.onShareApp?i({type:12,data:e.onShareApp()}):i({type:12,data:e})}})),se=d(async e=>{window.dispatchEvent(new Event(_)),l({name:"OpenActRequest",params:{type:58,data:e}})});function ae(e){return window.addEventListener(_,e),()=>{window.removeEventListener(_,e)}}const ce=d(e=>{l({name:"OpenActRequest",params:{type:68,data:{show:e.showMenu,showActionMode:e.panelStyle||0}}})}),de=d(()=>g({name:"OpenActRequest",params:{type:72}})),ue=d(async()=>{l({name:"OpenActRequest",params:{type:73}})});class le{}const q=d(async()=>(await g({name:"OpenActRequest",params:{type:31,data:{requireLogin:!1}}})).data||null),y=(()=>{const e=new Set,t=(()=>{let i;const s=a=>{i=setTimeout(async()=>{const n=await q();if(!n)return s(++a);e.forEach(c=>c(n)),e.clear()},(n=>n===0?0:n<50?600:n<80?1e3:5e3)(a))};return{start(){i&&clearTimeout(i),e.size>0&&s(0)},stop(){i&&clearTimeout(i)}}})();return{addTask(i){e.add(i)},removeTask(i){e.delete(i),e.size===0&&t.stop()},triggerCheckTask(){t.start()}}})(),fe=d(async()=>{y.triggerCheckTask(),g({name:"OpenActRequest",params:{type:31,data:{requireLogin:!0}},success(e){var t;(t=e.data)!=null&&t.userId&&y.triggerCheckTask()}})}),pe=e=>(y.addTask(e),y.triggerCheckTask(),()=>{y.removeTask(e)});r.AppBaseInfo=j,r.AppLoginInfo=le,r.AppShareModel=re,r.BridgeCode=f,r.IS_KB_APP_ENV=G,r.KbRequirement=N,r.NoteThreadPostRule=M,r.checkForNewVersion=W,r.closeWebView=J,r.createPostEditorParamsByThreadPostRule=$,r.decorateAppVersionSupport=F,r.defineAppShareModel=oe,r.defineAppSharePanelState=ce,r.defineBridgeCallback=R,r.definePermissionUsage=Q,r.generateKBSign=K,r.getAppBaseInfo=k,r.getAppLoginInfo=q,r.getAppSubscribeNotifyStatus=de,r.isAppVersionSupport=m,r.onAppSharePanelShow=ae,r.onLoopCheckAppLogin=pe,r.openAppSharePanel=se,r.openAppSubscribeNotifySettings=ue,r.openPostEditor=z,r.reportDAEvent=X,r.runAction=Y,r.runBridgeApi=l,r.runBridgeApiResponse=g,r.saveImageToLocal=Z,r.saveVideoToLocal=x,r.scanQRCode=ee,r.setScreenOrientation=te,r.setWebViewTitle=ne,r.shareImage=ie,r.triggerAppLogin=fe,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
+
export declare enum KbRequirement {
|
|
2
|
+
/** 不限 */
|
|
3
|
+
FREE = 1,
|
|
4
|
+
/** 禁用 */
|
|
5
|
+
FORBID = 2,
|
|
6
|
+
/** 必须 */
|
|
7
|
+
REQUIRED = 3
|
|
8
|
+
}
|
|
9
|
+
export declare class NoteThreadPostRule {
|
|
10
|
+
/** 帖子中, 文字的最少字数, 默认0 */
|
|
11
|
+
textMin: number;
|
|
12
|
+
/** 帖子中,文字的最大字数, 默认1000 */
|
|
13
|
+
textMax: number;
|
|
14
|
+
/** 帖子中, 图片的最大张数, 默认9 */
|
|
15
|
+
imageMax: number;
|
|
16
|
+
/** 帖子中, 图片的最小张数, 默认0 */
|
|
17
|
+
imageMin: number;
|
|
18
|
+
/** 音频限制, 默认不限 */
|
|
19
|
+
audioRqr?: KbRequirement;
|
|
20
|
+
/** 视频限制, 默认不限 */
|
|
21
|
+
videoRqr?: KbRequirement;
|
|
22
|
+
/** 媒资限制, 默认禁用 */
|
|
23
|
+
mediaRqr?: KbRequirement;
|
|
24
|
+
/** 位置-逆地理信息限制, 默认不限 */
|
|
25
|
+
streetRqr?: KbRequirement;
|
|
26
|
+
}
|
|
1
27
|
/**
|
|
2
28
|
*
|
|
3
|
-
* @description
|
|
29
|
+
* @description 构造富文本编辑器参数
|
|
4
30
|
*/
|
|
5
|
-
export declare
|
|
31
|
+
export declare function createPostEditorParamsByThreadPostRule(params?: Partial<NoteThreadPostRule> & {
|
|
6
32
|
/** 文本输入框 低下显示的提示文案 */
|
|
7
33
|
placeholder?: string;
|
|
8
34
|
/** 初始化文本内容 */
|
|
9
35
|
initialText?: string;
|
|
10
|
-
|
|
11
|
-
enableImageUpload: boolean;
|
|
12
|
-
/** 是否启用音频录制功能 默认启用 */
|
|
13
|
-
enableAudioUpload: boolean;
|
|
14
|
-
/** 是否启用普通视频上传功能 默认启用 */
|
|
15
|
-
enableVideoUpload: boolean;
|
|
16
|
-
/** 是否启用定位 */
|
|
17
|
-
enableAddress: boolean;
|
|
18
|
-
/** 是否启用媒资视频上传功能 默认禁用 */
|
|
19
|
-
enableMediaVideoUpload: boolean;
|
|
20
|
-
/** 最少输入多少字符, 默认 0 */
|
|
21
|
-
minTextLength: number;
|
|
22
|
-
/** 最多输入多少字符, 默认 1000 */
|
|
23
|
-
maxTextLength: number;
|
|
24
|
-
/** 最少上传多少张图片, 默认 0 */
|
|
25
|
-
minImageCount: number;
|
|
26
|
-
/** 最多上传多少张图片, 默认 9 */
|
|
27
|
-
maxImageCount: number;
|
|
28
|
-
/** 普通音频是否必传. 默认不必传 */
|
|
29
|
-
isAudioRequired: boolean;
|
|
30
|
-
/** 普通视频是否必传. 默认不必传 */
|
|
31
|
-
isVideoRequired: boolean;
|
|
32
|
-
/** 媒资视频是否必传. 默认不必传 */
|
|
33
|
-
isMediaVideoRequired: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @description 构造富文本编辑器参数
|
|
38
|
-
*/
|
|
39
|
-
export declare function createPostEditorParams(params?: Partial<PostEditorParams>): {
|
|
36
|
+
}): {
|
|
40
37
|
hint: string | undefined;
|
|
41
38
|
initialText: string | undefined;
|
|
42
39
|
audio: boolean;
|
|
@@ -44,15 +41,15 @@ export declare function createPostEditorParams(params?: Partial<PostEditorParams
|
|
|
44
41
|
video: boolean;
|
|
45
42
|
address: boolean;
|
|
46
43
|
asset_video: boolean;
|
|
47
|
-
|
|
48
|
-
content_min_length: number;
|
|
49
|
-
content_max_length: number;
|
|
44
|
+
audio_must: boolean;
|
|
50
45
|
image_must: boolean;
|
|
51
|
-
|
|
46
|
+
asset_video_must: boolean;
|
|
52
47
|
max_image_count: number;
|
|
53
|
-
|
|
48
|
+
min_image_count: number;
|
|
54
49
|
video_must: boolean;
|
|
55
|
-
|
|
50
|
+
text_must: boolean;
|
|
51
|
+
content_max_length: number;
|
|
52
|
+
content_min_length: number;
|
|
56
53
|
};
|
|
57
54
|
/**
|
|
58
55
|
*
|
|
@@ -81,37 +78,39 @@ export declare const openPostEditor: (...args: [params?: {
|
|
|
81
78
|
fail?: (error: import('./bridge-code').BridgeCode) => void;
|
|
82
79
|
complete?: () => void;
|
|
83
80
|
} | undefined] | [params?: ({
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
81
|
+
postRule?: {
|
|
82
|
+
/** 文本默认显示内容(placehold) */
|
|
83
|
+
hint?: string;
|
|
84
|
+
/** 默认初始化文案 */
|
|
85
|
+
initialText?: string;
|
|
86
|
+
/** 是否显示音频按钮, 默认显示 */
|
|
87
|
+
audio?: boolean;
|
|
88
|
+
/** 是否显示图片按钮, 默认显示 */
|
|
89
|
+
image?: boolean;
|
|
90
|
+
/** 是否显示视频按钮, 默认显示 */
|
|
91
|
+
video?: boolean;
|
|
92
|
+
/** 是否显示定位按钮, 默认显示 */
|
|
93
|
+
address?: boolean;
|
|
94
|
+
/** 是否显示媒资视频选项;默认不显示 */
|
|
95
|
+
asset_video?: boolean;
|
|
96
|
+
/** 音频是否必传 */
|
|
97
|
+
audio_must?: boolean;
|
|
98
|
+
/** 图片是否必传 */
|
|
99
|
+
image_must?: boolean;
|
|
100
|
+
/** 图片最大张数 */
|
|
101
|
+
max_image_count?: number;
|
|
102
|
+
/** 图片最小张数 */
|
|
103
|
+
min_image_count?: number;
|
|
104
|
+
/** 视频是否必传 */
|
|
105
|
+
video_must?: boolean;
|
|
106
|
+
/** 文本内容是否必传 */
|
|
107
|
+
text_must?: boolean;
|
|
108
|
+
/** 文本最大长度 */
|
|
109
|
+
content_max_length?: number;
|
|
110
|
+
/** 文本最小长度 */
|
|
111
|
+
content_min_length?: number;
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
};
|
|
115
114
|
} & {
|
|
116
115
|
success?: ((res: {
|
|
117
116
|
content: string;
|
|
@@ -45,17 +45,16 @@ export declare const triggerAppLogin: (params?: {
|
|
|
45
45
|
} | undefined) => Promise<void>;
|
|
46
46
|
/**
|
|
47
47
|
*
|
|
48
|
-
* @description
|
|
49
|
-
* 如果已登录, 立刻触发一次回调
|
|
48
|
+
* @description 启动轮询检查 APP 登录状态,查询到已登录后立即触发回调并自动回收回调函数(支持主动取消监听)
|
|
50
49
|
* @example **示例代码**
|
|
51
50
|
```js
|
|
52
|
-
import {
|
|
51
|
+
import { onLoopCheckAppLogin } from '@kbapp/js-bridge';
|
|
53
52
|
|
|
54
|
-
const handle =
|
|
53
|
+
const handle = onLoopCheckAppLogin(() => {
|
|
55
54
|
console.log('登录成功')
|
|
56
55
|
})
|
|
57
56
|
|
|
58
57
|
// handle() 停止监听
|
|
59
58
|
```
|
|
60
59
|
*/
|
|
61
|
-
export declare const
|
|
60
|
+
export declare const onLoopCheckAppLogin: (callback: (loginInfo: AppLoginInfo) => void) => () => void;
|