@tarojs/taro-h5 3.4.7 → 3.5.0-alpha.2
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/base/system.js +28 -24
- package/dist/api/canvas/CanvasContext.js +27 -16
- package/dist/api/device/accelerometer.js +9 -17
- package/dist/api/device/battery.js +12 -3
- package/dist/api/device/clipboard.js +13 -4
- package/dist/api/device/compass.js +32 -18
- package/dist/api/device/motion.js +8 -17
- package/dist/api/device/network.js +12 -3
- package/dist/api/location/chooseLocation.js +13 -8
- package/dist/api/media/image/previewImage.js +12 -3
- package/dist/api/taro.js +2 -3
- package/dist/api/ui/fonts.js +12 -3
- package/dist/api/ui/interaction/actionSheet.js +3 -12
- package/dist/api/ui/interaction/index.js +17 -8
- package/dist/api/ui/interaction/modal.js +6 -27
- package/dist/api/ui/interaction/toast.js +14 -40
- package/dist/api/utils/animation.js +14 -0
- package/dist/api/utils/index.js +3 -21
- package/dist/api/utils/lodash.js +29 -0
- package/dist/api/utils/valid.js +7 -0
- package/dist/dist/api/taro.d.ts +2 -2
- package/dist/dist/api/utils/animation.d.ts +6 -0
- package/dist/dist/api/utils/index.d.ts +3 -9
- package/dist/dist/api/utils/lodash.d.ts +2 -0
- package/dist/dist/api/utils/valid.d.ts +2 -0
- package/dist/index.cjs.js +424 -229
- package/dist/index.cjs.js.map +1 -1
- package/package.json +11 -12
- package/src/api/device/accelerometer.ts +8 -17
- package/src/api/device/compass.ts +34 -18
- package/src/api/device/motion.ts +9 -17
- package/src/api/taro.ts +2 -7
- package/src/api/ui/scroll/index.ts +1 -1
- package/src/api/utils/animation.ts +15 -0
- package/src/api/utils/index.ts +3 -25
- package/src/api/utils/lodash.ts +30 -0
- package/src/api/utils/valid.ts +8 -0
package/dist/index.cjs.js
CHANGED
|
@@ -17,6 +17,59 @@ var Taro__default = /*#__PURE__*/_interopDefaultLegacy(Taro);
|
|
|
17
17
|
var MobileDetect__default = /*#__PURE__*/_interopDefaultLegacy(MobileDetect);
|
|
18
18
|
var jsonpRetry__default = /*#__PURE__*/_interopDefaultLegacy(jsonpRetry);
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* ease-in-out的函数
|
|
22
|
+
* @param t 0-1的数字
|
|
23
|
+
*/
|
|
24
|
+
const easeInOut = (t) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1);
|
|
25
|
+
const getTimingFunc = (easeFunc, frameCnt) => {
|
|
26
|
+
return x => {
|
|
27
|
+
if (frameCnt <= 1) {
|
|
28
|
+
return easeFunc(1);
|
|
29
|
+
}
|
|
30
|
+
const t = x / (frameCnt - 1);
|
|
31
|
+
return easeFunc(t);
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function throttle(fn, threshold = 250, scope) {
|
|
36
|
+
let lastTime = 0;
|
|
37
|
+
let deferTimer;
|
|
38
|
+
return function (...args) {
|
|
39
|
+
const context = scope || this;
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
if (now - lastTime > threshold) {
|
|
42
|
+
fn.apply(this, args);
|
|
43
|
+
lastTime = now;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
clearTimeout(deferTimer);
|
|
47
|
+
deferTimer = setTimeout(() => {
|
|
48
|
+
lastTime = now;
|
|
49
|
+
fn.apply(context, args);
|
|
50
|
+
}, threshold);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function debounce(fn, ms = 250, scope) {
|
|
55
|
+
let timer;
|
|
56
|
+
return function (...args) {
|
|
57
|
+
const context = scope || this;
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
timer = setTimeout(function () {
|
|
60
|
+
fn.apply(context, args);
|
|
61
|
+
}, ms);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isFunction(obj) {
|
|
66
|
+
return typeof obj === 'function';
|
|
67
|
+
}
|
|
68
|
+
const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
69
|
+
const isValidColor = (color) => {
|
|
70
|
+
return VALID_COLOR_REG.test(color);
|
|
71
|
+
};
|
|
72
|
+
|
|
20
73
|
/* eslint-disable prefer-promise-reject-errors */
|
|
21
74
|
function shouldBeObject(target) {
|
|
22
75
|
if (target && typeof target === 'object')
|
|
@@ -140,13 +193,6 @@ function permanentlyNotSupport(apiName) {
|
|
|
140
193
|
}
|
|
141
194
|
};
|
|
142
195
|
}
|
|
143
|
-
function isFunction(obj) {
|
|
144
|
-
return typeof obj === 'function';
|
|
145
|
-
}
|
|
146
|
-
const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
147
|
-
const isValidColor = (color) => {
|
|
148
|
-
return VALID_COLOR_REG.test(color);
|
|
149
|
-
};
|
|
150
196
|
function processOpenApi({ name, defaultOptions, standardMethod, formatOptions = options => options, formatResult = res => res }) {
|
|
151
197
|
const notSupported = weixinCorpSupport(name);
|
|
152
198
|
return (options = {}) => {
|
|
@@ -179,20 +225,6 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
179
225
|
}
|
|
180
226
|
};
|
|
181
227
|
}
|
|
182
|
-
/**
|
|
183
|
-
* ease-in-out的函数
|
|
184
|
-
* @param t 0-1的数字
|
|
185
|
-
*/
|
|
186
|
-
const easeInOut = (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
|
187
|
-
const getTimingFunc = (easeFunc, frameCnt) => {
|
|
188
|
-
return x => {
|
|
189
|
-
if (frameCnt <= 1) {
|
|
190
|
-
return easeFunc(1);
|
|
191
|
-
}
|
|
192
|
-
const t = x / (frameCnt - 1);
|
|
193
|
-
return easeFunc(t);
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
228
|
|
|
197
229
|
// 广告
|
|
198
230
|
const createRewardedVideoAd = temporarilyNotSupport('createRewardedVideoAd');
|
|
@@ -208,6 +240,246 @@ const isVKSupport = temporarilyNotSupport('isVKSupport');
|
|
|
208
240
|
// 视觉算法
|
|
209
241
|
const createVKSession = temporarilyNotSupport('createVKSession');
|
|
210
242
|
|
|
243
|
+
/*! *****************************************************************************
|
|
244
|
+
Copyright (c) Microsoft Corporation.
|
|
245
|
+
|
|
246
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
247
|
+
purpose with or without fee is hereby granted.
|
|
248
|
+
|
|
249
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
250
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
251
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
252
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
253
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
254
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
255
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
256
|
+
***************************************************************************** */
|
|
257
|
+
/* global Reflect, Promise */
|
|
258
|
+
|
|
259
|
+
var extendStatics = function(d, b) {
|
|
260
|
+
extendStatics = Object.setPrototypeOf ||
|
|
261
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
262
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
263
|
+
return extendStatics(d, b);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
function __extends(d, b) {
|
|
267
|
+
if (typeof b !== "function" && b !== null)
|
|
268
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
269
|
+
extendStatics(d, b);
|
|
270
|
+
function __() { this.constructor = d; }
|
|
271
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var __assign = function() {
|
|
275
|
+
__assign = Object.assign || function __assign(t) {
|
|
276
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
277
|
+
s = arguments[i];
|
|
278
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
279
|
+
}
|
|
280
|
+
return t;
|
|
281
|
+
};
|
|
282
|
+
return __assign.apply(this, arguments);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
function __rest(s, e) {
|
|
286
|
+
var t = {};
|
|
287
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
288
|
+
t[p] = s[p];
|
|
289
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
290
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
291
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
292
|
+
t[p[i]] = s[p[i]];
|
|
293
|
+
}
|
|
294
|
+
return t;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function __decorate(decorators, target, key, desc) {
|
|
298
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
299
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
300
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
301
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function __param(paramIndex, decorator) {
|
|
305
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function __metadata(metadataKey, metadataValue) {
|
|
309
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
313
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
314
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
315
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
316
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
317
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
318
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function __generator(thisArg, body) {
|
|
323
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
324
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
325
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
326
|
+
function step(op) {
|
|
327
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
328
|
+
while (_) try {
|
|
329
|
+
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;
|
|
330
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
331
|
+
switch (op[0]) {
|
|
332
|
+
case 0: case 1: t = op; break;
|
|
333
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
334
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
335
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
336
|
+
default:
|
|
337
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
338
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
339
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
340
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
341
|
+
if (t[2]) _.ops.pop();
|
|
342
|
+
_.trys.pop(); continue;
|
|
343
|
+
}
|
|
344
|
+
op = body.call(thisArg, _);
|
|
345
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
346
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
|
351
|
+
if (k2 === undefined) k2 = k;
|
|
352
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
353
|
+
}) : (function(o, m, k, k2) {
|
|
354
|
+
if (k2 === undefined) k2 = k;
|
|
355
|
+
o[k2] = m[k];
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
function __exportStar(m, o) {
|
|
359
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function __values(o) {
|
|
363
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
364
|
+
if (m) return m.call(o);
|
|
365
|
+
if (o && typeof o.length === "number") return {
|
|
366
|
+
next: function () {
|
|
367
|
+
if (o && i >= o.length) o = void 0;
|
|
368
|
+
return { value: o && o[i++], done: !o };
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function __read(o, n) {
|
|
375
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
376
|
+
if (!m) return o;
|
|
377
|
+
var i = m.call(o), r, ar = [], e;
|
|
378
|
+
try {
|
|
379
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
380
|
+
}
|
|
381
|
+
catch (error) { e = { error: error }; }
|
|
382
|
+
finally {
|
|
383
|
+
try {
|
|
384
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
385
|
+
}
|
|
386
|
+
finally { if (e) throw e.error; }
|
|
387
|
+
}
|
|
388
|
+
return ar;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** @deprecated */
|
|
392
|
+
function __spread() {
|
|
393
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
394
|
+
ar = ar.concat(__read(arguments[i]));
|
|
395
|
+
return ar;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** @deprecated */
|
|
399
|
+
function __spreadArrays() {
|
|
400
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
401
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
402
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
403
|
+
r[k] = a[j];
|
|
404
|
+
return r;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function __spreadArray(to, from, pack) {
|
|
408
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
409
|
+
if (ar || !(i in from)) {
|
|
410
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
411
|
+
ar[i] = from[i];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function __await(v) {
|
|
418
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
422
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
423
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
424
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
425
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
426
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
427
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
428
|
+
function fulfill(value) { resume("next", value); }
|
|
429
|
+
function reject(value) { resume("throw", value); }
|
|
430
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function __asyncDelegator(o) {
|
|
434
|
+
var i, p;
|
|
435
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
436
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function __asyncValues(o) {
|
|
440
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
441
|
+
var m = o[Symbol.asyncIterator], i;
|
|
442
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
443
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
444
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function __makeTemplateObject(cooked, raw) {
|
|
448
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
449
|
+
return cooked;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
var __setModuleDefault = Object.create ? (function(o, v) {
|
|
453
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
454
|
+
}) : function(o, v) {
|
|
455
|
+
o["default"] = v;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
function __importStar(mod) {
|
|
459
|
+
if (mod && mod.__esModule) return mod;
|
|
460
|
+
var result = {};
|
|
461
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
462
|
+
__setModuleDefault(result, mod);
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function __importDefault(mod) {
|
|
467
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
471
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
472
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
473
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
477
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
478
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
479
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
480
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
481
|
+
}
|
|
482
|
+
|
|
211
483
|
class MethodHandler {
|
|
212
484
|
constructor({ name, success, fail, complete }) {
|
|
213
485
|
this.methodName = name;
|
|
@@ -413,44 +685,39 @@ const getSystemInfoSync = () => {
|
|
|
413
685
|
const appBaseInfo = getAppBaseInfo();
|
|
414
686
|
const appAuthorizeSetting = getAppAuthorizeSetting();
|
|
415
687
|
delete deviceInfo.abi;
|
|
416
|
-
const info = {
|
|
417
|
-
...windowInfo,
|
|
418
|
-
...systemSetting,
|
|
419
|
-
...deviceInfo,
|
|
420
|
-
...appBaseInfo,
|
|
688
|
+
const info = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, windowInfo), systemSetting), deviceInfo), appBaseInfo), {
|
|
421
689
|
/** 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 */
|
|
422
|
-
fontSizeSetting: NaN,
|
|
690
|
+
fontSizeSetting: NaN,
|
|
423
691
|
/** 允许微信使用相册的开关(仅 iOS 有效) */
|
|
424
|
-
albumAuthorized: appAuthorizeSetting.albumAuthorized === 'authorized',
|
|
692
|
+
albumAuthorized: appAuthorizeSetting.albumAuthorized === 'authorized',
|
|
425
693
|
/** 允许微信使用摄像头的开关 */
|
|
426
|
-
cameraAuthorized: appAuthorizeSetting.cameraAuthorized === 'authorized',
|
|
694
|
+
cameraAuthorized: appAuthorizeSetting.cameraAuthorized === 'authorized',
|
|
427
695
|
/** 允许微信使用定位的开关 */
|
|
428
|
-
locationAuthorized: appAuthorizeSetting.locationAuthorized === 'authorized',
|
|
696
|
+
locationAuthorized: appAuthorizeSetting.locationAuthorized === 'authorized',
|
|
429
697
|
/** 允许微信使用麦克风的开关 */
|
|
430
|
-
microphoneAuthorized: appAuthorizeSetting.microphoneAuthorized === 'authorized',
|
|
698
|
+
microphoneAuthorized: appAuthorizeSetting.microphoneAuthorized === 'authorized',
|
|
431
699
|
/** 允许微信通知的开关 */
|
|
432
|
-
notificationAuthorized: appAuthorizeSetting.notificationAuthorized === 'authorized',
|
|
700
|
+
notificationAuthorized: appAuthorizeSetting.notificationAuthorized === 'authorized',
|
|
433
701
|
/** 允许微信通知带有提醒的开关(仅 iOS 有效) */
|
|
434
|
-
notificationAlertAuthorized: appAuthorizeSetting.notificationAlertAuthorized === 'authorized',
|
|
702
|
+
notificationAlertAuthorized: appAuthorizeSetting.notificationAlertAuthorized === 'authorized',
|
|
435
703
|
/** 允许微信通知带有标记的开关(仅 iOS 有效) */
|
|
436
|
-
notificationBadgeAuthorized: appAuthorizeSetting.notificationBadgeAuthorized === 'authorized',
|
|
704
|
+
notificationBadgeAuthorized: appAuthorizeSetting.notificationBadgeAuthorized === 'authorized',
|
|
437
705
|
/** 允许微信通知带有声音的开关(仅 iOS 有效) */
|
|
438
|
-
notificationSoundAuthorized: appAuthorizeSetting.notificationSoundAuthorized === 'authorized',
|
|
706
|
+
notificationSoundAuthorized: appAuthorizeSetting.notificationSoundAuthorized === 'authorized',
|
|
439
707
|
/** 允许微信使用日历的开关 */
|
|
440
|
-
phoneCalendarAuthorized: appAuthorizeSetting.phoneCalendarAuthorized === 'authorized',
|
|
708
|
+
phoneCalendarAuthorized: appAuthorizeSetting.phoneCalendarAuthorized === 'authorized',
|
|
441
709
|
/** `true` 表示模糊定位,`false` 表示精确定位,仅 iOS 支持 */
|
|
442
|
-
locationReducedAccuracy: appAuthorizeSetting.locationReducedAccuracy,
|
|
710
|
+
locationReducedAccuracy: appAuthorizeSetting.locationReducedAccuracy,
|
|
443
711
|
/** 小程序当前运行环境 */
|
|
444
|
-
environment: ''
|
|
445
|
-
};
|
|
712
|
+
environment: '' });
|
|
446
713
|
return info;
|
|
447
714
|
};
|
|
448
715
|
/** 获取系统信息 */
|
|
449
|
-
const getSystemInfoAsync =
|
|
716
|
+
const getSystemInfoAsync = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
450
717
|
const { success, fail, complete } = options;
|
|
451
718
|
const handle = new MethodHandler({ name: 'getSystemInfoAsync', success, fail, complete });
|
|
452
719
|
try {
|
|
453
|
-
const info =
|
|
720
|
+
const info = yield getSystemInfoSync();
|
|
454
721
|
return handle.success(info);
|
|
455
722
|
}
|
|
456
723
|
catch (error) {
|
|
@@ -458,13 +725,13 @@ const getSystemInfoAsync = async (options = {}) => {
|
|
|
458
725
|
errMsg: error
|
|
459
726
|
});
|
|
460
727
|
}
|
|
461
|
-
};
|
|
728
|
+
});
|
|
462
729
|
/** 获取系统信息 */
|
|
463
|
-
const getSystemInfo =
|
|
730
|
+
const getSystemInfo = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
464
731
|
const { success, fail, complete } = options;
|
|
465
732
|
const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete });
|
|
466
733
|
try {
|
|
467
|
-
const info =
|
|
734
|
+
const info = yield getSystemInfoSync();
|
|
468
735
|
return handle.success(info);
|
|
469
736
|
}
|
|
470
737
|
catch (error) {
|
|
@@ -472,7 +739,7 @@ const getSystemInfo = async (options = {}) => {
|
|
|
472
739
|
errMsg: error
|
|
473
740
|
});
|
|
474
741
|
}
|
|
475
|
-
};
|
|
742
|
+
});
|
|
476
743
|
|
|
477
744
|
// 更新
|
|
478
745
|
const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
|
|
@@ -603,24 +870,26 @@ class CanvasContext {
|
|
|
603
870
|
* 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
|
|
604
871
|
* @todo 每次 draw 都会读取 width 和 height
|
|
605
872
|
*/
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
873
|
+
draw(reserve, callback) {
|
|
874
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
875
|
+
try {
|
|
876
|
+
if (!reserve) {
|
|
877
|
+
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
878
|
+
}
|
|
879
|
+
// 部分 action 是异步的
|
|
880
|
+
for (const { func, args } of this.actions) {
|
|
881
|
+
yield func.apply(this.ctx, args);
|
|
882
|
+
}
|
|
883
|
+
this.emptyActions();
|
|
884
|
+
callback && callback();
|
|
610
885
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
886
|
+
catch (e) {
|
|
887
|
+
/* eslint-disable no-throw-literal */
|
|
888
|
+
throw {
|
|
889
|
+
errMsg: e.message
|
|
890
|
+
};
|
|
614
891
|
}
|
|
615
|
-
|
|
616
|
-
callback && callback();
|
|
617
|
-
}
|
|
618
|
-
catch (e) {
|
|
619
|
-
/* eslint-disable no-throw-literal */
|
|
620
|
-
throw {
|
|
621
|
-
errMsg: e.message
|
|
622
|
-
};
|
|
623
|
-
}
|
|
892
|
+
});
|
|
624
893
|
}
|
|
625
894
|
drawImage(imageResource, ...extra) {
|
|
626
895
|
this.enqueueActions(() => {
|
|
@@ -854,22 +1123,6 @@ const INTERVAL_MAP$1 = {
|
|
|
854
1123
|
frequency: 5
|
|
855
1124
|
}
|
|
856
1125
|
};
|
|
857
|
-
const getDevicemotionListener = interval => {
|
|
858
|
-
let lock;
|
|
859
|
-
let timer;
|
|
860
|
-
return evt => {
|
|
861
|
-
if (lock)
|
|
862
|
-
return;
|
|
863
|
-
lock = true;
|
|
864
|
-
timer && clearTimeout(timer);
|
|
865
|
-
callbackManager$3.trigger({
|
|
866
|
-
x: evt.acceleration.x || 0,
|
|
867
|
-
y: evt.acceleration.y || 0,
|
|
868
|
-
z: evt.acceleration.z || 0
|
|
869
|
-
});
|
|
870
|
-
timer = setTimeout(() => { lock = false; }, interval);
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
1126
|
/**
|
|
874
1127
|
* 开始监听加速度数据。
|
|
875
1128
|
*/
|
|
@@ -881,7 +1134,14 @@ const startAccelerometer = ({ interval = 'normal', success, fail, complete } = {
|
|
|
881
1134
|
if (devicemotionListener) {
|
|
882
1135
|
stopAccelerometer();
|
|
883
1136
|
}
|
|
884
|
-
devicemotionListener =
|
|
1137
|
+
devicemotionListener = throttle((evt) => {
|
|
1138
|
+
var _a, _b, _c;
|
|
1139
|
+
callbackManager$3.trigger({
|
|
1140
|
+
x: ((_a = evt.acceleration) === null || _a === void 0 ? void 0 : _a.x) || 0,
|
|
1141
|
+
y: ((_b = evt.acceleration) === null || _b === void 0 ? void 0 : _b.y) || 0,
|
|
1142
|
+
z: ((_c = evt.acceleration) === null || _c === void 0 ? void 0 : _c.z) || 0
|
|
1143
|
+
});
|
|
1144
|
+
}, intervalObj.interval);
|
|
885
1145
|
window.addEventListener('devicemotion', devicemotionListener, true);
|
|
886
1146
|
}
|
|
887
1147
|
else {
|
|
@@ -911,12 +1171,12 @@ const checkIsOpenAccessibility = temporarilyNotSupport('checkIsOpenAccessibility
|
|
|
911
1171
|
|
|
912
1172
|
// 电量
|
|
913
1173
|
const getBatteryInfoSync = temporarilyNotSupport('getBatteryInfoSync');
|
|
914
|
-
const getBatteryInfo =
|
|
1174
|
+
const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
915
1175
|
var _a;
|
|
916
1176
|
const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
|
|
917
1177
|
try {
|
|
918
1178
|
// @ts-ignore
|
|
919
|
-
const battery =
|
|
1179
|
+
const battery = yield ((_a = navigator.getBattery) === null || _a === void 0 ? void 0 : _a.call(navigator));
|
|
920
1180
|
return handle.success({
|
|
921
1181
|
isCharging: battery.charging,
|
|
922
1182
|
level: Number(battery.level || 0) * 100
|
|
@@ -927,7 +1187,7 @@ const getBatteryInfo = async ({ success, fail, complete } = {}) => {
|
|
|
927
1187
|
errMsg: (error === null || error === void 0 ? void 0 : error.message) || error
|
|
928
1188
|
});
|
|
929
1189
|
}
|
|
930
|
-
};
|
|
1190
|
+
});
|
|
931
1191
|
|
|
932
1192
|
// 蓝牙-通用
|
|
933
1193
|
const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
@@ -1151,7 +1411,7 @@ document.addEventListener('copy', () => {
|
|
|
1151
1411
|
/**
|
|
1152
1412
|
* 设置系统剪贴板的内容
|
|
1153
1413
|
*/
|
|
1154
|
-
const setClipboardData =
|
|
1414
|
+
const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1155
1415
|
const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
|
|
1156
1416
|
try {
|
|
1157
1417
|
setStorageSync(CLIPBOARD_STORAGE_NAME, data);
|
|
@@ -1181,11 +1441,11 @@ const setClipboardData = async ({ data, success, fail, complete }) => {
|
|
|
1181
1441
|
catch (e) {
|
|
1182
1442
|
return handle.fail({ errMsg: e.message });
|
|
1183
1443
|
}
|
|
1184
|
-
};
|
|
1444
|
+
});
|
|
1185
1445
|
/**
|
|
1186
1446
|
* 获取系统剪贴板的内容
|
|
1187
1447
|
*/
|
|
1188
|
-
const getClipboardData =
|
|
1448
|
+
const getClipboardData = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1189
1449
|
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
1190
1450
|
try {
|
|
1191
1451
|
const data = getStorageSync(CLIPBOARD_STORAGE_NAME);
|
|
@@ -1194,49 +1454,61 @@ const getClipboardData = async ({ success, fail, complete } = {}) => {
|
|
|
1194
1454
|
catch (e) {
|
|
1195
1455
|
return handle.fail({ errMsg: e.message });
|
|
1196
1456
|
}
|
|
1197
|
-
};
|
|
1457
|
+
});
|
|
1198
1458
|
|
|
1199
1459
|
const callbackManager$2 = new CallbackManager();
|
|
1200
1460
|
let compassListener;
|
|
1461
|
+
/**
|
|
1462
|
+
* Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation
|
|
1463
|
+
*/
|
|
1464
|
+
const deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {
|
|
1465
|
+
if ('on' + item in window) {
|
|
1466
|
+
return item;
|
|
1467
|
+
}
|
|
1468
|
+
}) || '';
|
|
1201
1469
|
/**
|
|
1202
1470
|
* 停止监听罗盘数据
|
|
1203
1471
|
*/
|
|
1204
1472
|
const stopCompass = ({ success, fail, complete } = {}) => {
|
|
1205
1473
|
const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
|
|
1206
1474
|
try {
|
|
1207
|
-
window.removeEventListener(
|
|
1475
|
+
window.removeEventListener(deviceorientationEventName, compassListener, true);
|
|
1208
1476
|
return handle.success();
|
|
1209
1477
|
}
|
|
1210
1478
|
catch (e) {
|
|
1211
1479
|
return handle.fail({ errMsg: e.message });
|
|
1212
1480
|
}
|
|
1213
1481
|
};
|
|
1214
|
-
|
|
1215
|
-
let lock;
|
|
1216
|
-
let timer;
|
|
1217
|
-
return evt => {
|
|
1218
|
-
if (lock)
|
|
1219
|
-
return;
|
|
1220
|
-
lock = true;
|
|
1221
|
-
timer && clearTimeout(timer);
|
|
1222
|
-
callbackManager$2.trigger({
|
|
1223
|
-
direction: 360 - evt.alpha
|
|
1224
|
-
});
|
|
1225
|
-
timer = setTimeout(() => { lock = false; }, interval);
|
|
1226
|
-
};
|
|
1227
|
-
};
|
|
1482
|
+
let CompassChangeTrigger = false;
|
|
1228
1483
|
/**
|
|
1229
1484
|
* 开始监听罗盘数据
|
|
1230
1485
|
*/
|
|
1231
1486
|
const startCompass = ({ success, fail, complete } = {}) => {
|
|
1232
1487
|
const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
|
|
1233
1488
|
try {
|
|
1234
|
-
if (
|
|
1489
|
+
if (deviceorientationEventName !== '') {
|
|
1235
1490
|
if (compassListener) {
|
|
1236
1491
|
stopCompass();
|
|
1237
1492
|
}
|
|
1238
|
-
compassListener =
|
|
1239
|
-
|
|
1493
|
+
compassListener = throttle((evt) => {
|
|
1494
|
+
const isAndroid = getDeviceInfo().system === 'AndroidOS';
|
|
1495
|
+
if (isAndroid && !evt.absolute && !CompassChangeTrigger) {
|
|
1496
|
+
CompassChangeTrigger = true;
|
|
1497
|
+
console.warn('Warning: In \'onCompassChange\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .');
|
|
1498
|
+
}
|
|
1499
|
+
const alpha = evt.alpha || 0;
|
|
1500
|
+
/**
|
|
1501
|
+
* 由于平台差异,accuracy 在 iOS/Android 的值不同。
|
|
1502
|
+
* - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。
|
|
1503
|
+
* - Android:accuracy 是一个 string 类型的枚举值。
|
|
1504
|
+
*/
|
|
1505
|
+
const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha;
|
|
1506
|
+
callbackManager$2.trigger({
|
|
1507
|
+
direction: 360 - alpha,
|
|
1508
|
+
accuracy: accuracy
|
|
1509
|
+
});
|
|
1510
|
+
}, 5000);
|
|
1511
|
+
window.addEventListener(deviceorientationEventName, compassListener, true);
|
|
1240
1512
|
}
|
|
1241
1513
|
else {
|
|
1242
1514
|
throw new Error('compass is not supported');
|
|
@@ -1321,22 +1593,6 @@ const stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
|
|
|
1321
1593
|
return handle.fail({ errMsg: e.message });
|
|
1322
1594
|
}
|
|
1323
1595
|
};
|
|
1324
|
-
const getDeviceOrientationListener = interval => {
|
|
1325
|
-
let lock;
|
|
1326
|
-
let timer;
|
|
1327
|
-
return evt => {
|
|
1328
|
-
if (lock)
|
|
1329
|
-
return;
|
|
1330
|
-
lock = true;
|
|
1331
|
-
timer && clearTimeout(timer);
|
|
1332
|
-
callbackManager$1.trigger({
|
|
1333
|
-
alpha: evt.alpha,
|
|
1334
|
-
beta: evt.beta,
|
|
1335
|
-
gamma: evt.gamma
|
|
1336
|
-
});
|
|
1337
|
-
timer = setTimeout(() => { lock = false; }, interval);
|
|
1338
|
-
};
|
|
1339
|
-
};
|
|
1340
1596
|
/**
|
|
1341
1597
|
* 开始监听设备方向的变化。
|
|
1342
1598
|
*/
|
|
@@ -1348,7 +1604,13 @@ const startDeviceMotionListening = ({ interval = 'normal', success, fail, comple
|
|
|
1348
1604
|
if (deviceMotionListener) {
|
|
1349
1605
|
stopDeviceMotionListening();
|
|
1350
1606
|
}
|
|
1351
|
-
deviceMotionListener =
|
|
1607
|
+
deviceMotionListener = throttle((evt) => {
|
|
1608
|
+
callbackManager$1.trigger({
|
|
1609
|
+
alpha: evt.alpha,
|
|
1610
|
+
beta: evt.beta,
|
|
1611
|
+
gamma: evt.gamma
|
|
1612
|
+
});
|
|
1613
|
+
}, intervalObj.interval);
|
|
1352
1614
|
window.addEventListener('deviceorientation', deviceMotionListener, true);
|
|
1353
1615
|
}
|
|
1354
1616
|
else {
|
|
@@ -1419,12 +1681,12 @@ const getNetworkType = (options = {}) => {
|
|
|
1419
1681
|
return handle.success({ networkType });
|
|
1420
1682
|
};
|
|
1421
1683
|
const networkStatusManager = new CallbackManager();
|
|
1422
|
-
const networkStatusListener =
|
|
1423
|
-
const { networkType } =
|
|
1684
|
+
const networkStatusListener = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1685
|
+
const { networkType } = yield getNetworkType();
|
|
1424
1686
|
const isConnected = networkType !== 'none';
|
|
1425
1687
|
const obj = { isConnected, networkType };
|
|
1426
1688
|
networkStatusManager.trigger(obj);
|
|
1427
|
-
};
|
|
1689
|
+
});
|
|
1428
1690
|
/**
|
|
1429
1691
|
* 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
|
|
1430
1692
|
* - 出现三次以上连接超时
|
|
@@ -1664,14 +1926,8 @@ styleInject(css_248z,{"insertAt":"top"});
|
|
|
1664
1926
|
|
|
1665
1927
|
function createLocationChooser(handler, key = LOCATION_APIKEY, mapOpt = {}) {
|
|
1666
1928
|
var _a, _b, _c;
|
|
1667
|
-
const { latitude, longitude,
|
|
1668
|
-
const query = {
|
|
1669
|
-
key,
|
|
1670
|
-
type: 1,
|
|
1671
|
-
coord: ((_a = mapOpt.coord) !== null && _a !== void 0 ? _a : [latitude, longitude].every(e => Number(e) >= 0)) ? `${latitude},${longitude}` : undefined,
|
|
1672
|
-
referer: 'myapp',
|
|
1673
|
-
...opts
|
|
1674
|
-
};
|
|
1929
|
+
const { latitude, longitude } = mapOpt, opts = __rest(mapOpt, ["latitude", "longitude"]);
|
|
1930
|
+
const query = Object.assign({ key, type: 1, coord: ((_a = mapOpt.coord) !== null && _a !== void 0 ? _a : [latitude, longitude].every(e => Number(e) >= 0)) ? `${latitude},${longitude}` : undefined, referer: 'myapp' }, opts);
|
|
1675
1931
|
const html = `
|
|
1676
1932
|
<div class='taro_choose_location'>
|
|
1677
1933
|
<div class='taro_choose_location_bar'>
|
|
@@ -1980,7 +2236,7 @@ const createCameraContext = temporarilyNotSupport('createCameraContext');
|
|
|
1980
2236
|
/**
|
|
1981
2237
|
* 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
|
|
1982
2238
|
*/
|
|
1983
|
-
const previewImage =
|
|
2239
|
+
const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1984
2240
|
function loadImage(url, loadFail) {
|
|
1985
2241
|
return new Promise((resolve) => {
|
|
1986
2242
|
const item = document.createElement('taro-swiper-item-core');
|
|
@@ -2021,7 +2277,7 @@ const previewImage = async (options) => {
|
|
|
2021
2277
|
swiper.full = true;
|
|
2022
2278
|
let children = [];
|
|
2023
2279
|
try {
|
|
2024
|
-
children =
|
|
2280
|
+
children = yield Promise.all(urls.map(e => loadImage(e, fail)));
|
|
2025
2281
|
}
|
|
2026
2282
|
catch (error) {
|
|
2027
2283
|
return handle.fail({
|
|
@@ -2038,7 +2294,7 @@ const previewImage = async (options) => {
|
|
|
2038
2294
|
container.appendChild(swiper);
|
|
2039
2295
|
document.body.appendChild(container);
|
|
2040
2296
|
return handle.success();
|
|
2041
|
-
};
|
|
2297
|
+
});
|
|
2042
2298
|
|
|
2043
2299
|
/**
|
|
2044
2300
|
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
@@ -3290,7 +3546,7 @@ const setBackgroundColor = temporarilyNotSupport('setBackgroundColor');
|
|
|
3290
3546
|
const nextTick = Taro__default["default"].nextTick;
|
|
3291
3547
|
|
|
3292
3548
|
// 字体
|
|
3293
|
-
const loadFontFace =
|
|
3549
|
+
const loadFontFace = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3294
3550
|
options = Object.assign({ global: false }, options);
|
|
3295
3551
|
const { success, fail, complete, family, source, desc = {} } = options;
|
|
3296
3552
|
const handle = new MethodHandler({ name: 'loadFontFace', success, fail, complete });
|
|
@@ -3300,7 +3556,7 @@ const loadFontFace = async (options) => {
|
|
|
3300
3556
|
// @ts-ignore
|
|
3301
3557
|
const fontFace = new FontFace(family, source, desc);
|
|
3302
3558
|
try {
|
|
3303
|
-
|
|
3559
|
+
yield fontFace.load();
|
|
3304
3560
|
fonts.add(fontFace);
|
|
3305
3561
|
return handle.success({});
|
|
3306
3562
|
}
|
|
@@ -3338,7 +3594,7 @@ const loadFontFace = async (options) => {
|
|
|
3338
3594
|
document.head.appendChild(style);
|
|
3339
3595
|
return handle.success();
|
|
3340
3596
|
}
|
|
3341
|
-
};
|
|
3597
|
+
});
|
|
3342
3598
|
|
|
3343
3599
|
// 菜单
|
|
3344
3600
|
const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect');
|
|
@@ -3882,11 +4138,7 @@ class Toast {
|
|
|
3882
4138
|
// style
|
|
3883
4139
|
const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
|
|
3884
4140
|
// configuration
|
|
3885
|
-
const config = {
|
|
3886
|
-
...this.options,
|
|
3887
|
-
...options,
|
|
3888
|
-
_type
|
|
3889
|
-
};
|
|
4141
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
|
|
3890
4142
|
// wrapper
|
|
3891
4143
|
this.el = document.createElement('div');
|
|
3892
4144
|
this.el.className = 'taro__toast';
|
|
@@ -3899,27 +4151,18 @@ class Toast {
|
|
|
3899
4151
|
// icon
|
|
3900
4152
|
this.icon = document.createElement('p');
|
|
3901
4153
|
if (config.image) {
|
|
3902
|
-
this.icon.setAttribute('style', inlineStyle({
|
|
3903
|
-
...imageStyle,
|
|
3904
|
-
'background-image': `url(${config.image})`
|
|
3905
|
-
}));
|
|
4154
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
3906
4155
|
}
|
|
3907
4156
|
else {
|
|
3908
4157
|
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
3909
|
-
this.icon.setAttribute('style', inlineStyle({
|
|
3910
|
-
...iconStyle,
|
|
3911
|
-
...(config.icon === 'none' ? { display: 'none' } : {})
|
|
3912
|
-
}));
|
|
4158
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
3913
4159
|
}
|
|
3914
4160
|
// toast
|
|
3915
4161
|
this.toast = document.createElement('div');
|
|
3916
|
-
this.toast.setAttribute('style', inlineStyle({
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
padding: '10px 15px'
|
|
3921
|
-
} : {})
|
|
3922
|
-
}));
|
|
4162
|
+
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
4163
|
+
'min-height': '0',
|
|
4164
|
+
padding: '10px 15px'
|
|
4165
|
+
} : {}))));
|
|
3923
4166
|
// title
|
|
3924
4167
|
this.title = document.createElement('p');
|
|
3925
4168
|
this.title.setAttribute('style', inlineStyle(textStyle));
|
|
@@ -3938,11 +4181,7 @@ class Toast {
|
|
|
3938
4181
|
return '';
|
|
3939
4182
|
}
|
|
3940
4183
|
show(options = {}, _type = 'toast') {
|
|
3941
|
-
const config = {
|
|
3942
|
-
...this.options,
|
|
3943
|
-
...options,
|
|
3944
|
-
_type
|
|
3945
|
-
};
|
|
4184
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
|
|
3946
4185
|
if (this.hideOpacityTimer)
|
|
3947
4186
|
clearTimeout(this.hideOpacityTimer);
|
|
3948
4187
|
if (this.hideDisplayTimer)
|
|
@@ -3954,28 +4193,19 @@ class Toast {
|
|
|
3954
4193
|
// image
|
|
3955
4194
|
const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style;
|
|
3956
4195
|
if (config.image) {
|
|
3957
|
-
this.icon.setAttribute('style', inlineStyle({
|
|
3958
|
-
...imageStyle,
|
|
3959
|
-
'background-image': `url(${config.image})`
|
|
3960
|
-
}));
|
|
4196
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
3961
4197
|
}
|
|
3962
4198
|
else {
|
|
3963
4199
|
if (!config.image && config.icon) {
|
|
3964
4200
|
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
3965
|
-
this.icon.setAttribute('style', inlineStyle({
|
|
3966
|
-
...iconStyle,
|
|
3967
|
-
...(config.icon === 'none' ? { display: 'none' } : {})
|
|
3968
|
-
}));
|
|
4201
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
3969
4202
|
}
|
|
3970
4203
|
}
|
|
3971
4204
|
// toast
|
|
3972
|
-
this.toast.setAttribute('style', inlineStyle({
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
padding: '10px 15px'
|
|
3977
|
-
} : {})
|
|
3978
|
-
}));
|
|
4205
|
+
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
4206
|
+
'min-height': '0',
|
|
4207
|
+
padding: '10px 15px'
|
|
4208
|
+
} : {}))));
|
|
3979
4209
|
// show
|
|
3980
4210
|
this.el.style.display = 'block';
|
|
3981
4211
|
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
@@ -4063,10 +4293,7 @@ class Modal {
|
|
|
4063
4293
|
// style
|
|
4064
4294
|
const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
|
|
4065
4295
|
// configuration
|
|
4066
|
-
const config = {
|
|
4067
|
-
...this.options,
|
|
4068
|
-
...options
|
|
4069
|
-
};
|
|
4296
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
4070
4297
|
// wrapper
|
|
4071
4298
|
this.el = document.createElement('div');
|
|
4072
4299
|
this.el.className = 'taro__modal';
|
|
@@ -4081,20 +4308,13 @@ class Modal {
|
|
|
4081
4308
|
modal.className = 'taro-modal__content';
|
|
4082
4309
|
modal.setAttribute('style', inlineStyle(modalStyle));
|
|
4083
4310
|
// title
|
|
4084
|
-
const titleCSS = config.title ? titleStyle : {
|
|
4085
|
-
...titleStyle,
|
|
4086
|
-
display: 'none'
|
|
4087
|
-
};
|
|
4311
|
+
const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
|
|
4088
4312
|
this.title = document.createElement('div');
|
|
4089
4313
|
this.title.className = 'taro-modal__title';
|
|
4090
4314
|
this.title.setAttribute('style', inlineStyle(titleCSS));
|
|
4091
4315
|
this.title.textContent = config.title;
|
|
4092
4316
|
// text
|
|
4093
|
-
const textCSS = config.title ? textStyle : {
|
|
4094
|
-
...textStyle,
|
|
4095
|
-
padding: '40px 20px 26px',
|
|
4096
|
-
color: '#353535'
|
|
4097
|
-
};
|
|
4317
|
+
const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
4098
4318
|
this.text = document.createElement('div');
|
|
4099
4319
|
this.text.className = 'taro-modal__text';
|
|
4100
4320
|
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
@@ -4104,11 +4324,7 @@ class Modal {
|
|
|
4104
4324
|
foot.className = 'taro-modal__foot';
|
|
4105
4325
|
foot.setAttribute('style', inlineStyle(footStyle));
|
|
4106
4326
|
// cancel button
|
|
4107
|
-
const cancelCSS = {
|
|
4108
|
-
...btnStyle,
|
|
4109
|
-
color: config.cancelColor,
|
|
4110
|
-
display: config.showCancel ? 'block' : 'none'
|
|
4111
|
-
};
|
|
4327
|
+
const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
|
|
4112
4328
|
this.cancel = document.createElement('div');
|
|
4113
4329
|
this.cancel.className = 'taro-model__btn taro-model__cancel';
|
|
4114
4330
|
this.cancel.setAttribute('style', inlineStyle(cancelCSS));
|
|
@@ -4142,10 +4358,7 @@ class Modal {
|
|
|
4142
4358
|
}
|
|
4143
4359
|
show(options = {}) {
|
|
4144
4360
|
return new Promise((resolve) => {
|
|
4145
|
-
const config = {
|
|
4146
|
-
...this.options,
|
|
4147
|
-
...options
|
|
4148
|
-
};
|
|
4361
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
4149
4362
|
if (this.hideOpacityTimer)
|
|
4150
4363
|
clearTimeout(this.hideOpacityTimer);
|
|
4151
4364
|
if (this.hideDisplayTimer)
|
|
@@ -4161,11 +4374,7 @@ class Modal {
|
|
|
4161
4374
|
else {
|
|
4162
4375
|
// block => none
|
|
4163
4376
|
this.title.style.display = 'none';
|
|
4164
|
-
const textCSS = {
|
|
4165
|
-
...textStyle,
|
|
4166
|
-
padding: '40px 20px 26px',
|
|
4167
|
-
color: '#353535'
|
|
4168
|
-
};
|
|
4377
|
+
const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
4169
4378
|
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
4170
4379
|
}
|
|
4171
4380
|
this.text.textContent = config.content || '';
|
|
@@ -4263,10 +4472,7 @@ class ActionSheet {
|
|
|
4263
4472
|
// style
|
|
4264
4473
|
const { maskStyle, actionSheetStyle, menuStyle, cellStyle, cancelStyle } = this.style;
|
|
4265
4474
|
// configuration
|
|
4266
|
-
const config = {
|
|
4267
|
-
...this.options,
|
|
4268
|
-
...options
|
|
4269
|
-
};
|
|
4475
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
4270
4476
|
this.lastConfig = config;
|
|
4271
4477
|
// wrapper
|
|
4272
4478
|
this.el = document.createElement('div');
|
|
@@ -4281,10 +4487,7 @@ class ActionSheet {
|
|
|
4281
4487
|
this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
|
|
4282
4488
|
// menu
|
|
4283
4489
|
this.menu = document.createElement('div');
|
|
4284
|
-
this.menu.setAttribute('style', inlineStyle({
|
|
4285
|
-
...menuStyle,
|
|
4286
|
-
color: config.itemColor
|
|
4287
|
-
}));
|
|
4490
|
+
this.menu.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, menuStyle), { color: config.itemColor })));
|
|
4288
4491
|
// cells
|
|
4289
4492
|
this.cells = config.itemList.map((item, index) => {
|
|
4290
4493
|
const cell = document.createElement('div');
|
|
@@ -4327,10 +4530,7 @@ class ActionSheet {
|
|
|
4327
4530
|
}
|
|
4328
4531
|
show(options = {}) {
|
|
4329
4532
|
return new Promise((resolve) => {
|
|
4330
|
-
const config = {
|
|
4331
|
-
...this.options,
|
|
4332
|
-
...options
|
|
4333
|
-
};
|
|
4533
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
4334
4534
|
this.lastConfig = config;
|
|
4335
4535
|
if (this.hideOpacityTimer)
|
|
4336
4536
|
clearTimeout(this.hideOpacityTimer);
|
|
@@ -4495,7 +4695,7 @@ const hideLoading = ({ success, fail, complete } = {}) => {
|
|
|
4495
4695
|
toast.hide(0, 'loading');
|
|
4496
4696
|
return handle.success();
|
|
4497
4697
|
};
|
|
4498
|
-
const showModal =
|
|
4698
|
+
const showModal = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4499
4699
|
init(document);
|
|
4500
4700
|
options = Object.assign({
|
|
4501
4701
|
title: '',
|
|
@@ -4575,21 +4775,21 @@ const showModal = async (options = {}) => {
|
|
|
4575
4775
|
options.showCancel = !!options.showCancel;
|
|
4576
4776
|
let result = '';
|
|
4577
4777
|
if (!modal.el) {
|
|
4578
|
-
result =
|
|
4778
|
+
result = yield modal.create(options);
|
|
4579
4779
|
}
|
|
4580
4780
|
else {
|
|
4581
|
-
result =
|
|
4781
|
+
result = yield modal.show(options);
|
|
4582
4782
|
}
|
|
4583
4783
|
const res = { cancel: !1, confirm: !1 };
|
|
4584
4784
|
res[result] = !0;
|
|
4585
4785
|
return handle.success(res);
|
|
4586
|
-
};
|
|
4786
|
+
});
|
|
4587
4787
|
function hideModal() {
|
|
4588
4788
|
if (!modal.el)
|
|
4589
4789
|
return;
|
|
4590
4790
|
modal.hide();
|
|
4591
4791
|
}
|
|
4592
|
-
const showActionSheet =
|
|
4792
|
+
const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4593
4793
|
init(document);
|
|
4594
4794
|
options = Object.assign({
|
|
4595
4795
|
itemColor: '#000000',
|
|
@@ -4635,10 +4835,10 @@ const showActionSheet = async (options = { itemList: [] }) => {
|
|
|
4635
4835
|
}
|
|
4636
4836
|
let result = '';
|
|
4637
4837
|
if (!actionSheet.el) {
|
|
4638
|
-
result =
|
|
4838
|
+
result = yield actionSheet.create(options);
|
|
4639
4839
|
}
|
|
4640
4840
|
else {
|
|
4641
|
-
result =
|
|
4841
|
+
result = yield actionSheet.show(options);
|
|
4642
4842
|
}
|
|
4643
4843
|
if (typeof result === 'string') {
|
|
4644
4844
|
return handle.fail(({ errMsg: result }));
|
|
@@ -4646,7 +4846,7 @@ const showActionSheet = async (options = { itemList: [] }) => {
|
|
|
4646
4846
|
else {
|
|
4647
4847
|
return handle.success(({ tapIndex: result }));
|
|
4648
4848
|
}
|
|
4649
|
-
};
|
|
4849
|
+
});
|
|
4650
4850
|
Taro__default["default"].eventCenter.on('__taroRouterChange', () => {
|
|
4651
4851
|
hideToast();
|
|
4652
4852
|
hideLoading();
|
|
@@ -4950,7 +5150,6 @@ const taro = {
|
|
|
4950
5150
|
Events,
|
|
4951
5151
|
preload,
|
|
4952
5152
|
history: router.history,
|
|
4953
|
-
createRouter: router.createRouter,
|
|
4954
5153
|
navigateBack: router.navigateBack,
|
|
4955
5154
|
navigateTo: router.navigateTo,
|
|
4956
5155
|
reLaunch: router.reLaunch,
|
|
@@ -4976,10 +5175,6 @@ taro.initPxTransform = initPxTransform;
|
|
|
4976
5175
|
// @ts-ignore
|
|
4977
5176
|
taro.canIUseWebp = canIUseWebp;
|
|
4978
5177
|
|
|
4979
|
-
Object.defineProperty(exports, 'createRouter', {
|
|
4980
|
-
enumerable: true,
|
|
4981
|
-
get: function () { return router.createRouter; }
|
|
4982
|
-
});
|
|
4983
5178
|
Object.defineProperty(exports, 'getCurrentPages', {
|
|
4984
5179
|
enumerable: true,
|
|
4985
5180
|
get: function () { return router.getCurrentPages; }
|