@docoi/mys-sdk 1.0.0-beta.0 → 1.0.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/dist/api/basic.d.ts +288 -45
- package/dist/api/biz.d.ts +76 -15
- package/dist/api/index.d.ts +2 -2
- package/dist/bridge.d.ts +8 -13
- package/dist/constants/code.d.ts +21 -0
- package/dist/index.d.ts +41 -38
- package/dist/index.mjs +377 -46
- package/dist/types/base.d.ts +54 -0
- package/dist/types/enums.d.ts +44 -0
- package/dist/types/index.d.ts +8 -138
- package/dist/types/params.d.ts +249 -0
- package/dist/types/results.d.ts +102 -0
- package/package.json +46 -79
- package/LICENSE +0 -21
- package/README.md +0 -110
- package/dist/basic-C58euoyc.js +0 -153
- package/dist/basic-C58euoyc.js.map +0 -1
- package/dist/basic-CSwC4kuv.cjs +0 -2
- package/dist/basic-CSwC4kuv.cjs.map +0 -1
- package/dist/basic.d.ts +0 -32
- package/dist/basic.js +0 -2
- package/dist/basic.js.map +0 -1
- package/dist/basic.mjs +0 -37
- package/dist/basic.mjs.map +0 -1
- package/dist/biz-BUeFEJQb.cjs +0 -2
- package/dist/biz-BUeFEJQb.cjs.map +0 -1
- package/dist/biz-BbTdssY5.js +0 -43
- package/dist/biz-BbTdssY5.js.map +0 -1
- package/dist/biz.d.ts +0 -16
- package/dist/biz.js +0 -2
- package/dist/biz.js.map +0 -1
- package/dist/biz.mjs +0 -21
- package/dist/biz.mjs.map +0 -1
- package/dist/bridge-B5p50L4Z.cjs +0 -2
- package/dist/bridge-B5p50L4Z.cjs.map +0 -1
- package/dist/bridge-BsyNF-2c.js +0 -39
- package/dist/bridge-BsyNF-2c.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,382 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import v from "@docoi/jsbridge-sdk";
|
|
2
|
+
import { default as Se } from "@docoi/jsbridge-sdk";
|
|
3
|
+
const q = 0, b = -1, he = 1001, E = 1002, be = 2002, ye = 3002, ve = 4002, qe = 9002;
|
|
4
|
+
function R(e) {
|
|
5
|
+
return {
|
|
6
|
+
code: q,
|
|
7
|
+
msg: "ok",
|
|
8
|
+
result: e
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function I(e, t) {
|
|
12
|
+
const r = c(t) && typeof t.message == "string" || t instanceof Error ? t.message : c(t) && typeof t.msg == "string" ? t.msg : "fail";
|
|
13
|
+
return {
|
|
14
|
+
code: b,
|
|
15
|
+
msg: `${e}:fail ${r}`,
|
|
16
|
+
result: c(t) && "result" in t ? t.result : t
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const s = v.init({
|
|
20
|
+
debug: !1,
|
|
21
|
+
timeout: 6e4
|
|
22
|
+
}), A = (e) => s.setDebug(e);
|
|
23
|
+
function M(e, t) {
|
|
24
|
+
return s.register(e, async (r) => {
|
|
25
|
+
try {
|
|
26
|
+
const o = await t(r);
|
|
27
|
+
return R(o);
|
|
28
|
+
} catch (o) {
|
|
29
|
+
return I(e, o);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function i(e, t, r) {
|
|
34
|
+
const o = {
|
|
35
|
+
errMsg: `${e}:fail parameter error: ${t}`,
|
|
36
|
+
errCode: E
|
|
37
|
+
};
|
|
38
|
+
return P(o, r == null ? void 0 : r.fail, r == null ? void 0 : r.complete), Promise.reject(o);
|
|
39
|
+
}
|
|
40
|
+
function N(e) {
|
|
41
|
+
const t = e, r = {};
|
|
42
|
+
for (const o of Object.keys(t))
|
|
43
|
+
o !== "success" && o !== "fail" && o !== "complete" && (r[o] = t[o]);
|
|
44
|
+
return r;
|
|
45
|
+
}
|
|
46
|
+
function c(e) {
|
|
47
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
48
|
+
}
|
|
49
|
+
function a(e) {
|
|
50
|
+
return c(e) && typeof e.code == "number";
|
|
51
|
+
}
|
|
52
|
+
function D(e) {
|
|
53
|
+
if (typeof e != "string") return e;
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(e);
|
|
56
|
+
} catch {
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function P(e, t, r) {
|
|
61
|
+
t == null || t(e), r == null || r(e);
|
|
62
|
+
}
|
|
63
|
+
function y(e, t) {
|
|
64
|
+
if (c(t) && typeof t.errMsg == "string" && typeof t.errCode == "number")
|
|
65
|
+
return t;
|
|
66
|
+
if (a(t))
|
|
67
|
+
return {
|
|
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
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function n(e, t = {}, r, o) {
|
|
86
|
+
const d = String(e), { success: f, fail: S, complete: l } = r || {}, T = (g) => {
|
|
87
|
+
const u = D(g);
|
|
88
|
+
if (a(u) && u.code === q) {
|
|
89
|
+
const h = u;
|
|
90
|
+
return f == null || f(h), l == null || l(h), h;
|
|
91
|
+
}
|
|
92
|
+
throw y(d, u);
|
|
93
|
+
}, C = (g) => {
|
|
94
|
+
const u = y(d, g);
|
|
95
|
+
throw P(u, S, l), u;
|
|
96
|
+
};
|
|
97
|
+
return s.callAsync(d, N(t), o).then(T).catch(C);
|
|
98
|
+
}
|
|
99
|
+
var w = /* @__PURE__ */ ((e) => (e[e.Short = 0] = "Short", e[e.Long = 1] = "Long", e))(w || {});
|
|
100
|
+
function k(e) {
|
|
101
|
+
return e.text ? n(
|
|
102
|
+
"showToast",
|
|
103
|
+
{
|
|
104
|
+
text: e.text,
|
|
105
|
+
duration: e.duration ?? w.Short
|
|
106
|
+
},
|
|
107
|
+
e
|
|
108
|
+
) : i("showToast", "text is required", e);
|
|
109
|
+
}
|
|
110
|
+
function x(e = {}) {
|
|
111
|
+
return n("triggerVibrate", {
|
|
112
|
+
duration: e.duration,
|
|
113
|
+
intensity: e.intensity ?? 1,
|
|
114
|
+
steps: e.steps,
|
|
115
|
+
repeat: e.repeat ?? !1
|
|
116
|
+
}, e, { queue: "serial" });
|
|
117
|
+
}
|
|
118
|
+
function O(e) {
|
|
119
|
+
return n("stopVibrate", {}, e, { queue: "serial" });
|
|
120
|
+
}
|
|
121
|
+
function _(e) {
|
|
122
|
+
return n("hideKeyboard", {}, e);
|
|
123
|
+
}
|
|
124
|
+
function V() {
|
|
125
|
+
return typeof window > "u" ? 1 : window.devicePixelRatio || 1;
|
|
126
|
+
}
|
|
127
|
+
function j(e) {
|
|
128
|
+
s.on("keyboardHeightChange", (t) => {
|
|
129
|
+
const r = t ? t / V() : 0;
|
|
130
|
+
e(r);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function $() {
|
|
134
|
+
s.off("keyboardHeightChange");
|
|
135
|
+
}
|
|
136
|
+
function B(e) {
|
|
137
|
+
var r;
|
|
138
|
+
if (!((r = e.urls) != null && r.length))
|
|
139
|
+
return i("previewImage", "urls is required", e);
|
|
140
|
+
const t = e.current ?? 0;
|
|
141
|
+
return !Number.isInteger(t) || t < 0 || t >= e.urls.length ? i("previewImage", "current is out of range", e) : n(
|
|
142
|
+
"playMedia",
|
|
143
|
+
{
|
|
144
|
+
type: "image",
|
|
145
|
+
urls: e.urls,
|
|
146
|
+
current: t
|
|
147
|
+
},
|
|
148
|
+
e
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
function W(e) {
|
|
152
|
+
var r;
|
|
153
|
+
if (!((r = e.urls) != null && r.length))
|
|
154
|
+
return i("previewVideo", "urls is required", e);
|
|
155
|
+
const t = e.current ?? 0;
|
|
156
|
+
return !Number.isInteger(t) || t < 0 || t >= e.urls.length ? i("previewVideo", "current is out of range", e) : n(
|
|
157
|
+
"playMedia",
|
|
158
|
+
{
|
|
159
|
+
type: "video",
|
|
160
|
+
urls: e.urls,
|
|
161
|
+
current: t
|
|
162
|
+
},
|
|
163
|
+
e
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
function H(e = {}) {
|
|
167
|
+
return e.count !== void 0 && (!Number.isInteger(e.count) || e.count <= 0) ? i("chooseMedia", "count must be a positive integer", e) : e.maxDuration !== void 0 && (!Number.isFinite(e.maxDuration) || e.maxDuration <= 0) ? i("chooseMedia", "maxDuration must be greater than 0", e) : n(
|
|
168
|
+
"chooseMedia",
|
|
169
|
+
{
|
|
170
|
+
count: e.count ?? 9,
|
|
171
|
+
mediaType: e.mediaType ?? "image",
|
|
172
|
+
sourceType: e.sourceType ?? "all",
|
|
173
|
+
compressed: e.compressed ?? !0,
|
|
174
|
+
maxDuration: e.maxDuration ?? 60,
|
|
175
|
+
camera: e.camera ?? "back"
|
|
176
|
+
},
|
|
177
|
+
e,
|
|
178
|
+
{ queue: "serial", timeout: 6e4 }
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function G(e) {
|
|
182
|
+
return e.filePath ? n(
|
|
183
|
+
"uploadFile",
|
|
184
|
+
{
|
|
185
|
+
filePath: e.filePath
|
|
186
|
+
},
|
|
187
|
+
e,
|
|
188
|
+
{ queue: "serial", timeout: 12e4 }
|
|
189
|
+
) : i("uploadFile", "filePath is required", e);
|
|
190
|
+
}
|
|
191
|
+
function F(e) {
|
|
192
|
+
return e.filePath ? n("saveMediaToPhotosAlbum", { type: "image", file: e.filePath }, e, { queue: "serial" }) : i("saveImageToPhotosAlbum", "filePath is required", e);
|
|
193
|
+
}
|
|
194
|
+
function K(e) {
|
|
195
|
+
return e.filePath ? n("saveMediaToPhotosAlbum", { type: "video", file: e.filePath }, e, { queue: "serial" }) : i("saveVideoToPhotosAlbum", "filePath is required", e);
|
|
196
|
+
}
|
|
197
|
+
function z(e) {
|
|
198
|
+
return n("startRecord", e || {}, e, { queue: "serial" });
|
|
199
|
+
}
|
|
200
|
+
function J(e) {
|
|
201
|
+
return n("stopRecord", {}, e, { queue: "serial" });
|
|
202
|
+
}
|
|
203
|
+
function L(e) {
|
|
204
|
+
return n("getSystemInfo", {}, e);
|
|
205
|
+
}
|
|
206
|
+
function U(e) {
|
|
207
|
+
return n("getNetworkType", {}, e);
|
|
208
|
+
}
|
|
209
|
+
function X(e) {
|
|
210
|
+
return e.data === void 0 ? i("setClipboardData", "data is required", e) : n("setClipboardData", { data: e.data }, e);
|
|
211
|
+
}
|
|
212
|
+
function Y(e) {
|
|
213
|
+
return n("getClipboardData", {}, e);
|
|
214
|
+
}
|
|
215
|
+
function Q(e) {
|
|
216
|
+
return e.permission ? n(
|
|
217
|
+
"checkPermission",
|
|
218
|
+
{
|
|
219
|
+
permission: e.permission
|
|
220
|
+
},
|
|
221
|
+
e
|
|
222
|
+
) : i("checkPermission", "permission is required", e);
|
|
223
|
+
}
|
|
224
|
+
function Z(e) {
|
|
225
|
+
return e.type ? n(
|
|
226
|
+
"openPhoneSetting",
|
|
227
|
+
{
|
|
228
|
+
type: e.type
|
|
229
|
+
},
|
|
230
|
+
e,
|
|
231
|
+
{ queue: "serial" }
|
|
232
|
+
) : i("openPhoneSetting", "type is required", e);
|
|
233
|
+
}
|
|
234
|
+
function p(e) {
|
|
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) {
|
|
256
|
+
return n("closeWebView", {}, e, { queue: "serial" });
|
|
257
|
+
}
|
|
258
|
+
function re(e) {
|
|
259
|
+
return e.url ? n("openInExternalBrowser", { url: e.url }, e, { queue: "serial" }) : i("openInExternalBrowser", "url is required", e);
|
|
260
|
+
}
|
|
261
|
+
const ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
262
|
+
__proto__: null,
|
|
263
|
+
checkPermission: Q,
|
|
264
|
+
chooseMedia: H,
|
|
265
|
+
closeWebView: te,
|
|
266
|
+
getClipboardData: Y,
|
|
267
|
+
getNetworkType: U,
|
|
268
|
+
getSystemInfo: L,
|
|
269
|
+
hideKeyboard: _,
|
|
270
|
+
navigateToApp: p,
|
|
271
|
+
offKeyboardHeightChange: $,
|
|
272
|
+
onKeyboardHeightChange: j,
|
|
273
|
+
openInExternalBrowser: re,
|
|
274
|
+
openPhoneSetting: Z,
|
|
275
|
+
openWebview: ee,
|
|
276
|
+
previewImage: B,
|
|
277
|
+
previewVideo: W,
|
|
278
|
+
saveImageToPhotosAlbum: F,
|
|
279
|
+
saveVideoToPhotosAlbum: K,
|
|
280
|
+
setClipboardData: X,
|
|
281
|
+
showToast: k,
|
|
282
|
+
startRecord: z,
|
|
283
|
+
stopRecord: J,
|
|
284
|
+
stopVibrate: O,
|
|
285
|
+
switchTab: m,
|
|
286
|
+
triggerVibrate: x,
|
|
287
|
+
uploadFile: G
|
|
288
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
289
|
+
function ie(e) {
|
|
290
|
+
return n("login", {}, e, { queue: "serial" });
|
|
291
|
+
}
|
|
292
|
+
function oe(e) {
|
|
293
|
+
return n("getToken", {}, e);
|
|
294
|
+
}
|
|
295
|
+
function ue(e) {
|
|
296
|
+
return n("getCurrentCircleInfo", {}, e);
|
|
297
|
+
}
|
|
298
|
+
function ce(e) {
|
|
299
|
+
return e.title ? n(
|
|
300
|
+
"shareWebCard",
|
|
301
|
+
{
|
|
302
|
+
...e,
|
|
303
|
+
shareTypes: e.shareTypes ?? [1, 2, 3]
|
|
304
|
+
},
|
|
305
|
+
e,
|
|
306
|
+
{ queue: "serial" }
|
|
307
|
+
) : i("shareWebCard", "title is required", e);
|
|
308
|
+
}
|
|
309
|
+
function se(e) {
|
|
310
|
+
return n("openAddCustomEmoji", {}, e, { queue: "serial" });
|
|
311
|
+
}
|
|
312
|
+
function le(e) {
|
|
313
|
+
return e.gameName ? e.serverId ? n("pointsMallBindGame", e, e, { queue: "serial" }) : i("toBindGameRole", "serverId is required", e) : i("toBindGameRole", "gameName is required", e);
|
|
314
|
+
}
|
|
315
|
+
function de(e) {
|
|
316
|
+
return e.type === void 0 ? i("showAd", "type is required", e) : n("showAdVideo", e, e, { queue: "serial" });
|
|
317
|
+
}
|
|
318
|
+
const fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
319
|
+
__proto__: null,
|
|
320
|
+
getCurrentCircleInfo: ue,
|
|
321
|
+
getToken: oe,
|
|
322
|
+
login: ie,
|
|
323
|
+
openAddCustomEmoji: se,
|
|
324
|
+
shareWebCard: ce,
|
|
325
|
+
showAd: de,
|
|
326
|
+
toBindGameRole: le
|
|
327
|
+
}, Symbol.toStringTag, { value: "Module" })), ae = {
|
|
328
|
+
...ne,
|
|
329
|
+
...fe,
|
|
330
|
+
setDebug: A,
|
|
331
|
+
registerNativeHandler: M,
|
|
12
332
|
bridge: s,
|
|
13
|
-
JSBridgeSdk:
|
|
333
|
+
JSBridgeSdk: v
|
|
14
334
|
};
|
|
15
335
|
export {
|
|
16
|
-
|
|
336
|
+
qe as CUSTOM,
|
|
337
|
+
Se as JSBridgeSdk,
|
|
338
|
+
he as METHOD_NOT_FOUND,
|
|
339
|
+
ve as NETWORK_ERROR,
|
|
340
|
+
be as NOT_LOGGED_IN,
|
|
341
|
+
E as PARAMS_ERROR,
|
|
342
|
+
ye as PERMISSION_DENIED,
|
|
343
|
+
q as SUCCESS,
|
|
344
|
+
b as SYSTEM_EXCEPTION,
|
|
345
|
+
w as ToastDuration,
|
|
17
346
|
s as bridge,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
347
|
+
Q as checkPermission,
|
|
348
|
+
H as chooseMedia,
|
|
349
|
+
te as closeWebView,
|
|
350
|
+
ae as default,
|
|
351
|
+
Y as getClipboardData,
|
|
352
|
+
ue as getCurrentCircleInfo,
|
|
353
|
+
U as getNetworkType,
|
|
354
|
+
L as getSystemInfo,
|
|
355
|
+
oe as getToken,
|
|
356
|
+
_ as hideKeyboard,
|
|
357
|
+
ie as login,
|
|
358
|
+
p as navigateToApp,
|
|
359
|
+
$ as offKeyboardHeightChange,
|
|
360
|
+
j as onKeyboardHeightChange,
|
|
361
|
+
se as openAddCustomEmoji,
|
|
362
|
+
re as openInExternalBrowser,
|
|
363
|
+
Z as openPhoneSetting,
|
|
364
|
+
ee as openWebview,
|
|
365
|
+
B as previewImage,
|
|
366
|
+
W as previewVideo,
|
|
367
|
+
M as registerNativeHandler,
|
|
368
|
+
F as saveImageToPhotosAlbum,
|
|
369
|
+
K as saveVideoToPhotosAlbum,
|
|
370
|
+
X as setClipboardData,
|
|
371
|
+
A as setDebug,
|
|
372
|
+
ce as shareWebCard,
|
|
373
|
+
de as showAd,
|
|
374
|
+
k as showToast,
|
|
375
|
+
z as startRecord,
|
|
376
|
+
J as stopRecord,
|
|
377
|
+
O as stopVibrate,
|
|
378
|
+
m as switchTab,
|
|
379
|
+
le as toBindGameRole,
|
|
380
|
+
x as triggerVibrate,
|
|
381
|
+
G as uploadFile
|
|
50
382
|
};
|
|
51
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mys-sdk 基础协议类型
|
|
3
|
+
*
|
|
4
|
+
* 定义 Native 与 SDK 对外暴露的统一数据格式。
|
|
5
|
+
*
|
|
6
|
+
* @module types/base
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Native 返回的统一响应格式。
|
|
10
|
+
*
|
|
11
|
+
* SDK 成功时 Promise resolve、success 回调、complete 回调均返回该完整结构,
|
|
12
|
+
* 不拆包返回 result。
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TResult - result 字段的业务数据类型
|
|
15
|
+
*/
|
|
16
|
+
export interface NativeResponse<TResult = void> {
|
|
17
|
+
/** 状态码,0 表示成功 */
|
|
18
|
+
readonly code: number;
|
|
19
|
+
/** 业务数据 */
|
|
20
|
+
readonly result: TResult;
|
|
21
|
+
/** 提示信息 */
|
|
22
|
+
readonly msg: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* API 调用错误对象。
|
|
26
|
+
*
|
|
27
|
+
* SDK 失败时 Promise reject、fail 回调、complete 回调均返回该结构。
|
|
28
|
+
*/
|
|
29
|
+
export interface ApiError {
|
|
30
|
+
/** 错误描述,格式:`fnName:fail ...` */
|
|
31
|
+
readonly errMsg: string;
|
|
32
|
+
/** 错误码,-1 表示参数校验失败或未知错误 */
|
|
33
|
+
readonly errCode: number;
|
|
34
|
+
/** Native result 或额外错误详情 */
|
|
35
|
+
readonly errDetail?: unknown;
|
|
36
|
+
/** Native 原始响应,便于排查联调问题 */
|
|
37
|
+
readonly raw?: NativeResponse<unknown>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* API 回调接口。
|
|
41
|
+
*
|
|
42
|
+
* 所有 API 参数类型都 extends 此接口,以兼容 success/fail/complete 回调风格。
|
|
43
|
+
* 泛型表示 NativeResponse.result 的业务数据类型,而不是 success 的完整参数类型。
|
|
44
|
+
*
|
|
45
|
+
* @typeParam TResult - NativeResponse.result 字段的业务数据类型
|
|
46
|
+
*/
|
|
47
|
+
export interface Callbacks<TResult = void> {
|
|
48
|
+
/** 成功回调,返回完整 NativeResponse */
|
|
49
|
+
success?: (res: NativeResponse<TResult>) => void;
|
|
50
|
+
/** 失败回调,返回标准 ApiError */
|
|
51
|
+
fail?: (err: ApiError) => void;
|
|
52
|
+
/** 完成回调,成功时返回 NativeResponse,失败时返回 ApiError */
|
|
53
|
+
complete?: (res?: NativeResponse<TResult> | ApiError) => void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mys-sdk 枚举类型别名
|
|
3
|
+
*
|
|
4
|
+
* 为 API 参数提供精确的字符串/数字字面量联合类型,
|
|
5
|
+
* 替代传统的 TypeScript enum,实现更好的 IDE 自动补全和文档站精确解析
|
|
6
|
+
*
|
|
7
|
+
* @module types/enums
|
|
8
|
+
*/
|
|
9
|
+
/** Toast 显示时长 */
|
|
10
|
+
export declare enum ToastDuration {
|
|
11
|
+
/** 短时显示 */
|
|
12
|
+
Short = 0,
|
|
13
|
+
/** 长时显示 */
|
|
14
|
+
Long = 1
|
|
15
|
+
}
|
|
16
|
+
/** 媒体预览类型 */
|
|
17
|
+
export type PreviewMediaType = "image" | "video";
|
|
18
|
+
/** 媒体文件类型 */
|
|
19
|
+
export type MediaFileType = "image" | "video";
|
|
20
|
+
/** 媒体来源 */
|
|
21
|
+
export type MediaSourceType = "album" | "camera" | "all";
|
|
22
|
+
/** 系统设置页类型。当前仅支持通知设置页 */
|
|
23
|
+
export type SettingType = "notice";
|
|
24
|
+
/** 权限类型 */
|
|
25
|
+
export type PermissionType = "camera" | "microphone" | "location" | "storage" | "notification";
|
|
26
|
+
/** 权限状态 */
|
|
27
|
+
export type PermissionStatus = "granted" | "denied" | "permanentlyDenied";
|
|
28
|
+
/** 摄像头方向 */
|
|
29
|
+
export type CameraDirection = "back" | "front";
|
|
30
|
+
/** Webview 容器类型 */
|
|
31
|
+
export type WebviewType = "immersive" | "normal" | "mini";
|
|
32
|
+
/** 平台 */
|
|
33
|
+
export type Platform = "android" | "ios";
|
|
34
|
+
/** 网络类型 */
|
|
35
|
+
export type NetworkTypeStr = "wifi" | "2g" | "3g" | "4g" | "5g" | "unknown" | "none";
|
|
36
|
+
/**
|
|
37
|
+
* 分享渠道
|
|
38
|
+
* - 1: 微信好友
|
|
39
|
+
* - 2: 朋友圈
|
|
40
|
+
* - 3: QQ
|
|
41
|
+
*/
|
|
42
|
+
export type ShareChannelType = 1 | 2 | 3;
|
|
43
|
+
/** 文件类型标签 */
|
|
44
|
+
export type FileTypeTag = "image" | "video";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,141 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* mys-sdk 类型定义
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* barrel re-export,按需从拆分后的子模块导出
|
|
5
|
+
*
|
|
6
|
+
* @module types
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
result: T;
|
|
11
|
-
}
|
|
12
|
-
/** API 错误 */
|
|
13
|
-
export interface ApiError {
|
|
14
|
-
errMsg: string;
|
|
15
|
-
errCode: number;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}
|
|
18
|
-
/** 通用回调接口 */
|
|
19
|
-
export interface Callbacks<T = any> {
|
|
20
|
-
success?: (res: T) => void;
|
|
21
|
-
fail?: (err: ApiError) => void;
|
|
22
|
-
complete?: (res?: T | ApiError) => void;
|
|
23
|
-
}
|
|
24
|
-
export interface ShowToastParams extends Callbacks<void> {
|
|
25
|
-
title: string;
|
|
26
|
-
icon?: 'success' | 'error' | 'loading' | 'none';
|
|
27
|
-
duration?: number;
|
|
28
|
-
mask?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface HideToastParams extends Callbacks<void> {
|
|
31
|
-
}
|
|
32
|
-
export interface PlayMediaParams extends Callbacks<void> {
|
|
33
|
-
urls: string[];
|
|
34
|
-
url: string;
|
|
35
|
-
}
|
|
36
|
-
export interface ChooseMediaParams extends Callbacks<ChooseMediaResult> {
|
|
37
|
-
count?: number;
|
|
38
|
-
mediaType?: ('image' | 'video' | 'mix')[];
|
|
39
|
-
sourceType?: ('album' | 'camera')[];
|
|
40
|
-
maxDuration?: number;
|
|
41
|
-
sizeType?: ('original' | 'compressed')[];
|
|
42
|
-
camera?: 'back' | 'front';
|
|
43
|
-
}
|
|
44
|
-
export interface ChooseMediaResult {
|
|
45
|
-
tempFiles: Array<{
|
|
46
|
-
tempFilePath: string;
|
|
47
|
-
size: number;
|
|
48
|
-
duration?: number;
|
|
49
|
-
height?: number;
|
|
50
|
-
width?: number;
|
|
51
|
-
thumbTempFilePath?: string;
|
|
52
|
-
fileType: 'image' | 'video';
|
|
53
|
-
}>;
|
|
54
|
-
type: 'image' | 'video' | 'mix';
|
|
55
|
-
}
|
|
56
|
-
export interface SaveImageToPhotosAlbumParams extends Callbacks<void> {
|
|
57
|
-
filePath: string;
|
|
58
|
-
}
|
|
59
|
-
export interface SaveVideoToPhotosAlbumParams extends Callbacks<void> {
|
|
60
|
-
filePath: string;
|
|
61
|
-
}
|
|
62
|
-
export interface StartRecordParams extends Callbacks<void> {
|
|
63
|
-
maxDuration?: number;
|
|
64
|
-
}
|
|
65
|
-
export interface SetClipboardDataParams extends Callbacks<void> {
|
|
66
|
-
data: string;
|
|
67
|
-
}
|
|
68
|
-
export interface GetClipboardDataResult {
|
|
69
|
-
data: string;
|
|
70
|
-
}
|
|
71
|
-
export interface OpenInExternalBrowserParams extends Callbacks<void> {
|
|
72
|
-
url: string;
|
|
73
|
-
}
|
|
74
|
-
export interface NavigateToAppParams extends Callbacks<void> {
|
|
75
|
-
url: string;
|
|
76
|
-
}
|
|
77
|
-
export interface SwitchTabParams extends Callbacks<void> {
|
|
78
|
-
url: string;
|
|
79
|
-
}
|
|
80
|
-
export interface OpenWebviewParams extends Callbacks<void> {
|
|
81
|
-
url: string;
|
|
82
|
-
type?: 'immersive' | 'normal' | 'mini';
|
|
83
|
-
replace?: boolean;
|
|
84
|
-
}
|
|
85
|
-
export interface VibrateShortParams extends Callbacks<void> {
|
|
86
|
-
type: 'heavy' | 'medium' | 'light';
|
|
87
|
-
}
|
|
88
|
-
export interface SystemInfoResult {
|
|
89
|
-
brand: string;
|
|
90
|
-
model: string;
|
|
91
|
-
pixelRatio: number;
|
|
92
|
-
screenWidth: number;
|
|
93
|
-
screenHeight: number;
|
|
94
|
-
windowWidth: number;
|
|
95
|
-
windowHeight: number;
|
|
96
|
-
statusBarHeight: number;
|
|
97
|
-
version: string;
|
|
98
|
-
system: string;
|
|
99
|
-
platform: 'android' | 'ios';
|
|
100
|
-
}
|
|
101
|
-
export interface NetworkTypeResult {
|
|
102
|
-
networkType: 'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none';
|
|
103
|
-
}
|
|
104
|
-
export interface ShareWebCardParams extends Callbacks<void> {
|
|
105
|
-
title: string;
|
|
106
|
-
content?: string;
|
|
107
|
-
icon?: string;
|
|
108
|
-
shareUrl?: string;
|
|
109
|
-
externalContent?: string;
|
|
110
|
-
shareTypes?: (1 | 2 | 3)[];
|
|
111
|
-
isSharePic?: boolean;
|
|
112
|
-
serverId?: string;
|
|
113
|
-
trackData?: string;
|
|
114
|
-
daokeUrl?: string;
|
|
115
|
-
channelIds?: string;
|
|
116
|
-
contentType?: string;
|
|
117
|
-
}
|
|
118
|
-
export interface ShowAdParams extends Callbacks<void> {
|
|
119
|
-
type: number;
|
|
120
|
-
circle_id?: string;
|
|
121
|
-
cycle_day?: string | number;
|
|
122
|
-
module?: string | number;
|
|
123
|
-
cycle_id?: string;
|
|
124
|
-
wheel_lottery_id?: string | number;
|
|
125
|
-
}
|
|
126
|
-
export interface BindGameRoleParams extends Callbacks<void> {
|
|
127
|
-
gameName: string;
|
|
128
|
-
serverId: string;
|
|
129
|
-
}
|
|
130
|
-
export interface LoginResult {
|
|
131
|
-
code: string;
|
|
132
|
-
userInfo?: any;
|
|
133
|
-
}
|
|
134
|
-
export interface GetTokenResult {
|
|
135
|
-
token: string;
|
|
136
|
-
}
|
|
137
|
-
export interface GetCircleInfoResult {
|
|
138
|
-
serverId: string;
|
|
139
|
-
name: string;
|
|
140
|
-
icon: string;
|
|
141
|
-
}
|
|
8
|
+
export * from './base';
|
|
9
|
+
export * from './enums';
|
|
10
|
+
export * from './params';
|
|
11
|
+
export * from './results';
|