@docoi/mys-sdk 1.0.0 → 1.0.1
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/LICENSE +21 -0
- package/dist/api/basic.d.ts +59 -48
- package/dist/index.d.ts +8 -13
- package/dist/index.mjs +216 -207
- package/dist/types/enums.d.ts +0 -2
- package/dist/types/params.d.ts +22 -43
- package/dist/types/results.d.ts +51 -9
- package/package.json +45 -46
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 docoi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/api/basic.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShowToastParams, PlayMediaParams, ChooseMediaParams, ChooseMediaResult,
|
|
1
|
+
import { ShowToastParams, PlayMediaParams, ChooseMediaParams, ChooseMediaResult, UploadFilesParams, UploadFilesResult, SaveImageToPhotosAlbumParams, SaveVideoToPhotosAlbumParams, StartRecordParams, SetClipboardDataParams, GetClipboardDataResult, OpenInExternalBrowserParams, TriggerVibrateParams, Callbacks, NativeResponse, SystemInfoResult, NetworkTypeResult, OpenPhoneSettingParams, CheckPermissionParams, CheckPermissionResult, KeyboardHeightChangeCallback, CommentPanelChangeCallback, EventListenOptions } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* 显示消息提示框。
|
|
4
4
|
*
|
|
@@ -20,7 +20,7 @@ export declare function showToast(params: ShowToastParams): Promise<NativeRespon
|
|
|
20
20
|
* iOS 如果不支持自定义力度和精确时长,intensity 和 duration 会被忽略,退化为系统默认触感节奏。
|
|
21
21
|
* repeat 为 true 时会无限循环,需调用 stopVibrate 停止。
|
|
22
22
|
*
|
|
23
|
-
* @app 1.
|
|
23
|
+
* @app 4.1.0
|
|
24
24
|
* @example
|
|
25
25
|
* await mys.triggerVibrate({ duration: 30, intensity: 0.5 })
|
|
26
26
|
*
|
|
@@ -38,7 +38,7 @@ export declare function triggerVibrate(params?: TriggerVibrateParams): Promise<N
|
|
|
38
38
|
*
|
|
39
39
|
* 用于停止 triggerVibrate 发起的循环震动。
|
|
40
40
|
*
|
|
41
|
-
* @app 1.
|
|
41
|
+
* @app 4.1.0
|
|
42
42
|
* @example
|
|
43
43
|
* await mys.stopVibrate()
|
|
44
44
|
*/
|
|
@@ -61,22 +61,64 @@ export declare function hideKeyboard(params?: Callbacks): Promise<NativeResponse
|
|
|
61
61
|
*
|
|
62
62
|
* @note
|
|
63
63
|
* 回调参数 height 单位为 CSS 逻辑像素,可直接用于页面布局。
|
|
64
|
+
* 事件监听类型直接返回原始 payload,不包装 code/msg/result。
|
|
65
|
+
* options.once 为 true 时只触发一次,触发后由 jsbridge 自动取消监听。
|
|
64
66
|
*
|
|
65
|
-
* @app
|
|
67
|
+
* @app 3.9.0
|
|
66
68
|
* @example
|
|
67
69
|
* mys.onKeyboardHeightChange((height) => {
|
|
68
70
|
* console.log('键盘高度:', height)
|
|
69
71
|
* })
|
|
72
|
+
*
|
|
73
|
+
* mys.onKeyboardHeightChange((height) => {
|
|
74
|
+
* console.log('只监听一次键盘高度:', height)
|
|
75
|
+
* }, { once: true })
|
|
76
|
+
*
|
|
77
|
+
* mys.offKeyboardHeightChange()
|
|
70
78
|
*/
|
|
71
|
-
export declare function onKeyboardHeightChange(callback:
|
|
79
|
+
export declare function onKeyboardHeightChange(callback: KeyboardHeightChangeCallback, options?: EventListenOptions): void;
|
|
72
80
|
/**
|
|
73
81
|
* 取消监听键盘高度变化。
|
|
74
82
|
*
|
|
83
|
+
* 不传 callback 时取消全部键盘高度监听;传入 callback 时只取消指定监听。
|
|
84
|
+
*
|
|
75
85
|
* @app 1.2.3
|
|
76
86
|
* @example
|
|
77
87
|
* mys.offKeyboardHeightChange()
|
|
78
88
|
*/
|
|
79
|
-
export declare function offKeyboardHeightChange(): void;
|
|
89
|
+
export declare function offKeyboardHeightChange(callback?: KeyboardHeightChangeCallback): void;
|
|
90
|
+
/**
|
|
91
|
+
* 监听评论区面板状态变化。
|
|
92
|
+
*
|
|
93
|
+
* 当 Native 评论区面板打开、关闭或状态变化时触发。
|
|
94
|
+
*
|
|
95
|
+
* @note
|
|
96
|
+
* 事件监听类型直接返回原始 payload,不包装 code/msg/result。
|
|
97
|
+
* options.once 为 true 时只触发一次,触发后由 jsbridge 自动取消监听。
|
|
98
|
+
*
|
|
99
|
+
* @app 4.2.0
|
|
100
|
+
* @example
|
|
101
|
+
* mys.onCommentPanelChange((res) => {
|
|
102
|
+
* console.log('评论区面板状态:', res.visible, res.reason)
|
|
103
|
+
* })
|
|
104
|
+
*
|
|
105
|
+
* mys.onCommentPanelChange((res) => {
|
|
106
|
+
* console.log('只监听一次:', res.visible, res.reason)
|
|
107
|
+
* }, { once: true })
|
|
108
|
+
*
|
|
109
|
+
* mys.offCommentPanelChange()
|
|
110
|
+
*/
|
|
111
|
+
export declare function onCommentPanelChange(callback: CommentPanelChangeCallback, options?: EventListenOptions): void;
|
|
112
|
+
/**
|
|
113
|
+
* 取消监听评论区面板状态变化。
|
|
114
|
+
*
|
|
115
|
+
* 不传 callback 时取消全部评论区面板监听;传入 callback 时只取消指定监听。
|
|
116
|
+
*
|
|
117
|
+
* @app 4.2.0
|
|
118
|
+
* @example
|
|
119
|
+
* mys.offCommentPanelChange()
|
|
120
|
+
*/
|
|
121
|
+
export declare function offCommentPanelChange(callback?: CommentPanelChangeCallback): void;
|
|
80
122
|
/**
|
|
81
123
|
* 预览图片。
|
|
82
124
|
*
|
|
@@ -84,10 +126,10 @@ export declare function offKeyboardHeightChange(): void;
|
|
|
84
126
|
* urls 不能为空。
|
|
85
127
|
* current 为当前预览图片在 urls 中的数组下标,默认 0。
|
|
86
128
|
*
|
|
87
|
-
* @app
|
|
129
|
+
* @app 4.3.0
|
|
88
130
|
* @example
|
|
89
131
|
* await mys.previewImage({
|
|
90
|
-
* urls: ['https://example.com/1.jpg', '
|
|
132
|
+
* urls: ['https://example.com/1.jpg', 'mysFile://temp/files/xxx.jpg'],
|
|
91
133
|
* current: 0,
|
|
92
134
|
* })
|
|
93
135
|
*/
|
|
@@ -111,15 +153,14 @@ export declare function previewVideo(params: PlayMediaParams): Promise<NativeRes
|
|
|
111
153
|
*
|
|
112
154
|
* @note
|
|
113
155
|
* 成功返回的 files[].tempFilePath 为临时文件路径,例如 mysFile://temp/xxxx.png。
|
|
114
|
-
* tempFilePath 可用于 img / video 预览,也可传给
|
|
156
|
+
* tempFilePath 可用于 img / video 预览,也可传给 uploadFiles 上传。
|
|
115
157
|
* 临时文件不应作为长期业务资源保存。
|
|
116
158
|
*
|
|
117
|
-
* @app
|
|
159
|
+
* @app 4.3.0
|
|
118
160
|
* @example
|
|
119
161
|
* const res = await mys.chooseMedia({
|
|
120
162
|
* count: 1,
|
|
121
163
|
* mediaType: 'image',
|
|
122
|
-
* sourceType: 'all',
|
|
123
164
|
* })
|
|
124
165
|
* console.log(res.result.files[0].tempFilePath)
|
|
125
166
|
*/
|
|
@@ -127,19 +168,20 @@ export declare function chooseMedia(params?: ChooseMediaParams): Promise<NativeR
|
|
|
127
168
|
/**
|
|
128
169
|
* 上传本地临时文件。
|
|
129
170
|
*
|
|
130
|
-
*
|
|
171
|
+
* 批量串行上传 chooseMedia 返回的临时文件路径,成功后返回网络 URL。
|
|
131
172
|
*
|
|
132
173
|
* @note
|
|
133
174
|
* filePath 应为 chooseMedia 返回的临时文件路径,例如 mysFile://temp/xxxx.png。
|
|
175
|
+
* cosDirPath 默认 multipleSource/common/。
|
|
134
176
|
*
|
|
135
|
-
* @app
|
|
177
|
+
* @app 4.3.0
|
|
136
178
|
* @example
|
|
137
|
-
* const uploadRes = await mys.
|
|
138
|
-
*
|
|
179
|
+
* const uploadRes = await mys.uploadFiles({
|
|
180
|
+
* files: [chooseRes.result.files[0].tempFilePath],
|
|
139
181
|
* })
|
|
140
|
-
* console.log(uploadRes.result.url)
|
|
182
|
+
* console.log(uploadRes.result.files[0].url)
|
|
141
183
|
*/
|
|
142
|
-
export declare function
|
|
184
|
+
export declare function uploadFiles(params: UploadFilesParams): Promise<NativeResponse<UploadFilesResult>>;
|
|
143
185
|
/**
|
|
144
186
|
* 保存图片到系统相册。
|
|
145
187
|
*
|
|
@@ -241,37 +283,6 @@ export declare function checkPermission(params: CheckPermissionParams): Promise<
|
|
|
241
283
|
* await mys.openPhoneSetting({ type: 'notice' })
|
|
242
284
|
*/
|
|
243
285
|
export declare function openPhoneSetting(params: OpenPhoneSettingParams): Promise<NativeResponse<void>>;
|
|
244
|
-
/**
|
|
245
|
-
* 跳转到应用内的某个页面(非 Tab 页面)。
|
|
246
|
-
*
|
|
247
|
-
* @app 1.2.3
|
|
248
|
-
* @example
|
|
249
|
-
* await mys.navigateToApp({ url: '/pages/detail/index' })
|
|
250
|
-
*/
|
|
251
|
-
export declare function navigateToApp(params: NavigateToAppParams): Promise<NativeResponse<void>>;
|
|
252
|
-
/**
|
|
253
|
-
* 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。
|
|
254
|
-
*
|
|
255
|
-
* @app 1.2.3
|
|
256
|
-
* @example
|
|
257
|
-
* await mys.switchTab({ url: '/pages/index/index' })
|
|
258
|
-
*/
|
|
259
|
-
export declare function switchTab(params: SwitchTabParams): Promise<NativeResponse<void>>;
|
|
260
|
-
/**
|
|
261
|
-
* 打开 Webview 容器。
|
|
262
|
-
*
|
|
263
|
-
* 支持 immersive、normal、mini 三种容器类型。
|
|
264
|
-
*
|
|
265
|
-
* @note
|
|
266
|
-
* 当 replace 为 true 时直接替换当前页面。
|
|
267
|
-
*
|
|
268
|
-
* @app 1.2.3
|
|
269
|
-
* @example
|
|
270
|
-
* await mys.openWebview({ url: 'https://example.com', type: 'immersive' })
|
|
271
|
-
*
|
|
272
|
-
* await mys.openWebview({ url: 'https://example.com', replace: true })
|
|
273
|
-
*/
|
|
274
|
-
export declare function openWebview(params: OpenWebviewParams): Promise<NativeResponse<void>>;
|
|
275
286
|
/**
|
|
276
287
|
* 关闭当前网页视图。
|
|
277
288
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { registerNativeHandler, setDebug, JSBridgeSdk
|
|
2
|
-
import {
|
|
3
|
-
import { Callbacks, LoginResult, NativeResponse, GetTokenResult, GetCircleInfoResult, ShareWebCardParams, BindGameRoleParams, ShowAdParams, ShowToastParams, TriggerVibrateParams, PlayMediaParams, ChooseMediaParams, ChooseMediaResult, UploadFileParams, UploadFileResult, SaveImageToPhotosAlbumParams, SaveVideoToPhotosAlbumParams, StartRecordParams, SystemInfoResult, NetworkTypeResult, SetClipboardDataParams, GetClipboardDataResult, CheckPermissionParams, CheckPermissionResult, OpenPhoneSettingParams, NavigateToAppParams, SwitchTabParams, OpenWebviewParams, OpenInExternalBrowserParams } from './types';
|
|
1
|
+
import { default as bridge, registerNativeHandler, setDebug, JSBridgeSdk } from './bridge';
|
|
2
|
+
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';
|
|
4
3
|
declare const mys: {
|
|
5
|
-
setDebug: (enabled: boolean) => JSBridgeInterface;
|
|
6
4
|
registerNativeHandler: typeof registerNativeHandler;
|
|
7
|
-
bridge: JSBridgeInterface;
|
|
8
|
-
JSBridgeSdk: JSBridgeInterface;
|
|
9
5
|
login(params?: Callbacks<LoginResult>): Promise< NativeResponse<LoginResult>>;
|
|
10
6
|
getToken(params?: Callbacks<GetTokenResult>): Promise< NativeResponse<GetTokenResult>>;
|
|
11
7
|
getCurrentCircleInfo(params?: Callbacks<GetCircleInfoResult>): Promise< NativeResponse<GetCircleInfoResult>>;
|
|
@@ -17,12 +13,14 @@ declare const mys: {
|
|
|
17
13
|
triggerVibrate(params?: TriggerVibrateParams): Promise< NativeResponse<void>>;
|
|
18
14
|
stopVibrate(params?: Callbacks): Promise< NativeResponse<void>>;
|
|
19
15
|
hideKeyboard(params?: Callbacks): Promise< NativeResponse<void>>;
|
|
20
|
-
onKeyboardHeightChange(callback:
|
|
21
|
-
offKeyboardHeightChange(): void;
|
|
16
|
+
onKeyboardHeightChange(callback: KeyboardHeightChangeCallback, options?: EventListenOptions): void;
|
|
17
|
+
offKeyboardHeightChange(callback?: KeyboardHeightChangeCallback): void;
|
|
18
|
+
onCommentPanelChange(callback: CommentPanelChangeCallback, options?: EventListenOptions): void;
|
|
19
|
+
offCommentPanelChange(callback?: CommentPanelChangeCallback): void;
|
|
22
20
|
previewImage(params: PlayMediaParams): Promise< NativeResponse<void>>;
|
|
23
21
|
previewVideo(params: PlayMediaParams): Promise< NativeResponse<void>>;
|
|
24
22
|
chooseMedia(params?: ChooseMediaParams): Promise< NativeResponse<ChooseMediaResult>>;
|
|
25
|
-
|
|
23
|
+
uploadFiles(params: UploadFilesParams): Promise< NativeResponse<UploadFilesResult>>;
|
|
26
24
|
saveImageToPhotosAlbum(params: SaveImageToPhotosAlbumParams): Promise< NativeResponse<void>>;
|
|
27
25
|
saveVideoToPhotosAlbum(params: SaveVideoToPhotosAlbumParams): Promise< NativeResponse<void>>;
|
|
28
26
|
startRecord(params?: StartRecordParams): Promise< NativeResponse<void>>;
|
|
@@ -33,16 +31,13 @@ declare const mys: {
|
|
|
33
31
|
getClipboardData(params?: Callbacks<GetClipboardDataResult>): Promise< NativeResponse<GetClipboardDataResult>>;
|
|
34
32
|
checkPermission(params: CheckPermissionParams): Promise< NativeResponse<CheckPermissionResult>>;
|
|
35
33
|
openPhoneSetting(params: OpenPhoneSettingParams): Promise< NativeResponse<void>>;
|
|
36
|
-
navigateToApp(params: NavigateToAppParams): Promise< NativeResponse<void>>;
|
|
37
|
-
switchTab(params: SwitchTabParams): Promise< NativeResponse<void>>;
|
|
38
|
-
openWebview(params: OpenWebviewParams): Promise< NativeResponse<void>>;
|
|
39
34
|
closeWebView(params?: Callbacks): Promise< NativeResponse<void>>;
|
|
40
35
|
openInExternalBrowser(params: OpenInExternalBrowserParams): Promise< NativeResponse<void>>;
|
|
41
36
|
};
|
|
42
37
|
export default mys;
|
|
43
38
|
export * from './api/basic';
|
|
44
39
|
export * from './api/biz';
|
|
45
|
-
export { setDebug, registerNativeHandler,
|
|
40
|
+
export { setDebug, registerNativeHandler, bridge };
|
|
46
41
|
export { JSBridgeSdk };
|
|
47
42
|
export { ToastDuration } from './types';
|
|
48
43
|
export * from './constants/code';
|
package/dist/index.mjs
CHANGED
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import A from "@docoi/jsbridge-sdk";
|
|
2
|
+
import { default as Ee } from "@docoi/jsbridge-sdk";
|
|
3
|
+
const S = 0, v = -1, ae = 1001, I = 1002, Ce = 2002, Pe = 3002, be = 4002, qe = 9002;
|
|
4
|
+
function N(e) {
|
|
5
5
|
return {
|
|
6
|
-
code:
|
|
6
|
+
code: S,
|
|
7
7
|
msg: "ok",
|
|
8
8
|
result: e
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function w(e) {
|
|
12
|
+
if (typeof e == "string") return e;
|
|
13
|
+
if (e instanceof Error) return e.message || "system error";
|
|
14
|
+
if (h(e)) {
|
|
15
|
+
if (typeof e.errMsg == "string") return e.errMsg;
|
|
16
|
+
if (typeof e.msg == "string") return e.msg;
|
|
17
|
+
if (typeof e.message == "string") return e.message;
|
|
18
|
+
}
|
|
19
|
+
return "system error";
|
|
20
|
+
}
|
|
21
|
+
function O(e, t) {
|
|
13
22
|
return {
|
|
14
|
-
code:
|
|
15
|
-
msg: `${e}:fail ${
|
|
16
|
-
result:
|
|
23
|
+
code: v,
|
|
24
|
+
msg: `${e}:fail ${w(t)}`,
|
|
25
|
+
result: h(t) && "result" in t ? t.result : t
|
|
17
26
|
};
|
|
18
27
|
}
|
|
19
|
-
const
|
|
28
|
+
const u = A.init({
|
|
20
29
|
debug: !1,
|
|
21
|
-
timeout:
|
|
22
|
-
}),
|
|
23
|
-
function
|
|
24
|
-
return
|
|
30
|
+
timeout: 9e4
|
|
31
|
+
}), Se = (e) => u.setDebug(e);
|
|
32
|
+
function H(e, t) {
|
|
33
|
+
return u.register(e, async (r) => {
|
|
25
34
|
try {
|
|
26
35
|
const o = await t(r);
|
|
27
|
-
return
|
|
36
|
+
return N(o);
|
|
28
37
|
} catch (o) {
|
|
29
|
-
return
|
|
38
|
+
return O(e, o);
|
|
30
39
|
}
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
42
|
function i(e, t, r) {
|
|
43
|
+
var f, s;
|
|
34
44
|
const o = {
|
|
35
45
|
errMsg: `${e}:fail parameter error: ${t}`,
|
|
36
|
-
errCode:
|
|
46
|
+
errCode: I
|
|
37
47
|
};
|
|
38
|
-
return
|
|
48
|
+
return (f = r == null ? void 0 : r.fail) == null || f.call(r, o), (s = r == null ? void 0 : r.complete) == null || s.call(r, o), Promise.reject(o);
|
|
39
49
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return r;
|
|
50
|
+
function _(e) {
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(e).filter(([, r]) => typeof r != "function")
|
|
53
|
+
);
|
|
45
54
|
}
|
|
46
|
-
function
|
|
55
|
+
function h(e) {
|
|
47
56
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
48
57
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
58
|
+
function M(e) {
|
|
59
|
+
return h(e) && typeof e.code == "number";
|
|
51
60
|
}
|
|
52
61
|
function D(e) {
|
|
53
62
|
if (typeof e != "string") return e;
|
|
@@ -57,52 +66,37 @@ function D(e) {
|
|
|
57
66
|
return e;
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
|
-
function
|
|
61
|
-
t ==
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
errMsg: `${e}:fail ${t.msg || "fail"}`,
|
|
69
|
-
errCode: t.code,
|
|
70
|
-
errDetail: t.result,
|
|
71
|
-
raw: t
|
|
72
|
-
};
|
|
73
|
-
if (t instanceof Error)
|
|
74
|
-
return {
|
|
75
|
-
errMsg: `${e}:fail ${t.message || "fail"}`,
|
|
76
|
-
errCode: b
|
|
77
|
-
};
|
|
78
|
-
const r = c(t) && t.msg !== void 0 ? String(t.msg) : "fail";
|
|
79
|
-
return {
|
|
80
|
-
errMsg: `${e}:fail ${r}`,
|
|
81
|
-
errCode: b,
|
|
82
|
-
errDetail: t
|
|
69
|
+
function q(e, t) {
|
|
70
|
+
return h(t) && typeof t.errMsg == "string" && typeof t.errCode == "number" ? t : M(t) ? {
|
|
71
|
+
errMsg: `${e}:fail ${t.msg || "fail"}`,
|
|
72
|
+
errCode: t.code,
|
|
73
|
+
raw: t
|
|
74
|
+
} : {
|
|
75
|
+
errMsg: `${e}:fail ${w(t)}`,
|
|
76
|
+
errCode: v
|
|
83
77
|
};
|
|
84
78
|
}
|
|
85
79
|
function n(e, t = {}, r, o) {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
return
|
|
80
|
+
const f = String(e), { success: s, fail: y, complete: l } = r || {}, R = (a) => {
|
|
81
|
+
const d = D(a);
|
|
82
|
+
if (M(d) && d.code === S) {
|
|
83
|
+
const C = d;
|
|
84
|
+
return s == null || s(C), l == null || l(C), C;
|
|
91
85
|
}
|
|
92
|
-
throw
|
|
93
|
-
},
|
|
94
|
-
const
|
|
95
|
-
throw
|
|
86
|
+
throw q(f, d);
|
|
87
|
+
}, T = (a) => {
|
|
88
|
+
const d = q(f, a);
|
|
89
|
+
throw y == null || y(d), l == null || l(d), d;
|
|
96
90
|
};
|
|
97
|
-
return
|
|
91
|
+
return u.callAsync(f, _(t), o).then(R).catch(T);
|
|
98
92
|
}
|
|
99
|
-
var
|
|
100
|
-
function
|
|
93
|
+
var E = /* @__PURE__ */ ((e) => (e[e.Short = 0] = "Short", e[e.Long = 1] = "Long", e))(E || {});
|
|
94
|
+
function m(e) {
|
|
101
95
|
return e.text ? n(
|
|
102
96
|
"showToast",
|
|
103
97
|
{
|
|
104
98
|
text: e.text,
|
|
105
|
-
duration: e.duration ??
|
|
99
|
+
duration: e.duration ?? E.Short
|
|
106
100
|
},
|
|
107
101
|
e
|
|
108
102
|
) : i("showToast", "text is required", e);
|
|
@@ -115,30 +109,63 @@ function x(e = {}) {
|
|
|
115
109
|
repeat: e.repeat ?? !1
|
|
116
110
|
}, e, { queue: "serial" });
|
|
117
111
|
}
|
|
118
|
-
function
|
|
112
|
+
function V(e) {
|
|
119
113
|
return n("stopVibrate", {}, e, { queue: "serial" });
|
|
120
114
|
}
|
|
121
|
-
function
|
|
115
|
+
function j(e) {
|
|
122
116
|
return n("hideKeyboard", {}, e);
|
|
123
117
|
}
|
|
124
|
-
function
|
|
118
|
+
function F() {
|
|
125
119
|
return typeof window > "u" ? 1 : window.devicePixelRatio || 1;
|
|
126
120
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
const c = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
122
|
+
function B(e, t) {
|
|
123
|
+
const r = c.get(e);
|
|
124
|
+
r && u.off("keyboardHeightChange", r);
|
|
125
|
+
const o = (f) => {
|
|
126
|
+
const s = f ? f / F() : 0;
|
|
127
|
+
e(s), t != null && t.once && c.delete(e);
|
|
128
|
+
};
|
|
129
|
+
if (c.set(e, o), t != null && t.once) {
|
|
130
|
+
u.once("keyboardHeightChange", o);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
u.on("keyboardHeightChange", o);
|
|
134
|
+
}
|
|
135
|
+
function $(e) {
|
|
136
|
+
if (!e) {
|
|
137
|
+
c.clear(), u.off("keyboardHeightChange");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const t = c.get(e);
|
|
141
|
+
c.delete(e), u.off("keyboardHeightChange", t || e);
|
|
142
|
+
}
|
|
143
|
+
function k(e, t) {
|
|
144
|
+
const r = g.get(e);
|
|
145
|
+
r && u.off("onCommentPanelChange", r);
|
|
146
|
+
const o = (f) => {
|
|
147
|
+
e(f), t != null && t.once && g.delete(e);
|
|
148
|
+
};
|
|
149
|
+
if (g.set(e, o), t != null && t.once) {
|
|
150
|
+
u.once("onCommentPanelChange", o);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
u.on("onCommentPanelChange", o);
|
|
132
154
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
155
|
+
function G(e) {
|
|
156
|
+
if (!e) {
|
|
157
|
+
g.clear(), u.off("onCommentPanelChange");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const t = g.get(e);
|
|
161
|
+
g.delete(e), u.off("onCommentPanelChange", t || e);
|
|
135
162
|
}
|
|
136
|
-
function
|
|
163
|
+
function W(e) {
|
|
137
164
|
var r;
|
|
138
165
|
if (!((r = e.urls) != null && r.length))
|
|
139
|
-
return i("
|
|
166
|
+
return i("playMedia", "urls is required", e);
|
|
140
167
|
const t = e.current ?? 0;
|
|
141
|
-
return !Number.isInteger(t) || t < 0 || t >= e.urls.length ? i("
|
|
168
|
+
return !Number.isInteger(t) || t < 0 || t >= e.urls.length ? i("playMedia", "current is out of range", e) : n(
|
|
142
169
|
"playMedia",
|
|
143
170
|
{
|
|
144
171
|
type: "image",
|
|
@@ -148,7 +175,7 @@ function B(e) {
|
|
|
148
175
|
e
|
|
149
176
|
);
|
|
150
177
|
}
|
|
151
|
-
function
|
|
178
|
+
function K(e) {
|
|
152
179
|
var r;
|
|
153
180
|
if (!((r = e.urls) != null && r.length))
|
|
154
181
|
return i("previewVideo", "urls is required", e);
|
|
@@ -163,13 +190,12 @@ function W(e) {
|
|
|
163
190
|
e
|
|
164
191
|
);
|
|
165
192
|
}
|
|
166
|
-
function
|
|
167
|
-
return e.count !== void 0 && (!Number.isInteger(e.count) || e.count <= 0) ? i("chooseMedia", "
|
|
193
|
+
function z(e = {}) {
|
|
194
|
+
return e.count !== void 0 && (!Number.isInteger(e.count) || e.count <= 0) ? i("chooseMedia", "可选择照片数量范围为1-9张", e) : n(
|
|
168
195
|
"chooseMedia",
|
|
169
196
|
{
|
|
170
197
|
count: e.count ?? 9,
|
|
171
198
|
mediaType: e.mediaType ?? "image",
|
|
172
|
-
sourceType: e.sourceType ?? "all",
|
|
173
199
|
compressed: e.compressed ?? !0,
|
|
174
200
|
maxDuration: e.maxDuration ?? 60,
|
|
175
201
|
camera: e.camera ?? "back"
|
|
@@ -178,41 +204,50 @@ function H(e = {}) {
|
|
|
178
204
|
{ queue: "serial", timeout: 6e4 }
|
|
179
205
|
);
|
|
180
206
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
const b = /* @__PURE__ */ new Set();
|
|
208
|
+
let P = !1;
|
|
209
|
+
u.on("uploadFilesProgress", (e) => {
|
|
210
|
+
for (const t of b)
|
|
211
|
+
t(e);
|
|
212
|
+
});
|
|
213
|
+
function J(e) {
|
|
214
|
+
return !Array.isArray(e.files) || e.files.length === 0 ? i("uploadFiles", "files is required", e) : e.files.some((t) => !t) ? i("uploadFiles", "files[] is required", e) : P ? i("uploadFiles", "another uploadFiles request is in progress", e) : (P = !0, e.onProgress && b.add(e.onProgress), n(
|
|
215
|
+
"uploadFiles",
|
|
184
216
|
{
|
|
185
|
-
|
|
217
|
+
files: e.files,
|
|
218
|
+
cosDirPath: e.cosDirPath ?? "multipleSource/common/"
|
|
186
219
|
},
|
|
187
220
|
e,
|
|
188
221
|
{ queue: "serial", timeout: 12e4 }
|
|
189
|
-
)
|
|
222
|
+
).finally(() => {
|
|
223
|
+
P = !1, e.onProgress && b.delete(e.onProgress);
|
|
224
|
+
}));
|
|
190
225
|
}
|
|
191
|
-
function
|
|
226
|
+
function L(e) {
|
|
192
227
|
return e.filePath ? n("saveMediaToPhotosAlbum", { type: "image", file: e.filePath }, e, { queue: "serial" }) : i("saveImageToPhotosAlbum", "filePath is required", e);
|
|
193
228
|
}
|
|
194
|
-
function
|
|
229
|
+
function U(e) {
|
|
195
230
|
return e.filePath ? n("saveMediaToPhotosAlbum", { type: "video", file: e.filePath }, e, { queue: "serial" }) : i("saveVideoToPhotosAlbum", "filePath is required", e);
|
|
196
231
|
}
|
|
197
|
-
function
|
|
232
|
+
function X(e) {
|
|
198
233
|
return n("startRecord", e || {}, e, { queue: "serial" });
|
|
199
234
|
}
|
|
200
|
-
function
|
|
235
|
+
function Y(e) {
|
|
201
236
|
return n("stopRecord", {}, e, { queue: "serial" });
|
|
202
237
|
}
|
|
203
|
-
function
|
|
238
|
+
function Q(e) {
|
|
204
239
|
return n("getSystemInfo", {}, e);
|
|
205
240
|
}
|
|
206
|
-
function
|
|
241
|
+
function Z(e) {
|
|
207
242
|
return n("getNetworkType", {}, e);
|
|
208
243
|
}
|
|
209
|
-
function
|
|
244
|
+
function p(e) {
|
|
210
245
|
return e.data === void 0 ? i("setClipboardData", "data is required", e) : n("setClipboardData", { data: e.data }, e);
|
|
211
246
|
}
|
|
212
|
-
function
|
|
247
|
+
function ee(e) {
|
|
213
248
|
return n("getClipboardData", {}, e);
|
|
214
249
|
}
|
|
215
|
-
function
|
|
250
|
+
function te(e) {
|
|
216
251
|
return e.permission ? n(
|
|
217
252
|
"checkPermission",
|
|
218
253
|
{
|
|
@@ -221,7 +256,7 @@ function Q(e) {
|
|
|
221
256
|
e
|
|
222
257
|
) : i("checkPermission", "permission is required", e);
|
|
223
258
|
}
|
|
224
|
-
function
|
|
259
|
+
function re(e) {
|
|
225
260
|
return e.type ? n(
|
|
226
261
|
"openPhoneSetting",
|
|
227
262
|
{
|
|
@@ -231,71 +266,49 @@ function Z(e) {
|
|
|
231
266
|
{ queue: "serial" }
|
|
232
267
|
) : i("openPhoneSetting", "type is required", e);
|
|
233
268
|
}
|
|
234
|
-
function
|
|
235
|
-
return e.url ? n("redirectPage", { page: 11, params: { url: e.url } }, e, { queue: "serial" }) : i("navigateToApp", "url is required", e);
|
|
236
|
-
}
|
|
237
|
-
function m(e) {
|
|
238
|
-
return e.url ? n("redirectPage", { page: 1, params: { url: e.url } }, e, { queue: "serial" }) : i("switchTab", "url is required", e);
|
|
239
|
-
}
|
|
240
|
-
function ee(e) {
|
|
241
|
-
var t, r;
|
|
242
|
-
if (!e.url)
|
|
243
|
-
return i("openWebview", "url is required", e);
|
|
244
|
-
if (e.replace) {
|
|
245
|
-
window.location.replace(e.url);
|
|
246
|
-
const o = {
|
|
247
|
-
code: 0,
|
|
248
|
-
msg: "success",
|
|
249
|
-
result: void 0
|
|
250
|
-
};
|
|
251
|
-
return (t = e.success) == null || t.call(e, o), (r = e.complete) == null || r.call(e, o), Promise.resolve(o);
|
|
252
|
-
}
|
|
253
|
-
return n("openWebview", { link: e.url, type: e.type || "normal" }, e, { queue: "serial" });
|
|
254
|
-
}
|
|
255
|
-
function te(e) {
|
|
269
|
+
function ne(e) {
|
|
256
270
|
return n("closeWebView", {}, e, { queue: "serial" });
|
|
257
271
|
}
|
|
258
|
-
function
|
|
272
|
+
function ie(e) {
|
|
259
273
|
return e.url ? n("openInExternalBrowser", { url: e.url }, e, { queue: "serial" }) : i("openInExternalBrowser", "url is required", e);
|
|
260
274
|
}
|
|
261
|
-
const
|
|
275
|
+
const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
262
276
|
__proto__: null,
|
|
263
|
-
checkPermission:
|
|
264
|
-
chooseMedia:
|
|
265
|
-
closeWebView:
|
|
266
|
-
getClipboardData:
|
|
267
|
-
getNetworkType:
|
|
268
|
-
getSystemInfo:
|
|
269
|
-
hideKeyboard:
|
|
270
|
-
|
|
277
|
+
checkPermission: te,
|
|
278
|
+
chooseMedia: z,
|
|
279
|
+
closeWebView: ne,
|
|
280
|
+
getClipboardData: ee,
|
|
281
|
+
getNetworkType: Z,
|
|
282
|
+
getSystemInfo: Q,
|
|
283
|
+
hideKeyboard: j,
|
|
284
|
+
offCommentPanelChange: G,
|
|
271
285
|
offKeyboardHeightChange: $,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
previewImage:
|
|
277
|
-
previewVideo:
|
|
278
|
-
saveImageToPhotosAlbum:
|
|
279
|
-
saveVideoToPhotosAlbum:
|
|
280
|
-
setClipboardData:
|
|
281
|
-
showToast:
|
|
282
|
-
startRecord:
|
|
283
|
-
stopRecord:
|
|
284
|
-
stopVibrate:
|
|
285
|
-
switchTab: m,
|
|
286
|
+
onCommentPanelChange: k,
|
|
287
|
+
onKeyboardHeightChange: B,
|
|
288
|
+
openInExternalBrowser: ie,
|
|
289
|
+
openPhoneSetting: re,
|
|
290
|
+
previewImage: W,
|
|
291
|
+
previewVideo: K,
|
|
292
|
+
saveImageToPhotosAlbum: L,
|
|
293
|
+
saveVideoToPhotosAlbum: U,
|
|
294
|
+
setClipboardData: p,
|
|
295
|
+
showToast: m,
|
|
296
|
+
startRecord: X,
|
|
297
|
+
stopRecord: Y,
|
|
298
|
+
stopVibrate: V,
|
|
286
299
|
triggerVibrate: x,
|
|
287
|
-
|
|
300
|
+
uploadFiles: J
|
|
288
301
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
289
|
-
function
|
|
302
|
+
function ue(e) {
|
|
290
303
|
return n("login", {}, e, { queue: "serial" });
|
|
291
304
|
}
|
|
292
|
-
function
|
|
305
|
+
function fe(e) {
|
|
293
306
|
return n("getToken", {}, e);
|
|
294
307
|
}
|
|
295
|
-
function
|
|
308
|
+
function se(e) {
|
|
296
309
|
return n("getCurrentCircleInfo", {}, e);
|
|
297
310
|
}
|
|
298
|
-
function
|
|
311
|
+
function de(e) {
|
|
299
312
|
return e.title ? n(
|
|
300
313
|
"shareWebCard",
|
|
301
314
|
{
|
|
@@ -306,77 +319,73 @@ function ce(e) {
|
|
|
306
319
|
{ queue: "serial" }
|
|
307
320
|
) : i("shareWebCard", "title is required", e);
|
|
308
321
|
}
|
|
309
|
-
function
|
|
322
|
+
function le(e) {
|
|
310
323
|
return n("openAddCustomEmoji", {}, e, { queue: "serial" });
|
|
311
324
|
}
|
|
312
|
-
function
|
|
325
|
+
function ce(e) {
|
|
313
326
|
return e.gameName ? e.serverId ? n("pointsMallBindGame", e, e, { queue: "serial" }) : i("toBindGameRole", "serverId is required", e) : i("toBindGameRole", "gameName is required", e);
|
|
314
327
|
}
|
|
315
|
-
function
|
|
328
|
+
function ge(e) {
|
|
316
329
|
return e.type === void 0 ? i("showAd", "type is required", e) : n("showAdVideo", e, e, { queue: "serial" });
|
|
317
330
|
}
|
|
318
|
-
const
|
|
331
|
+
const he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
319
332
|
__proto__: null,
|
|
320
|
-
getCurrentCircleInfo:
|
|
321
|
-
getToken:
|
|
322
|
-
login:
|
|
323
|
-
openAddCustomEmoji:
|
|
324
|
-
shareWebCard:
|
|
325
|
-
showAd:
|
|
326
|
-
toBindGameRole:
|
|
327
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
328
|
-
...
|
|
329
|
-
...
|
|
330
|
-
|
|
331
|
-
registerNativeHandler: M,
|
|
332
|
-
bridge: s,
|
|
333
|
-
JSBridgeSdk: v
|
|
333
|
+
getCurrentCircleInfo: se,
|
|
334
|
+
getToken: fe,
|
|
335
|
+
login: ue,
|
|
336
|
+
openAddCustomEmoji: le,
|
|
337
|
+
shareWebCard: de,
|
|
338
|
+
showAd: ge,
|
|
339
|
+
toBindGameRole: ce
|
|
340
|
+
}, Symbol.toStringTag, { value: "Module" })), ve = {
|
|
341
|
+
...oe,
|
|
342
|
+
...he,
|
|
343
|
+
registerNativeHandler: H
|
|
334
344
|
};
|
|
335
345
|
export {
|
|
336
346
|
qe as CUSTOM,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
347
|
+
Ee as JSBridgeSdk,
|
|
348
|
+
ae as METHOD_NOT_FOUND,
|
|
349
|
+
be as NETWORK_ERROR,
|
|
350
|
+
Ce as NOT_LOGGED_IN,
|
|
351
|
+
I as PARAMS_ERROR,
|
|
352
|
+
Pe as PERMISSION_DENIED,
|
|
353
|
+
S as SUCCESS,
|
|
354
|
+
v as SYSTEM_EXCEPTION,
|
|
355
|
+
E as ToastDuration,
|
|
356
|
+
u as bridge,
|
|
357
|
+
te as checkPermission,
|
|
358
|
+
z as chooseMedia,
|
|
359
|
+
ne as closeWebView,
|
|
360
|
+
ve as default,
|
|
361
|
+
ee as getClipboardData,
|
|
362
|
+
se as getCurrentCircleInfo,
|
|
363
|
+
Z as getNetworkType,
|
|
364
|
+
Q as getSystemInfo,
|
|
365
|
+
fe as getToken,
|
|
366
|
+
j as hideKeyboard,
|
|
367
|
+
ue as login,
|
|
368
|
+
G as offCommentPanelChange,
|
|
359
369
|
$ as offKeyboardHeightChange,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
le as toBindGameRole,
|
|
370
|
+
k as onCommentPanelChange,
|
|
371
|
+
B as onKeyboardHeightChange,
|
|
372
|
+
le as openAddCustomEmoji,
|
|
373
|
+
ie as openInExternalBrowser,
|
|
374
|
+
re as openPhoneSetting,
|
|
375
|
+
W as previewImage,
|
|
376
|
+
K as previewVideo,
|
|
377
|
+
H as registerNativeHandler,
|
|
378
|
+
L as saveImageToPhotosAlbum,
|
|
379
|
+
U as saveVideoToPhotosAlbum,
|
|
380
|
+
p as setClipboardData,
|
|
381
|
+
Se as setDebug,
|
|
382
|
+
de as shareWebCard,
|
|
383
|
+
ge as showAd,
|
|
384
|
+
m as showToast,
|
|
385
|
+
X as startRecord,
|
|
386
|
+
Y as stopRecord,
|
|
387
|
+
V as stopVibrate,
|
|
388
|
+
ce as toBindGameRole,
|
|
380
389
|
x as triggerVibrate,
|
|
381
|
-
|
|
390
|
+
J as uploadFiles
|
|
382
391
|
};
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -17,8 +17,6 @@ export declare enum ToastDuration {
|
|
|
17
17
|
export type PreviewMediaType = "image" | "video";
|
|
18
18
|
/** 媒体文件类型 */
|
|
19
19
|
export type MediaFileType = "image" | "video";
|
|
20
|
-
/** 媒体来源 */
|
|
21
|
-
export type MediaSourceType = "album" | "camera" | "all";
|
|
22
20
|
/** 系统设置页类型。当前仅支持通知设置页 */
|
|
23
21
|
export type SettingType = "notice";
|
|
24
22
|
/** 权限类型 */
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Callbacks } from './base';
|
|
2
|
-
import { MediaFileType, SettingType,
|
|
3
|
-
import { ChooseMediaResult, CheckPermissionResult,
|
|
2
|
+
import { MediaFileType, SettingType, CameraDirection, ShareChannelType, PermissionType, PreviewMediaType, ToastDuration } from './enums';
|
|
3
|
+
import { ChooseMediaResult, CheckPermissionResult, UploadFilesProgress, UploadFilesResult } from './results';
|
|
4
|
+
/**
|
|
5
|
+
* 事件监听选项。
|
|
6
|
+
*
|
|
7
|
+
* 事件监听属于 native-event 通道,回调直接接收 Native 原始 payload,
|
|
8
|
+
* 不包装 code/msg/result。
|
|
9
|
+
*/
|
|
10
|
+
export interface EventListenOptions {
|
|
11
|
+
/** 是否只监听一次,触发后自动取消监听 */
|
|
12
|
+
once?: boolean;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* showToast 参数
|
|
6
16
|
*
|
|
@@ -65,16 +75,6 @@ export interface ChooseMediaParams extends Callbacks<ChooseMediaResult> {
|
|
|
65
75
|
* @default 'image'
|
|
66
76
|
*/
|
|
67
77
|
mediaType?: MediaFileType;
|
|
68
|
-
/**
|
|
69
|
-
* 媒体来源。
|
|
70
|
-
*
|
|
71
|
-
* - album: 只打开相册
|
|
72
|
-
* - camera: 只打开相机
|
|
73
|
-
* - all: 由 Native 提供拍摄/相册选择入口
|
|
74
|
-
*
|
|
75
|
-
* @default 'all'
|
|
76
|
-
*/
|
|
77
|
-
sourceType?: MediaSourceType;
|
|
78
78
|
/**
|
|
79
79
|
* 是否压缩后生成临时文件。
|
|
80
80
|
*
|
|
@@ -94,10 +94,14 @@ export interface ChooseMediaParams extends Callbacks<ChooseMediaResult> {
|
|
|
94
94
|
*/
|
|
95
95
|
camera?: CameraDirection;
|
|
96
96
|
}
|
|
97
|
-
/**
|
|
98
|
-
export interface
|
|
99
|
-
/**
|
|
100
|
-
|
|
97
|
+
/** uploadFiles 参数 */
|
|
98
|
+
export interface UploadFilesParams extends Callbacks<UploadFilesResult> {
|
|
99
|
+
/** 待上传文件列表,单个文件也需要放在数组中 */
|
|
100
|
+
files: string[];
|
|
101
|
+
/** 腾讯云 COS 目录前缀,默认 multipleSource/common/ */
|
|
102
|
+
cosDirPath?: string;
|
|
103
|
+
/** 上传进度回调,仅 H5 侧生效 */
|
|
104
|
+
onProgress?: (progress: UploadFilesProgress) => void;
|
|
101
105
|
}
|
|
102
106
|
/** 保存媒体文件到系统相册的通用参数 */
|
|
103
107
|
export interface SaveImageToPhotosAlbumParams extends Callbacks {
|
|
@@ -116,35 +120,10 @@ export interface SetClipboardDataParams extends Callbacks {
|
|
|
116
120
|
/** 剪贴板内容 */
|
|
117
121
|
data: string;
|
|
118
122
|
}
|
|
119
|
-
/** 导航跳转通用参数(url 必填) */
|
|
120
|
-
export interface NavigateToAppParams extends Callbacks {
|
|
121
|
-
/** 目标 URL */
|
|
122
|
-
url: string;
|
|
123
|
-
}
|
|
124
123
|
/** 外部浏览器打开参数 */
|
|
125
|
-
export
|
|
126
|
-
/**
|
|
127
|
-
export type SwitchTabParams = NavigateToAppParams;
|
|
128
|
-
/**
|
|
129
|
-
* openWebview 参数
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```ts
|
|
133
|
-
* mys.openWebview({ url: 'https://example.com', type: 'immersive' })
|
|
134
|
-
* mys.openWebview({ url: 'https://example.com', replace: true }) // 直接替换当前页面
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
export interface OpenWebviewParams extends Callbacks {
|
|
138
|
-
/** 页面链接 */
|
|
124
|
+
export interface OpenInExternalBrowserParams extends Callbacks {
|
|
125
|
+
/** 目标 URL */
|
|
139
126
|
url: string;
|
|
140
|
-
/**
|
|
141
|
-
* Webview 类型
|
|
142
|
-
*
|
|
143
|
-
* @default 'normal'
|
|
144
|
-
*/
|
|
145
|
-
type?: WebviewType;
|
|
146
|
-
/** 是否直接替换当前页面(不走 bridge) */
|
|
147
|
-
replace?: boolean;
|
|
148
127
|
}
|
|
149
128
|
/** triggerVibrate 多段震动序列项 */
|
|
150
129
|
export interface VibrateStep {
|
package/dist/types/results.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { Platform, NetworkTypeStr, PermissionStatus, PermissionType } from './en
|
|
|
2
2
|
/** chooseMedia 返回值 */
|
|
3
3
|
export interface ChooseMediaResult {
|
|
4
4
|
/** 本地临时媒体文件列表 */
|
|
5
|
-
|
|
5
|
+
tempFiles: ChooseMediaFile[];
|
|
6
6
|
}
|
|
7
7
|
/** chooseMedia 临时媒体文件 */
|
|
8
8
|
export interface ChooseMediaFile {
|
|
9
|
-
/** 临时文件路径,可用于 img / video 预览,也可传给
|
|
9
|
+
/** 临时文件路径,可用于 img / video 预览,也可传给 uploadFiles 上传 */
|
|
10
10
|
tempFilePath: string;
|
|
11
|
-
/** 文件大小,单位
|
|
11
|
+
/** 文件大小,单位 KB */
|
|
12
12
|
size?: number;
|
|
13
13
|
/** 宽度,单位 px */
|
|
14
14
|
width?: number;
|
|
@@ -16,16 +16,39 @@ export interface ChooseMediaFile {
|
|
|
16
16
|
height?: number;
|
|
17
17
|
/** 视频时长,单位秒,仅视频文件返回 */
|
|
18
18
|
duration?: number;
|
|
19
|
-
/** 缩略图临时路径 */
|
|
19
|
+
/** 缩略图临时路径 仅视频 */
|
|
20
20
|
thumbTempFilePath?: string;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
export interface
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
22
|
+
/** uploadFiles 单个文件上传结果 */
|
|
23
|
+
export interface UploadFilesResultItem {
|
|
24
|
+
/** 原始本地文件路径 */
|
|
25
|
+
filePath: string;
|
|
26
|
+
/** 当前文件是否上传成功 */
|
|
27
|
+
success: boolean;
|
|
28
|
+
/** 上传后的网络 URL,成功时返回 */
|
|
29
|
+
url?: string;
|
|
30
|
+
/** 上传后的缩略图网络 URL,图片/视频可选 */
|
|
27
31
|
thumbUrl?: string;
|
|
28
32
|
}
|
|
33
|
+
/** uploadFiles 返回值 */
|
|
34
|
+
export interface UploadFilesResult {
|
|
35
|
+
/** 上传结果文件列表 */
|
|
36
|
+
files: UploadFilesResultItem[];
|
|
37
|
+
}
|
|
38
|
+
/** uploadFiles 进度 */
|
|
39
|
+
export interface UploadFilesProgress {
|
|
40
|
+
/** 每个文件的上传进度 */
|
|
41
|
+
files: UploadFilesProgressFile[];
|
|
42
|
+
}
|
|
43
|
+
/** uploadFiles 单个文件进度 */
|
|
44
|
+
export interface UploadFilesProgressFile {
|
|
45
|
+
/** 当前文件下标,从 0 开始 */
|
|
46
|
+
index: number;
|
|
47
|
+
/** 当前临时文件路径 */
|
|
48
|
+
filePath: string;
|
|
49
|
+
/** 当前文件进度,范围 0-100 */
|
|
50
|
+
progress: number;
|
|
51
|
+
}
|
|
29
52
|
/** getClipboardData 返回值 */
|
|
30
53
|
export interface GetClipboardDataResult {
|
|
31
54
|
/** 剪贴板内容 */
|
|
@@ -68,6 +91,25 @@ export interface CheckPermissionResult {
|
|
|
68
91
|
/** 权限检查结果 */
|
|
69
92
|
result: PermissionStatus;
|
|
70
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* 键盘高度变化回调。
|
|
96
|
+
*
|
|
97
|
+
* 事件监听直接返回 CSS 逻辑像素高度,不包装 code/msg/result。
|
|
98
|
+
*/
|
|
99
|
+
export type KeyboardHeightChangeCallback = (height: number) => void;
|
|
100
|
+
/**
|
|
101
|
+
* 评论区面板状态变化事件 payload。
|
|
102
|
+
*
|
|
103
|
+
* 事件监听直接返回该业务对象,不包装 code/msg/result。
|
|
104
|
+
*/
|
|
105
|
+
export interface CommentPanelChangeResult {
|
|
106
|
+
/** 评论区面板是否可见 */
|
|
107
|
+
visible: boolean;
|
|
108
|
+
/** 评论区面板状态变化原因 */
|
|
109
|
+
reason: string;
|
|
110
|
+
}
|
|
111
|
+
/** 评论区面板状态变化回调 */
|
|
112
|
+
export type CommentPanelChangeCallback = (res: CommentPanelChangeResult) => void;
|
|
71
113
|
/** 用户基本信息 */
|
|
72
114
|
export interface UserInfo {
|
|
73
115
|
/** 用户昵称 */
|
package/package.json
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@docoi/mys-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "基于 JSBridge 封装的H5 SDK,统一 Native 通信与业务 API 封装",
|
|
5
|
-
"author": "tanyangkang",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"homepage": "https://gitlab.docoi.cc/tanyangkang/mys-sdk",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://gitlab.docoi.cc/tanyangkang/mys-sdk.git"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://gitlab.docoi.cc/tanyangkang/mys-sdk/issues"
|
|
15
|
-
},
|
|
16
|
-
"publishConfig": {
|
|
17
|
-
"access": "public"
|
|
18
|
-
},
|
|
19
|
-
"type": "module",
|
|
20
|
-
"module": "./dist/index.mjs",
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"exports": {
|
|
23
|
-
".": {
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/index.mjs"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@docoi/mys-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "基于 JSBridge 封装的H5 SDK,统一 Native 通信与业务 API 封装",
|
|
5
|
+
"author": "tanyangkang",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"homepage": "https://gitlab.docoi.cc/tanyangkang/mys-sdk",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://gitlab.docoi.cc/tanyangkang/mys-sdk.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://gitlab.docoi.cc/tanyangkang/mys-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@docoi/jsbridge-sdk": "2.0.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@changesets/cli": "^2.31.1",
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"vite": "^5.4.21",
|
|
38
|
+
"vite-plugin-dts": "^5.0.3"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "vite build --watch",
|
|
42
|
+
"build": "vite build",
|
|
43
|
+
"type-check": "tsc --noEmit"
|
|
44
|
+
}
|
|
45
|
+
}
|