@kbapp/js-bridge 1.0.5-alpha.0 → 1.0.7-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 → README.md} +1 -1
- package/dist/es/core/index.js +73 -0
- package/dist/es/core/lib/flutter-ds-bridge.js +93 -0
- package/dist/es/index.js +59 -0
- package/dist/es/lib/app-version-support.js +18 -0
- package/dist/es/lib/bridge-code.js +22 -0
- package/dist/es/lib/check-for-new-version.js +14 -0
- package/dist/es/lib/close-webview.js +14 -0
- package/dist/es/lib/define-permission-usage.js +15 -0
- package/dist/es/lib/env.js +4 -0
- package/dist/es/lib/generate-kb-sign.js +16 -0
- package/dist/es/lib/get-app-base-info.js +19 -0
- package/dist/es/lib/open-post-editor.js +46 -0
- package/dist/es/lib/report-da-event.js +23 -0
- package/dist/es/lib/run-action.js +14 -0
- package/dist/es/lib/save-image-to-local.js +16 -0
- package/dist/es/lib/save-video-to-local.js +16 -0
- package/dist/es/lib/scan-qr-code.js +12 -0
- package/dist/es/lib/screen-orientation.js +16 -0
- package/dist/es/lib/set-webview-title.js +16 -0
- package/dist/es/lib/share-image.js +16 -0
- package/dist/es/lib/share-model.js +45 -0
- package/dist/es/lib/subscribe-notify.js +19 -0
- package/dist/es/lib/trigger-login.js +60 -0
- package/dist/es/utils/filter-undefined-properties.js +12 -0
- package/dist/es/utils/promise-cache.js +11 -0
- package/dist/es/utils/wrap-async.js +21 -0
- package/dist/{core → types/core}/index.d.ts +1 -1
- package/dist/umd/index.js +1 -0
- package/examples/index.html +2 -2
- package/package.json +13 -5
- package/dist/core/lib/flutter-ds-bridge.d.ts +0 -7
- package/dist/index.es.js +0 -519
- package/dist/index.umd.js +0 -1
- package/vite.config.ts +0 -32
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{lib → types/lib}/app-version-support.d.ts +0 -0
- /package/dist/{lib → types/lib}/bridge-code.d.ts +0 -0
- /package/dist/{lib → types/lib}/check-for-new-version.d.ts +0 -0
- /package/dist/{lib → types/lib}/close-webview.d.ts +0 -0
- /package/dist/{lib → types/lib}/define-permission-usage.d.ts +0 -0
- /package/dist/{lib → types/lib}/env.d.ts +0 -0
- /package/dist/{lib → types/lib}/generate-kb-sign.d.ts +0 -0
- /package/dist/{lib → types/lib}/get-app-base-info.d.ts +0 -0
- /package/dist/{lib → types/lib}/open-post-editor.d.ts +0 -0
- /package/dist/{lib → types/lib}/report-da-event.d.ts +0 -0
- /package/dist/{lib → types/lib}/run-action.d.ts +0 -0
- /package/dist/{lib → types/lib}/save-image-to-local.d.ts +0 -0
- /package/dist/{lib → types/lib}/save-video-to-local.d.ts +0 -0
- /package/dist/{lib → types/lib}/scan-qr-code.d.ts +0 -0
- /package/dist/{lib → types/lib}/screen-orientation.d.ts +0 -0
- /package/dist/{lib → types/lib}/set-webview-title.d.ts +0 -0
- /package/dist/{lib → types/lib}/share-image.d.ts +0 -0
- /package/dist/{lib → types/lib}/share-model.d.ts +0 -0
- /package/dist/{lib → types/lib}/subscribe-notify.d.ts +0 -0
- /package/dist/{lib → types/lib}/trigger-login.d.ts +0 -0
- /package/dist/{utils → types/utils}/filter-undefined-properties.d.ts +0 -0
- /package/dist/{utils → types/utils}/promise-cache.d.ts +0 -0
- /package/dist/{utils → types/utils}/wrap-async.d.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function n(e) {
|
|
2
|
+
if (Object.prototype.toString.call(e) !== "[object Object]")
|
|
3
|
+
return e;
|
|
4
|
+
const r = {};
|
|
5
|
+
return Object.keys(e).forEach((c) => {
|
|
6
|
+
const t = e[c];
|
|
7
|
+
t != null && (r[c] = Object.prototype.toString.call(t) === "[object Object]" ? n(t) : t);
|
|
8
|
+
}), r;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
n as filterUndefinedAndNullProperties
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BridgeCode as s } from "../lib/bridge-code.js";
|
|
2
|
+
function w(a) {
|
|
3
|
+
return async function(...c) {
|
|
4
|
+
const i = c[0] || {}, { success: o, fail: t, complete: e, ...d } = i;
|
|
5
|
+
try {
|
|
6
|
+
const r = await Promise.resolve(a(d));
|
|
7
|
+
return o == null || o(r), r;
|
|
8
|
+
} catch (r) {
|
|
9
|
+
const n = r != null && r.errorCode ? r : new s({
|
|
10
|
+
errorCode: s.UNKNOWN.errorCode,
|
|
11
|
+
errorMsg: String(r)
|
|
12
|
+
});
|
|
13
|
+
throw t == null || t(n), n;
|
|
14
|
+
} finally {
|
|
15
|
+
e == null || e();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
w as wrapAsync
|
|
21
|
+
};
|
|
@@ -0,0 +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 V;function A(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const t={};return Object.keys(e).forEach(i=>{const a=e[i];a!=null&&(t[i]=Object.prototype.toString.call(a)==="[object Object]"?A(a):a)}),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=(s,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(""+s,u)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(c=prompt("_flutterDsbridge="+s,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 s=[],o=setInterval(()=>{t()&&(clearInterval(o),s.forEach(n=>{e.apply(window,n)}),s.length=0)},500);return(...n)=>{s.push(n)}})();var a={default:void 0,callHandler:function(s,o,n){return t()?e(s,o,n):i(s,o,n)},register:function(s,o,n){var c=n?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){a.callHandler("_dsb.dsinit")},0)),typeof o=="object"?c._obs[s]=o:c[s]=o},registerHandler:function(s,o){this.register(s,o,!0)}};return function(){if(!window._dsf){var s={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:a,_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),a.callHandler("_dsb.returnValue",u)},U=function(P,b){c.push(function(ge,he){u.data=ge,u.complete=he!==!1,a.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 s)window[o]=s[o]}}(),a},S=(e=>/(kb)/i.test(e)?L():{registerHandler(t,i){throw f.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,a){throw f.UNSUPPORTED_BRIDGE_ENV}})((V=window==null?void 0:window.navigator)==null?void 0:V.userAgent),R=e=>new Promise((t,i)=>{var a,s,o;try{S.registerHandler(e.name,e.handler),(a=e.success)==null||a.call(e),t()}catch(n){(s=e.fail)==null||s.call(e,n),i(n)}finally{(o=e.complete)==null||o.call(e)}});function g(e){const t=i=>{let a;const s=n=>{var c;(!a||a==="success")&&(a="success",(c=i.success)==null||c.call(i,n))},o=n=>{var c;a||(a="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}s(c)})}catch(n){o(n)}};return new Promise((i,a)=>{t({name:e.name,params:A(e.params),timeout:e.timeout,success:s=>{var o,n;(o=e.success)==null||o.call(e,s),(n=e.complete)==null||n.call(e),i(s)},fail:s=>{var o,n;(o=e.fail)==null||o.call(e,s),(n=e.complete)==null||n.call(e),a(s)}})})}function l(e){S.callHandler(e.name,e.params,t=>{})}function d(e){return async function(...i){const a=i[0]||{},{success:s,fail:o,complete:n,...c}=a;try{const u=await Promise.resolve(e(c));return s==null||s(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 m=d(H(()=>g({name:"OpenActRequest",timeout:5e3,params:{type:35,data:{}}}))),k=d(async e=>(await m()).vcode>=e.minVersion);function F(e,t){return(...i)=>k({minVersion:e.minVersion}).then(a=>a?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:a}=await g({name:"OpenActRequest",timeout:5e3,params:{type:51,data:i}});return a});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,...a}=t;return{images:i,...a}})),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",timeout:5e3,params:{type:31,data:{requireLogin:!1}}})).data||null),y=(()=>{const e=new Set,t=(()=>{let i;const a=s=>{i=setTimeout(async()=>{const n=await q();if(!n)return a(++s);e.forEach(c=>c(n)),e.clear()},(n=>n===0?0:n<50?600:n<80?1e3:5e3)(s))};return{start(){i&&clearTimeout(i),e.size>0&&a(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.decorateAppVersionSupport=F,r.defineAppShareModel=oe,r.defineAppSharePanelState=ce,r.defineBridgeCallback=R,r.definePermissionUsage=Q,r.generateKBSign=K,r.generatePostEditorParamsByThreadPostRule=$,r.getAppBaseInfo=m,r.getAppLoginInfo=q,r.getAppSubscribeNotifyStatus=de,r.isAppVersionSupport=k,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"})});
|
package/examples/index.html
CHANGED
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
</body>
|
|
82
82
|
<script type="module">
|
|
83
83
|
import { createApp, ref, reactive } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
|
|
84
|
-
import { runAction, defineAppShareModel, openAppSharePanel, reportDAEvent, getAppBaseInfo, shareImage, scanQRCode } from '../dist/index.
|
|
84
|
+
import { runAction, defineAppShareModel, openAppSharePanel, reportDAEvent, getAppBaseInfo, shareImage, scanQRCode } from '../dist/es/index.js'
|
|
85
85
|
|
|
86
|
-
// import '../dist/index.
|
|
86
|
+
// import '../dist/umd/index.js'
|
|
87
87
|
// const { runAction, defineAppShareModel, openAppSharePanel, reportDAEvent, getAppBaseInfo, shareImage, scanQRCode } = window.kbBridge
|
|
88
88
|
|
|
89
89
|
/**
|
package/package.json
CHANGED
|
@@ -3,13 +3,21 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.7-alpha.0",
|
|
7
7
|
"description": "开吧客户端桥接",
|
|
8
8
|
"author": "along",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
9
|
+
"main": "./dist/umd/index.js",
|
|
10
|
+
"module": "./dist/es/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"import": "./dist/es/index.js",
|
|
16
|
+
"require": "./dist/umd/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": true,
|
|
13
21
|
"scripts": {
|
|
14
22
|
"build": "rm -rf ./dist && vite build",
|
|
15
23
|
"dev": "npm run build && vite",
|
package/dist/index.es.js
DELETED
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
function N(e) {
|
|
2
|
-
if (Object.prototype.toString.call(e) !== "[object Object]")
|
|
3
|
-
return e;
|
|
4
|
-
const t = {};
|
|
5
|
-
return Object.keys(e).forEach((r) => {
|
|
6
|
-
const i = e[r];
|
|
7
|
-
i != null && (t[r] = Object.prototype.toString.call(i) === "[object Object]" ? N(i) : i);
|
|
8
|
-
}), t;
|
|
9
|
-
}
|
|
10
|
-
const l = class l {
|
|
11
|
-
constructor(t) {
|
|
12
|
-
this.errorCode = t.errorCode, this.errorMsg = t.errorMsg;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
l.UNKNOWN = new l({
|
|
16
|
-
errorCode: 1e3,
|
|
17
|
-
errorMsg: "未知错误"
|
|
18
|
-
}), l.UNSUPPORTED_VERSION = new l({
|
|
19
|
-
errorCode: 1001,
|
|
20
|
-
errorMsg: "当前开吧版本不支持"
|
|
21
|
-
}), l.TIMEOUT = new l({
|
|
22
|
-
errorCode: 1002,
|
|
23
|
-
errorMsg: "执行超时"
|
|
24
|
-
}), l.UNSUPPORTED_BRIDGE_ENV = new l({
|
|
25
|
-
errorCode: 1003,
|
|
26
|
-
errorMsg: "请在开吧app内执行"
|
|
27
|
-
});
|
|
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
|
-
if (typeof n == "function") {
|
|
35
|
-
var p = "dscb" + window.dscb++;
|
|
36
|
-
window[p] = n, d._dscbstub = p;
|
|
37
|
-
}
|
|
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
|
-
try {
|
|
41
|
-
return JSON.parse(c || "{}").data;
|
|
42
|
-
} catch {
|
|
43
|
-
console.error("callHandle异常,JSON.parse错误");
|
|
44
|
-
}
|
|
45
|
-
}, t = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, r = (() => {
|
|
46
|
-
const s = [], o = setInterval(() => {
|
|
47
|
-
t() && (clearInterval(o), s.forEach((n) => {
|
|
48
|
-
e.apply(window, n);
|
|
49
|
-
}), s.length = 0);
|
|
50
|
-
}, 500);
|
|
51
|
-
return (...n) => {
|
|
52
|
-
s.push(n);
|
|
53
|
-
};
|
|
54
|
-
})();
|
|
55
|
-
var i = {
|
|
56
|
-
default: void 0,
|
|
57
|
-
// for typescript
|
|
58
|
-
callHandler: function(s, o, n) {
|
|
59
|
-
return t() ? e(s, o, n) : r(s, o, n);
|
|
60
|
-
},
|
|
61
|
-
register: function(s, o, n) {
|
|
62
|
-
var c = n ? window._dsaf : window._dsf;
|
|
63
|
-
window._dsInit || (window._dsInit = !0, setTimeout(function() {
|
|
64
|
-
i.callHandler("_dsb.dsinit");
|
|
65
|
-
}, 0)), typeof o == "object" ? c._obs[s] = o : c[s] = o;
|
|
66
|
-
},
|
|
67
|
-
registerHandler: function(s, o) {
|
|
68
|
-
this.register(s, o, !0);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return function() {
|
|
72
|
-
if (!window._dsf) {
|
|
73
|
-
var s = {
|
|
74
|
-
//保存JS同步方法
|
|
75
|
-
_dsf: {
|
|
76
|
-
_obs: {}
|
|
77
|
-
},
|
|
78
|
-
//保存JS异步方法
|
|
79
|
-
_dsaf: {
|
|
80
|
-
_obs: {}
|
|
81
|
-
},
|
|
82
|
-
dscb: 0,
|
|
83
|
-
jsBridge: i,
|
|
84
|
-
_handleMessageFromNative: function(n) {
|
|
85
|
-
var c = JSON.parse(n.data), d = {
|
|
86
|
-
id: n.callbackId,
|
|
87
|
-
complete: !0
|
|
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
|
-
};
|
|
95
|
-
if (p)
|
|
96
|
-
T(p, this._dsf);
|
|
97
|
-
else if (y)
|
|
98
|
-
k(y, this._dsaf);
|
|
99
|
-
else {
|
|
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
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (R = this._dsaf._obs, g = R[b] || {}, w = g[P], w && typeof w == "function") {
|
|
108
|
-
k(w, g);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
for (var o in s)
|
|
115
|
-
window[o] = s[o];
|
|
116
|
-
}
|
|
117
|
-
}(), i;
|
|
118
|
-
};
|
|
119
|
-
var I;
|
|
120
|
-
const S = ((e) => /(kb)/i.test(e) ? V() : {
|
|
121
|
-
registerHandler(t, r) {
|
|
122
|
-
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
123
|
-
},
|
|
124
|
-
callHandler(t, r, i) {
|
|
125
|
-
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
126
|
-
}
|
|
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
|
-
try {
|
|
130
|
-
S.registerHandler(e.name, e.handler), (i = e.success) == null || i.call(e), t();
|
|
131
|
-
} catch (n) {
|
|
132
|
-
(s = e.fail) == null || s.call(e, n), r(n);
|
|
133
|
-
} finally {
|
|
134
|
-
(o = e.complete) == null || o.call(e);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
function h(e) {
|
|
138
|
-
const t = (r) => {
|
|
139
|
-
let i;
|
|
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
|
-
};
|
|
147
|
-
r.timeout && setTimeout(() => {
|
|
148
|
-
o(f.TIMEOUT);
|
|
149
|
-
}, r.timeout);
|
|
150
|
-
try {
|
|
151
|
-
S.callHandler(r.name, r.params, (n) => {
|
|
152
|
-
let c;
|
|
153
|
-
try {
|
|
154
|
-
typeof n == "string" && /^\s*(\{|\[).*(\}|\])\s*$/.test(n) ? c = JSON.parse(n.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : c = n;
|
|
155
|
-
} catch {
|
|
156
|
-
c = n;
|
|
157
|
-
}
|
|
158
|
-
s(c);
|
|
159
|
-
});
|
|
160
|
-
} catch (n) {
|
|
161
|
-
o(n);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
return new Promise((r, i) => {
|
|
165
|
-
t({
|
|
166
|
-
name: e.name,
|
|
167
|
-
params: N(e.params),
|
|
168
|
-
timeout: e.timeout,
|
|
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
|
-
},
|
|
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
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function u(e) {
|
|
181
|
-
S.callHandler(e.name, e.params, (t) => {
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function a(e) {
|
|
185
|
-
return async function(...r) {
|
|
186
|
-
const i = r[0] || {}, { success: s, fail: o, complete: n, ...c } = i;
|
|
187
|
-
try {
|
|
188
|
-
const d = await Promise.resolve(e(c));
|
|
189
|
-
return s == null || s(d), d;
|
|
190
|
-
} catch (d) {
|
|
191
|
-
const p = d != null && d.errorCode ? d : new f({
|
|
192
|
-
errorCode: f.UNKNOWN.errorCode,
|
|
193
|
-
errorMsg: String(d)
|
|
194
|
-
});
|
|
195
|
-
throw o == null || o(p), p;
|
|
196
|
-
} finally {
|
|
197
|
-
n == null || n();
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function D(e) {
|
|
202
|
-
let t;
|
|
203
|
-
return function(...r) {
|
|
204
|
-
return t || (t = e(...r), Promise.resolve(t).catch(() => {
|
|
205
|
-
t = void 0;
|
|
206
|
-
}), t);
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
class B {
|
|
210
|
-
}
|
|
211
|
-
const H = a(
|
|
212
|
-
D(() => h({
|
|
213
|
-
name: "OpenActRequest",
|
|
214
|
-
params: {
|
|
215
|
-
type: 35,
|
|
216
|
-
data: {}
|
|
217
|
-
}
|
|
218
|
-
}))
|
|
219
|
-
), C = a(async (e) => (await H()).vcode >= e.minVersion);
|
|
220
|
-
function F(e, t) {
|
|
221
|
-
return (...r) => C({
|
|
222
|
-
minVersion: e.minVersion
|
|
223
|
-
}).then((i) => i ? t(...r) : Promise.reject(
|
|
224
|
-
new f({
|
|
225
|
-
errorCode: f.UNSUPPORTED_VERSION.errorCode,
|
|
226
|
-
errorMsg: `最低版本要求${e.minVersion}`
|
|
227
|
-
})
|
|
228
|
-
));
|
|
229
|
-
}
|
|
230
|
-
const J = a(() => {
|
|
231
|
-
u({
|
|
232
|
-
name: "OpenActRequest",
|
|
233
|
-
params: {
|
|
234
|
-
type: 56,
|
|
235
|
-
data: null
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}), W = a(() => {
|
|
239
|
-
u({
|
|
240
|
-
name: "OpenActRequest",
|
|
241
|
-
params: {
|
|
242
|
-
type: -1,
|
|
243
|
-
data: {}
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}), m = {
|
|
247
|
-
microphone: { description: "用于发帖上传音频" },
|
|
248
|
-
location: { description: "获取你选择的位置信息,用于线下导航服务" },
|
|
249
|
-
camera: { description: "收集你选中的照片或视频信息 ,用于 发表评论、分享视频" }
|
|
250
|
-
}, G = a((e) => (Object.assign(m, e), q({
|
|
251
|
-
name: "getPermissionUsage",
|
|
252
|
-
handler(t, r) {
|
|
253
|
-
r(m[t.permission]);
|
|
254
|
-
}
|
|
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
|
-
name: "OpenActRequest",
|
|
258
|
-
params: {
|
|
259
|
-
type: 51,
|
|
260
|
-
data: r
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
return i;
|
|
264
|
-
});
|
|
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 {
|
|
267
|
-
constructor() {
|
|
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;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function z(e) {
|
|
272
|
-
const t = new L();
|
|
273
|
-
return e && Object.keys(e).forEach((r) => {
|
|
274
|
-
t[r] = e[r];
|
|
275
|
-
}), {
|
|
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
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
const K = a(
|
|
295
|
-
async (e) => h({
|
|
296
|
-
name: "OpenActRequest",
|
|
297
|
-
params: { type: 13, data: (e == null ? void 0 : e.postRule) ?? {} }
|
|
298
|
-
}).then(({ data: t }) => {
|
|
299
|
-
const { pic: r, ...i } = t;
|
|
300
|
-
return { images: r, ...i };
|
|
301
|
-
})
|
|
302
|
-
), X = a(
|
|
303
|
-
(e) => {
|
|
304
|
-
u({
|
|
305
|
-
name: "OpenActRequest",
|
|
306
|
-
params: {
|
|
307
|
-
type: 69,
|
|
308
|
-
data: {
|
|
309
|
-
/** 事件名 */
|
|
310
|
-
eventId: e.eventName,
|
|
311
|
-
/** 上报值 */
|
|
312
|
-
trackParams: e.eventParams,
|
|
313
|
-
/** 开始结束类型传递 */
|
|
314
|
-
ExtEventType: e.eventType
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
), Y = a((e) => {
|
|
320
|
-
u({
|
|
321
|
-
name: "OpenActRequest",
|
|
322
|
-
params: {
|
|
323
|
-
type: 1001,
|
|
324
|
-
data: e
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}), Z = a(
|
|
328
|
-
(e) => {
|
|
329
|
-
u({
|
|
330
|
-
name: "OpenActRequest",
|
|
331
|
-
params: {
|
|
332
|
-
type: 62,
|
|
333
|
-
data: e
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
), ee = a(
|
|
338
|
-
(e) => {
|
|
339
|
-
u({
|
|
340
|
-
name: "OpenActRequest",
|
|
341
|
-
params: {
|
|
342
|
-
type: 63,
|
|
343
|
-
data: e
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
), te = a(() => h({
|
|
348
|
-
name: "OpenActRequest",
|
|
349
|
-
params: {
|
|
350
|
-
type: 26,
|
|
351
|
-
data: {}
|
|
352
|
-
}
|
|
353
|
-
})), ne = a(
|
|
354
|
-
(e) => {
|
|
355
|
-
u({
|
|
356
|
-
name: "OpenActRequest",
|
|
357
|
-
params: {
|
|
358
|
-
type: 71,
|
|
359
|
-
data: e
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
), re = a(
|
|
364
|
-
(e) => {
|
|
365
|
-
u({
|
|
366
|
-
name: "OpenActRequest",
|
|
367
|
-
params: {
|
|
368
|
-
type: 64,
|
|
369
|
-
data: e
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
), oe = a(
|
|
374
|
-
(e) => {
|
|
375
|
-
u({
|
|
376
|
-
name: "OpenActRequest",
|
|
377
|
-
params: {
|
|
378
|
-
type: 58,
|
|
379
|
-
data: e
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
), _ = "SHARE_EVENT_NAME";
|
|
384
|
-
class ie {
|
|
385
|
-
}
|
|
386
|
-
const se = a((e) => q({
|
|
387
|
-
name: "CommonShare",
|
|
388
|
-
handler(t, r) {
|
|
389
|
-
window.dispatchEvent(new Event(_)), "onShareApp" in e && e.onShareApp ? r({ type: 12, data: e.onShareApp() }) : r({ type: 12, data: e });
|
|
390
|
-
}
|
|
391
|
-
})), ce = a(async (e) => {
|
|
392
|
-
window.dispatchEvent(new Event(_)), u({
|
|
393
|
-
name: "OpenActRequest",
|
|
394
|
-
params: {
|
|
395
|
-
type: 58,
|
|
396
|
-
data: e
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
function ae(e) {
|
|
401
|
-
return window.addEventListener(_, e), () => {
|
|
402
|
-
window.removeEventListener(_, e);
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
const de = a(
|
|
406
|
-
(e) => {
|
|
407
|
-
u({
|
|
408
|
-
name: "OpenActRequest",
|
|
409
|
-
params: {
|
|
410
|
-
type: 68,
|
|
411
|
-
data: {
|
|
412
|
-
show: e.showMenu,
|
|
413
|
-
showActionMode: e.panelStyle || 0
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
), ue = a(() => h({
|
|
419
|
-
name: "OpenActRequest",
|
|
420
|
-
params: {
|
|
421
|
-
type: 72
|
|
422
|
-
}
|
|
423
|
-
})), le = a(async () => {
|
|
424
|
-
u({
|
|
425
|
-
name: "OpenActRequest",
|
|
426
|
-
params: {
|
|
427
|
-
type: 73
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
class fe {
|
|
432
|
-
}
|
|
433
|
-
const j = a(async () => (await h({
|
|
434
|
-
name: "OpenActRequest",
|
|
435
|
-
params: { type: 31, data: { requireLogin: !1 } }
|
|
436
|
-
})).data || null), v = /* @__PURE__ */ (() => {
|
|
437
|
-
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ (() => {
|
|
438
|
-
let r;
|
|
439
|
-
const i = (s) => {
|
|
440
|
-
r = setTimeout(async () => {
|
|
441
|
-
const n = await j();
|
|
442
|
-
if (!n)
|
|
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));
|
|
446
|
-
};
|
|
447
|
-
return {
|
|
448
|
-
start() {
|
|
449
|
-
r && clearTimeout(r), e.size > 0 && i(0);
|
|
450
|
-
},
|
|
451
|
-
stop() {
|
|
452
|
-
r && clearTimeout(r);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
})();
|
|
456
|
-
return {
|
|
457
|
-
/** 注册监听事件(需要通过triggerCheckTask触发检测任务) */
|
|
458
|
-
addTask(r) {
|
|
459
|
-
e.add(r);
|
|
460
|
-
},
|
|
461
|
-
/** 移除监听 */
|
|
462
|
-
removeTask(r) {
|
|
463
|
-
e.delete(r), e.size === 0 && t.stop();
|
|
464
|
-
},
|
|
465
|
-
/** 触发定时检测是否登录成功任务 */
|
|
466
|
-
triggerCheckTask() {
|
|
467
|
-
t.start();
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
})(), pe = a(async () => {
|
|
471
|
-
v.triggerCheckTask(), h({
|
|
472
|
-
name: "OpenActRequest",
|
|
473
|
-
params: { type: 31, data: { requireLogin: !0 } },
|
|
474
|
-
success(e) {
|
|
475
|
-
var t;
|
|
476
|
-
(t = e.data) != null && t.userId && v.triggerCheckTask();
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
}), we = (e) => (v.addTask(e), v.triggerCheckTask(), () => {
|
|
480
|
-
v.removeTask(e);
|
|
481
|
-
});
|
|
482
|
-
export {
|
|
483
|
-
B as AppBaseInfo,
|
|
484
|
-
fe as AppLoginInfo,
|
|
485
|
-
ie as AppShareModel,
|
|
486
|
-
f as BridgeCode,
|
|
487
|
-
Q as IS_KB_APP_ENV,
|
|
488
|
-
x as KbRequirement,
|
|
489
|
-
L as NoteThreadPostRule,
|
|
490
|
-
J as checkForNewVersion,
|
|
491
|
-
W as closeWebView,
|
|
492
|
-
F as decorateAppVersionSupport,
|
|
493
|
-
se as defineAppShareModel,
|
|
494
|
-
de as defineAppSharePanelState,
|
|
495
|
-
q as defineBridgeCallback,
|
|
496
|
-
G as definePermissionUsage,
|
|
497
|
-
$ as generateKBSign,
|
|
498
|
-
z as generatePostEditorParamsByThreadPostRule,
|
|
499
|
-
H as getAppBaseInfo,
|
|
500
|
-
j as getAppLoginInfo,
|
|
501
|
-
ue as getAppSubscribeNotifyStatus,
|
|
502
|
-
C as isAppVersionSupport,
|
|
503
|
-
ae as onAppSharePanelShow,
|
|
504
|
-
we as onLoopCheckAppLogin,
|
|
505
|
-
ce as openAppSharePanel,
|
|
506
|
-
le as openAppSubscribeNotifySettings,
|
|
507
|
-
K as openPostEditor,
|
|
508
|
-
X as reportDAEvent,
|
|
509
|
-
Y as runAction,
|
|
510
|
-
u as runBridgeApi,
|
|
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,
|
|
518
|
-
pe as triggerAppLogin
|
|
519
|
-
};
|
package/dist/index.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.decorateAppVersionSupport=F,r.defineAppShareModel=oe,r.defineAppSharePanelState=ce,r.defineBridgeCallback=R,r.definePermissionUsage=Q,r.generateKBSign=K,r.generatePostEditorParamsByThreadPostRule=$,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"})});
|