@dcloudio/uni-shared 3.0.0-4080720251210001 → 3.0.0-5000420260317001
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/uni-shared.cjs.js +959 -114
- package/dist/uni-shared.d.ts +151 -5
- package/dist/uni-shared.es.js +945 -119
- package/package.json +1 -1
package/dist/uni-shared.cjs.js
CHANGED
|
@@ -123,7 +123,10 @@ const UVUE_BUILT_IN_TAGS = [
|
|
|
123
123
|
'list-item',
|
|
124
124
|
'swiper',
|
|
125
125
|
'swiper-item',
|
|
126
|
-
|
|
126
|
+
// 已经交由 vue 实现
|
|
127
|
+
// 'rich-text',
|
|
128
|
+
// android 平台 type=native 时原生实现
|
|
129
|
+
'rich-text-native',
|
|
127
130
|
'sticky-view',
|
|
128
131
|
'sticky-header',
|
|
129
132
|
'sticky-section',
|
|
@@ -153,11 +156,22 @@ const UVUE_BUILT_IN_TAGS = [
|
|
|
153
156
|
// 'radio-group',
|
|
154
157
|
];
|
|
155
158
|
const UVUE_WEB_BUILT_IN_TAGS = [
|
|
159
|
+
'page-container',
|
|
160
|
+
'list-view',
|
|
161
|
+
'list-item',
|
|
162
|
+
'sticky-section',
|
|
163
|
+
'sticky-header',
|
|
164
|
+
'cloud-db-element',
|
|
165
|
+
'loading-element',
|
|
166
|
+
'loading'
|
|
167
|
+
].map((tag) => 'uni-' + tag);
|
|
168
|
+
const UVUE_MP_BUILT_IN_TAGS = [
|
|
156
169
|
'list-view',
|
|
157
170
|
'list-item',
|
|
158
171
|
'sticky-section',
|
|
159
172
|
'sticky-header',
|
|
160
173
|
'cloud-db-element',
|
|
174
|
+
'loading-element',
|
|
161
175
|
].map((tag) => 'uni-' + tag);
|
|
162
176
|
const UVUE_IOS_BUILT_IN_TAGS = [
|
|
163
177
|
'scroll-view',
|
|
@@ -195,6 +209,26 @@ function isBuiltInComponent(tag) {
|
|
|
195
209
|
return (BUILT_IN_TAGS.indexOf(realTag) !== -1 ||
|
|
196
210
|
UVUE_WEB_BUILT_IN_TAGS.indexOf(realTag) !== -1);
|
|
197
211
|
}
|
|
212
|
+
function isWebBuiltInComponent(tag) {
|
|
213
|
+
if (UNI_UI_CONFLICT_TAGS.indexOf(tag) !== -1) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
// h5 平台会被转换为 v-uni-
|
|
217
|
+
const realTag = 'uni-' + tag.replace('v-uni-', '');
|
|
218
|
+
// TODO 区分x和非x
|
|
219
|
+
return (BUILT_IN_TAGS.indexOf(realTag) !== -1 ||
|
|
220
|
+
UVUE_WEB_BUILT_IN_TAGS.indexOf(realTag) !== -1);
|
|
221
|
+
}
|
|
222
|
+
function isMPBuiltInComponent(tag) {
|
|
223
|
+
if (UNI_UI_CONFLICT_TAGS.indexOf(tag) !== -1) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
// h5 平台会被转换为 v-uni-
|
|
227
|
+
const realTag = 'uni-' + tag.replace('v-uni-', '');
|
|
228
|
+
// TODO 区分x和非x
|
|
229
|
+
return (BUILT_IN_TAGS.indexOf(realTag) !== -1 ||
|
|
230
|
+
UVUE_MP_BUILT_IN_TAGS.indexOf(realTag) !== -1);
|
|
231
|
+
}
|
|
198
232
|
function isH5CustomElement(tag, isX = false) {
|
|
199
233
|
if (isX && UVUE_WEB_BUILT_IN_TAGS.indexOf(tag) !== -1) {
|
|
200
234
|
return true;
|
|
@@ -207,7 +241,7 @@ function isUniXElement(name) {
|
|
|
207
241
|
function isH5NativeTag(tag) {
|
|
208
242
|
return (tag !== 'head' &&
|
|
209
243
|
(shared.isHTMLTag(tag) || shared.isSVGTag(tag)) &&
|
|
210
|
-
!
|
|
244
|
+
!isWebBuiltInComponent(tag));
|
|
211
245
|
}
|
|
212
246
|
function isAppNativeTag(tag) {
|
|
213
247
|
return shared.isHTMLTag(tag) || shared.isSVGTag(tag) || isBuiltInComponent(tag);
|
|
@@ -243,6 +277,10 @@ const UVUE_BUILT_IN_EASY_COMPONENTS = [
|
|
|
243
277
|
'camera',
|
|
244
278
|
'live-player',
|
|
245
279
|
'live-pusher',
|
|
280
|
+
'loading',
|
|
281
|
+
'web-view',
|
|
282
|
+
'rich-text',
|
|
283
|
+
'page-container',
|
|
246
284
|
];
|
|
247
285
|
function isAppUVueBuiltInEasyComponent(tag) {
|
|
248
286
|
return UVUE_BUILT_IN_EASY_COMPONENTS.includes(tag);
|
|
@@ -272,11 +310,19 @@ function isAppUVueNativeTag(tag) {
|
|
|
272
310
|
}
|
|
273
311
|
return false;
|
|
274
312
|
}
|
|
313
|
+
// dom1 ios端 vue 实现的组件
|
|
314
|
+
const IOS_DOM1_VUE_COMPONENTS = ['match-media'];
|
|
275
315
|
function isAppIOSUVueNativeTag(tag) {
|
|
276
316
|
// 前端实现的内置组件都会注册一个根组件
|
|
277
317
|
if (tag.startsWith('uni-') && tag.endsWith('-element')) {
|
|
278
318
|
return true;
|
|
279
319
|
}
|
|
320
|
+
if (IOS_DOM1_VUE_COMPONENTS.includes(tag)) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (UVUE_BUILT_IN_EASY_COMPONENTS.includes(tag)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
280
326
|
if (NVUE_BUILT_IN_TAGS.includes(tag)) {
|
|
281
327
|
return true;
|
|
282
328
|
}
|
|
@@ -304,9 +350,15 @@ function isAppIOSUVueNativeTag(tag) {
|
|
|
304
350
|
}
|
|
305
351
|
return false;
|
|
306
352
|
}
|
|
353
|
+
const UVUE_BUILT_IN_EASY_COMPONENTS_HARMONY = [
|
|
354
|
+
'video',
|
|
355
|
+
'map',
|
|
356
|
+
'loading',
|
|
357
|
+
'rich-text',
|
|
358
|
+
];
|
|
307
359
|
function isAppHarmonyUVueNativeTag(tag) {
|
|
308
360
|
// video 目前是easycom实现的
|
|
309
|
-
if (tag
|
|
361
|
+
if (UVUE_BUILT_IN_EASY_COMPONENTS_HARMONY.includes(tag)) {
|
|
310
362
|
return false;
|
|
311
363
|
}
|
|
312
364
|
// 前端实现的内置组件都会注册一个根组件
|
|
@@ -348,7 +400,7 @@ function isMiniProgramUVueNativeTag(tag) {
|
|
|
348
400
|
if (tag.startsWith('uni-') && tag.endsWith('-element')) {
|
|
349
401
|
return true;
|
|
350
402
|
}
|
|
351
|
-
return
|
|
403
|
+
return isMPBuiltInComponent(tag);
|
|
352
404
|
}
|
|
353
405
|
function createIsCustomElement(tags = []) {
|
|
354
406
|
return function isCustomElement(tag) {
|
|
@@ -415,6 +467,11 @@ const ON_UNLOAD = 'onUnload';
|
|
|
415
467
|
const ON_INIT = 'onInit';
|
|
416
468
|
// 微信特有
|
|
417
469
|
const ON_SAVE_EXIT_STATE = 'onSaveExitState';
|
|
470
|
+
// 抖音特有
|
|
471
|
+
const ON_UPLOAD_DOUYIN_VIDEO = 'onUploadDouyinVideo';
|
|
472
|
+
const ON_LIVE_MOUNT = 'onLiveMount';
|
|
473
|
+
// 支付宝特有
|
|
474
|
+
const ON_TITLE_CLICK = 'onTitleClick';
|
|
418
475
|
const ON_RESIZE = 'onResize';
|
|
419
476
|
const ON_BACK_PRESS = 'onBackPress';
|
|
420
477
|
const ON_PAGE_SCROLL = 'onPageScroll';
|
|
@@ -423,6 +480,7 @@ const ON_REACH_BOTTOM = 'onReachBottom';
|
|
|
423
480
|
const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
|
|
424
481
|
const ON_SHARE_TIMELINE = 'onShareTimeline';
|
|
425
482
|
const ON_SHARE_CHAT = 'onShareChat'; // xhs-share
|
|
483
|
+
const ON_COPY_URL = 'onCopyUrl';
|
|
426
484
|
const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
|
|
427
485
|
const ON_SHARE_APP_MESSAGE = 'onShareAppMessage';
|
|
428
486
|
// navigationBar
|
|
@@ -442,146 +500,681 @@ const VIRTUAL_HOST_STYLE = 'virtualHostStyle';
|
|
|
442
500
|
const VIRTUAL_HOST_CLASS = 'virtualHostClass';
|
|
443
501
|
const VIRTUAL_HOST_HIDDEN = 'virtualHostHidden';
|
|
444
502
|
const VIRTUAL_HOST_ID = 'virtualHostId';
|
|
503
|
+
// statusBarHeight
|
|
504
|
+
const UNI_STATUS_BAR_HEIGHT = 'u_s_b_h';
|
|
445
505
|
|
|
446
|
-
function
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
};
|
|
506
|
+
function arrayPop(array) {
|
|
507
|
+
if (array.length === 0) {
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
return array.pop();
|
|
452
511
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
512
|
+
function arrayShift(array) {
|
|
513
|
+
if (array.length === 0) {
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
return array.shift();
|
|
455
517
|
}
|
|
456
|
-
function
|
|
457
|
-
|
|
518
|
+
function arrayFind(array, predicate) {
|
|
519
|
+
const index = array.findIndex(predicate);
|
|
520
|
+
if (index < 0) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
return array[index];
|
|
458
524
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
525
|
+
function arrayFindLast(array, predicate) {
|
|
526
|
+
const index = array.findLastIndex(predicate);
|
|
527
|
+
if (index < 0) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
return array[index];
|
|
461
531
|
}
|
|
462
|
-
function
|
|
463
|
-
|
|
532
|
+
function arrayAt(array, index) {
|
|
533
|
+
if (index < -array.length || index >= array.length) {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
return array.at(index);
|
|
464
537
|
}
|
|
465
|
-
|
|
466
|
-
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* copy from @uts/shared
|
|
541
|
+
*/
|
|
542
|
+
const UTS_CLASS_METADATA_KIND_LIST = [0, 1, 2];
|
|
543
|
+
|
|
544
|
+
function getType(val) {
|
|
545
|
+
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
|
|
467
546
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
ret = fns[i](arg);
|
|
547
|
+
function isPlainObject(val) {
|
|
548
|
+
if (val == null || typeof val !== 'object') {
|
|
549
|
+
return false;
|
|
472
550
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
551
|
+
const proto = Object.getPrototypeOf(val);
|
|
552
|
+
return proto === Object.prototype || proto === null;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// TODO 实现UTSError
|
|
556
|
+
class UTSError extends Error {
|
|
557
|
+
constructor(message) {
|
|
558
|
+
super(message);
|
|
478
559
|
}
|
|
479
560
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
return (
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
fn = null;
|
|
486
|
-
}
|
|
487
|
-
return res;
|
|
488
|
-
});
|
|
561
|
+
|
|
562
|
+
function isUTSMetadata(metadata) {
|
|
563
|
+
return !!(metadata &&
|
|
564
|
+
UTS_CLASS_METADATA_KIND_LIST.includes(metadata.kind) &&
|
|
565
|
+
metadata.interfaces);
|
|
489
566
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
567
|
+
function isNativeType(proto) {
|
|
568
|
+
return !proto || proto === Object.prototype;
|
|
569
|
+
}
|
|
570
|
+
const utsMetadataKey = "$UTSMetadata$" /* IDENTIFIER.UTS_METADATA */;
|
|
571
|
+
/**
|
|
572
|
+
* 处理复杂的继承关系。
|
|
573
|
+
* 例如:
|
|
574
|
+
* class A extends abstract class B,abstract class B implements interface C
|
|
575
|
+
* new A() instanceof C -> true
|
|
576
|
+
*/
|
|
577
|
+
function getParentTypeList(type) {
|
|
578
|
+
const metadata = utsMetadataKey in type ? type[utsMetadataKey] : {};
|
|
579
|
+
let interfaces = [];
|
|
580
|
+
if (!isUTSMetadata(metadata)) {
|
|
581
|
+
interfaces = [];
|
|
495
582
|
}
|
|
496
583
|
else {
|
|
497
|
-
|
|
498
|
-
'-' +
|
|
499
|
-
_completeValue(date.getMonth() + 1) +
|
|
500
|
-
'-' +
|
|
501
|
-
_completeValue(date.getDate()));
|
|
584
|
+
interfaces = metadata.interfaces || [];
|
|
502
585
|
}
|
|
586
|
+
const proto = Object.getPrototypeOf(type);
|
|
587
|
+
if (!isNativeType(proto)) {
|
|
588
|
+
interfaces.push(proto.constructor);
|
|
589
|
+
}
|
|
590
|
+
return interfaces;
|
|
503
591
|
}
|
|
504
|
-
function
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
592
|
+
function isImplementationOf(leftType, rightType, visited = []) {
|
|
593
|
+
if (isNativeType(leftType)) {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
if (leftType === rightType) {
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
599
|
+
visited.push(leftType);
|
|
600
|
+
const parentTypeList = getParentTypeList(leftType);
|
|
601
|
+
return parentTypeList.some((parentType) => {
|
|
602
|
+
if (visited.includes(parentType)) {
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
return isImplementationOf(parentType, rightType, visited);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
function isInstanceOf(value, type) {
|
|
609
|
+
if (type === UTSValueIterable) {
|
|
610
|
+
return value && value[Symbol.iterator];
|
|
611
|
+
}
|
|
612
|
+
const isNativeInstanceofType = value instanceof type;
|
|
613
|
+
if (isNativeInstanceofType || typeof value !== 'object' || value === null) {
|
|
614
|
+
return isNativeInstanceofType;
|
|
615
|
+
}
|
|
616
|
+
const proto = Object.getPrototypeOf(value).constructor;
|
|
617
|
+
return isImplementationOf(proto, type);
|
|
618
|
+
}
|
|
619
|
+
function isBaseType(type) {
|
|
620
|
+
return type === Number || type === String || type === Boolean;
|
|
621
|
+
}
|
|
622
|
+
function isUnknownType(type) {
|
|
623
|
+
return type === 'Unknown';
|
|
624
|
+
}
|
|
625
|
+
function isAnyType(type) {
|
|
626
|
+
return type === 'Any';
|
|
627
|
+
}
|
|
628
|
+
function isUTSType(type) {
|
|
629
|
+
return type && type.prototype && type.prototype instanceof UTSType;
|
|
630
|
+
}
|
|
631
|
+
function normalizeGenericValue(value, genericType, isJSONParse = false) {
|
|
632
|
+
return value == null
|
|
633
|
+
? null
|
|
634
|
+
: isBaseType(genericType) ||
|
|
635
|
+
isUnknownType(genericType) ||
|
|
636
|
+
isAnyType(genericType)
|
|
637
|
+
? value
|
|
638
|
+
: genericType === Array
|
|
639
|
+
? new Array(...value)
|
|
640
|
+
: new genericType(value, undefined, isJSONParse);
|
|
641
|
+
}
|
|
642
|
+
class UTSType {
|
|
643
|
+
static get$UTSMetadata$(...args) {
|
|
644
|
+
return {
|
|
645
|
+
name: '',
|
|
646
|
+
kind: 2 /* UTS_CLASS_METADATA_KIND.TYPE */,
|
|
647
|
+
interfaces: [],
|
|
648
|
+
fields: {},
|
|
509
649
|
};
|
|
510
650
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
651
|
+
get $UTSMetadata$() {
|
|
652
|
+
return UTSType.get$UTSMetadata$();
|
|
653
|
+
}
|
|
654
|
+
// TODO 缓存withGenerics结果
|
|
655
|
+
static withGenerics(parent, generics, isJSONParse = false) {
|
|
656
|
+
// 仅JSON.parse uni.request内报错,其他地方不报错
|
|
657
|
+
// generic类型为UTSType子类或Array或基础类型,否则报错
|
|
658
|
+
if (isJSONParse) {
|
|
659
|
+
const illegalGeneric = generics.find((item) => !(item === Array ||
|
|
660
|
+
isBaseType(item) ||
|
|
661
|
+
isUnknownType(item) ||
|
|
662
|
+
isAnyType(item) ||
|
|
663
|
+
item === UTSJSONObject ||
|
|
664
|
+
(item.prototype && item.prototype instanceof UTSType)));
|
|
665
|
+
if (illegalGeneric) {
|
|
666
|
+
throw new Error('Generic is not UTSType or Array or UTSJSONObject or base type, generic: ' +
|
|
667
|
+
illegalGeneric);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (parent === Array) {
|
|
671
|
+
// 不带泛型的Array有一部分不会进入这里,需要在构造type时处理
|
|
672
|
+
return class UTSArray extends UTSType {
|
|
673
|
+
constructor(options, isJSONParse = false) {
|
|
674
|
+
if (!Array.isArray(options)) {
|
|
675
|
+
throw new UTSError(`Failed to contruct type, ${options} is not an array`);
|
|
676
|
+
}
|
|
677
|
+
super();
|
|
678
|
+
// @ts-expect-error
|
|
679
|
+
return options.map((item) => {
|
|
680
|
+
return normalizeGenericValue(item, generics[0], isJSONParse);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
else if (parent === Map || parent === WeakMap) {
|
|
686
|
+
return class UTSMap extends UTSType {
|
|
687
|
+
constructor(options, isJSONParse = false) {
|
|
688
|
+
if (options == null || typeof options !== 'object') {
|
|
689
|
+
throw new UTSError(`Failed to contruct type, ${options} is not an object`);
|
|
690
|
+
}
|
|
691
|
+
super();
|
|
692
|
+
const obj = new parent();
|
|
693
|
+
for (const key in options) {
|
|
694
|
+
obj.set(normalizeGenericValue(key, generics[0], isJSONParse), normalizeGenericValue(options[key], generics[1], isJSONParse));
|
|
695
|
+
}
|
|
696
|
+
return obj;
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
else if (isUTSType(parent)) {
|
|
701
|
+
return class VirtualClassWithGenerics extends parent {
|
|
702
|
+
static get$UTSMetadata$() {
|
|
703
|
+
return parent.get$UTSMetadata$(...generics);
|
|
704
|
+
}
|
|
705
|
+
constructor(options, metadata = VirtualClassWithGenerics.get$UTSMetadata$(), isJSONParse = false) {
|
|
706
|
+
// @ts-expect-error
|
|
707
|
+
super(options, metadata, isJSONParse);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
return parent;
|
|
514
713
|
}
|
|
515
714
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
715
|
+
constructor() { }
|
|
716
|
+
static initProps(options, metadata, isJSONParse = false) {
|
|
717
|
+
// 为了性能,非JSON.parse场景直接返回
|
|
718
|
+
if (!isJSONParse) {
|
|
719
|
+
return options;
|
|
720
|
+
}
|
|
721
|
+
const obj = {};
|
|
722
|
+
if (!metadata.fields) {
|
|
723
|
+
return obj;
|
|
724
|
+
}
|
|
725
|
+
for (const key in metadata.fields) {
|
|
726
|
+
const { type, optional, jsonField } = metadata.fields[key];
|
|
727
|
+
const realKey = isJSONParse ? jsonField || key : key;
|
|
728
|
+
if (options[realKey] == null) {
|
|
729
|
+
if (optional) {
|
|
730
|
+
obj[key] = null;
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
throw new UTSError(`Failed to contruct type, missing required property: ${key}`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (isUTSType(type)) {
|
|
738
|
+
// 带有泛型的数组会走此分支
|
|
739
|
+
obj[key] = isJSONParse
|
|
740
|
+
? // @ts-expect-error
|
|
741
|
+
new type(options[realKey], undefined, isJSONParse)
|
|
742
|
+
: options[realKey];
|
|
743
|
+
}
|
|
744
|
+
else if (type === Array) {
|
|
745
|
+
// 不带泛型的数组会走此分支
|
|
746
|
+
if (!Array.isArray(options[realKey])) {
|
|
747
|
+
throw new UTSError(`Failed to contruct type, property ${key} is not an array`);
|
|
748
|
+
}
|
|
749
|
+
obj[key] = options[realKey];
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
obj[key] = options[realKey];
|
|
753
|
+
}
|
|
519
754
|
}
|
|
755
|
+
return obj;
|
|
520
756
|
}
|
|
521
|
-
|
|
522
|
-
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function initUTSJSONObjectProperties(obj) {
|
|
760
|
+
const propertyList = [
|
|
761
|
+
'_resolveKeyPath',
|
|
762
|
+
'_getValue',
|
|
763
|
+
'toJSON',
|
|
764
|
+
'get',
|
|
765
|
+
'set',
|
|
766
|
+
'getAny',
|
|
767
|
+
'getString',
|
|
768
|
+
'getNumber',
|
|
769
|
+
'getBoolean',
|
|
770
|
+
'getJSON',
|
|
771
|
+
'getArray',
|
|
772
|
+
'toMap',
|
|
773
|
+
'forEach',
|
|
774
|
+
];
|
|
775
|
+
const propertyDescriptorMap = {};
|
|
776
|
+
for (let i = 0; i < propertyList.length; i++) {
|
|
777
|
+
const property = propertyList[i];
|
|
778
|
+
propertyDescriptorMap[property] = {
|
|
779
|
+
enumerable: false,
|
|
780
|
+
value: obj[property],
|
|
781
|
+
};
|
|
523
782
|
}
|
|
783
|
+
Object.defineProperties(obj, propertyDescriptorMap);
|
|
524
784
|
}
|
|
525
|
-
function
|
|
526
|
-
|
|
527
|
-
|
|
785
|
+
function getRealDefaultValue(defaultValue) {
|
|
786
|
+
return defaultValue === void 0 ? null : defaultValue;
|
|
787
|
+
}
|
|
788
|
+
class UTSJSONObject {
|
|
789
|
+
static keys(obj) {
|
|
790
|
+
return Object.keys(obj);
|
|
528
791
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
792
|
+
static assign(target, ...sources) {
|
|
793
|
+
for (let i = 0; i < sources.length; i++) {
|
|
794
|
+
const source = sources[i];
|
|
795
|
+
for (let key in source) {
|
|
796
|
+
target[key] = source[key];
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return target;
|
|
534
800
|
}
|
|
535
|
-
|
|
536
|
-
|
|
801
|
+
constructor(content = {}) {
|
|
802
|
+
if (content instanceof Map) {
|
|
803
|
+
content.forEach((value, key) => {
|
|
804
|
+
this[key] = value;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
else {
|
|
808
|
+
for (const key in content) {
|
|
809
|
+
if (Object.prototype.hasOwnProperty.call(content, key)) {
|
|
810
|
+
this[key] = content[key];
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
initUTSJSONObjectProperties(this);
|
|
815
|
+
}
|
|
816
|
+
_resolveKeyPath(keyPath) {
|
|
817
|
+
// 非法keyPath不抛出错误,直接返回空数组
|
|
818
|
+
let token = '';
|
|
819
|
+
const keyPathArr = [];
|
|
820
|
+
let inOpenParentheses = false;
|
|
821
|
+
for (let i = 0; i < keyPath.length; i++) {
|
|
822
|
+
const word = keyPath[i];
|
|
823
|
+
switch (word) {
|
|
824
|
+
case '.':
|
|
825
|
+
if (token.length > 0) {
|
|
826
|
+
keyPathArr.push(token);
|
|
827
|
+
token = '';
|
|
828
|
+
}
|
|
829
|
+
break;
|
|
830
|
+
case '[': {
|
|
831
|
+
inOpenParentheses = true;
|
|
832
|
+
if (token.length > 0) {
|
|
833
|
+
keyPathArr.push(token);
|
|
834
|
+
token = '';
|
|
835
|
+
}
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
case ']':
|
|
839
|
+
if (inOpenParentheses) {
|
|
840
|
+
if (token.length > 0) {
|
|
841
|
+
const tokenFirstChar = token[0];
|
|
842
|
+
const tokenLastChar = token[token.length - 1];
|
|
843
|
+
if ((tokenFirstChar === '"' && tokenLastChar === '"') ||
|
|
844
|
+
(tokenFirstChar === "'" && tokenLastChar === "'") ||
|
|
845
|
+
(tokenFirstChar === '`' && tokenLastChar === '`')) {
|
|
846
|
+
if (token.length > 2) {
|
|
847
|
+
token = token.slice(1, -1);
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
return [];
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if (!/^\d+$/.test(token)) {
|
|
854
|
+
return [];
|
|
855
|
+
}
|
|
856
|
+
keyPathArr.push(token);
|
|
857
|
+
token = '';
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
return [];
|
|
861
|
+
}
|
|
862
|
+
inOpenParentheses = false;
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
return [];
|
|
866
|
+
}
|
|
867
|
+
break;
|
|
868
|
+
default:
|
|
869
|
+
token += word;
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
if (i === keyPath.length - 1) {
|
|
873
|
+
if (token.length > 0) {
|
|
874
|
+
keyPathArr.push(token);
|
|
875
|
+
token = '';
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return keyPathArr;
|
|
880
|
+
}
|
|
881
|
+
_getValue(keyPath, defaultValue) {
|
|
882
|
+
const keyPathArr = this._resolveKeyPath(keyPath);
|
|
883
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
884
|
+
if (keyPathArr.length === 0) {
|
|
885
|
+
return realDefaultValue;
|
|
886
|
+
}
|
|
887
|
+
let value = this;
|
|
888
|
+
for (let i = 0; i < keyPathArr.length; i++) {
|
|
889
|
+
const key = keyPathArr[i];
|
|
890
|
+
if (value instanceof Object) {
|
|
891
|
+
if (key in value) {
|
|
892
|
+
value = value[key];
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
return realDefaultValue;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
return realDefaultValue;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return value;
|
|
903
|
+
}
|
|
904
|
+
get(key) {
|
|
905
|
+
return this._getValue(key);
|
|
906
|
+
}
|
|
907
|
+
set(key, value) {
|
|
908
|
+
this[key] = value;
|
|
909
|
+
}
|
|
910
|
+
getAny(key, defaultValue) {
|
|
911
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
912
|
+
return this._getValue(key, realDefaultValue);
|
|
913
|
+
}
|
|
914
|
+
getString(key, defaultValue) {
|
|
915
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
916
|
+
const value = this._getValue(key, realDefaultValue);
|
|
917
|
+
if (typeof value === 'string') {
|
|
918
|
+
return value;
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
return realDefaultValue;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
getNumber(key, defaultValue) {
|
|
925
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
926
|
+
const value = this._getValue(key, realDefaultValue);
|
|
927
|
+
if (typeof value === 'number') {
|
|
928
|
+
return value;
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
return realDefaultValue;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
getBoolean(key, defaultValue) {
|
|
935
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
936
|
+
const boolean = this._getValue(key, realDefaultValue);
|
|
937
|
+
if (typeof boolean === 'boolean') {
|
|
938
|
+
return boolean;
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
return realDefaultValue;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
getJSON(key, defaultValue) {
|
|
945
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
946
|
+
let value = this._getValue(key, realDefaultValue);
|
|
947
|
+
if (value instanceof Object) {
|
|
948
|
+
return value;
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
return realDefaultValue;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
getArray(key, defaultValue) {
|
|
955
|
+
const realDefaultValue = getRealDefaultValue(defaultValue);
|
|
956
|
+
let value = this._getValue(key, realDefaultValue);
|
|
957
|
+
if (value instanceof Array) {
|
|
958
|
+
return value;
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
return realDefaultValue;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
toMap() {
|
|
965
|
+
let map = new Map();
|
|
966
|
+
for (let key in this) {
|
|
967
|
+
map.set(key, this[key]);
|
|
968
|
+
}
|
|
969
|
+
return map;
|
|
970
|
+
}
|
|
971
|
+
forEach(callback) {
|
|
972
|
+
for (let key in this) {
|
|
973
|
+
callback(this[key], key);
|
|
974
|
+
}
|
|
537
975
|
}
|
|
538
|
-
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
539
976
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const _key = key;
|
|
547
|
-
sortObj[_key] = obj[_key];
|
|
977
|
+
|
|
978
|
+
const OriginalJSON = JSON;
|
|
979
|
+
function createUTSJSONObjectOrArray(obj) {
|
|
980
|
+
if (Array.isArray(obj)) {
|
|
981
|
+
return obj.map((item) => {
|
|
982
|
+
return createUTSJSONObjectOrArray(item);
|
|
548
983
|
});
|
|
549
984
|
}
|
|
550
|
-
|
|
985
|
+
else if (isPlainObject(obj)) {
|
|
986
|
+
const result = new UTSJSONObject({});
|
|
987
|
+
for (const key in obj) {
|
|
988
|
+
const value = obj[key];
|
|
989
|
+
result[key] = createUTSJSONObjectOrArray(value);
|
|
990
|
+
}
|
|
991
|
+
return result;
|
|
992
|
+
}
|
|
993
|
+
return obj;
|
|
551
994
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
995
|
+
function parseObjectOrArray(object, utsType) {
|
|
996
|
+
const objectType = getType(object);
|
|
997
|
+
if (object === null || (objectType !== 'object' && objectType !== 'array')) {
|
|
998
|
+
return object;
|
|
555
999
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
1000
|
+
if (utsType && utsType !== UTSJSONObject) {
|
|
1001
|
+
try {
|
|
1002
|
+
return new utsType(object, undefined, true);
|
|
1003
|
+
}
|
|
1004
|
+
catch (error) {
|
|
1005
|
+
console.error(error);
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
559
1008
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return window;
|
|
1009
|
+
if (objectType === 'array' || objectType === 'object') {
|
|
1010
|
+
return createUTSJSONObjectOrArray(object);
|
|
563
1011
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
1012
|
+
return object;
|
|
1013
|
+
}
|
|
1014
|
+
const UTSJSON = {
|
|
1015
|
+
parse: (text, reviver, utsType) => {
|
|
1016
|
+
// @ts-expect-error
|
|
1017
|
+
if (reviver && (isUTSType(reviver) || reviver === UTSJSONObject)) {
|
|
1018
|
+
utsType = reviver;
|
|
1019
|
+
reviver = undefined;
|
|
1020
|
+
}
|
|
1021
|
+
try {
|
|
1022
|
+
const parseResult = OriginalJSON.parse(text, reviver);
|
|
1023
|
+
return parseObjectOrArray(parseResult, utsType);
|
|
1024
|
+
}
|
|
1025
|
+
catch (error) {
|
|
1026
|
+
console.error(error);
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
parseArray(text, utsType) {
|
|
1031
|
+
try {
|
|
1032
|
+
const parseResult = OriginalJSON.parse(text);
|
|
1033
|
+
if (Array.isArray(parseResult)) {
|
|
1034
|
+
return parseObjectOrArray(parseResult, utsType ? UTSType.withGenerics(Array, [utsType], true) : undefined);
|
|
1035
|
+
}
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
catch (error) {
|
|
1039
|
+
console.error(error);
|
|
1040
|
+
return null;
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
parseObject(text, utsType) {
|
|
1044
|
+
try {
|
|
1045
|
+
const parseResult = OriginalJSON.parse(text);
|
|
1046
|
+
if (Array.isArray(parseResult)) {
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
return parseObjectOrArray(parseResult, utsType);
|
|
1050
|
+
}
|
|
1051
|
+
catch (error) {
|
|
1052
|
+
console.error(error);
|
|
1053
|
+
return null;
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
stringify: (value, replacer, space) => {
|
|
1057
|
+
try {
|
|
1058
|
+
if (!replacer) {
|
|
1059
|
+
const visited = new Set();
|
|
1060
|
+
replacer = function (_, v) {
|
|
1061
|
+
if (typeof v === 'object') {
|
|
1062
|
+
if (visited.has(v)) {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
visited.add(v);
|
|
1066
|
+
}
|
|
1067
|
+
return v;
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
return OriginalJSON.stringify(value, replacer, space);
|
|
1071
|
+
}
|
|
1072
|
+
catch (error) {
|
|
1073
|
+
console.error(error);
|
|
1074
|
+
return '';
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
function mapGet(map, key) {
|
|
1080
|
+
if (!map.has(key)) {
|
|
1081
|
+
return null;
|
|
570
1082
|
}
|
|
571
|
-
|
|
572
|
-
|
|
1083
|
+
return map.get(key);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
function stringCodePointAt(str, pos) {
|
|
1087
|
+
if (pos < 0 || pos >= str.length) {
|
|
1088
|
+
return null;
|
|
573
1089
|
}
|
|
574
|
-
return (
|
|
575
|
-
return new Function('return this')();
|
|
576
|
-
})();
|
|
1090
|
+
return str.codePointAt(pos);
|
|
577
1091
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
1092
|
+
function stringAt(str, pos) {
|
|
1093
|
+
if (pos < -str.length || pos >= str.length) {
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
return str.at(pos);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function weakMapGet(map, key) {
|
|
1100
|
+
if (!map.has(key)) {
|
|
1101
|
+
return null;
|
|
1102
|
+
}
|
|
1103
|
+
return map.get(key);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
const UTS = {
|
|
1107
|
+
arrayAt,
|
|
1108
|
+
arrayFind,
|
|
1109
|
+
arrayFindLast,
|
|
1110
|
+
arrayPop,
|
|
1111
|
+
arrayShift,
|
|
1112
|
+
isInstanceOf,
|
|
1113
|
+
UTSType,
|
|
1114
|
+
mapGet,
|
|
1115
|
+
stringAt,
|
|
1116
|
+
stringCodePointAt,
|
|
1117
|
+
weakMapGet,
|
|
1118
|
+
JSON: UTSJSON,
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
class UniError extends Error {
|
|
1122
|
+
constructor(errSubject, errCode, errMsg) {
|
|
1123
|
+
let options = {};
|
|
1124
|
+
const argsLength = Array.from(arguments).length;
|
|
1125
|
+
switch (argsLength) {
|
|
1126
|
+
case 0:
|
|
1127
|
+
errSubject = '';
|
|
1128
|
+
errMsg = '';
|
|
1129
|
+
errCode = 0;
|
|
1130
|
+
break;
|
|
1131
|
+
case 1:
|
|
1132
|
+
errMsg = errSubject;
|
|
1133
|
+
errSubject = '';
|
|
1134
|
+
errCode = 0;
|
|
1135
|
+
break;
|
|
1136
|
+
case 2:
|
|
1137
|
+
errMsg = errSubject;
|
|
1138
|
+
options = errCode;
|
|
1139
|
+
errCode = options.errCode || 0;
|
|
1140
|
+
errSubject = options.errSubject || '';
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
super(errMsg);
|
|
1144
|
+
this.name = 'UniError';
|
|
1145
|
+
this.errSubject = errSubject;
|
|
1146
|
+
this.errCode = errCode;
|
|
1147
|
+
this.errMsg = errMsg;
|
|
1148
|
+
if (options.data) {
|
|
1149
|
+
this.data = options.data;
|
|
1150
|
+
}
|
|
1151
|
+
if (options.cause) {
|
|
1152
|
+
this.cause = options.cause;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
set errMsg(msg) {
|
|
1156
|
+
this.message = msg;
|
|
1157
|
+
}
|
|
1158
|
+
get errMsg() {
|
|
1159
|
+
return this.message;
|
|
1160
|
+
}
|
|
1161
|
+
toString() {
|
|
1162
|
+
return this.errMsg;
|
|
1163
|
+
}
|
|
1164
|
+
toJSON() {
|
|
1165
|
+
return {
|
|
1166
|
+
errSubject: this.errSubject,
|
|
1167
|
+
errCode: this.errCode,
|
|
1168
|
+
errMsg: this.errMsg,
|
|
1169
|
+
data: this.data,
|
|
1170
|
+
cause: this.cause && typeof this.cause.toJSON === 'function'
|
|
1171
|
+
? this.cause.toJSON()
|
|
1172
|
+
: this.cause,
|
|
1173
|
+
};
|
|
582
1174
|
}
|
|
583
|
-
|
|
584
|
-
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
class UTSValueIterable {
|
|
585
1178
|
}
|
|
586
1179
|
|
|
587
1180
|
function isComponentInternalInstance(vm) {
|
|
@@ -633,10 +1226,9 @@ function customizeEvent(str) {
|
|
|
633
1226
|
return shared.camelize(str.replace(customizeRE, '-'));
|
|
634
1227
|
}
|
|
635
1228
|
function normalizeStyle(value) {
|
|
636
|
-
|
|
637
|
-
if (g && g.UTSJSONObject && value instanceof g.UTSJSONObject) {
|
|
1229
|
+
if (value instanceof UTSJSONObject) {
|
|
638
1230
|
const styleObject = {};
|
|
639
|
-
|
|
1231
|
+
UTSJSONObject.keys(value).forEach((key) => {
|
|
640
1232
|
styleObject[key] = value[key];
|
|
641
1233
|
});
|
|
642
1234
|
return shared.normalizeStyle(styleObject);
|
|
@@ -672,9 +1264,8 @@ function normalizeStyle(value) {
|
|
|
672
1264
|
}
|
|
673
1265
|
function normalizeClass(value) {
|
|
674
1266
|
let res = '';
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
g.UTSJSONObject.keys(value).forEach((key) => {
|
|
1267
|
+
if (value instanceof UTSJSONObject) {
|
|
1268
|
+
UTSJSONObject.keys(value).forEach((key) => {
|
|
678
1269
|
if (value[key]) {
|
|
679
1270
|
res += key + ' ';
|
|
680
1271
|
}
|
|
@@ -723,6 +1314,144 @@ function formatLog(module, ...args) {
|
|
|
723
1314
|
.join(' ')}`;
|
|
724
1315
|
}
|
|
725
1316
|
|
|
1317
|
+
function cache(fn) {
|
|
1318
|
+
const cache = Object.create(null);
|
|
1319
|
+
return (str) => {
|
|
1320
|
+
const hit = cache[str];
|
|
1321
|
+
return hit || (cache[str] = fn(str));
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
function cacheStringFunction(fn) {
|
|
1325
|
+
return cache(fn);
|
|
1326
|
+
}
|
|
1327
|
+
function getLen(str = '') {
|
|
1328
|
+
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
1329
|
+
}
|
|
1330
|
+
function hasLeadingSlash(str) {
|
|
1331
|
+
return str.indexOf('/') === 0;
|
|
1332
|
+
}
|
|
1333
|
+
function addLeadingSlash(str) {
|
|
1334
|
+
return hasLeadingSlash(str) ? str : '/' + str;
|
|
1335
|
+
}
|
|
1336
|
+
function removeLeadingSlash(str) {
|
|
1337
|
+
return hasLeadingSlash(str) ? str.slice(1) : str;
|
|
1338
|
+
}
|
|
1339
|
+
const invokeArrayFns = (fns, arg) => {
|
|
1340
|
+
let ret;
|
|
1341
|
+
for (let i = 0; i < fns.length; i++) {
|
|
1342
|
+
ret = fns[i](arg);
|
|
1343
|
+
}
|
|
1344
|
+
return ret;
|
|
1345
|
+
};
|
|
1346
|
+
const invokeArrayFnsWithResults = (fns, arg) => {
|
|
1347
|
+
return fns.map((fn) => fn(arg));
|
|
1348
|
+
};
|
|
1349
|
+
function updateElementStyle(element, styles) {
|
|
1350
|
+
for (const attrName in styles) {
|
|
1351
|
+
element.style[attrName] = styles[attrName];
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
function once(fn, ctx = null) {
|
|
1355
|
+
let res;
|
|
1356
|
+
return ((...args) => {
|
|
1357
|
+
if (fn) {
|
|
1358
|
+
res = fn.apply(ctx, args);
|
|
1359
|
+
fn = null;
|
|
1360
|
+
}
|
|
1361
|
+
return res;
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
1365
|
+
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
1366
|
+
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
1367
|
+
if (mode === 'time') {
|
|
1368
|
+
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
1369
|
+
}
|
|
1370
|
+
else {
|
|
1371
|
+
return (date.getFullYear() +
|
|
1372
|
+
'-' +
|
|
1373
|
+
_completeValue(date.getMonth() + 1) +
|
|
1374
|
+
'-' +
|
|
1375
|
+
_completeValue(date.getDate()));
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function callOptions(options, data) {
|
|
1379
|
+
options = options || {};
|
|
1380
|
+
if (shared.isString(data)) {
|
|
1381
|
+
data = {
|
|
1382
|
+
errMsg: data,
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
if (/:ok$/.test(data.errMsg)) {
|
|
1386
|
+
if (shared.isFunction(options.success)) {
|
|
1387
|
+
options.success(data);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
if (shared.isFunction(options.fail)) {
|
|
1392
|
+
options.fail(data);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (shared.isFunction(options.complete)) {
|
|
1396
|
+
options.complete(data);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
function getValueByDataPath(obj, path) {
|
|
1400
|
+
if (!shared.isString(path)) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
1404
|
+
const parts = path.split('.');
|
|
1405
|
+
let key = parts[0];
|
|
1406
|
+
if (!obj) {
|
|
1407
|
+
obj = {};
|
|
1408
|
+
}
|
|
1409
|
+
if (parts.length === 1) {
|
|
1410
|
+
return obj[key];
|
|
1411
|
+
}
|
|
1412
|
+
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* @deprecated
|
|
1416
|
+
*/
|
|
1417
|
+
function sortObject(obj) {
|
|
1418
|
+
return obj;
|
|
1419
|
+
}
|
|
1420
|
+
function getGlobalOnce() {
|
|
1421
|
+
if (typeof globalThis !== 'undefined') {
|
|
1422
|
+
return globalThis;
|
|
1423
|
+
}
|
|
1424
|
+
// worker
|
|
1425
|
+
if (typeof self !== 'undefined') {
|
|
1426
|
+
return self;
|
|
1427
|
+
}
|
|
1428
|
+
// browser
|
|
1429
|
+
if (typeof window !== 'undefined') {
|
|
1430
|
+
return window;
|
|
1431
|
+
}
|
|
1432
|
+
// nodejs
|
|
1433
|
+
// if (typeof global !== 'undefined') {
|
|
1434
|
+
// return global
|
|
1435
|
+
// }
|
|
1436
|
+
function g() {
|
|
1437
|
+
return this;
|
|
1438
|
+
}
|
|
1439
|
+
if (typeof g() !== 'undefined') {
|
|
1440
|
+
return g();
|
|
1441
|
+
}
|
|
1442
|
+
return (function () {
|
|
1443
|
+
return new Function('return this')();
|
|
1444
|
+
})();
|
|
1445
|
+
}
|
|
1446
|
+
let g = undefined;
|
|
1447
|
+
function getGlobal() {
|
|
1448
|
+
if (g) {
|
|
1449
|
+
return g;
|
|
1450
|
+
}
|
|
1451
|
+
g = getGlobalOnce();
|
|
1452
|
+
return g;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
726
1455
|
function formatKey(key) {
|
|
727
1456
|
return shared.camelize(key.substring(5));
|
|
728
1457
|
}
|
|
@@ -738,7 +1467,10 @@ const initCustomDatasetOnce = /*#__PURE__*/ once((isBuiltInElement) => {
|
|
|
738
1467
|
(this.__uniDataset = {});
|
|
739
1468
|
dataset[formatKey(key)] = value;
|
|
740
1469
|
}
|
|
741
|
-
|
|
1470
|
+
// github issues5773 过滤 web 端 query key为数字开头
|
|
1471
|
+
if (!/^\d/.test(key)) {
|
|
1472
|
+
setAttribute.call(this, key, value);
|
|
1473
|
+
}
|
|
742
1474
|
};
|
|
743
1475
|
const removeAttribute = prototype.removeAttribute;
|
|
744
1476
|
prototype.removeAttribute = function (key) {
|
|
@@ -784,6 +1516,16 @@ function createRpx2Unit(unit, unitRatio, unitPrecision) {
|
|
|
784
1516
|
return value === 0 ? '0' : `${value}${unit}`;
|
|
785
1517
|
});
|
|
786
1518
|
}
|
|
1519
|
+
function getPartClass(partName) {
|
|
1520
|
+
return `-_part__${partName}_-`;
|
|
1521
|
+
}
|
|
1522
|
+
function batchGetPartClass(partNames) {
|
|
1523
|
+
return partNames
|
|
1524
|
+
.split(/\s+/)
|
|
1525
|
+
.filter(Boolean)
|
|
1526
|
+
.map((partName) => getPartClass(partName))
|
|
1527
|
+
.join(' ');
|
|
1528
|
+
}
|
|
787
1529
|
|
|
788
1530
|
function passive(passive) {
|
|
789
1531
|
return { passive };
|
|
@@ -1553,6 +2295,7 @@ const PAGE_HOOKS = [
|
|
|
1553
2295
|
ON_SHOW,
|
|
1554
2296
|
ON_HIDE,
|
|
1555
2297
|
ON_UNLOAD,
|
|
2298
|
+
ON_RESIZE,
|
|
1556
2299
|
ON_BACK_PRESS,
|
|
1557
2300
|
ON_PAGE_SCROLL,
|
|
1558
2301
|
ON_TAB_ITEM_TAP,
|
|
@@ -1561,6 +2304,10 @@ const PAGE_HOOKS = [
|
|
|
1561
2304
|
ON_SHARE_TIMELINE,
|
|
1562
2305
|
ON_SHARE_APP_MESSAGE,
|
|
1563
2306
|
ON_SHARE_CHAT,
|
|
2307
|
+
ON_COPY_URL,
|
|
2308
|
+
ON_UPLOAD_DOUYIN_VIDEO,
|
|
2309
|
+
ON_LIVE_MOUNT,
|
|
2310
|
+
ON_TITLE_CLICK,
|
|
1564
2311
|
ON_ADD_TO_FAVORITES,
|
|
1565
2312
|
ON_SAVE_EXIT_STATE,
|
|
1566
2313
|
ON_NAVIGATION_BAR_BUTTON_TAP,
|
|
@@ -1600,12 +2347,17 @@ const UniLifecycleHooks = [
|
|
|
1600
2347
|
ON_ADD_TO_FAVORITES,
|
|
1601
2348
|
ON_SHARE_APP_MESSAGE,
|
|
1602
2349
|
ON_SHARE_CHAT,
|
|
2350
|
+
ON_COPY_URL,
|
|
2351
|
+
ON_UPLOAD_DOUYIN_VIDEO,
|
|
2352
|
+
ON_LIVE_MOUNT,
|
|
2353
|
+
ON_TITLE_CLICK,
|
|
1603
2354
|
ON_SAVE_EXIT_STATE,
|
|
1604
2355
|
ON_NAVIGATION_BAR_BUTTON_TAP,
|
|
1605
2356
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED,
|
|
1606
2357
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
|
|
1607
2358
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
|
|
1608
2359
|
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
|
|
2360
|
+
ON_LAST_PAGE_BACK_PRESS,
|
|
1609
2361
|
];
|
|
1610
2362
|
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
|
|
1611
2363
|
return {
|
|
@@ -1613,6 +2365,10 @@ const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
|
|
|
1613
2365
|
onShareAppMessage: 1 << 1,
|
|
1614
2366
|
onShareTimeline: 1 << 2,
|
|
1615
2367
|
onShareChat: 1 << 3,
|
|
2368
|
+
onCopyUrl: 1 << 4,
|
|
2369
|
+
onUploadDouyinVideo: 1 << 5,
|
|
2370
|
+
onLiveMount: 1 << 6,
|
|
2371
|
+
onTitleClick: 1 << 7,
|
|
1616
2372
|
};
|
|
1617
2373
|
})();
|
|
1618
2374
|
function isUniLifecycleHook(name, value, checkType = true) {
|
|
@@ -1762,6 +2518,76 @@ function normalizeStyles(pageStyle, themeConfig = {}, mode = 'light') {
|
|
|
1762
2518
|
return styles;
|
|
1763
2519
|
}
|
|
1764
2520
|
|
|
2521
|
+
const APP_NATIVE_TAGS = [
|
|
2522
|
+
'view',
|
|
2523
|
+
'text',
|
|
2524
|
+
'image',
|
|
2525
|
+
'scroll-view',
|
|
2526
|
+
'native-view',
|
|
2527
|
+
'nested-scroll-header',
|
|
2528
|
+
'nested-scroll-body',
|
|
2529
|
+
'rich-text-native',
|
|
2530
|
+
'cover-image',
|
|
2531
|
+
'cover-view',
|
|
2532
|
+
];
|
|
2533
|
+
function isDom2AppNativeTag(tag) {
|
|
2534
|
+
return APP_NATIVE_TAGS.includes(tag);
|
|
2535
|
+
}
|
|
2536
|
+
const APP_VUE_COMPONENT_TAGS = [
|
|
2537
|
+
'swiper',
|
|
2538
|
+
'swiper-item',
|
|
2539
|
+
'match-media',
|
|
2540
|
+
'movable-area',
|
|
2541
|
+
'movable-view',
|
|
2542
|
+
'cover-view',
|
|
2543
|
+
'list-view',
|
|
2544
|
+
'list-item',
|
|
2545
|
+
'waterflow',
|
|
2546
|
+
'flow-item',
|
|
2547
|
+
'sticky-header',
|
|
2548
|
+
'sticky-section',
|
|
2549
|
+
'share-element',
|
|
2550
|
+
'icon',
|
|
2551
|
+
'rich-text',
|
|
2552
|
+
'progress',
|
|
2553
|
+
'button',
|
|
2554
|
+
'checkbox-group',
|
|
2555
|
+
'checkbox',
|
|
2556
|
+
'form',
|
|
2557
|
+
'input',
|
|
2558
|
+
'editor',
|
|
2559
|
+
'label',
|
|
2560
|
+
'picker',
|
|
2561
|
+
'picker-view',
|
|
2562
|
+
'picker-view-column',
|
|
2563
|
+
'radio-group',
|
|
2564
|
+
'radio',
|
|
2565
|
+
'slider',
|
|
2566
|
+
'switch',
|
|
2567
|
+
'textarea',
|
|
2568
|
+
'navigator',
|
|
2569
|
+
'video',
|
|
2570
|
+
'animation-view',
|
|
2571
|
+
'camera',
|
|
2572
|
+
'live-player',
|
|
2573
|
+
'live-pusher',
|
|
2574
|
+
'map',
|
|
2575
|
+
'canvas',
|
|
2576
|
+
'ad',
|
|
2577
|
+
'web-view',
|
|
2578
|
+
'loading',
|
|
2579
|
+
'page-container',
|
|
2580
|
+
];
|
|
2581
|
+
function isDom2VueComponentTag(tag) {
|
|
2582
|
+
return APP_VUE_COMPONENT_TAGS.includes(tag);
|
|
2583
|
+
}
|
|
2584
|
+
function isDom2AppVueComponentTag(tag) {
|
|
2585
|
+
return APP_VUE_COMPONENT_TAGS.includes(tag);
|
|
2586
|
+
}
|
|
2587
|
+
function isDom2AppUserVueComponentTag(tag) {
|
|
2588
|
+
return !isDom2AppNativeTag(tag) && !isDom2VueComponentTag(tag);
|
|
2589
|
+
}
|
|
2590
|
+
|
|
1765
2591
|
function getEnvLocale() {
|
|
1766
2592
|
const { env } = process;
|
|
1767
2593
|
const lang = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;
|
|
@@ -1838,6 +2664,7 @@ exports.ON_ADD_TO_FAVORITES = ON_ADD_TO_FAVORITES;
|
|
|
1838
2664
|
exports.ON_APP_ENTER_BACKGROUND = ON_APP_ENTER_BACKGROUND;
|
|
1839
2665
|
exports.ON_APP_ENTER_FOREGROUND = ON_APP_ENTER_FOREGROUND;
|
|
1840
2666
|
exports.ON_BACK_PRESS = ON_BACK_PRESS;
|
|
2667
|
+
exports.ON_COPY_URL = ON_COPY_URL;
|
|
1841
2668
|
exports.ON_ERROR = ON_ERROR;
|
|
1842
2669
|
exports.ON_EXIT = ON_EXIT;
|
|
1843
2670
|
exports.ON_HIDE = ON_HIDE;
|
|
@@ -1846,6 +2673,7 @@ exports.ON_INIT = ON_INIT;
|
|
|
1846
2673
|
exports.ON_KEYBOARD_HEIGHT_CHANGE = ON_KEYBOARD_HEIGHT_CHANGE;
|
|
1847
2674
|
exports.ON_LAST_PAGE_BACK_PRESS = ON_LAST_PAGE_BACK_PRESS;
|
|
1848
2675
|
exports.ON_LAUNCH = ON_LAUNCH;
|
|
2676
|
+
exports.ON_LIVE_MOUNT = ON_LIVE_MOUNT;
|
|
1849
2677
|
exports.ON_LOAD = ON_LOAD;
|
|
1850
2678
|
exports.ON_NAVIGATION_BAR_BUTTON_TAP = ON_NAVIGATION_BAR_BUTTON_TAP;
|
|
1851
2679
|
exports.ON_NAVIGATION_BAR_CHANGE = ON_NAVIGATION_BAR_CHANGE;
|
|
@@ -1867,8 +2695,10 @@ exports.ON_SHARE_TIMELINE = ON_SHARE_TIMELINE;
|
|
|
1867
2695
|
exports.ON_SHOW = ON_SHOW;
|
|
1868
2696
|
exports.ON_TAB_ITEM_TAP = ON_TAB_ITEM_TAP;
|
|
1869
2697
|
exports.ON_THEME_CHANGE = ON_THEME_CHANGE;
|
|
2698
|
+
exports.ON_TITLE_CLICK = ON_TITLE_CLICK;
|
|
1870
2699
|
exports.ON_UNHANDLE_REJECTION = ON_UNHANDLE_REJECTION;
|
|
1871
2700
|
exports.ON_UNLOAD = ON_UNLOAD;
|
|
2701
|
+
exports.ON_UPLOAD_DOUYIN_VIDEO = ON_UPLOAD_DOUYIN_VIDEO;
|
|
1872
2702
|
exports.ON_WEB_INVOKE_APP_SERVICE = ON_WEB_INVOKE_APP_SERVICE;
|
|
1873
2703
|
exports.ON_WXS_INVOKE_CALL_METHOD = ON_WXS_INVOKE_CALL_METHOD;
|
|
1874
2704
|
exports.PLUS_RE = PLUS_RE;
|
|
@@ -1886,16 +2716,22 @@ exports.UNI_SSR_DATA = UNI_SSR_DATA;
|
|
|
1886
2716
|
exports.UNI_SSR_GLOBAL_DATA = UNI_SSR_GLOBAL_DATA;
|
|
1887
2717
|
exports.UNI_SSR_STORE = UNI_SSR_STORE;
|
|
1888
2718
|
exports.UNI_SSR_TITLE = UNI_SSR_TITLE;
|
|
2719
|
+
exports.UNI_STATUS_BAR_HEIGHT = UNI_STATUS_BAR_HEIGHT;
|
|
1889
2720
|
exports.UNI_STORAGE_LOCALE = UNI_STORAGE_LOCALE;
|
|
1890
2721
|
exports.UNI_UI_CONFLICT_TAGS = UNI_UI_CONFLICT_TAGS;
|
|
2722
|
+
exports.UTS = UTS;
|
|
2723
|
+
exports.UTSJSONObject = UTSJSONObject;
|
|
2724
|
+
exports.UTSValueIterable = UTSValueIterable;
|
|
1891
2725
|
exports.UVUE_BUILT_IN_TAGS = UVUE_BUILT_IN_TAGS;
|
|
1892
2726
|
exports.UVUE_HARMONY_BUILT_IN_TAGS = UVUE_HARMONY_BUILT_IN_TAGS;
|
|
1893
2727
|
exports.UVUE_IOS_BUILT_IN_TAGS = UVUE_IOS_BUILT_IN_TAGS;
|
|
2728
|
+
exports.UVUE_MP_BUILT_IN_TAGS = UVUE_MP_BUILT_IN_TAGS;
|
|
1894
2729
|
exports.UVUE_WEB_BUILT_IN_CUSTOM_ELEMENTS = UVUE_WEB_BUILT_IN_CUSTOM_ELEMENTS;
|
|
1895
2730
|
exports.UVUE_WEB_BUILT_IN_TAGS = UVUE_WEB_BUILT_IN_TAGS;
|
|
1896
2731
|
exports.UniBaseNode = UniBaseNode;
|
|
1897
2732
|
exports.UniCommentNode = UniCommentNode;
|
|
1898
2733
|
exports.UniElement = UniElement;
|
|
2734
|
+
exports.UniError = UniError;
|
|
1899
2735
|
exports.UniEvent = UniEvent;
|
|
1900
2736
|
exports.UniInputElement = UniInputElement;
|
|
1901
2737
|
exports.UniLifecycleHooks = UniLifecycleHooks;
|
|
@@ -1911,6 +2747,7 @@ exports.WXS_MODULES = WXS_MODULES;
|
|
|
1911
2747
|
exports.WXS_PROTOCOL = WXS_PROTOCOL;
|
|
1912
2748
|
exports.addFont = addFont;
|
|
1913
2749
|
exports.addLeadingSlash = addLeadingSlash;
|
|
2750
|
+
exports.batchGetPartClass = batchGetPartClass;
|
|
1914
2751
|
exports.borderStyles = borderStyles;
|
|
1915
2752
|
exports.cache = cache;
|
|
1916
2753
|
exports.cacheStringFunction = cacheStringFunction;
|
|
@@ -1933,9 +2770,11 @@ exports.getCustomDataset = getCustomDataset;
|
|
|
1933
2770
|
exports.getEnvLocale = getEnvLocale;
|
|
1934
2771
|
exports.getGlobal = getGlobal;
|
|
1935
2772
|
exports.getLen = getLen;
|
|
2773
|
+
exports.getPartClass = getPartClass;
|
|
1936
2774
|
exports.getValueByDataPath = getValueByDataPath;
|
|
1937
2775
|
exports.initCustomDatasetOnce = initCustomDatasetOnce;
|
|
1938
2776
|
exports.invokeArrayFns = invokeArrayFns;
|
|
2777
|
+
exports.invokeArrayFnsWithResults = invokeArrayFnsWithResults;
|
|
1939
2778
|
exports.invokeCreateErrorHandler = invokeCreateErrorHandler;
|
|
1940
2779
|
exports.invokeCreateVueAppHook = invokeCreateVueAppHook;
|
|
1941
2780
|
exports.isAppHarmonyUVueNativeTag = isAppHarmonyUVueNativeTag;
|
|
@@ -1948,16 +2787,22 @@ exports.isAppVoidTag = isAppVoidTag;
|
|
|
1948
2787
|
exports.isBuiltInComponent = isBuiltInComponent;
|
|
1949
2788
|
exports.isComponentInternalInstance = isComponentInternalInstance;
|
|
1950
2789
|
exports.isComponentTag = isComponentTag;
|
|
2790
|
+
exports.isDom2AppNativeTag = isDom2AppNativeTag;
|
|
2791
|
+
exports.isDom2AppUserVueComponentTag = isDom2AppUserVueComponentTag;
|
|
2792
|
+
exports.isDom2AppVueComponentTag = isDom2AppVueComponentTag;
|
|
2793
|
+
exports.isDom2VueComponentTag = isDom2VueComponentTag;
|
|
1951
2794
|
exports.isGloballyAllowed = isGloballyAllowed;
|
|
1952
2795
|
exports.isH5CustomElement = isH5CustomElement;
|
|
1953
2796
|
exports.isH5NativeTag = isH5NativeTag;
|
|
1954
2797
|
exports.isIntegerKey = isIntegerKey;
|
|
2798
|
+
exports.isMPBuiltInComponent = isMPBuiltInComponent;
|
|
1955
2799
|
exports.isMiniProgramNativeTag = isMiniProgramNativeTag;
|
|
1956
2800
|
exports.isMiniProgramUVueNativeTag = isMiniProgramUVueNativeTag;
|
|
1957
2801
|
exports.isRootHook = isRootHook;
|
|
1958
2802
|
exports.isRootImmediateHook = isRootImmediateHook;
|
|
1959
2803
|
exports.isUniLifecycleHook = isUniLifecycleHook;
|
|
1960
2804
|
exports.isUniXElement = isUniXElement;
|
|
2805
|
+
exports.isWebBuiltInComponent = isWebBuiltInComponent;
|
|
1961
2806
|
exports.normalizeClass = normalizeClass;
|
|
1962
2807
|
exports.normalizeDataset = normalizeDataset;
|
|
1963
2808
|
exports.normalizeEventType = normalizeEventType;
|