@kbapp/js-bridge 1.0.9-alpha.0 → 1.0.10-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.
@@ -1,73 +1,74 @@
1
- import { filterUndefinedAndNullProperties as r } from "../utils/filter-undefined-properties.js";
1
+ import { filterUndefinedAndNullProperties as b } from "../utils/filter-undefined-properties.js";
2
2
  import { BridgeCode as d } from "../lib/bridge-code.js";
3
- import b from "./lib/flutter-ds-bridge.js";
3
+ import k from "./lib/flutter-ds-bridge.js";
4
4
  var g;
5
- const f = ((e) => /(kb)/i.test(e) ? b() : {
5
+ const r = ((e) => /(kb)/i.test(e) ? k() : {
6
6
  registerHandler(u, n) {
7
7
  throw d.UNSUPPORTED_BRIDGE_ENV;
8
8
  },
9
9
  callHandler(u, n, i) {
10
10
  throw d.UNSUPPORTED_BRIDGE_ENV;
11
11
  }
12
- })((g = window == null ? void 0 : window.navigator) == null ? void 0 : g.userAgent), w = (e) => new Promise((u, n) => {
13
- var i, o, c;
12
+ })((g = window == null ? void 0 : window.navigator) == null ? void 0 : g.userAgent), B = (e) => new Promise((u, n) => {
13
+ var i, c, o;
14
14
  try {
15
- f.registerHandler(e.name, e.handler), (i = e.success) == null || i.call(e), u();
15
+ r.registerHandler(e.name, e.handler), (i = e.success) == null || i.call(e), u();
16
16
  } catch (t) {
17
- (o = e.fail) == null || o.call(e, t), n(t);
17
+ (c = e.fail) == null || c.call(e, t), n(t);
18
18
  } finally {
19
- (c = e.complete) == null || c.call(e);
19
+ (o = e.complete) == null || o.call(e);
20
20
  }
21
21
  });
22
- function B(e) {
22
+ function N(e) {
23
23
  const u = (n) => {
24
24
  let i;
25
- const o = (t) => {
25
+ const c = (t) => {
26
26
  var l;
27
27
  (!i || i === "success") && (i = "success", (l = n.success) == null || l.call(n, t));
28
- }, c = (t) => {
28
+ }, o = (t) => {
29
29
  var l;
30
30
  i || (i = "error", (l = n.fail) == null || l.call(n, t));
31
31
  };
32
32
  n.timeout && setTimeout(() => {
33
- c(d.TIMEOUT);
33
+ o(d.TIMEOUT);
34
34
  }, n.timeout);
35
35
  try {
36
- f.callHandler(n.name, n.params, (t) => {
36
+ r.callHandler(n.name, n.params, (t) => {
37
37
  let l;
38
38
  try {
39
- typeof t == "string" && /^\s*(\{|\[).*(\}|\])\s*$/.test(t) ? l = JSON.parse(t.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : l = t;
40
- } catch (k) {
39
+ typeof t == "string" && /^\s*(\{|\[).*(\}|\])\s*$/.test(t) ? l = JSON.parse(t.trim().replace(/[\u0000-\u001F\u007F-\u009F]/g, (f) => f === `
40
+ ` ? "\\n" : f === "\r" ? "\\r" : f === " " ? "\\t" : "")) : l = t;
41
+ } catch (f) {
41
42
  l = t;
42
43
  }
43
- o(l);
44
+ c(l);
44
45
  });
45
46
  } catch (t) {
46
- c(t);
47
+ o(t);
47
48
  }
48
49
  };
49
50
  return new Promise((n, i) => {
50
51
  u({
51
52
  name: e.name,
52
- params: r(e.params),
53
+ params: b(e.params),
53
54
  timeout: e.timeout,
54
- success: (o) => {
55
- var c, t;
56
- (c = e.success) == null || c.call(e, o), (t = e.complete) == null || t.call(e), n(o);
55
+ success: (c) => {
56
+ var o, t;
57
+ (o = e.success) == null || o.call(e, c), (t = e.complete) == null || t.call(e), n(c);
57
58
  },
58
- fail: (o) => {
59
- var c, t;
60
- (c = e.fail) == null || c.call(e, o), (t = e.complete) == null || t.call(e), i(o);
59
+ fail: (c) => {
60
+ var o, t;
61
+ (o = e.fail) == null || o.call(e, c), (t = e.complete) == null || t.call(e), i(c);
61
62
  }
62
63
  });
63
64
  });
64
65
  }
65
- function N(e) {
66
- f.callHandler(e.name, e.params, (u) => {
66
+ function U(e) {
67
+ r.callHandler(e.name, e.params, (u) => {
67
68
  });
68
69
  }
69
70
  export {
70
- w as defineBridgeCallback,
71
- N as runBridgeApi,
72
- B as runBridgeApiResponse
71
+ B as defineBridgeCallback,
72
+ U as runBridgeApi,
73
+ N as runBridgeApiResponse
73
74
  };
package/dist/umd/index.js CHANGED
@@ -1 +1,2 @@
1
- (function(t,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(t=typeof globalThis!="undefined"?globalThis:t||self,l(t.kbBridge={}))})(this,function(t){"use strict";var Ee=Object.defineProperty;var b=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var W=(t,l,c)=>l in t?Ee(t,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):t[l]=c,K=(t,l)=>{for(var c in l||(l={}))Q.call(l,c)&&W(t,c,l[c]);if(b)for(var c of b(l))G.call(l,c)&&W(t,c,l[c]);return t};var m=(t,l)=>{var c={};for(var h in t)Q.call(t,h)&&l.indexOf(h)<0&&(c[h]=t[h]);if(t!=null&&b)for(var h of b(t))l.indexOf(h)<0&&G.call(t,h)&&(c[h]=t[h]);return c};var A=(t,l,c)=>new Promise((h,_)=>{var R=d=>{try{f(c.next(d))}catch(E){_(E)}},y=d=>{try{f(c.throw(d))}catch(E){_(E)}},f=d=>d.done?h(d.value):Promise.resolve(d.value).then(R,y);f((c=c.apply(t,l)).next())});var L;function l(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const r={};return Object.keys(e).forEach(n=>{const a=e[n];a!=null&&(r[n]=Object.prototype.toString.call(a)==="[object Object]"?l(a):a)}),r}const w=class w{constructor(r){this.errorCode=r.errorCode,this.errorMsg=r.errorMsg}};w.UNKNOWN=new w({errorCode:1e3,errorMsg:"未知错误"}),w.UNSUPPORTED_VERSION=new w({errorCode:1001,errorMsg:"当前开吧版本不支持"}),w.TIMEOUT=new w({errorCode:1002,errorMsg:"执行超时"}),w.UNSUPPORTED_BRIDGE_ENV=new w({errorCode:1003,errorMsg:"请在开吧app内执行"});let c=w;const h=()=>{const e=(o,s,i)=>{var u="";typeof s=="function"&&(i=s,s={});var p={data:s===void 0?null:s};if(typeof i=="function"){var g="dscb"+window.dscb++;window[g]=i,p._dscbstub=g}if(p=JSON.stringify(p),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+o,p)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+o,p)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch(S){console.error("callHandle异常,JSON.parse错误")}},r=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,n=(()=>{const o=[],s=setInterval(()=>{r()&&(clearInterval(s),o.forEach(i=>{e.apply(window,i)}),o.length=0)},500);return(...i)=>{o.push(i)}})();var a={default:void 0,callHandler:function(o,s,i){return r()?e(o,s,i):n(o,s,i)},register:function(o,s,i){var u=i?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){a.callHandler("_dsb.dsinit")},0)),typeof s=="object"?u._obs[o]=s:u[o]=s},registerHandler:function(o,s){this.register(o,s,!0)}};return function(){if(!window._dsf){var o={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:a,_handleMessageFromNative:function(i){var u=JSON.parse(i.data),p={id:i.callbackId,complete:!0},g=this._dsf[i.method],S=this._dsaf[i.method],H=function(N,M){p.data=N.apply(M,u),a.callHandler("_dsb.returnValue",p)},j=function(N,M){u.push(function(Se,Re){p.data=Se,p.complete=Re!==!1,a.callHandler("_dsb.returnValue",p)}),N.apply(M,u)};if(g)H(g,this._dsf);else if(S)j(S,this._dsaf);else{var k=i.method.split(".");if(k.length<2)return;var F=k.pop(),J=k.join("."),I=this._dsf._obs,O=I[J]||{},v=O[F];if(v&&typeof v=="function"){H(v,O);return}if(I=this._dsaf._obs,O=I[J]||{},v=O[F],v&&typeof v=="function"){j(v,O);return}}}};for(var s in o)window[s]=o[s]}}(),a},_=(e=>/(kb)/i.test(e)?h():{registerHandler(r,n){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(r,n,a){throw c.UNSUPPORTED_BRIDGE_ENV}})((L=window==null?void 0:window.navigator)==null?void 0:L.userAgent),R=e=>new Promise((r,n)=>{var a,o,s;try{_.registerHandler(e.name,e.handler),(a=e.success)==null||a.call(e),r()}catch(i){(o=e.fail)==null||o.call(e,i),n(i)}finally{(s=e.complete)==null||s.call(e)}});function y(e){const r=n=>{let a;const o=i=>{var u;(!a||a==="success")&&(a="success",(u=n.success)==null||u.call(n,i))},s=i=>{var u;a||(a="error",(u=n.fail)==null||u.call(n,i))};n.timeout&&setTimeout(()=>{s(c.TIMEOUT)},n.timeout);try{_.callHandler(n.name,n.params,i=>{let u;try{typeof i=="string"&&/^\s*(\{|\[).*(\}|\])\s*$/.test(i)?u=JSON.parse(i.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):u=i}catch(p){u=i}o(u)})}catch(i){s(i)}};return new Promise((n,a)=>{r({name:e.name,params:l(e.params),timeout:e.timeout,success:o=>{var s,i;(s=e.success)==null||s.call(e,o),(i=e.complete)==null||i.call(e),n(o)},fail:o=>{var s,i;(s=e.fail)==null||s.call(e,o),(i=e.complete)==null||i.call(e),a(o)}})})}function f(e){_.callHandler(e.name,e.params,r=>{})}function d(e){return function(...n){return A(this,null,function*(){const p=n[0]||{},{success:o,fail:s,complete:i}=p,u=m(p,["success","fail","complete"]);try{const g=yield Promise.resolve(e(u));return o==null||o(g),g}catch(g){const S=g!=null&&g.errorCode?g:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(g)});throw s==null||s(S),S}finally{i==null||i()}})}}function E(e){const r=new Map;return function(...n){const a=JSON.stringify(n);if(r.has(a))return r.get(a);const o=e(...n);return r.set(a,o),Promise.resolve(o).catch(()=>{r.delete(a)}),o}}class ${}const q=d(E(()=>y({name:"OpenActRequest",timeout:5e3,params:{type:35,data:{}}}))),V=d(e=>A(this,null,function*(){return(yield q()).vcode>=e.minVersion}));function z(e,r){return(...n)=>V({minVersion:e.minVersion}).then(a=>a?r(...n):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}const X=d(()=>{f({name:"OpenActRequest",params:{type:56,data:null}})}),Y=d(()=>{f({name:"OpenActRequest",params:{type:-1,data:{}}})}),U={microphone:{description:"用于发帖上传音频"},location:{description:"获取你选择的位置信息,用于线下导航服务"},camera:{description:"收集你选中的照片或视频信息 ,用于 发表评论、分享视频"}},Z=d(e=>(Object.assign(U,e),R({name:"getPermissionUsage",handler(r,n){n(U[r.permission])}}))),x=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent),ee=d(e=>A(this,null,function*(){const o=e,{kbKey:r}=o,n=m(o,["kbKey"]),{data:a}=yield y({name:"OpenActRequest",timeout:5e3,params:{type:51,data:n}});return a}));var B=(e=>(e[e.FREE=1]="FREE",e[e.FORBID=2]="FORBID",e[e.REQUIRED=3]="REQUIRED",e))(B||{});class C{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 te(e){const r=new C;return e&&Object.keys(e).forEach(n=>{r[n]=e[n]}),{hint:e==null?void 0:e.placeholder,initialText:e==null?void 0:e.initialText,audio:r.audioRqr!==2,image:r.imageMax!==0,video:r.videoRqr!==2,address:r.streetRqr!==2,asset_video:r.mediaRqr!==2,audio_must:r.audioRqr===3,image_must:r.imageMin>0,asset_video_must:r.mediaRqr===3,max_image_count:r.imageMax,min_image_count:r.imageMin,video_must:r.videoRqr===3,text_must:r.textMin>0,content_max_length:r.textMax,content_min_length:r.textMin}}const ne=d(e=>A(this,null,function*(){var r;return y({name:"OpenActRequest",params:{type:13,data:(r=e==null?void 0:e.postRule)!=null?r:{}}}).then(({data:n})=>{const s=n,{pic:a}=s,o=m(s,["pic"]);return K({images:a},o)})})),ie=d(e=>{f({name:"OpenActRequest",params:{type:69,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})}),re=d(e=>{f({name:"OpenActRequest",params:{type:1001,data:e}})}),oe=d(e=>{f({name:"OpenActRequest",params:{type:62,data:e}})}),se=d(e=>{f({name:"OpenActRequest",params:{type:63,data:e}})}),ae=d(()=>y({name:"OpenActRequest",params:{type:26,data:{}}})),ce=d(e=>{f({name:"OpenActRequest",params:{type:71,data:e}})}),de=d(e=>{f({name:"OpenActRequest",params:{type:64,data:e}})}),ue=d(e=>{f({name:"OpenActRequest",params:{type:58,data:e}})}),P="SHARE_EVENT_NAME";class le{}const fe=d(e=>R({name:"CommonShare",handler(r,n){window.dispatchEvent(new Event(P)),"onShareApp"in e&&e.onShareApp?n({type:12,data:e.onShareApp()}):n({type:12,data:e})}})),pe=d(e=>A(this,null,function*(){window.dispatchEvent(new Event(P)),f({name:"OpenActRequest",params:{type:58,data:e}})}));function ge(e){return window.addEventListener(P,e),()=>{window.removeEventListener(P,e)}}const he=d(e=>{f({name:"OpenActRequest",params:{type:68,data:{show:e.showMenu,showActionMode:e.panelStyle||0}}})}),we=d(()=>y({name:"OpenActRequest",params:{type:72}})),Ae=d(()=>A(this,null,function*(){f({name:"OpenActRequest",params:{type:73}})}));class ye{}const D=d(()=>A(this,null,function*(){return(yield y({name:"OpenActRequest",timeout:5e3,params:{type:31,data:{requireLogin:!1}}})).data||null})),T=(()=>{const e=new Set,r=(()=>{let n;const a=o=>{n=setTimeout(()=>A(this,null,function*(){const i=yield D();if(!i)return a(++o);e.forEach(u=>u(i)),e.clear()}),(i=>i===0?0:i<50?600:i<80?1e3:5e3)(o))};return{start(){n&&clearTimeout(n),e.size>0&&a(0)},stop(){n&&clearTimeout(n)}}})();return{addTask(n){e.add(n)},removeTask(n){e.delete(n),e.size===0&&r.stop()},triggerCheckTask(){r.start()}}})(),ve=d(()=>A(this,null,function*(){T.triggerCheckTask(),yield f({name:"OpenActRequest",params:{type:31,data:{requireLogin:!0}}})})),_e=e=>(T.addTask(e),T.triggerCheckTask(),()=>{T.removeTask(e)});t.AppBaseInfo=$,t.AppLoginInfo=ye,t.AppShareModel=le,t.BridgeCode=c,t.IS_KB_APP_ENV=x,t.KbRequirement=B,t.NoteThreadPostRule=C,t.checkForNewVersion=X,t.closeWebView=Y,t.decorateAppVersionSupport=z,t.defineAppShareModel=fe,t.defineAppSharePanelState=he,t.defineBridgeCallback=R,t.definePermissionUsage=Z,t.generateKBSign=ee,t.generatePostEditorParamsByThreadPostRule=te,t.getAppBaseInfo=q,t.getAppLoginInfo=D,t.getAppSubscribeNotifyStatus=we,t.isAppVersionSupport=V,t.onAppSharePanelShow=ge,t.onLoopCheckAppLogin=_e,t.openAppSharePanel=pe,t.openAppSubscribeNotifySettings=Ae,t.openPostEditor=ne,t.reportDAEvent=ie,t.runAction=re,t.runBridgeApi=f,t.runBridgeApiResponse=y,t.saveImageToLocal=oe,t.saveVideoToLocal=se,t.scanQRCode=ae,t.setScreenOrientation=ce,t.setWebViewTitle=de,t.shareImage=ue,t.triggerAppLogin=ve,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(t=typeof globalThis!="undefined"?globalThis:t||self,l(t.kbBridge={}))})(this,function(t){"use strict";var Ee=Object.defineProperty;var b=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var W=(t,l,c)=>l in t?Ee(t,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):t[l]=c,K=(t,l)=>{for(var c in l||(l={}))Q.call(l,c)&&W(t,c,l[c]);if(b)for(var c of b(l))G.call(l,c)&&W(t,c,l[c]);return t};var m=(t,l)=>{var c={};for(var h in t)Q.call(t,h)&&l.indexOf(h)<0&&(c[h]=t[h]);if(t!=null&&b)for(var h of b(t))l.indexOf(h)<0&&G.call(t,h)&&(c[h]=t[h]);return c};var A=(t,l,c)=>new Promise((h,_)=>{var R=d=>{try{p(c.next(d))}catch(E){_(E)}},y=d=>{try{p(c.throw(d))}catch(E){_(E)}},p=d=>d.done?h(d.value):Promise.resolve(d.value).then(R,y);p((c=c.apply(t,l)).next())});var L;function l(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const r={};return Object.keys(e).forEach(n=>{const a=e[n];a!=null&&(r[n]=Object.prototype.toString.call(a)==="[object Object]"?l(a):a)}),r}const w=class w{constructor(r){this.errorCode=r.errorCode,this.errorMsg=r.errorMsg}};w.UNKNOWN=new w({errorCode:1e3,errorMsg:"未知错误"}),w.UNSUPPORTED_VERSION=new w({errorCode:1001,errorMsg:"当前开吧版本不支持"}),w.TIMEOUT=new w({errorCode:1002,errorMsg:"执行超时"}),w.UNSUPPORTED_BRIDGE_ENV=new w({errorCode:1003,errorMsg:"请在开吧app内执行"});let c=w;const h=()=>{const e=(o,s,i)=>{var u="";typeof s=="function"&&(i=s,s={});var f={data:s===void 0?null:s};if(typeof i=="function"){var g="dscb"+window.dscb++;window[g]=i,f._dscbstub=g}if(f=JSON.stringify(f),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+o,f)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+o,f)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch(S){console.error("callHandle异常,JSON.parse错误")}},r=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,n=(()=>{const o=[],s=setInterval(()=>{r()&&(clearInterval(s),o.forEach(i=>{e.apply(window,i)}),o.length=0)},500);return(...i)=>{o.push(i)}})();var a={default:void 0,callHandler:function(o,s,i){return r()?e(o,s,i):n(o,s,i)},register:function(o,s,i){var u=i?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){a.callHandler("_dsb.dsinit")},0)),typeof s=="object"?u._obs[o]=s:u[o]=s},registerHandler:function(o,s){this.register(o,s,!0)}};return function(){if(!window._dsf){var o={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:a,_handleMessageFromNative:function(i){var u=JSON.parse(i.data),f={id:i.callbackId,complete:!0},g=this._dsf[i.method],S=this._dsaf[i.method],H=function(N,M){f.data=N.apply(M,u),a.callHandler("_dsb.returnValue",f)},j=function(N,M){u.push(function(Se,Re){f.data=Se,f.complete=Re!==!1,a.callHandler("_dsb.returnValue",f)}),N.apply(M,u)};if(g)H(g,this._dsf);else if(S)j(S,this._dsaf);else{var k=i.method.split(".");if(k.length<2)return;var F=k.pop(),J=k.join("."),I=this._dsf._obs,O=I[J]||{},v=O[F];if(v&&typeof v=="function"){H(v,O);return}if(I=this._dsaf._obs,O=I[J]||{},v=O[F],v&&typeof v=="function"){j(v,O);return}}}};for(var s in o)window[s]=o[s]}}(),a},_=(e=>/(kb)/i.test(e)?h():{registerHandler(r,n){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(r,n,a){throw c.UNSUPPORTED_BRIDGE_ENV}})((L=window==null?void 0:window.navigator)==null?void 0:L.userAgent),R=e=>new Promise((r,n)=>{var a,o,s;try{_.registerHandler(e.name,e.handler),(a=e.success)==null||a.call(e),r()}catch(i){(o=e.fail)==null||o.call(e,i),n(i)}finally{(s=e.complete)==null||s.call(e)}});function y(e){const r=n=>{let a;const o=i=>{var u;(!a||a==="success")&&(a="success",(u=n.success)==null||u.call(n,i))},s=i=>{var u;a||(a="error",(u=n.fail)==null||u.call(n,i))};n.timeout&&setTimeout(()=>{s(c.TIMEOUT)},n.timeout);try{_.callHandler(n.name,n.params,i=>{let u;try{typeof i=="string"&&/^\s*(\{|\[).*(\}|\])\s*$/.test(i)?u=JSON.parse(i.trim().replace(/[\u0000-\u001F\u007F-\u009F]/g,f=>f===`
2
+ `?"\\n":f==="\r"?"\\r":f===" "?"\\t":"")):u=i}catch(f){u=i}o(u)})}catch(i){s(i)}};return new Promise((n,a)=>{r({name:e.name,params:l(e.params),timeout:e.timeout,success:o=>{var s,i;(s=e.success)==null||s.call(e,o),(i=e.complete)==null||i.call(e),n(o)},fail:o=>{var s,i;(s=e.fail)==null||s.call(e,o),(i=e.complete)==null||i.call(e),a(o)}})})}function p(e){_.callHandler(e.name,e.params,r=>{})}function d(e){return function(...n){return A(this,null,function*(){const f=n[0]||{},{success:o,fail:s,complete:i}=f,u=m(f,["success","fail","complete"]);try{const g=yield Promise.resolve(e(u));return o==null||o(g),g}catch(g){const S=g!=null&&g.errorCode?g:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(g)});throw s==null||s(S),S}finally{i==null||i()}})}}function E(e){const r=new Map;return function(...n){const a=JSON.stringify(n);if(r.has(a))return r.get(a);const o=e(...n);return r.set(a,o),Promise.resolve(o).catch(()=>{r.delete(a)}),o}}class ${}const q=d(E(()=>y({name:"OpenActRequest",timeout:5e3,params:{type:35,data:{}}}))),V=d(e=>A(this,null,function*(){return(yield q()).vcode>=e.minVersion}));function z(e,r){return(...n)=>V({minVersion:e.minVersion}).then(a=>a?r(...n):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}const X=d(()=>{p({name:"OpenActRequest",params:{type:56,data:null}})}),Y=d(()=>{p({name:"OpenActRequest",params:{type:-1,data:{}}})}),U={microphone:{description:"用于发帖上传音频"},location:{description:"获取你选择的位置信息,用于线下导航服务"},camera:{description:"收集你选中的照片或视频信息 ,用于 发表评论、分享视频"}},Z=d(e=>(Object.assign(U,e),R({name:"getPermissionUsage",handler(r,n){n(U[r.permission])}}))),x=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent),ee=d(e=>A(this,null,function*(){const o=e,{kbKey:r}=o,n=m(o,["kbKey"]),{data:a}=yield y({name:"OpenActRequest",timeout:5e3,params:{type:51,data:n}});return a}));var B=(e=>(e[e.FREE=1]="FREE",e[e.FORBID=2]="FORBID",e[e.REQUIRED=3]="REQUIRED",e))(B||{});class C{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 te(e){const r=new C;return e&&Object.keys(e).forEach(n=>{r[n]=e[n]}),{hint:e==null?void 0:e.placeholder,initialText:e==null?void 0:e.initialText,audio:r.audioRqr!==2,image:r.imageMax!==0,video:r.videoRqr!==2,address:r.streetRqr!==2,asset_video:r.mediaRqr!==2,audio_must:r.audioRqr===3,image_must:r.imageMin>0,asset_video_must:r.mediaRqr===3,max_image_count:r.imageMax,min_image_count:r.imageMin,video_must:r.videoRqr===3,text_must:r.textMin>0,content_max_length:r.textMax,content_min_length:r.textMin}}const ne=d(e=>A(this,null,function*(){var r;return y({name:"OpenActRequest",params:{type:13,data:(r=e==null?void 0:e.postRule)!=null?r:{}}}).then(({data:n})=>{const s=n,{pic:a}=s,o=m(s,["pic"]);return K({images:a},o)})})),ie=d(e=>{p({name:"OpenActRequest",params:{type:69,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})}),re=d(e=>{p({name:"OpenActRequest",params:{type:1001,data:e}})}),oe=d(e=>{p({name:"OpenActRequest",params:{type:62,data:e}})}),se=d(e=>{p({name:"OpenActRequest",params:{type:63,data:e}})}),ae=d(()=>y({name:"OpenActRequest",params:{type:26,data:{}}})),ce=d(e=>{p({name:"OpenActRequest",params:{type:71,data:e}})}),de=d(e=>{p({name:"OpenActRequest",params:{type:64,data:e}})}),ue=d(e=>{p({name:"OpenActRequest",params:{type:58,data:e}})}),P="SHARE_EVENT_NAME";class le{}const fe=d(e=>R({name:"CommonShare",handler(r,n){window.dispatchEvent(new Event(P)),"onShareApp"in e&&e.onShareApp?n({type:12,data:e.onShareApp()}):n({type:12,data:e})}})),pe=d(e=>A(this,null,function*(){window.dispatchEvent(new Event(P)),p({name:"OpenActRequest",params:{type:58,data:e}})}));function ge(e){return window.addEventListener(P,e),()=>{window.removeEventListener(P,e)}}const he=d(e=>{p({name:"OpenActRequest",params:{type:68,data:{show:e.showMenu,showActionMode:e.panelStyle||0}}})}),we=d(()=>y({name:"OpenActRequest",params:{type:72}})),Ae=d(()=>A(this,null,function*(){p({name:"OpenActRequest",params:{type:73}})}));class ye{}const D=d(()=>A(this,null,function*(){return(yield y({name:"OpenActRequest",timeout:5e3,params:{type:31,data:{requireLogin:!1}}})).data||null})),T=(()=>{const e=new Set,r=(()=>{let n;const a=o=>{n=setTimeout(()=>A(this,null,function*(){const i=yield D();if(!i)return a(++o);e.forEach(u=>u(i)),e.clear()}),(i=>i===0?0:i<50?600:i<80?1e3:5e3)(o))};return{start(){n&&clearTimeout(n),e.size>0&&a(0)},stop(){n&&clearTimeout(n)}}})();return{addTask(n){e.add(n)},removeTask(n){e.delete(n),e.size===0&&r.stop()},triggerCheckTask(){r.start()}}})(),ve=d(()=>A(this,null,function*(){T.triggerCheckTask(),yield p({name:"OpenActRequest",params:{type:31,data:{requireLogin:!0}}})})),_e=e=>(T.addTask(e),T.triggerCheckTask(),()=>{T.removeTask(e)});t.AppBaseInfo=$,t.AppLoginInfo=ye,t.AppShareModel=le,t.BridgeCode=c,t.IS_KB_APP_ENV=x,t.KbRequirement=B,t.NoteThreadPostRule=C,t.checkForNewVersion=X,t.closeWebView=Y,t.decorateAppVersionSupport=z,t.defineAppShareModel=fe,t.defineAppSharePanelState=he,t.defineBridgeCallback=R,t.definePermissionUsage=Z,t.generateKBSign=ee,t.generatePostEditorParamsByThreadPostRule=te,t.getAppBaseInfo=q,t.getAppLoginInfo=D,t.getAppSubscribeNotifyStatus=we,t.isAppVersionSupport=V,t.onAppSharePanelShow=ge,t.onLoopCheckAppLogin=_e,t.openAppSharePanel=pe,t.openAppSubscribeNotifySettings=Ae,t.openPostEditor=ne,t.reportDAEvent=ie,t.runAction=re,t.runBridgeApi=p,t.runBridgeApiResponse=y,t.saveImageToLocal=oe,t.saveVideoToLocal=se,t.scanQRCode=ae,t.setScreenOrientation=ce,t.setWebViewTitle=de,t.shareImage=ue,t.triggerAppLogin=ve,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.9-alpha.0",
6
+ "version": "1.0.10-alpha.0",
7
7
  "description": "开吧客户端桥接",
8
8
  "author": "along",
9
9
  "main": "./dist/umd/index.js",