hylid-bridge 6.3.2 → 6.4.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.
Files changed (73) hide show
  1. package/README.md +165 -165
  2. package/lib/bridges.d.ts +23 -23
  3. package/lib/bridges.js +47 -24
  4. package/lib/clients/web/huawei_atomic/getAuthCode.d.ts +2 -0
  5. package/lib/clients/web/huawei_atomic/getAuthCode.js +3 -0
  6. package/lib/clients/web/huawei_atomic/getLocation.d.ts +2 -0
  7. package/lib/clients/web/huawei_atomic/getLocation.js +3 -0
  8. package/lib/clients/web/huawei_atomic/getStorage.d.ts +2 -0
  9. package/lib/clients/web/huawei_atomic/getStorage.js +3 -0
  10. package/lib/clients/web/huawei_atomic/getSystemInfo.d.ts +2 -0
  11. package/lib/clients/web/huawei_atomic/getSystemInfo.js +3 -0
  12. package/lib/clients/web/huawei_atomic/getSystemInfoSync.d.ts +2 -0
  13. package/lib/clients/web/huawei_atomic/getSystemInfoSync.js +3 -0
  14. package/lib/clients/web/huawei_atomic/index.d.ts +45 -0
  15. package/lib/clients/web/huawei_atomic/index.js +28 -0
  16. package/lib/clients/web/huawei_atomic/navigateBack.d.ts +2 -0
  17. package/lib/clients/web/huawei_atomic/navigateBack.js +3 -0
  18. package/lib/clients/web/huawei_atomic/navigateTo.d.ts +2 -0
  19. package/lib/clients/web/huawei_atomic/navigateTo.js +3 -0
  20. package/lib/clients/web/huawei_atomic/redirectTo.d.ts +2 -0
  21. package/lib/clients/web/huawei_atomic/redirectTo.js +3 -0
  22. package/lib/clients/web/huawei_atomic/request.d.ts +2 -0
  23. package/lib/clients/web/huawei_atomic/request.js +3 -0
  24. package/lib/clients/web/huawei_atomic/setClipboard.d.ts +2 -0
  25. package/lib/clients/web/huawei_atomic/setClipboard.js +3 -0
  26. package/lib/clients/web/huawei_atomic/setStorage.d.ts +2 -0
  27. package/lib/clients/web/huawei_atomic/setStorage.js +3 -0
  28. package/lib/clients/web/huawei_atomic/showAuthGuide.d.ts +2 -0
  29. package/lib/clients/web/huawei_atomic/showAuthGuide.js +3 -0
  30. package/lib/clients/web/kaspi/getSystemInfo.d.ts +1 -1
  31. package/lib/clients/web/kaspi/getSystemInfo.js +1 -1
  32. package/lib/code/authLoginSrcCode.d.ts +1 -1
  33. package/lib/code/authLoginSrcCode.js +90 -17
  34. package/lib/common/apis/custom/web/huawei_atomic/getAuthCode.d.ts +3 -0
  35. package/lib/common/apis/custom/web/huawei_atomic/getAuthCode.js +201 -0
  36. package/lib/common/apis/custom/web/huawei_atomic/getLocation.d.ts +1 -0
  37. package/lib/common/apis/custom/web/huawei_atomic/getLocation.js +34 -0
  38. package/lib/common/apis/custom/web/huawei_atomic/navigateBack.d.ts +3 -0
  39. package/lib/common/apis/custom/web/huawei_atomic/navigateBack.js +6 -0
  40. package/lib/common/apis/custom/web/huawei_atomic/navigateTo.d.ts +2 -0
  41. package/lib/common/apis/custom/web/huawei_atomic/navigateTo.js +3 -0
  42. package/lib/common/apis/custom/web/huawei_atomic/setClipboard.d.ts +2 -0
  43. package/lib/common/apis/custom/web/huawei_atomic/setClipboard.js +38 -0
  44. package/lib/common/apis/custom/web/huawei_atomic/showLBSAuthGuide.d.ts +1 -0
  45. package/lib/common/apis/custom/web/huawei_atomic/showLBSAuthGuide.js +13 -0
  46. package/lib/dsl.d.ts +23 -23
  47. package/lib/dsl.js +23 -23
  48. package/lib/umd/index.js +1 -1
  49. package/lib/umd/mp_web_alipay.js +1 -1
  50. package/lib/umd/mp_web_alipayhk.js +1 -1
  51. package/lib/umd/mp_web_chope.js +1 -1
  52. package/lib/umd/mp_web_dana.js +1 -1
  53. package/lib/umd/mp_web_demo.js +1 -1
  54. package/lib/umd/mp_web_gcash.js +1 -1
  55. package/lib/umd/mp_web_hipay.js +1 -1
  56. package/lib/umd/mp_web_kakaopay.js +1 -1
  57. package/lib/umd/mp_web_mpay.js +1 -1
  58. package/lib/umd/mp_web_scb_planetplus.js +1 -1
  59. package/lib/umd/mp_web_tinaba.js +1 -1
  60. package/lib/umd/mp_web_tmn.js +1 -1
  61. package/lib/umd/mp_web_tngd.js +1 -1
  62. package/lib/umd/mp_web_toss.js +1 -1
  63. package/lib/umd/mp_web_zalopay.js +1 -1
  64. package/lib/umd/web_alipay.js +1 -1
  65. package/lib/umd/web_alipayhk.js +1 -1
  66. package/lib/umd/web_changipay.js +1 -1
  67. package/lib/umd/web_demo.js +1 -1
  68. package/lib/umd/web_h5.js +1 -1
  69. package/lib/umd/web_huawei_atomic.js +2 -0
  70. package/lib/umd/web_huawei_atomic.js.LICENSE.txt +1 -0
  71. package/lib/umd/web_kaspi.js +1 -1
  72. package/lib/umd/web_tngdh5ng.js +1 -1
  73. package/package.json +1 -1
