@docoi/mys-sdk 1.0.2 → 1.0.3
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/dist/api/biz.d.ts +15 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +62 -57
- package/dist/types/enums.d.ts +9 -0
- package/dist/types/params.d.ts +15 -1
- package/dist/types/results.d.ts +6 -1
- package/package.json +1 -1
package/dist/api/biz.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Callbacks, NativeResponse, ShareWebCardParams, ShowAdParams, BindGameRoleParams, LoginResult, GetTokenResult, GetCircleInfoResult } from '../types';
|
|
1
|
+
import { Callbacks, NativeResponse, ShareWebCardParams, ShareImageParams, ShareImageResult, ShowAdParams, BindGameRoleParams, LoginResult, GetTokenResult, GetCircleInfoResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* 登录授权,获取用户信息。
|
|
4
4
|
*
|
|
@@ -44,6 +44,20 @@ export declare function getCurrentCircleInfo(params?: Callbacks<GetCircleInfoRes
|
|
|
44
44
|
* })
|
|
45
45
|
*/
|
|
46
46
|
export declare function shareWebCard(params: ShareWebCardParams): Promise<NativeResponse<void>>;
|
|
47
|
+
/**
|
|
48
|
+
* 唤起客户端图片分享弹窗,分享网络图片。
|
|
49
|
+
*
|
|
50
|
+
* 弹窗提供微信好友、微信朋友圈、QQ 好友、保存图片、取消五个操作,用户点击后通过 result.action 返回所选操作。
|
|
51
|
+
*
|
|
52
|
+
* @note
|
|
53
|
+
* url 不能为空,且必须为 http(s) 网络地址。
|
|
54
|
+
* 点击取消按钮属于成功响应,result.action 为 cancel。
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const res = await mys.shareImage({ url: 'https://example.com/poster.png' })
|
|
58
|
+
* console.log(res.result.action) // 'wechat' | 'moment' | 'qq' | 'save' | 'cancel'
|
|
59
|
+
*/
|
|
60
|
+
export declare function shareImage(params: ShareImageParams): Promise<NativeResponse<ShareImageResult>>;
|
|
47
61
|
/**
|
|
48
62
|
* 打开添加自定义表情页面。
|
|
49
63
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as bridge, registerNativeHandler, setDebug, JSBridgeSdk } from './bridge';
|
|
2
2
|
import { DebugOptions, JSBridgeInterface } from '@docoi/jsbridge-sdk';
|
|
3
|
-
import { Callbacks, LoginResult, NativeResponse, GetTokenResult, GetCircleInfoResult, ShareWebCardParams, BindGameRoleParams, ShowAdParams, ShowToastParams, TriggerVibrateParams, KeyboardHeightChangeCallback, EventListenOptions, CommentPanelChangeCallback, PlayMediaParams, ChooseMediaParams, ChooseMediaResult, UploadFilesParams, UploadFilesResult, SaveImageToPhotosAlbumParams, SaveVideoToPhotosAlbumParams, StartRecordParams, SystemInfoResult, NetworkTypeResult, SetClipboardDataParams, GetClipboardDataResult, CheckPermissionParams, CheckPermissionResult, OpenPhoneSettingParams, OpenInExternalBrowserParams } from './types';
|
|
3
|
+
import { Callbacks, LoginResult, NativeResponse, GetTokenResult, GetCircleInfoResult, ShareWebCardParams, ShareImageParams, ShareImageResult, BindGameRoleParams, ShowAdParams, ShowToastParams, TriggerVibrateParams, KeyboardHeightChangeCallback, EventListenOptions, CommentPanelChangeCallback, PlayMediaParams, ChooseMediaParams, ChooseMediaResult, UploadFilesParams, UploadFilesResult, SaveImageToPhotosAlbumParams, SaveVideoToPhotosAlbumParams, StartRecordParams, SystemInfoResult, NetworkTypeResult, SetClipboardDataParams, GetClipboardDataResult, CheckPermissionParams, CheckPermissionResult, OpenPhoneSettingParams, OpenInExternalBrowserParams } from './types';
|
|
4
4
|
declare const mys: {
|
|
5
5
|
setDebug: (enabled: boolean, options?: Partial< DebugOptions>) => JSBridgeInterface;
|
|
6
6
|
registerNativeHandler: typeof registerNativeHandler;
|
|
@@ -8,6 +8,7 @@ declare const mys: {
|
|
|
8
8
|
getToken(params?: Callbacks<GetTokenResult>): Promise< NativeResponse<GetTokenResult>>;
|
|
9
9
|
getCurrentCircleInfo(params?: Callbacks<GetCircleInfoResult>): Promise< NativeResponse<GetCircleInfoResult>>;
|
|
10
10
|
shareWebCard(params: ShareWebCardParams): Promise< NativeResponse<void>>;
|
|
11
|
+
shareImage(params: ShareImageParams): Promise< NativeResponse<ShareImageResult>>;
|
|
11
12
|
openAddCustomEmoji(params?: Callbacks): Promise< NativeResponse<void>>;
|
|
12
13
|
toBindGameRole(params: BindGameRoleParams): Promise< NativeResponse<void>>;
|
|
13
14
|
showAd(params: ShowAdParams): Promise< NativeResponse<void>>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
1
|
+
import T from "@docoi/jsbridge-sdk";
|
|
2
|
+
import { default as Ie } from "@docoi/jsbridge-sdk";
|
|
3
|
+
const v = 0, S = -1, Pe = 1001, A = 1002, be = 2002, qe = 3002, ve = 4002, Se = 9002;
|
|
4
4
|
function N(e) {
|
|
5
5
|
return {
|
|
6
|
-
code:
|
|
6
|
+
code: v,
|
|
7
7
|
msg: "ok",
|
|
8
8
|
result: e
|
|
9
9
|
};
|
|
@@ -20,12 +20,12 @@ function w(e) {
|
|
|
20
20
|
}
|
|
21
21
|
function O(e, t) {
|
|
22
22
|
return {
|
|
23
|
-
code:
|
|
23
|
+
code: S,
|
|
24
24
|
msg: `${e}:fail ${w(t)}`,
|
|
25
25
|
result: h(t) && "result" in t ? t.result : t
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
const u =
|
|
28
|
+
const u = T.init({
|
|
29
29
|
debug: !1,
|
|
30
30
|
timeout: 9e4
|
|
31
31
|
}), H = (e, t) => u.setDebug(e, t);
|
|
@@ -40,12 +40,12 @@ function _(e, t) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
function i(e, t, r) {
|
|
43
|
-
var
|
|
43
|
+
var s, f;
|
|
44
44
|
const o = {
|
|
45
45
|
errMsg: `${e}:fail parameter error: ${t}`,
|
|
46
|
-
errCode:
|
|
46
|
+
errCode: A
|
|
47
47
|
};
|
|
48
|
-
return (
|
|
48
|
+
return (s = r == null ? void 0 : r.fail) == null || s.call(r, o), (f = r == null ? void 0 : r.complete) == null || f.call(r, o), Promise.reject(o);
|
|
49
49
|
}
|
|
50
50
|
function D(e) {
|
|
51
51
|
return Object.fromEntries(
|
|
@@ -73,22 +73,22 @@ function q(e, t) {
|
|
|
73
73
|
raw: t
|
|
74
74
|
} : {
|
|
75
75
|
errMsg: `${e}:fail ${w(t)}`,
|
|
76
|
-
errCode:
|
|
76
|
+
errCode: S
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
function n(e, t = {}, r, o) {
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
if (M(
|
|
83
|
-
const C =
|
|
84
|
-
return
|
|
80
|
+
const s = String(e), { success: f, fail: y, complete: d } = r || {}, I = (a) => {
|
|
81
|
+
const l = m(a);
|
|
82
|
+
if (M(l) && l.code === v) {
|
|
83
|
+
const C = l;
|
|
84
|
+
return f == null || f(C), d == null || d(C), C;
|
|
85
85
|
}
|
|
86
|
-
throw q(
|
|
87
|
-
},
|
|
88
|
-
const
|
|
89
|
-
throw y == null || y(
|
|
86
|
+
throw q(s, l);
|
|
87
|
+
}, R = (a) => {
|
|
88
|
+
const l = q(s, a);
|
|
89
|
+
throw y == null || y(l), d == null || d(l), l;
|
|
90
90
|
};
|
|
91
|
-
return u.callAsync(
|
|
91
|
+
return u.callAsync(s, D(t), o).then(I).catch(R);
|
|
92
92
|
}
|
|
93
93
|
var E = /* @__PURE__ */ ((e) => (e[e.Short = 0] = "Short", e[e.Long = 1] = "Long", e))(E || {});
|
|
94
94
|
function x(e) {
|
|
@@ -122,9 +122,9 @@ const c = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
|
122
122
|
function $(e, t) {
|
|
123
123
|
const r = c.get(e);
|
|
124
124
|
r && u.off("keyboardHeightChange", r);
|
|
125
|
-
const o = (
|
|
126
|
-
const
|
|
127
|
-
e(
|
|
125
|
+
const o = (s) => {
|
|
126
|
+
const f = s ? s / B() : 0;
|
|
127
|
+
e(f), t != null && t.once && c.delete(e);
|
|
128
128
|
};
|
|
129
129
|
if (c.set(e, o), t != null && t.once) {
|
|
130
130
|
u.once("keyboardHeightChange", o);
|
|
@@ -143,8 +143,8 @@ function k(e) {
|
|
|
143
143
|
function G(e, t) {
|
|
144
144
|
const r = g.get(e);
|
|
145
145
|
r && u.off("onCommentPanelChange", r);
|
|
146
|
-
const o = (
|
|
147
|
-
e(
|
|
146
|
+
const o = (s) => {
|
|
147
|
+
e(s), t != null && t.once && g.delete(e);
|
|
148
148
|
};
|
|
149
149
|
if (g.set(e, o), t != null && t.once) {
|
|
150
150
|
u.once("onCommentPanelChange", o);
|
|
@@ -299,16 +299,16 @@ const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
299
299
|
triggerVibrate: V,
|
|
300
300
|
uploadFiles: L
|
|
301
301
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
302
|
-
function
|
|
302
|
+
function se(e) {
|
|
303
303
|
return n("login", {}, e, { queue: "serial" });
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function fe(e) {
|
|
306
306
|
return n("getToken", {}, e);
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function le(e) {
|
|
309
309
|
return n("getCurrentCircleInfo", {}, e);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function de(e) {
|
|
312
312
|
return e.title ? n(
|
|
313
313
|
"shareWebCard",
|
|
314
314
|
{
|
|
@@ -320,57 +320,61 @@ function le(e) {
|
|
|
320
320
|
) : i("shareWebCard", "title is required", e);
|
|
321
321
|
}
|
|
322
322
|
function ce(e) {
|
|
323
|
-
return n("
|
|
323
|
+
return !e.url || !/^https?:\/\//i.test(e.url) ? i("shareImage", "url must be a valid http(s) url", e) : n("shareImage", { url: e.url }, e, { queue: "serial" });
|
|
324
324
|
}
|
|
325
325
|
function ge(e) {
|
|
326
|
-
return
|
|
326
|
+
return n("openAddCustomEmoji", {}, e, { queue: "serial" });
|
|
327
327
|
}
|
|
328
328
|
function he(e) {
|
|
329
|
+
return e.gameName ? e.serverId ? n("pointsMallBindGame", e, e, { queue: "serial" }) : i("toBindGameRole", "serverId is required", e) : i("toBindGameRole", "gameName is required", e);
|
|
330
|
+
}
|
|
331
|
+
function ye(e) {
|
|
329
332
|
return e.type === void 0 ? i("showAd", "type is required", e) : n("showAdVideo", e, e, { queue: "serial" });
|
|
330
333
|
}
|
|
331
|
-
const
|
|
334
|
+
const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
332
335
|
__proto__: null,
|
|
333
|
-
getCurrentCircleInfo:
|
|
334
|
-
getToken:
|
|
335
|
-
login:
|
|
336
|
-
openAddCustomEmoji:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
336
|
+
getCurrentCircleInfo: le,
|
|
337
|
+
getToken: fe,
|
|
338
|
+
login: se,
|
|
339
|
+
openAddCustomEmoji: ge,
|
|
340
|
+
shareImage: ce,
|
|
341
|
+
shareWebCard: de,
|
|
342
|
+
showAd: ye,
|
|
343
|
+
toBindGameRole: he
|
|
344
|
+
}, Symbol.toStringTag, { value: "Module" })), we = {
|
|
341
345
|
...ue,
|
|
342
|
-
...
|
|
346
|
+
...ae,
|
|
343
347
|
setDebug: H,
|
|
344
348
|
registerNativeHandler: _
|
|
345
349
|
};
|
|
346
350
|
export {
|
|
347
351
|
Se as CUSTOM,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
352
|
+
Ie as JSBridgeSdk,
|
|
353
|
+
Pe as METHOD_NOT_FOUND,
|
|
354
|
+
ve as NETWORK_ERROR,
|
|
355
|
+
be as NOT_LOGGED_IN,
|
|
356
|
+
A as PARAMS_ERROR,
|
|
357
|
+
qe as PERMISSION_DENIED,
|
|
358
|
+
v as SUCCESS,
|
|
359
|
+
S as SYSTEM_EXCEPTION,
|
|
356
360
|
E as ToastDuration,
|
|
357
361
|
u as bridge,
|
|
358
362
|
re as checkPermission,
|
|
359
363
|
J as chooseMedia,
|
|
360
364
|
ie as closeWebView,
|
|
361
|
-
|
|
365
|
+
we as default,
|
|
362
366
|
te as getClipboardData,
|
|
363
|
-
|
|
367
|
+
le as getCurrentCircleInfo,
|
|
364
368
|
p as getNetworkType,
|
|
365
369
|
Z as getSystemInfo,
|
|
366
|
-
|
|
370
|
+
fe as getToken,
|
|
367
371
|
F as hideKeyboard,
|
|
368
|
-
|
|
372
|
+
se as login,
|
|
369
373
|
W as offCommentPanelChange,
|
|
370
374
|
k as offKeyboardHeightChange,
|
|
371
375
|
G as onCommentPanelChange,
|
|
372
376
|
$ as onKeyboardHeightChange,
|
|
373
|
-
|
|
377
|
+
ge as openAddCustomEmoji,
|
|
374
378
|
oe as openInExternalBrowser,
|
|
375
379
|
ne as openPhoneSetting,
|
|
376
380
|
K as previewImage,
|
|
@@ -380,13 +384,14 @@ export {
|
|
|
380
384
|
X as saveVideoToPhotosAlbum,
|
|
381
385
|
ee as setClipboardData,
|
|
382
386
|
H as setDebug,
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
ce as shareImage,
|
|
388
|
+
de as shareWebCard,
|
|
389
|
+
ye as showAd,
|
|
385
390
|
x as showToast,
|
|
386
391
|
Y as startRecord,
|
|
387
392
|
Q as stopRecord,
|
|
388
393
|
j as stopVibrate,
|
|
389
|
-
|
|
394
|
+
he as toBindGameRole,
|
|
390
395
|
V as triggerVibrate,
|
|
391
396
|
L as uploadFiles
|
|
392
397
|
};
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -38,5 +38,14 @@ export type NetworkTypeStr = "wifi" | "2g" | "3g" | "4g" | "5g" | "unknown" | "n
|
|
|
38
38
|
* - 3: QQ
|
|
39
39
|
*/
|
|
40
40
|
export type ShareChannelType = 1 | 2 | 3;
|
|
41
|
+
/**
|
|
42
|
+
* 图片分享弹窗操作
|
|
43
|
+
* - wechat: 微信好友
|
|
44
|
+
* - moment: 微信朋友圈
|
|
45
|
+
* - qq: QQ 好友
|
|
46
|
+
* - save: 保存图片
|
|
47
|
+
* - cancel: 取消
|
|
48
|
+
*/
|
|
49
|
+
export type ShareImageAction = "wechat" | "moment" | "qq" | "save" | "cancel";
|
|
41
50
|
/** 文件类型标签 */
|
|
42
51
|
export type FileTypeTag = "image" | "video";
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Callbacks } from './base';
|
|
2
2
|
import { MediaFileType, SettingType, CameraDirection, ShareChannelType, PermissionType, PreviewMediaType, ToastDuration } from './enums';
|
|
3
|
-
import { ChooseMediaResult, CheckPermissionResult, UploadFilesProgress, UploadFilesResult } from './results';
|
|
3
|
+
import { ChooseMediaResult, CheckPermissionResult, ShareImageResult, UploadFilesProgress, UploadFilesResult } from './results';
|
|
4
4
|
/**
|
|
5
5
|
* 事件监听选项。
|
|
6
6
|
*
|
|
@@ -195,6 +195,20 @@ export interface ShareWebCardParams extends Callbacks {
|
|
|
195
195
|
/** 内容类型 */
|
|
196
196
|
contentType?: string;
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* shareImage 参数
|
|
200
|
+
*
|
|
201
|
+
* 唤起客户端图片分享弹窗
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* mys.shareImage({ url: 'https://example.com/poster.png' })
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export interface ShareImageParams extends Callbacks<ShareImageResult> {
|
|
209
|
+
/** 待分享图片的网络地址,需为 http(s) URL */
|
|
210
|
+
url: string;
|
|
211
|
+
}
|
|
198
212
|
/**
|
|
199
213
|
* showAd 参数
|
|
200
214
|
*
|
package/dist/types/results.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform, NetworkTypeStr, PermissionStatus, PermissionType } from './enums';
|
|
1
|
+
import { Platform, NetworkTypeStr, PermissionStatus, PermissionType, ShareImageAction } from './enums';
|
|
2
2
|
/** chooseMedia 返回值 */
|
|
3
3
|
export interface ChooseMediaResult {
|
|
4
4
|
/** 本地临时媒体文件列表 */
|
|
@@ -133,6 +133,11 @@ export interface GetTokenResult {
|
|
|
133
133
|
/** 登录 Token */
|
|
134
134
|
readonly token: string;
|
|
135
135
|
}
|
|
136
|
+
/** shareImage 返回值 */
|
|
137
|
+
export interface ShareImageResult {
|
|
138
|
+
/** 用户在分享弹窗中点击的操作 */
|
|
139
|
+
readonly action: ShareImageAction;
|
|
140
|
+
}
|
|
136
141
|
/** getCurrentCircleInfo 返回值 */
|
|
137
142
|
export interface GetCircleInfoResult {
|
|
138
143
|
/** 服务器 ID */
|