@kbapp/js-bridge 1.0.16-alpha.0 → 1.0.18-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 CHANGED
@@ -79,8 +79,9 @@ async function saveImageHandle() {
79
79
  | - | `onAppSharePanelShow` | 监听分享面板打开事件 |
80
80
  | 12 | `defineAppShareModel` | 定义页面分享内容 |
81
81
  | 58 | `openAppSharePanel` | 主动唤起分享面板 |
82
- | 68 | `defineAppSharePanelState` | 定义分享面板控件布局 |
83
- | 13 | `openPostEditor` | 唤起发帖器 |
82
+ | 68 | `defineAppSharePanelState` | 定义分享面板控件布局 |
83
+ | 75 | `defineKeyboardActivePagePush` | 定义键盘唤起时页面上推 |
84
+ | 13 | `openPostEditor` | 唤起发帖器 |
84
85
  | 26 | `scanQRCode` | 扫描二维码 |
85
86
  | 35 | `getAppBaseInfo` | 获取设备信息 |
86
87
  | 51 | `generateKBSign` | 生成 kbsign |
@@ -300,9 +301,9 @@ defineAppShareModel({
300
301
 
301
302
  ---
302
303
 
303
- ### defineAppSharePanelState
304
-
305
- > 定义页面是否显示右上角分享菜单, 定义分享面板显示的相关状态
304
+ ### defineAppSharePanelState
305
+
306
+ > 定义页面是否显示右上角分享菜单, 定义分享面板显示的相关状态
306
307
 
307
308
  #### 请求参数
308
309
 
@@ -337,13 +338,39 @@ defineAppSharePanelState({
337
338
  })
338
339
  ```
339
340
 
340
- > 支持 Promise 风格调用
341
-
342
- ---
343
-
344
- ### generateKBSign
345
-
346
- > 生成 kbsign
341
+ > 支持 Promise 风格调用
342
+
343
+ ---
344
+
345
+ ### defineKeyboardActivePagePush
346
+
347
+ > 定义键盘唤起时候, 页面推上去, 必须页面加载时候就调用
348
+
349
+ #### 请求参数
350
+
351
+
352
+
353
+ #### 返回值
354
+
355
+ ```js
356
+ Promise<void>
357
+ ```
358
+
359
+ #### 示例代码
360
+
361
+ ```js
362
+ import { defineKeyboardActivePagePush } from '@kbapp/js-bridge'
363
+
364
+ defineKeyboardActivePagePush()
365
+ ```
366
+
367
+ > 支持 Promise 风格调用
368
+
369
+ ---
370
+
371
+ ### generateKBSign
372
+
373
+ > 生成 kbsign
347
374
 
348
375
  #### 请求参数
349
376
 
@@ -795,12 +822,13 @@ runAction({
795
822
 
796
823
  #### 请求参数
797
824
 
798
- | 参数 | 类型 | 必填 | 说明 |
799
- | ---------- | ----------------------------- | ---- | ------------ |
800
- | `imageUrl` | `string` | | 图片网络地址 |
801
- | `success` | `() => void` | 否 | 成功回调 |
802
- | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
803
- | `complete` | `() => void` | 否 | 完成回调 |
825
+ | 参数 | 类型 | 必填 | 说明 |
826
+ | -------------- | ----------------------------- | ---- | --------------------------------------- |
827
+ | `imageUrl` | `string` | | 图片网络地址(与 `encodedImage` 二选一) |
828
+ | `encodedImage` | `string` | 否 | 图片 base64(与 `imageUrl` 二选一) |
829
+ | `success` | `() => void` | 否 | 成功回调 |
830
+ | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
831
+ | `complete` | `() => void` | 否 | 完成回调 |
804
832
 
805
833
  #### 返回值
806
834
 
@@ -819,16 +847,23 @@ Promise<{ errCode: BridgeCode }>
819
847
  ```js
820
848
  import { saveImageToLocal, BridgeCode } from '@kbapp/js-bridge'
821
849
 
822
- saveImageToLocal({
823
- imageUrl: 'https://static.kaiba315.com.cn/kaiba-logo.png',
824
- success() {
825
- console.log('保存图片成功')
826
- },
850
+ saveImageToLocal({
851
+ imageUrl: 'https://static.kaiba315.com.cn/kaiba-logo.png',
852
+ success() {
853
+ console.log('保存图片成功')
854
+ },
827
855
  fail(error) {
828
856
  console.log('保存图片失败', error)
829
857
  },
830
- })
831
- ```
858
+ })
859
+
860
+ saveImageToLocal({
861
+ encodedImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...',
862
+ success() {
863
+ console.log('保存base64图片成功')
864
+ },
865
+ })
866
+ ```
832
867
 
833
868
  > 支持 Promise 风格调用
834
869
 
package/dist/es/index.js CHANGED
@@ -3,57 +3,59 @@ import { decorateAppVersionSupport as i, isAppVersionSupport as a } from "./lib/
3
3
  import { BridgeCode as s } from "./lib/bridge-code.js";
4
4
  import { checkForNewVersion as x } from "./lib/check-for-new-version.js";
5
5
  import { closeWebView as A } from "./lib/close-webview.js";
6
- import { definePermissionUsage as S } from "./lib/define-permission-usage.js";
7
- import { IS_KB_APP_ENV as l } from "./lib/env.js";
8
- import { generateKBSign as u } from "./lib/generate-kb-sign.js";
9
- import { AppBaseInfo as B, getAppBaseInfo as b } from "./lib/get-app-base-info.js";
10
- import { KbRequirement as L, NoteThreadPostRule as V, generatePostEditorParamsByThreadPostRule as N, openPostEditor as R } from "./lib/open-post-editor.js";
11
- import { reportDAEvent as w } from "./lib/report-da-event.js";
6
+ import { defineKeyboardActivePagePush as S } from "./lib/define-keyboard-active-page-push.js";
7
+ import { definePermissionUsage as l } from "./lib/define-permission-usage.js";
8
+ import { IS_KB_APP_ENV as h } from "./lib/env.js";
9
+ import { generateKBSign as b } from "./lib/generate-kb-sign.js";
10
+ import { AppBaseInfo as I, getAppBaseInfo as L } from "./lib/get-app-base-info.js";
11
+ import { KbRequirement as N, NoteThreadPostRule as R, generatePostEditorParamsByThreadPostRule as T, openPostEditor as v } from "./lib/open-post-editor.js";
12
+ import { reportDAEvent as y } from "./lib/report-da-event.js";
12
13
  import { runAction as E } from "./lib/run-action.js";
13
- import { saveImageToLocal as v } from "./lib/save-image-to-local.js";
14
- import { saveVideoToLocal as K } from "./lib/save-video-to-local.js";
15
- import { scanQRCode as M } from "./lib/scan-qr-code.js";
16
- import { setScreenOrientation as q } from "./lib/screen-orientation.js";
17
- import { setWebViewTitle as F } from "./lib/set-webview-title.js";
18
- import { shareImage as Q } from "./lib/share-image.js";
19
- import { AppShareModel as j, defineAppShareModel as z, defineAppSharePanelState as G, onAppSharePanelShow as H, openAppSharePanel as J } from "./lib/share-model.js";
20
- import { getAppSubscribeNotifyStatus as Y, openAppSubscribeNotifySettings as Z } from "./lib/subscribe-notify.js";
21
- import { AppLoginInfo as ee, getAppLoginInfo as oe, onLoopCheckAppLogin as re, triggerAppLogin as pe } from "./lib/trigger-login.js";
14
+ import { saveImageToLocal as k } from "./lib/save-image-to-local.js";
15
+ import { saveVideoToLocal as M } from "./lib/save-video-to-local.js";
16
+ import { scanQRCode as q } from "./lib/scan-qr-code.js";
17
+ import { setScreenOrientation as F } from "./lib/screen-orientation.js";
18
+ import { setWebViewTitle as Q } from "./lib/set-webview-title.js";
19
+ import { shareImage as j } from "./lib/share-image.js";
20
+ import { AppShareModel as G, defineAppShareModel as H, defineAppSharePanelState as J, onAppSharePanelShow as X, openAppSharePanel as Y } from "./lib/share-model.js";
21
+ import { getAppSubscribeNotifyStatus as $, openAppSubscribeNotifySettings as ee } from "./lib/subscribe-notify.js";
22
+ import { AppLoginInfo as re, getAppLoginInfo as pe, onLoopCheckAppLogin as te, triggerAppLogin as ne } from "./lib/trigger-login.js";
22
23
  export {
23
- B as AppBaseInfo,
24
- ee as AppLoginInfo,
25
- j as AppShareModel,
24
+ I as AppBaseInfo,
25
+ re as AppLoginInfo,
26
+ G as AppShareModel,
26
27
  s as BridgeCode,
27
- l as IS_KB_APP_ENV,
28
- L as KbRequirement,
29
- V as NoteThreadPostRule,
28
+ h as IS_KB_APP_ENV,
29
+ N as KbRequirement,
30
+ R as NoteThreadPostRule,
30
31
  x as checkForNewVersion,
31
32
  A as closeWebView,
32
33
  i as decorateAppVersionSupport,
33
- z as defineAppShareModel,
34
- G as defineAppSharePanelState,
34
+ H as defineAppShareModel,
35
+ J as defineAppSharePanelState,
35
36
  r as defineBridgeCallback,
36
- S as definePermissionUsage,
37
- u as generateKBSign,
38
- N as generatePostEditorParamsByThreadPostRule,
39
- b as getAppBaseInfo,
40
- oe as getAppLoginInfo,
41
- Y as getAppSubscribeNotifyStatus,
37
+ S as defineKeyboardActivePagePush,
38
+ l as definePermissionUsage,
39
+ b as generateKBSign,
40
+ T as generatePostEditorParamsByThreadPostRule,
41
+ L as getAppBaseInfo,
42
+ pe as getAppLoginInfo,
43
+ $ as getAppSubscribeNotifyStatus,
42
44
  a as isAppVersionSupport,
43
- H as onAppSharePanelShow,
44
- re as onLoopCheckAppLogin,
45
- J as openAppSharePanel,
46
- Z as openAppSubscribeNotifySettings,
47
- R as openPostEditor,
48
- w as reportDAEvent,
45
+ X as onAppSharePanelShow,
46
+ te as onLoopCheckAppLogin,
47
+ Y as openAppSharePanel,
48
+ ee as openAppSubscribeNotifySettings,
49
+ v as openPostEditor,
50
+ y as reportDAEvent,
49
51
  E as runAction,
50
52
  p as runBridgeApi,
51
53
  t as runBridgeApiResponse,
52
- v as saveImageToLocal,
53
- K as saveVideoToLocal,
54
- M as scanQRCode,
55
- q as setScreenOrientation,
56
- F as setWebViewTitle,
57
- Q as shareImage,
58
- pe as triggerAppLogin
54
+ k as saveImageToLocal,
55
+ M as saveVideoToLocal,
56
+ q as scanQRCode,
57
+ F as setScreenOrientation,
58
+ Q as setWebViewTitle,
59
+ j as shareImage,
60
+ ne as triggerAppLogin
59
61
  };
@@ -2,6 +2,16 @@ const r = class r {
2
2
  constructor(s) {
3
3
  this.errorCode = s.errorCode, this.errorMsg = s.errorMsg;
4
4
  }
5
+ /**
6
+ *
7
+ * @description 自定义业务错误
8
+ */
9
+ static createBusinessError(s) {
10
+ return new r({
11
+ errorCode: 1004,
12
+ errorMsg: s
13
+ });
14
+ }
5
15
  };
6
16
  r.UNKNOWN = new r({
7
17
  errorCode: 1e3,
@@ -16,7 +26,7 @@ r.UNKNOWN = new r({
16
26
  errorCode: 1003,
17
27
  errorMsg: "请在开吧app内执行"
18
28
  });
19
- let t = r;
29
+ let e = r;
20
30
  export {
21
- t as BridgeCode
31
+ e as BridgeCode
22
32
  };
@@ -0,0 +1,17 @@
1
+ import { runBridgeApi as e } from "../core/index.js";
2
+ import { wrapAsync as r } from "../utils/wrap-async.js";
3
+ import { decorateAppVersionSupport as o } from "./app-version-support.js";
4
+ const a = r(o({ minVersion: 80814 }, () => {
5
+ e({
6
+ name: "OpenActRequest",
7
+ params: {
8
+ type: 75,
9
+ data: {
10
+ keyboardResize: !0
11
+ }
12
+ }
13
+ });
14
+ }));
15
+ export {
16
+ a as defineKeyboardActivePagePush
17
+ };
@@ -1,16 +1,35 @@
1
- import { runBridgeApi as r } from "../core/index.js";
2
- import { wrapAsync as o } from "../utils/wrap-async.js";
3
- const m = o(
4
- (e) => {
5
- r({
1
+ var n = (r, a, o) => new Promise((c, s) => {
2
+ var p = (e) => {
3
+ try {
4
+ m(o.next(e));
5
+ } catch (i) {
6
+ s(i);
7
+ }
8
+ }, t = (e) => {
9
+ try {
10
+ m(o.throw(e));
11
+ } catch (i) {
12
+ s(i);
13
+ }
14
+ }, m = (e) => e.done ? c(e.value) : Promise.resolve(e.value).then(p, t);
15
+ m((o = o.apply(r, a)).next());
16
+ });
17
+ import { runBridgeApi as g } from "../core/index.js";
18
+ import { wrapAsync as d } from "../utils/wrap-async.js";
19
+ import { BridgeCode as u } from "./bridge-code.js";
20
+ const B = d(
21
+ (r) => n(void 0, null, function* () {
22
+ if (!r.imageUrl && !r.encodedImage)
23
+ return Promise.reject(u.createBusinessError("imageUrl or encodedImage is required"));
24
+ g({
6
25
  name: "OpenActRequest",
7
26
  params: {
8
27
  type: 62,
9
- data: e
28
+ data: r
10
29
  }
11
30
  });
12
- }
31
+ })
13
32
  );
14
33
  export {
15
- m as saveImageToLocal
34
+ B as saveImageToLocal
16
35
  };
@@ -3,6 +3,7 @@ export * from './lib/app-version-support';
3
3
  export * from './lib/bridge-code';
4
4
  export * from './lib/check-for-new-version';
5
5
  export * from './lib/close-webview';
6
+ export * from './lib/define-keyboard-active-page-push';
6
7
  export * from './lib/define-permission-usage';
7
8
  export * from './lib/env';
8
9
  export * from './lib/generate-kb-sign';
@@ -11,4 +11,9 @@ export declare class BridgeCode {
11
11
  static UNSUPPORTED_VERSION: BridgeCode;
12
12
  static TIMEOUT: BridgeCode;
13
13
  static UNSUPPORTED_BRIDGE_ENV: BridgeCode;
14
+ /**
15
+ *
16
+ * @description 自定义业务错误
17
+ */
18
+ static createBusinessError(message: string): BridgeCode;
14
19
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * @description 定义键盘唤起时候, 页面推上去, 必须页面加载时候就调用
4
+ * 桥接type: 75
5
+ * @example **示例代码**
6
+ ```js
7
+ import { defineKeyboardActivePagePush } from '@kbapp/js-bridge';
8
+
9
+ defineKeyboardActivePagePush()
10
+ ```
11
+ */
12
+ export declare const defineKeyboardActivePagePush: (params?: {
13
+ success?: ((res: void) => void) | undefined;
14
+ fail?: (error: import('./bridge-code').BridgeCode) => void;
15
+ complete?: () => void;
16
+ } | undefined) => Promise<void>;
@@ -1,3 +1,5 @@
1
+ import { BridgeCode } from './bridge-code';
2
+
1
3
  /**
2
4
  *
3
5
  * @description 保存图片到本地
@@ -12,11 +14,13 @@ saveImageToLocal({
12
14
  ```
13
15
  *
14
16
  */
15
- export declare const saveImageToLocal: (params: {
16
- /** 图片url(仅支持网络地址) */
17
- imageUrl: string;
17
+ export declare const saveImageToLocal: (params?: ({
18
+ /** 图片url(网络地址) imageUrl|encodedImage 二选一 */
19
+ imageUrl?: string;
20
+ /** 图片base64 imageBase64|encodedImage 二选一 */
21
+ encodedImage?: string;
18
22
  } & {
19
- success?: ((res: void) => void) | undefined;
20
- fail?: (error: import('./bridge-code').BridgeCode) => void;
23
+ success?: ((res: undefined) => void) | undefined;
24
+ fail?: (error: BridgeCode) => void;
21
25
  complete?: () => void;
22
- }) => Promise<void>;
26
+ }) | undefined) => Promise<undefined>;
package/dist/umd/index.js CHANGED
@@ -1,2 +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 k=(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 i={};return Object.keys(e).forEach(n=>{const a=e[n];a!=null&&(i[n]=Object.prototype.toString.call(a)==="[object Object]"?l(a):a)}),i}const w=class w{constructor(i){this.errorCode=i.errorCode,this.errorMsg=i.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,r)=>{var u="";typeof s=="function"&&(r=s,s={});var f={data:s===void 0?null:s};if(typeof r=="function"){var g="dscb"+window.dscb++;window[g]=r,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错误")}},i=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,n=(()=>{const o=[],s=setInterval(()=>{i()&&(clearInterval(s),o.forEach(r=>{e.apply(window,r)}),o.length=0)},500);return(...r)=>{o.push(r)}})();var a={default:void 0,callHandler:function(o,s,r){return i()?e(o,s,r):n(o,s,r)},register:function(o,s,r){var u=r?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(r){var u=JSON.parse(r.data),f={id:r.callbackId,complete:!0},g=this._dsf[r.method],S=this._dsaf[r.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 m=r.method.split(".");if(m.length<2)return;var F=m.pop(),J=m.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(i,n){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(i,n,a){throw c.UNSUPPORTED_BRIDGE_ENV}})((L=window==null?void 0:window.navigator)==null?void 0:L.userAgent),R=e=>new Promise((i,n)=>{var a,o,s;try{_.registerHandler(e.name,e.handler),(a=e.success)==null||a.call(e),i()}catch(r){(o=e.fail)==null||o.call(e,r),n(r)}finally{(s=e.complete)==null||s.call(e)}});function y(e){const i=n=>{let a;const o=r=>{var u;(!a||a==="success")&&(a="success",(u=n.success)==null||u.call(n,r))},s=r=>{var u;a||(a="error",(u=n.fail)==null||u.call(n,r))};n.timeout&&setTimeout(()=>{s(c.TIMEOUT)},n.timeout);try{_.callHandler(n.name,n.params,r=>{let u;try{typeof r=="string"?u=JSON.parse(r.replace(/^\s+|\s+$/g,"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\u0000-\u001F\u007F-\u009F]/g,function(f){return f===`
2
- `||f==="\r"?f:f===" "?"\\t":""})):u=r}catch(f){u=r}o(u)})}catch(r){s(r)}};return new Promise((n,a)=>{i({name:e.name,params:l(e.params),timeout:e.timeout,success:o=>{var s,r;(s=e.success)==null||s.call(e,o),(r=e.complete)==null||r.call(e),n(o)},fail:o=>{var s,r;(s=e.fail)==null||s.call(e,o),(r=e.complete)==null||r.call(e),a(o)}})})}function p(e){_.callHandler(e.name,e.params,i=>{})}function d(e){return function(...n){return A(this,null,function*(){const f=n[0]||{},{success:o,fail:s,complete:r}=f,u=k(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{r==null||r()}})}}function E(e){const i=new Map;return function(...n){const a=JSON.stringify(n);if(i.has(a))return i.get(a);const o=e(...n);return i.set(a,o),Promise.resolve(o).catch(()=>{i.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,i){return(...n)=>V({minVersion:e.minVersion}).then(a=>a?i(...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(i,n){n(U[i.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:i}=o,n=k(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 i=new C;return e&&Object.keys(e).forEach(n=>{i[n]=e[n]}),{hint:e==null?void 0:e.placeholder,initialText:e==null?void 0:e.initialText,audio:i.audioRqr!==2,image:i.imageMax!==0,video:i.videoRqr!==2,address:i.streetRqr!==2,asset_video:i.mediaRqr!==2,audio_must:i.audioRqr===3,image_must:i.imageMin>0,asset_video_must:i.mediaRqr===3,max_image_count:i.imageMax,min_image_count:i.imageMin,video_must:i.videoRqr===3,text_must:i.textMin>0,content_max_length:i.textMax,content_min_length:i.textMin}}const ne=d(e=>A(this,null,function*(){var i;return y({name:"OpenActRequest",params:{type:13,data:(i=e==null?void 0:e.postRule)!=null?i:{}}}).then(({data:n})=>{const s=n,{pic:a}=s,o=k(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(i,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,i=(()=>{let n;const a=o=>{n=setTimeout(()=>A(this,null,function*(){const r=yield D();if(!r)return a(++o);e.forEach(u=>u(r)),e.clear()}),(r=>r===0?0:r<50?600:r<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&&i.stop()},triggerCheckTask(){i.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"})});
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 Pe=Object.defineProperty;var b=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var K=(t,l,c)=>l in t?Pe(t,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):t[l]=c,G=(t,l)=>{for(var c in l||(l={}))Q.call(l,c)&&K(t,c,l[c]);if(b)for(var c of b(l))z.call(l,c)&&K(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&&z.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 H;function l(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const n={};return Object.keys(e).forEach(r=>{const a=e[r];a!=null&&(n[r]=Object.prototype.toString.call(a)==="[object Object]"?l(a):a)}),n}const w=class w{constructor(n){this.errorCode=n.errorCode,this.errorMsg=n.errorMsg}static createBusinessError(n){return new w({errorCode:1004,errorMsg:n})}};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错误")}},n=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,r=(()=>{const o=[],s=setInterval(()=>{n()&&(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 n()?e(o,s,i):r(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],j=function(N,M){f.data=N.apply(M,u),a.callHandler("_dsb.returnValue",f)},F=function(N,M){u.push(function(Re,Ee){f.data=Re,f.complete=Ee!==!1,a.callHandler("_dsb.returnValue",f)}),N.apply(M,u)};if(g)j(g,this._dsf);else if(S)F(S,this._dsaf);else{var k=i.method.split(".");if(k.length<2)return;var J=k.pop(),W=k.join("."),I=this._dsf._obs,P=I[W]||{},v=P[J];if(v&&typeof v=="function"){j(v,P);return}if(I=this._dsaf._obs,P=I[W]||{},v=P[J],v&&typeof v=="function"){F(v,P);return}}}};for(var s in o)window[s]=o[s]}}(),a},_=(e=>/(kb)/i.test(e)?h():{registerHandler(n,r){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(n,r,a){throw c.UNSUPPORTED_BRIDGE_ENV}})((H=window==null?void 0:window.navigator)==null?void 0:H.userAgent),R=e=>new Promise((n,r)=>{var a,o,s;try{_.registerHandler(e.name,e.handler),(a=e.success)==null||a.call(e),n()}catch(i){(o=e.fail)==null||o.call(e,i),r(i)}finally{(s=e.complete)==null||s.call(e)}});function y(e){const n=r=>{let a;const o=i=>{var u;(!a||a==="success")&&(a="success",(u=r.success)==null||u.call(r,i))},s=i=>{var u;a||(a="error",(u=r.fail)==null||u.call(r,i))};r.timeout&&setTimeout(()=>{s(c.TIMEOUT)},r.timeout);try{_.callHandler(r.name,r.params,i=>{let u;try{typeof i=="string"?u=JSON.parse(i.replace(/^\s+|\s+$/g,"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\u0000-\u001F\u007F-\u009F]/g,function(f){return f===`
2
+ `||f==="\r"?f:f===" "?"\\t":""})):u=i}catch(f){u=i}o(u)})}catch(i){s(i)}};return new Promise((r,a)=>{n({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),r(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,n=>{})}function d(e){return function(...r){return A(this,null,function*(){const f=r[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 n=new Map;return function(...r){const a=JSON.stringify(r);if(n.has(a))return n.get(a);const o=e(...r);return n.set(a,o),Promise.resolve(o).catch(()=>{n.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 U(e,n){return(...r)=>V({minVersion:e.minVersion}).then(a=>a?n(...r):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:{}}})}),Z=d(U({minVersion:80814},()=>{p({name:"OpenActRequest",params:{type:75,data:{keyboardResize:!0}}})})),B={microphone:{description:"用于发帖上传音频"},location:{description:"获取你选择的位置信息,用于线下导航服务"},camera:{description:"收集你选中的照片或视频信息 ,用于 发表评论、分享视频"}},x=d(e=>(Object.assign(B,e),R({name:"getPermissionUsage",handler(n,r){r(B[n.permission])}}))),ee=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent),te=d(e=>A(this,null,function*(){const o=e,{kbKey:n}=o,r=m(o,["kbKey"]),{data:a}=yield y({name:"OpenActRequest",timeout:5e3,params:{type:51,data:r}});return a}));var C=(e=>(e[e.FREE=1]="FREE",e[e.FORBID=2]="FORBID",e[e.REQUIRED=3]="REQUIRED",e))(C||{});class D{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 ne(e){const n=new D;return e&&Object.keys(e).forEach(r=>{n[r]=e[r]}),{hint:e==null?void 0:e.placeholder,initialText:e==null?void 0:e.initialText,audio:n.audioRqr!==2,image:n.imageMax!==0,video:n.videoRqr!==2,address:n.streetRqr!==2,asset_video:n.mediaRqr!==2,audio_must:n.audioRqr===3,image_must:n.imageMin>0,asset_video_must:n.mediaRqr===3,max_image_count:n.imageMax,min_image_count:n.imageMin,video_must:n.videoRqr===3,text_must:n.textMin>0,content_max_length:n.textMax,content_min_length:n.textMin}}const re=d(e=>A(this,null,function*(){var n;return y({name:"OpenActRequest",params:{type:13,data:(n=e==null?void 0:e.postRule)!=null?n:{}}}).then(({data:r})=>{const s=r,{pic:a}=s,o=m(s,["pic"]);return G({images:a},o)})})),ie=d(e=>{p({name:"OpenActRequest",params:{type:69,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})}),oe=d(e=>{p({name:"OpenActRequest",params:{type:1001,data:e}})}),se=d(e=>A(this,null,function*(){if(!e.imageUrl&&!e.encodedImage)return Promise.reject(c.createBusinessError("imageUrl or encodedImage is required"));p({name:"OpenActRequest",params:{type:62,data:e}})})),ae=d(e=>{p({name:"OpenActRequest",params:{type:63,data:e}})}),ce=d(()=>y({name:"OpenActRequest",params:{type:26,data:{}}})),de=d(e=>{p({name:"OpenActRequest",params:{type:71,data:e}})}),ue=d(e=>{p({name:"OpenActRequest",params:{type:64,data:e}})}),le=d(e=>{p({name:"OpenActRequest",params:{type:58,data:e}})}),O="SHARE_EVENT_NAME";class fe{}const pe=d(e=>R({name:"CommonShare",handler(n,r){window.dispatchEvent(new Event(O)),"onShareApp"in e&&e.onShareApp?r({type:12,data:e.onShareApp()}):r({type:12,data:e})}})),ge=d(e=>A(this,null,function*(){window.dispatchEvent(new Event(O)),p({name:"OpenActRequest",params:{type:58,data:e}})}));function he(e){return window.addEventListener(O,e),()=>{window.removeEventListener(O,e)}}const we=d(e=>{p({name:"OpenActRequest",params:{type:68,data:{show:e.showMenu,showActionMode:e.panelStyle||0}}})}),Ae=d(()=>y({name:"OpenActRequest",params:{type:72}})),ye=d(()=>A(this,null,function*(){p({name:"OpenActRequest",params:{type:73}})}));class ve{}const L=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,n=(()=>{let r;const a=o=>{r=setTimeout(()=>A(this,null,function*(){const i=yield L();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(){r&&clearTimeout(r),e.size>0&&a(0)},stop(){r&&clearTimeout(r)}}})();return{addTask(r){e.add(r)},removeTask(r){e.delete(r),e.size===0&&n.stop()},triggerCheckTask(){n.start()}}})(),_e=d(()=>A(this,null,function*(){T.triggerCheckTask(),yield p({name:"OpenActRequest",params:{type:31,data:{requireLogin:!0}}})})),Se=e=>(T.addTask(e),T.triggerCheckTask(),()=>{T.removeTask(e)});t.AppBaseInfo=$,t.AppLoginInfo=ve,t.AppShareModel=fe,t.BridgeCode=c,t.IS_KB_APP_ENV=ee,t.KbRequirement=C,t.NoteThreadPostRule=D,t.checkForNewVersion=X,t.closeWebView=Y,t.decorateAppVersionSupport=U,t.defineAppShareModel=pe,t.defineAppSharePanelState=we,t.defineBridgeCallback=R,t.defineKeyboardActivePagePush=Z,t.definePermissionUsage=x,t.generateKBSign=te,t.generatePostEditorParamsByThreadPostRule=ne,t.getAppBaseInfo=q,t.getAppLoginInfo=L,t.getAppSubscribeNotifyStatus=Ae,t.isAppVersionSupport=V,t.onAppSharePanelShow=he,t.onLoopCheckAppLogin=Se,t.openAppSharePanel=ge,t.openAppSubscribeNotifySettings=ye,t.openPostEditor=re,t.reportDAEvent=ie,t.runAction=oe,t.runBridgeApi=p,t.runBridgeApiResponse=y,t.saveImageToLocal=se,t.saveVideoToLocal=ae,t.scanQRCode=ce,t.setScreenOrientation=de,t.setWebViewTitle=ue,t.shareImage=le,t.triggerAppLogin=_e,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/docs/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # 开吧客户端桥接
2
+
3
+ > ⚠️ 重要提示:本 SDK 基于 TypeScript 开发,所有 API 参数均带有明确的必填 / 选填类型标注。使用时请务必开启 TS 类型检查或在 IDE 中查看参数提示,必填项缺失会直接提示错误,选填项可按需传入,请勿忽略类型提示以避免使用异常。
4
+
5
+ ## 下载
6
+
7
+ npm:
8
+
9
+ ```js
10
+ npm i @kbapp/js-bridge
11
+ ```
12
+
13
+ ### 或通过 script 标签引入
14
+
15
+ 使用 unpkg CDN:
16
+
17
+ ```html
18
+ <script src="https://unpkg.com/@kbapp/js-bridge@latest/dist/umd/index.js"></script>
19
+ ```
20
+
21
+ 使用 jsdelivr CDN:
22
+
23
+ ```html
24
+ <script src="https://cdn.jsdelivr.net/npm/@kbapp/js-bridge@latest/dist/umd/index.js"></script>
25
+ ```
26
+
27
+ > 通过 script 标签引入后,SDK 将作为全局变量 `kbBridge` 挂载在 window 对象上
28
+
29
+ ## 测试页面
30
+
31
+ [https://unpkg.com/@kbapp/js-bridge@latest/examples/index.html](https://unpkg.com/@kbapp/js-bridge@latest/examples/index.html)
32
+
33
+ ## 示例
34
+
35
+ ```js
36
+ import { saveImageToLocal } from '@kbapp/js-bridge'
37
+
38
+ function saveImageHandle() {
39
+ saveImageToLocal({
40
+ imageUrl: 'https://static.kaiba315.com.cn/kaiba-logo.png',
41
+ success() {
42
+ console.log('执行成功')
43
+ },
44
+ })
45
+ }
46
+ ```
47
+
48
+ ### 通过 script 标签引入的使用示例
49
+
50
+ ```html
51
+ <script src="https://unpkg.com/@kbapp/js-bridge@latest/dist/umd/index.js"></script>
52
+ <script>
53
+ async function saveImageHandle() {
54
+ // 通过全局变量kbBridge访问SDK功能
55
+ kbBridge.saveImageToLocal({
56
+ imageUrl: 'https://static.kaiba315.com.cn/kaiba-logo.png',
57
+ success() {
58
+ console.log('保存成功')
59
+ },
60
+ fail(error) {
61
+ console.log('保存失败', error)
62
+ },
63
+ })
64
+ }
65
+ </script>
66
+ ```
67
+
68
+ ## API
69
+
70
+ ### 总览
71
+
72
+ | 桥接 type | 方法 | 说明 | 链接 |
73
+ | --------- | ---- | ---- | ---- |
74
+ | - | `defineBridgeCallback` | 定义桥接调用的回调函数 | [查看文档](docs/api/define-bridge-callback.md) |
75
+ | - | `runBridgeApi` | 执行桥接(无返回值) | [查看文档](docs/api/run-bridge-api.md) |
76
+ | - | `runBridgeApiResponse` | 执行桥接(等待响应) | [查看文档](docs/api/run-bridge-api-response.md) |
77
+ | - | `isAppVersionSupport` | 判断当前版本号是否支持 | [查看文档](docs/api/is-app-version-support.md) |
78
+ | -1 | `closeWebView` | 关闭当前 webview | [查看文档](docs/api/close-web-view.md) |
79
+ | - | `definePermissionUsage` | 定义隐私权限协议文案 | [查看文档](docs/api/define-permission-usage.md) |
80
+ | - | `onAppSharePanelShow` | 监听分享面板打开事件 | [查看文档](docs/api/on-app-share-panel-show.md) |
81
+ | 12 | `defineAppShareModel` | 定义页面分享内容 | [查看文档](docs/api/define-app-share-model.md) |
82
+ | 58 | `openAppSharePanel` | 主动唤起分享面板 | [查看文档](docs/api/open-app-share-panel.md) |
83
+ | 68 | `defineAppSharePanelState` | 定义分享面板控件布局 | [查看文档](docs/api/define-app-share-panel-state.md) |
84
+ | 75 | `defineKeyboardActivePagePush` | 定义键盘唤起时页面上推 | [查看文档](docs/api/define-keyboard-active-page-push.md) |
85
+ | 13 | `openPostEditor` | 唤起发帖器 | [查看文档](docs/api/open-post-editor.md) |
86
+ | 26 | `scanQRCode` | 扫描二维码 | [查看文档](docs/api/scan-qrcode.md) |
87
+ | 35 | `getAppBaseInfo` | 获取设备信息 | [查看文档](docs/api/get-app-base-info.md) |
88
+ | 51 | `generateKBSign` | 生成 kbsign | [查看文档](docs/api/generate-kbsign.md) |
89
+ | 56 | `checkForNewVersion` | 检测是否有新版本 | [查看文档](docs/api/check-for-new-version.md) |
90
+ | 58 | `shareImage` | 分享海报 | [查看文档](docs/api/share-image.md) |
91
+ | 64 | `setWebViewTitle` | 设置网页标题 | [查看文档](docs/api/set-web-view-title.md) |
92
+ | 62 | `saveImageToLocal` | 保存图片到本地 | [查看文档](docs/api/save-image-to-local.md) |
93
+ | 63 | `saveVideoToLocal` | 保存视频到本地 | [查看文档](docs/api/save-video-to-local.md) |
94
+ | 69 | `reportDAEvent` | 上报数据埋点 | [查看文档](docs/api/report-daevent.md) |
95
+ | - | `onLoopCheckAppLogin` | 启动轮询检查 APP 登录状态 | [查看文档](docs/api/on-loop-check-app-login.md) |
96
+ | 31 | `getAppLoginInfo` | 获取 app 登录信息 | [查看文档](docs/api/get-app-login-info.md) |
97
+ | 31 | `triggerAppLogin` | 触发 app 登录 | [查看文档](docs/api/trigger-app-login.md) |
98
+ | 71 | `setScreenOrientation` | 设置屏幕方向 | [查看文档](docs/api/set-screen-orientation.md) |
99
+ | 72 | `getAppSubscribeNotifyStatus` | 获取APP订阅通知状态 | [查看文档](docs/api/get-app-subscribe-notify-status.md) |
100
+ | 73 | `openAppSubscribeNotifySettings` | 前往/打开 app订阅管理页面 | [查看文档](docs/api/open-app-subscribe-notify-settings.md) |
101
+ | 1001 | `runAction` | 执行 action | [查看文档](docs/api/run-action.md) |
102
+
103
+ | 类/枚举 | 说明 |
104
+ | --------------- | --------------------- |
105
+ | `BridgeCode` | kbapp 桥接状态码 |
106
+ | `IS_KB_APP_ENV` | 是否在开吧 APP 环境中 |
107
+ | `AppLoginInfo` | 登录信息模型 |
108
+ | `AppShareModel` | 应用分享模型 |
109
+ | `AppBaseInfo` | 设备信息模型 |
@@ -0,0 +1,27 @@
1
+ # defineKeyboardActivePagePush
2
+
3
+ > 定义键盘唤起时候, 页面推上去, 必须页面加载时候就调用
4
+
5
+ ### defineKeyboardActivePagePush
6
+
7
+ > 定义键盘唤起时候, 页面推上去, 必须页面加载时候就调用
8
+
9
+ #### 请求参数
10
+
11
+
12
+
13
+ #### 返回值
14
+
15
+ ```js
16
+ Promise<void>
17
+ ```
18
+
19
+ #### 示例代码
20
+
21
+ ```js
22
+ import { defineKeyboardActivePagePush } from '@kbapp/js-bridge'
23
+
24
+ defineKeyboardActivePagePush()
25
+ ```
26
+
27
+ > 支持 Promise 风格调用
@@ -8,12 +8,13 @@
8
8
 
9
9
  #### 请求参数
10
10
 
11
- | 参数 | 类型 | 必填 | 说明 |
12
- | ---------- | ----------------------------- | ---- | ------------ |
13
- | `imageUrl` | `string` | | 图片网络地址 |
14
- | `success` | `() => void` | 否 | 成功回调 |
15
- | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
16
- | `complete` | `() => void` | 否 | 完成回调 |
11
+ | 参数 | 类型 | 必填 | 说明 |
12
+ | -------------- | ----------------------------- | ---- | --------------------------------------- |
13
+ | `imageUrl` | `string` | | 图片网络地址(与 `encodedImage` 二选一) |
14
+ | `encodedImage` | `string` | 否 | 图片 base64(与 `imageUrl` 二选一) |
15
+ | `success` | `() => void` | 否 | 成功回调 |
16
+ | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
17
+ | `complete` | `() => void` | 否 | 完成回调 |
17
18
 
18
19
  #### 返回值
19
20
 
@@ -41,6 +42,13 @@ saveImageToLocal({
41
42
  console.log('保存图片失败', error)
42
43
  },
43
44
  })
45
+
46
+ saveImageToLocal({
47
+ encodedImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...',
48
+ success() {
49
+ console.log('保存base64图片成功')
50
+ },
51
+ })
44
52
  ```
45
53
 
46
54
  > 支持 Promise 风格调用
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.16-alpha.0",
6
+ "version": "1.0.18-alpha.0",
7
7
  "description": "开吧客户端桥接",
8
8
  "author": "along",
9
9
  "main": "./dist/umd/index.js",