@@ -133,6 +133,7 @@ var __generator = this && this.__generator || function (thisArg, body) {
133
133
  *
134
134
  */
135
135
  import md5 from 'crypto-js/md5';
136
+ import { client, CLIENT } from '@hylid/env';
136
137
  // 钱包密钥,混淆代码前,填入真实的密钥
137
138
  var appSecretMap = {
138
139
  TOSS: '',
@@ -144,7 +145,8 @@ var appSecretMap = {
144
145
  HIPAY: '',
145
146
  SCB_PLANETPLUS: '',
146
147
  CHANGIPAY: '',
147
- KASPI: ''
148
+ KASPI: '',
149
+ HUAWEI_ATOMIC: ''
148
150
  };
149
151
  // 登录接口, 当前MPAY用新的,TOSS本期保留rewards的,后续服务端统一迁移到新的alipayplusvoyager
150
152
  var authLoginApiMap = {
@@ -157,7 +159,8 @@ var authLoginApiMap = {
157
159
  MPAY: 'ap.alipayplusvoyager.auth.authlogin',
158
160
  ALIPAY: 'ap.alipayplusvoyager.auth.authlogin',
159
161
  CHANGIPAY: 'ap.alipayplusvoyager.auth.authlogin',
160
- KASPI: 'ap.alipayplusvoyager.auth.authlogin'
162
+ KASPI: 'ap.alipayplusvoyager.auth.authlogin',
163
+ HUAWEI_ATOMIC: 'ap.alipayplusvoyager.traffic.auth.authlogin'
161
164
  };
162
165
  // http加签
163
166
  export var httpSign = function httpSign(params, siteName) {
@@ -188,23 +191,25 @@ function randomUUID() {
188
191
  }
189
192
  // 避免authLogin重复请求
190
193
  var authLoginPromise;
194
+ // checkIsLogin Promise锁,用于授权超时时拦截排队的请求
195
+ var checkIsLoginPromise = null;
191
196
  var sendLoginHttp = function sendLoginHttp(params) {
192
197
  return __awaiter(void 0, void 0, void 0, function () {
193
- var sessionIdPreTime, clientKeyPreTime, httpRequest, getAuthParams, saveAuthParams, getAuthCode, getAppId, siteName, AUTH_LOGIN, tokenRes, token, requestParams, appId, authCodeRes, httpParams, signData, res;
194
- var _a, _b;
195
- return __generator(this, function (_c) {
196
- switch (_c.label) {
198
+ var sessionIdPreTime, clientKeyPreTime, httpRequest, getAuthParams, saveAuthParams, getAuthCode, getAppId, siteName, AUTH_LOGIN, tokenRes, token, requestParams, appId, authCodeRes, httpParams, signData, res, walletAuthCodeRes, _requestParams, _httpParams, _signData;
199
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
200
+ return __generator(this, function (_k) {
201
+ switch (_k.label) {
197
202
  case 0:
198
203
  sessionIdPreTime = 60 * 1000;
199
204
  clientKeyPreTime = 3600 * 1000;
200
205
  httpRequest = params.httpRequest, getAuthParams = params.getAuthParams, saveAuthParams = params.saveAuthParams, getAuthCode = params.getAuthCode, getAppId = params.getAppId, siteName = params.siteName;
201
206
  AUTH_LOGIN = authLoginApiMap[siteName];
202
- _c.label = 1;
207
+ _k.label = 1;
203
208
  case 1:
204
- _c.trys.push([1,, 8, 9]);
209
+ _k.trys.push([1,, 12, 13]);
205
210
  return [4 /*yield*/, getAuthParams()];
206
211
  case 2:
207
- tokenRes = _c.sent();
212
+ tokenRes = _k.sent();
208
213
  token = '';
209
214
  if ((tokenRes === null || tokenRes === void 0 ? void 0 : tokenRes.data) && ((_a = tokenRes === null || tokenRes === void 0 ? void 0 : tokenRes.data) === null || _a === void 0 ? void 0 : _a.token)) {
210
215
  token = (_b = tokenRes === null || tokenRes === void 0 ? void 0 : tokenRes.data) === null || _b === void 0 ? void 0 : _b.token;
@@ -217,21 +222,25 @@ var sendLoginHttp = function sendLoginHttp(params) {
217
222
  if (!getAppId) return [3 /*break*/, 4];
218
223
  return [4 /*yield*/, getAppId()];
219
224
  case 3:
220
- appId = _c.sent().appId;
225
+ appId = _k.sent().appId;
221
226
  requestParams.appId = appId;
222
227
  return [3 /*break*/, 5];
223
228
  case 4:
224
229
  // H5场景没有appId时,terminalType传WAP,服务会跳过appId的强校验逻辑
225
230
  requestParams.terminalType = "WAP";
226
- _c.label = 5;
231
+ _k.label = 5;
227
232
  case 5:
228
233
  return [4 /*yield*/, getAuthCode()];
229
234
  case 6:
230
- authCodeRes = _c.sent();
235
+ authCodeRes = _k.sent();
231
236
  if (!(authCodeRes === null || authCodeRes === void 0 ? void 0 : authCodeRes.authCode)) {
232
237
  throw authCodeRes;
233
238
  }
234
239
  requestParams.authCode = authCodeRes.authCode || '';
240
+ if (siteName === "HUAWEI_ATOMIC") {
241
+ requestParams.loginMode = "AUTH_LOGIN";
242
+ requestParams.trafficSideId = authCodeRes.trafficSideId;
243
+ }
235
244
  httpParams = {
236
245
  operationType: AUTH_LOGIN,
237
246
  requestData: JSON.stringify([requestParams])
@@ -241,10 +250,46 @@ var sendLoginHttp = function sendLoginHttp(params) {
241
250
  headers: __assign({}, signData)
242
251
  }))];
243
252
  case 7:
244
- res = _c.sent();
253
+ res = _k.sent();
254
+ if (!(!res || !res.success)) return [3 /*break*/, 11];
255
+ if (!(res.errorCode === "USER_IS_NOT_BOUND" && client === CLIENT.HUAWEI_ATOMIC)) return [3 /*break*/, 10];
256
+ return [4 /*yield*/, getAuthCode({
257
+ scopes: "alipay"
258
+ })];
259
+ case 8:
260
+ walletAuthCodeRes = _k.sent();
261
+ if (!((_e = (_d = (_c = walletAuthCodeRes === null || walletAuthCodeRes === void 0 ? void 0 : walletAuthCodeRes.authCode) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.parameters) === null || _e === void 0 ? void 0 : _e.auth_code)) {
262
+ throw {
263
+ success: false,
264
+ errorCode: 'GET_WALLET_AUTHCODE_TIMEOUT',
265
+ errorMsg: ((_f = walletAuthCodeRes === null || walletAuthCodeRes === void 0 ? void 0 : walletAuthCodeRes.authCode) === null || _f === void 0 ? void 0 : _f.message) || 'GET_WALLET_AUTHCODE_TIMEOUT'
266
+ };
267
+ }
268
+ _requestParams = __assign(__assign({}, requestParams), {
269
+ authCode: ((_j = (_h = (_g = walletAuthCodeRes.authCode) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.parameters) === null || _j === void 0 ? void 0 : _j.auth_code) || '',
270
+ loginMode: 'AUTH_LOGIN_BIND',
271
+ bindUserToken: authCodeRes.authCode,
272
+ trafficSideId: authCodeRes.trafficSideId
273
+ });
274
+ _httpParams = {
275
+ operationType: AUTH_LOGIN,
276
+ requestData: JSON.stringify([_requestParams])
277
+ };
278
+ _signData = httpSign(_httpParams, siteName);
279
+ return [4 /*yield*/, httpRequest(__assign(__assign({}, _httpParams), {
280
+ headers: __assign({}, _signData)
281
+ }))];
282
+ case 9:
283
+ // 绑定并登录
284
+ res = _k.sent();
245
285
  if (!res || !res.success) {
246
286
  throw res;
247
287
  }
288
+ return [3 /*break*/, 11];
289
+ case 10:
290
+ // 非 USER_IS_NOT_BOUND 错误,抛出错误
291
+ throw res;
292
+ case 11:
248
293
  // 存储sessionID 及 clientKey、openId
249
294
  saveAuthParams({
250
295
  sessionIdLastTime: Date.now(),
@@ -253,14 +298,15 @@ var sendLoginHttp = function sendLoginHttp(params) {
253
298
  clientKeyExpiresTime: (res.clientKeyExpireTime || 0) * 1000 - clientKeyPreTime,
254
299
  clientKey: res.clientKey || '',
255
300
  openId: res.openId || '',
256
- token: token
301
+ token: token,
302
+ trafficMemberSessionId: (res === null || res === void 0 ? void 0 : res.trafficMemberSessionId) || ''
257
303
  });
258
- return [3 /*break*/, 9];
259
- case 8:
304
+ return [3 /*break*/, 13];
305
+ case 12:
260
306
  // 释放登录中的标志
261
307
  authLoginPromise = undefined;
262
308
  return [7 /*endfinally*/];
263
- case 9:
309
+ case 13:
264
310
  return [2 /*return*/];
265
311
  }
266
312
  });
@@ -296,6 +342,33 @@ export var checkIsLogin = function checkIsLogin(params) {
296
342
  if (!isForceLogin && sessionIdLastTime && sessionIdExpiresTime && Date.now() - sessionIdLastTime < sessionIdExpiresTime) {
297
343
  return [2 /*return*/];
298
344
  }
345
+ if (client === CLIENT.HUAWEI_ATOMIC) {
346
+ // 如果已有正在执行的checkIsLogin,直接返回共享的Promise
347
+ // 所有并发请求等待同一个结果:成功则继续,超时/失败则都被拦截
348
+ if (checkIsLoginPromise) {
349
+ return [2 /*return*/, checkIsLoginPromise];
350
+ }
351
+ // 用Promise包起整个登录流程,所有并发请求共享同一个Promise
352
+ checkIsLoginPromise = new Promise(function (resolve, reject) {
353
+ authLoginPromise = authLoginPromise || sendLoginHttp(params);
354
+ authLoginPromise.then(function () {
355
+ // 登录成功后解锁
356
+ checkIsLoginPromise = null;
357
+ resolve();
358
+ }).catch(function (error) {
359
+ // getAuthCode授权超时,拦截所有排队的接口请求
360
+ if (error.errorCode !== "GET_WALLET_AUTHCODE_TIMEOUT") {
361
+ // 非超时授权异常解锁,允许后续新的登录请求
362
+ checkIsLoginPromise = null;
363
+ }
364
+ reject(error);
365
+ }).finally(function () {
366
+ // 执行完成后重置,允许后续新的登录请求
367
+ // checkIsLoginPromise = null;
368
+ });
369
+ });
370
+ return [2 /*return*/, checkIsLoginPromise];
371
+ }
299
372
  authLoginPromise = authLoginPromise || sendLoginHttp(params);
300
373
  return [4 /*yield*/, authLoginPromise];
301
374
  case 2:
@@ -0,0 +1,3 @@
1
+ import { PickMPAttr } from '@hylid/types';
2
+ declare const getAuthCode: PickMPAttr<'getAuthCode'>;
3
+ export default getAuthCode;
@@ -0,0 +1,201 @@
1
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) {
3
+ return value instanceof P ? value : new P(function (resolve) {
4
+ resolve(value);
5
+ });
6
+ }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) {
9
+ try {
10
+ step(generator.next(value));
11
+ } catch (e) {
12
+ reject(e);
13
+ }
14
+ }
15
+ function rejected(value) {
16
+ try {
17
+ step(generator["throw"](value));
18
+ } catch (e) {
19
+ reject(e);
20
+ }
21
+ }
22
+ function step(result) {
23
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
24
+ }
25
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
26
+ });
27
+ };
28
+ var __generator = this && this.__generator || function (thisArg, body) {
29
+ var _ = {
30
+ label: 0,
31
+ sent: function sent() {
32
+ if (t[0] & 1) throw t[1];
33
+ return t[1];
34
+ },
35
+ trys: [],
36
+ ops: []
37
+ },
38
+ f,
39
+ y,
40
+ t,
41
+ g;
42
+ return g = {
43
+ next: verb(0),
44
+ "throw": verb(1),
45
+ "return": verb(2)
46
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
47
+ return this;
48
+ }), g;
49
+ function verb(n) {
50
+ return function (v) {
51
+ return step([n, v]);
52
+ };
53
+ }
54
+ function step(op) {
55
+ if (f) throw new TypeError("Generator is already executing.");
56
+ while (_) try {
57
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
+ if (y = 0, t) op = [op[0] & 2, t.value];
59
+ switch (op[0]) {
60
+ case 0:
61
+ case 1:
62
+ t = op;
63
+ break;
64
+ case 4:
65
+ _.label++;
66
+ return {
67
+ value: op[1],
68
+ done: false
69
+ };
70
+ case 5:
71
+ _.label++;
72
+ y = op[1];
73
+ op = [0];
74
+ continue;
75
+ case 7:
76
+ op = _.ops.pop();
77
+ _.trys.pop();
78
+ continue;
79
+ default:
80
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
81
+ _ = 0;
82
+ continue;
83
+ }
84
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
85
+ _.label = op[1];
86
+ break;
87
+ }
88
+ if (op[0] === 6 && _.label < t[1]) {
89
+ _.label = t[1];
90
+ t = op;
91
+ break;
92
+ }
93
+ if (t && _.label < t[2]) {
94
+ _.label = t[2];
95
+ _.ops.push(op);
96
+ break;
97
+ }
98
+ if (t[2]) _.ops.pop();
99
+ _.trys.pop();
100
+ continue;
101
+ }
102
+ op = body.call(thisArg, _);
103
+ } catch (e) {
104
+ op = [6, e];
105
+ y = 0;
106
+ } finally {
107
+ f = t = 0;
108
+ }
109
+ if (op[0] & 5) throw op[1];
110
+ return {
111
+ value: op[0] ? op[1] : void 0,
112
+ done: true
113
+ };
114
+ }
115
+ };
116
+ /**
117
+ * 创建带超时的 Promise
118
+ * @param promise 原始 Promise
119
+ * @param timeout 超时时间(毫秒)
120
+ * @param errorMessage 超时错误信息
121
+ */
122
+ function withTimeout(promise, timeout, errorMessage) {
123
+ var timeoutId;
124
+ var timeoutPromise = new Promise(function (_, reject) {
125
+ timeoutId = setTimeout(function () {
126
+ reject({
127
+ success: false,
128
+ errorCode: 'GET_WALLET_AUTHCODE_TIMEOUT',
129
+ errorMsg: errorMessage
130
+ });
131
+ }, timeout);
132
+ });
133
+ // @ts-ignore
134
+ return Promise.race([promise, timeoutPromise]).finally(function () {
135
+ clearTimeout(timeoutId);
136
+ });
137
+ }
138
+ var getAuthCode = function getAuthCode(options) {
139
+ if (options === void 0) {
140
+ options = {
141
+ scopes: "container"
142
+ };
143
+ }
144
+ return __awaiter(void 0, void 0, void 0, function () {
145
+ var huaweiOpenId, walletAuthCodeTimeout, aliPayAuthCode, error_1;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0:
149
+ console.log('getAuthCode-start');
150
+ _a.label = 1;
151
+ case 1:
152
+ _a.trys.push([1, 6,, 7]);
153
+ if (!(options.scopes === "container")) return [3 /*break*/, 3];
154
+ return [4 /*yield*/, window.atomicsdk.invokeMethod({
155
+ appMethod: 'getHuaweiOpenId',
156
+ jsMethod: '',
157
+ data: {
158
+ authCode: ''
159
+ } // 参数对象
160
+ })];
161
+ case 2:
162
+ huaweiOpenId = _a.sent();
163
+ console.log('getAuthCode-end');
164
+ return [2 /*return*/, {
165
+ authCode: huaweiOpenId,
166
+ trafficSideId: "HUAWEI_TRAFFIC_2026"
167
+ }];
168
+ case 3:
169
+ if (!(options.scopes === "alipay")) return [3 /*break*/, 5];
170
+ walletAuthCodeTimeout = Number(sessionStorage.getItem('__hylid-bridge__walletAuthCodeTimeout') || 10000);
171
+ return [4 /*yield*/, withTimeout(
172
+ // @ts-ignore
173
+ window.atomicsdk.invokeMethod({
174
+ appMethod: 'getAliPayAuth',
175
+ jsMethod: '',
176
+ data: {}
177
+ }), walletAuthCodeTimeout, "getAliPayAuth timeout after ".concat(walletAuthCodeTimeout, "ms"))];
178
+ case 4:
179
+ aliPayAuthCode = _a.sent();
180
+ console.log('getAuthCode-end', aliPayAuthCode);
181
+ // @ts-ignore
182
+ return [2 /*return*/, {
183
+ authCode: aliPayAuthCode
184
+ }];
185
+ case 5:
186
+ // 兜底
187
+ throw {
188
+ errorCode: 'NO_BRIDGE',
189
+ errorMsg: 'getAuthCode_Bridge_huawei_atomic error'
190
+ };
191
+ case 6:
192
+ error_1 = _a.sent();
193
+ console.log('getAuthCode-error', error_1);
194
+ throw error_1;
195
+ case 7:
196
+ return [2 /*return*/];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ export default getAuthCode;
@@ -0,0 +1 @@
1
+ export default function getLocation(options?: any): void;
@@ -0,0 +1,34 @@
1
+ export default function getLocation(options) {
2
+ // @ts-ignore
3
+ window.atomicsdk.invokeMethod({
4
+ appMethod: 'getLocation',
5
+ data: {
6
+ cacheTimeout: (options === null || options === void 0 ? void 0 : options.cacheTimeout) || 30000
7
+ }
8
+ }).then(function (data) {
9
+ var _a, _b;
10
+ if (!(data === null || data === void 0 ? void 0 : data.error)) {
11
+ // 成功回调
12
+ var result = {
13
+ accuracy: "".concat(data === null || data === void 0 ? void 0 : data.accuracy),
14
+ horizontalAccuracy: "".concat(data === null || data === void 0 ? void 0 : data.horizontalAccuracy),
15
+ latitude: "".concat(data === null || data === void 0 ? void 0 : data.latitude),
16
+ longitude: "".concat(data === null || data === void 0 ? void 0 : data.longitude)
17
+ };
18
+ (_a = options.success) === null || _a === void 0 ? void 0 : _a.call(options, result);
19
+ } else {
20
+ // 错误码映射:code为1表示用户拒绝授权,对应错误码11;其他错误对应错误码13
21
+ var error = (data === null || data === void 0 ? void 0 : data.error) === 1 || (data === null || data === void 0 ? void 0 : data.error) === 11 ? 11 : 13;
22
+ (_b = options.fail) === null || _b === void 0 ? void 0 : _b.call(options, {
23
+ error: error
24
+ });
25
+ }
26
+ }).catch(function (err) {
27
+ var _a;
28
+ // 错误码映射:code为1表示用户拒绝授权,对应错误码11;其他错误对应错误码13
29
+ var error = (err === null || err === void 0 ? void 0 : err.error) === 1 || (err === null || err === void 0 ? void 0 : err.error) === 11 ? 11 : 13;
30
+ (_a = options.fail) === null || _a === void 0 ? void 0 : _a.call(options, {
31
+ error: error
32
+ });
33
+ });
34
+ }
@@ -0,0 +1,3 @@
1
+ import { PickMPAttr } from '@hylid/types';
2
+ declare const navigateBack: PickMPAttr<'navigateBack'>;
3
+ export default navigateBack;
@@ -0,0 +1,6 @@
1
+ import { webCall as call } from '@hylid/call';
2
+ var navigateBack = function navigateBack() {
3
+ // @ts-ignore
4
+ call('executeBackPress', -1);
5
+ };
6
+ export default navigateBack;
@@ -0,0 +1,2 @@
1
+ /// <reference types="miniprogram" />
2
+ export default function navigateTo(options: NavigateToArgs): Window | null;
@@ -0,0 +1,3 @@
1
+ export default function navigateTo(options) {
2
+ return window.open(options.url, '_blank');
3
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="miniprogram" />
2
+ export default function setClipboard(options: SetClipboardArgs): void;
@@ -0,0 +1,38 @@
1
+ function _setClipboard(options) {
2
+ var _a, _b, _c, _d, _e, _f;
3
+ if (!options.text) {
4
+ (_a = options.fail) === null || _a === void 0 ? void 0 : _a.call(options);
5
+ (_b = options.complete) === null || _b === void 0 ? void 0 : _b.call(options, {
6
+ success: false
7
+ });
8
+ return;
9
+ }
10
+ var input = document.createElement('input');
11
+ input.style.position = 'fixed';
12
+ input.style.opacity = '0';
13
+ input.style.zIndex = '-1000';
14
+ document.body.appendChild(input);
15
+ input.setAttribute('readonly', 'readonly');
16
+ input.setAttribute('value', options.text);
17
+ input.setSelectionRange(0, options.text.length);
18
+ input.focus();
19
+ input.select();
20
+ document.execCommand('copy');
21
+ if (document.execCommand('copy')) {
22
+ (_c = options.success) === null || _c === void 0 ? void 0 : _c.call(options, {
23
+ success: true
24
+ });
25
+ (_d = options.complete) === null || _d === void 0 ? void 0 : _d.call(options, {
26
+ success: true
27
+ });
28
+ } else {
29
+ (_e = options.fail) === null || _e === void 0 ? void 0 : _e.call(options);
30
+ (_f = options.complete) === null || _f === void 0 ? void 0 : _f.call(options, {
31
+ success: false
32
+ });
33
+ }
34
+ document.body.removeChild(input);
35
+ }
36
+ export default function setClipboard(options) {
37
+ return _setClipboard(options);
38
+ }
@@ -0,0 +1 @@
1
+ export default function showAuthGuide(options?: any): void;
@@ -0,0 +1,13 @@
1
+ export default function showAuthGuide(options) {
2
+ // @ts-ignore
3
+ window.atomicsdk.invokeMethod({
4
+ appMethod: 'showLBSAuthGuide',
5
+ data: options
6
+ }).then(function (data) {
7
+ var _a;
8
+ (_a = options.success) === null || _a === void 0 ? void 0 : _a.call(options, data);
9
+ }).catch(function (error) {
10
+ var _a;
11
+ (_a = options.fail) === null || _a === void 0 ? void 0 : _a.call(options, error);
12
+ });
13
+ }