@dcloudio/uni-shared 3.0.0-alpha-3030820220114009 → 3.0.0-alpha-3031120220221001
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 +114 -110
- package/dist/uni-shared.d.ts +5 -1
- package/dist/uni-shared.es.js +115 -111
- package/package.json +3 -3
package/dist/uni-shared.cjs.js
CHANGED
|
@@ -104,15 +104,18 @@ const NVUE_BUILT_IN_TAGS = [
|
|
|
104
104
|
'timepicker',
|
|
105
105
|
'marquee',
|
|
106
106
|
'countdown',
|
|
107
|
+
'dc-switch',
|
|
107
108
|
];
|
|
108
109
|
const NVUE_U_BUILT_IN_TAGS = [
|
|
109
|
-
'text',
|
|
110
|
-
'image',
|
|
111
|
-
'input',
|
|
112
|
-
'textarea',
|
|
113
|
-
'video',
|
|
114
|
-
'web-view',
|
|
115
|
-
'slider',
|
|
110
|
+
'u-text',
|
|
111
|
+
'u-image',
|
|
112
|
+
'u-input',
|
|
113
|
+
'u-textarea',
|
|
114
|
+
'u-video',
|
|
115
|
+
'u-web-view',
|
|
116
|
+
'u-slider',
|
|
117
|
+
'u-ad',
|
|
118
|
+
'u-ad-draw',
|
|
116
119
|
];
|
|
117
120
|
function isBuiltInComponent(tag) {
|
|
118
121
|
// h5 平台会被转换为 v-uni-
|
|
@@ -149,22 +152,22 @@ const NVUE_CUSTOM_COMPONENTS = [
|
|
|
149
152
|
'swiper-item',
|
|
150
153
|
'swiper',
|
|
151
154
|
'switch',
|
|
152
|
-
'slider',
|
|
155
|
+
// 'slider',
|
|
153
156
|
'picker-view',
|
|
154
157
|
'picker-view-column',
|
|
155
158
|
];
|
|
156
159
|
function isAppNVueNativeTag(tag) {
|
|
160
|
+
if (NVUE_BUILT_IN_TAGS.includes(tag)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
157
163
|
if (NVUE_CUSTOM_COMPONENTS.includes(tag)) {
|
|
158
164
|
return false;
|
|
159
165
|
}
|
|
160
166
|
if (isBuiltInComponent(tag)) {
|
|
161
167
|
return true;
|
|
162
168
|
}
|
|
163
|
-
if (NVUE_BUILT_IN_TAGS.includes(tag)) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
169
|
// u-text,u-video...
|
|
167
|
-
if (NVUE_U_BUILT_IN_TAGS.includes(tag
|
|
170
|
+
if (NVUE_U_BUILT_IN_TAGS.includes(tag)) {
|
|
168
171
|
return true;
|
|
169
172
|
}
|
|
170
173
|
return false;
|
|
@@ -300,10 +303,106 @@ function formatLog(module, ...args) {
|
|
|
300
303
|
.join(' ')}`;
|
|
301
304
|
}
|
|
302
305
|
|
|
306
|
+
function cache(fn) {
|
|
307
|
+
const cache = Object.create(null);
|
|
308
|
+
return (str) => {
|
|
309
|
+
const hit = cache[str];
|
|
310
|
+
return hit || (cache[str] = fn(str));
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function cacheStringFunction(fn) {
|
|
314
|
+
return cache(fn);
|
|
315
|
+
}
|
|
316
|
+
function getLen(str = '') {
|
|
317
|
+
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
318
|
+
}
|
|
319
|
+
function hasLeadingSlash(str) {
|
|
320
|
+
return str.indexOf('/') === 0;
|
|
321
|
+
}
|
|
322
|
+
function addLeadingSlash(str) {
|
|
323
|
+
return hasLeadingSlash(str) ? str : '/' + str;
|
|
324
|
+
}
|
|
325
|
+
function removeLeadingSlash(str) {
|
|
326
|
+
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
327
|
+
}
|
|
328
|
+
const invokeArrayFns = (fns, arg) => {
|
|
329
|
+
let ret;
|
|
330
|
+
for (let i = 0; i < fns.length; i++) {
|
|
331
|
+
ret = fns[i](arg);
|
|
332
|
+
}
|
|
333
|
+
return ret;
|
|
334
|
+
};
|
|
335
|
+
function updateElementStyle(element, styles) {
|
|
336
|
+
for (const attrName in styles) {
|
|
337
|
+
element.style[attrName] = styles[attrName];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function once(fn, ctx = null) {
|
|
341
|
+
let res;
|
|
342
|
+
return ((...args) => {
|
|
343
|
+
if (fn) {
|
|
344
|
+
res = fn.apply(ctx, args);
|
|
345
|
+
fn = null;
|
|
346
|
+
}
|
|
347
|
+
return res;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
351
|
+
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
352
|
+
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
353
|
+
if (mode === 'time') {
|
|
354
|
+
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
return (date.getFullYear() +
|
|
358
|
+
'-' +
|
|
359
|
+
_completeValue(date.getMonth() + 1) +
|
|
360
|
+
'-' +
|
|
361
|
+
_completeValue(date.getDate()));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function callOptions(options, data) {
|
|
365
|
+
options = options || {};
|
|
366
|
+
if (typeof data === 'string') {
|
|
367
|
+
data = {
|
|
368
|
+
errMsg: data,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if (/:ok$/.test(data.errMsg)) {
|
|
372
|
+
if (typeof options.success === 'function') {
|
|
373
|
+
options.success(data);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
if (typeof options.fail === 'function') {
|
|
378
|
+
options.fail(data);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (typeof options.complete === 'function') {
|
|
382
|
+
options.complete(data);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function getValueByDataPath(obj, path) {
|
|
386
|
+
if (!shared.isString(path)) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
390
|
+
const parts = path.split('.');
|
|
391
|
+
let key = parts[0];
|
|
392
|
+
if (!obj) {
|
|
393
|
+
obj = {};
|
|
394
|
+
}
|
|
395
|
+
if (parts.length === 1) {
|
|
396
|
+
return obj[key];
|
|
397
|
+
}
|
|
398
|
+
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
399
|
+
}
|
|
400
|
+
|
|
303
401
|
function formatKey(key) {
|
|
304
402
|
return shared.camelize(key.substring(5));
|
|
305
403
|
}
|
|
306
|
-
|
|
404
|
+
// question/139181,增加副作用,避免 initCustomDataset 在 build 下被 tree-shaking
|
|
405
|
+
const initCustomDatasetOnce = /*#__PURE__*/ once(() => {
|
|
307
406
|
const prototype = HTMLElement.prototype;
|
|
308
407
|
const setAttribute = prototype.setAttribute;
|
|
309
408
|
prototype.setAttribute = function (key, value) {
|
|
@@ -323,7 +422,7 @@ function initCustomDataset() {
|
|
|
323
422
|
}
|
|
324
423
|
removeAttribute.call(this, key);
|
|
325
424
|
};
|
|
326
|
-
}
|
|
425
|
+
});
|
|
327
426
|
function getCustomDataset(el) {
|
|
328
427
|
return shared.extend({}, el.dataset, el.__uniDataset);
|
|
329
428
|
}
|
|
@@ -1063,101 +1162,6 @@ const ACTION_TYPE_ADD_WXS_EVENT = 12;
|
|
|
1063
1162
|
const ACTION_TYPE_PAGE_SCROLL = 15;
|
|
1064
1163
|
const ACTION_TYPE_EVENT = 20;
|
|
1065
1164
|
|
|
1066
|
-
function cache(fn) {
|
|
1067
|
-
const cache = Object.create(null);
|
|
1068
|
-
return (str) => {
|
|
1069
|
-
const hit = cache[str];
|
|
1070
|
-
return hit || (cache[str] = fn(str));
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
function cacheStringFunction(fn) {
|
|
1074
|
-
return cache(fn);
|
|
1075
|
-
}
|
|
1076
|
-
function getLen(str = '') {
|
|
1077
|
-
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
1078
|
-
}
|
|
1079
|
-
function hasLeadingSlash(str) {
|
|
1080
|
-
return str.indexOf('/') === 0;
|
|
1081
|
-
}
|
|
1082
|
-
function addLeadingSlash(str) {
|
|
1083
|
-
return hasLeadingSlash(str) ? str : '/' + str;
|
|
1084
|
-
}
|
|
1085
|
-
function removeLeadingSlash(str) {
|
|
1086
|
-
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
1087
|
-
}
|
|
1088
|
-
const invokeArrayFns = (fns, arg) => {
|
|
1089
|
-
let ret;
|
|
1090
|
-
for (let i = 0; i < fns.length; i++) {
|
|
1091
|
-
ret = fns[i](arg);
|
|
1092
|
-
}
|
|
1093
|
-
return ret;
|
|
1094
|
-
};
|
|
1095
|
-
function updateElementStyle(element, styles) {
|
|
1096
|
-
for (const attrName in styles) {
|
|
1097
|
-
element.style[attrName] = styles[attrName];
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
function once(fn, ctx = null) {
|
|
1101
|
-
let res;
|
|
1102
|
-
return ((...args) => {
|
|
1103
|
-
if (fn) {
|
|
1104
|
-
res = fn.apply(ctx, args);
|
|
1105
|
-
fn = null;
|
|
1106
|
-
}
|
|
1107
|
-
return res;
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
1111
|
-
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
1112
|
-
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
1113
|
-
if (mode === 'time') {
|
|
1114
|
-
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1117
|
-
return (date.getFullYear() +
|
|
1118
|
-
'-' +
|
|
1119
|
-
_completeValue(date.getMonth() + 1) +
|
|
1120
|
-
'-' +
|
|
1121
|
-
_completeValue(date.getDate()));
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
function callOptions(options, data) {
|
|
1125
|
-
options = options || {};
|
|
1126
|
-
if (typeof data === 'string') {
|
|
1127
|
-
data = {
|
|
1128
|
-
errMsg: data,
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
if (/:ok$/.test(data.errMsg)) {
|
|
1132
|
-
if (typeof options.success === 'function') {
|
|
1133
|
-
options.success(data);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
else {
|
|
1137
|
-
if (typeof options.fail === 'function') {
|
|
1138
|
-
options.fail(data);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
if (typeof options.complete === 'function') {
|
|
1142
|
-
options.complete(data);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
function getValueByDataPath(obj, path) {
|
|
1146
|
-
if (!shared.isString(path)) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
1150
|
-
const parts = path.split('.');
|
|
1151
|
-
let key = parts[0];
|
|
1152
|
-
if (!obj) {
|
|
1153
|
-
obj = {};
|
|
1154
|
-
}
|
|
1155
|
-
if (parts.length === 1) {
|
|
1156
|
-
return obj[key];
|
|
1157
|
-
}
|
|
1158
|
-
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
1165
|
function debounce(fn, delay) {
|
|
1162
1166
|
let timeout;
|
|
1163
1167
|
const newFn = function () {
|
|
@@ -1471,7 +1475,7 @@ exports.getCustomDataset = getCustomDataset;
|
|
|
1471
1475
|
exports.getEnvLocale = getEnvLocale;
|
|
1472
1476
|
exports.getLen = getLen;
|
|
1473
1477
|
exports.getValueByDataPath = getValueByDataPath;
|
|
1474
|
-
exports.
|
|
1478
|
+
exports.initCustomDatasetOnce = initCustomDatasetOnce;
|
|
1475
1479
|
exports.invokeArrayFns = invokeArrayFns;
|
|
1476
1480
|
exports.isAppNVueNativeTag = isAppNVueNativeTag;
|
|
1477
1481
|
exports.isAppNativeTag = isAppNativeTag;
|
package/dist/uni-shared.d.ts
CHANGED
|
@@ -231,7 +231,7 @@ declare interface HTMLElementWithDataset extends HTMLElement {
|
|
|
231
231
|
|
|
232
232
|
export declare const I18N_JSON_DELIMITERS: [string, string];
|
|
233
233
|
|
|
234
|
-
export declare
|
|
234
|
+
export declare const initCustomDatasetOnce: () => void;
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
237
|
* nodeId
|
|
@@ -349,6 +349,8 @@ export declare interface NVueElement {
|
|
|
349
349
|
type: string;
|
|
350
350
|
ref: string;
|
|
351
351
|
text?: string;
|
|
352
|
+
styleSheet: Record<string, Record<string, Record<string, unknown>>>;
|
|
353
|
+
classList: string[];
|
|
352
354
|
parentNode: NVueElement | null;
|
|
353
355
|
children: Array<NVueElement>;
|
|
354
356
|
previousSibling: NVueElement | null;
|
|
@@ -359,8 +361,10 @@ export declare interface NVueElement {
|
|
|
359
361
|
insertAfter: (node: NVueElement, after: NVueElement) => void;
|
|
360
362
|
setAttr: (key: string, value: any, silent?: boolean) => void;
|
|
361
363
|
setAttrs: (attrs: Record<string, unknown>, silent?: boolean) => void;
|
|
364
|
+
setClassList: (classList: string[]) => void;
|
|
362
365
|
setStyle: (key: string, value: any, silent?: boolean) => void;
|
|
363
366
|
setStyles: (attrs: Record<string, unknown>, silent?: boolean) => void;
|
|
367
|
+
setStyleSheet: (styleSheet: Record<string, Record<string, Record<string, unknown>>>) => void;
|
|
364
368
|
addEvent: (type: string, handler: Function, args?: Array<any>) => void;
|
|
365
369
|
removeEvent: (type: string) => void;
|
|
366
370
|
fireEvent: (type: string) => void;
|
package/dist/uni-shared.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHTMLTag, isSVGTag, hyphenate, camelize,
|
|
1
|
+
import { isHTMLTag, isSVGTag, hyphenate, camelize, isString, extend, isPlainObject, isArray, toTypeString, toRawType, capitalize } from '@vue/shared';
|
|
2
2
|
|
|
3
3
|
const BUILT_IN_TAG_NAMES = [
|
|
4
4
|
'ad',
|
|
@@ -100,15 +100,18 @@ const NVUE_BUILT_IN_TAGS = [
|
|
|
100
100
|
'timepicker',
|
|
101
101
|
'marquee',
|
|
102
102
|
'countdown',
|
|
103
|
+
'dc-switch',
|
|
103
104
|
];
|
|
104
105
|
const NVUE_U_BUILT_IN_TAGS = [
|
|
105
|
-
'text',
|
|
106
|
-
'image',
|
|
107
|
-
'input',
|
|
108
|
-
'textarea',
|
|
109
|
-
'video',
|
|
110
|
-
'web-view',
|
|
111
|
-
'slider',
|
|
106
|
+
'u-text',
|
|
107
|
+
'u-image',
|
|
108
|
+
'u-input',
|
|
109
|
+
'u-textarea',
|
|
110
|
+
'u-video',
|
|
111
|
+
'u-web-view',
|
|
112
|
+
'u-slider',
|
|
113
|
+
'u-ad',
|
|
114
|
+
'u-ad-draw',
|
|
112
115
|
];
|
|
113
116
|
function isBuiltInComponent(tag) {
|
|
114
117
|
// h5 平台会被转换为 v-uni-
|
|
@@ -145,22 +148,22 @@ const NVUE_CUSTOM_COMPONENTS = [
|
|
|
145
148
|
'swiper-item',
|
|
146
149
|
'swiper',
|
|
147
150
|
'switch',
|
|
148
|
-
'slider',
|
|
151
|
+
// 'slider',
|
|
149
152
|
'picker-view',
|
|
150
153
|
'picker-view-column',
|
|
151
154
|
];
|
|
152
155
|
function isAppNVueNativeTag(tag) {
|
|
156
|
+
if (NVUE_BUILT_IN_TAGS.includes(tag)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
153
159
|
if (NVUE_CUSTOM_COMPONENTS.includes(tag)) {
|
|
154
160
|
return false;
|
|
155
161
|
}
|
|
156
162
|
if (isBuiltInComponent(tag)) {
|
|
157
163
|
return true;
|
|
158
164
|
}
|
|
159
|
-
if (NVUE_BUILT_IN_TAGS.includes(tag)) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
165
|
// u-text,u-video...
|
|
163
|
-
if (NVUE_U_BUILT_IN_TAGS.includes(tag
|
|
166
|
+
if (NVUE_U_BUILT_IN_TAGS.includes(tag)) {
|
|
164
167
|
return true;
|
|
165
168
|
}
|
|
166
169
|
return false;
|
|
@@ -296,10 +299,106 @@ function formatLog(module, ...args) {
|
|
|
296
299
|
.join(' ')}`;
|
|
297
300
|
}
|
|
298
301
|
|
|
302
|
+
function cache(fn) {
|
|
303
|
+
const cache = Object.create(null);
|
|
304
|
+
return (str) => {
|
|
305
|
+
const hit = cache[str];
|
|
306
|
+
return hit || (cache[str] = fn(str));
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function cacheStringFunction(fn) {
|
|
310
|
+
return cache(fn);
|
|
311
|
+
}
|
|
312
|
+
function getLen(str = '') {
|
|
313
|
+
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
314
|
+
}
|
|
315
|
+
function hasLeadingSlash(str) {
|
|
316
|
+
return str.indexOf('/') === 0;
|
|
317
|
+
}
|
|
318
|
+
function addLeadingSlash(str) {
|
|
319
|
+
return hasLeadingSlash(str) ? str : '/' + str;
|
|
320
|
+
}
|
|
321
|
+
function removeLeadingSlash(str) {
|
|
322
|
+
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
323
|
+
}
|
|
324
|
+
const invokeArrayFns = (fns, arg) => {
|
|
325
|
+
let ret;
|
|
326
|
+
for (let i = 0; i < fns.length; i++) {
|
|
327
|
+
ret = fns[i](arg);
|
|
328
|
+
}
|
|
329
|
+
return ret;
|
|
330
|
+
};
|
|
331
|
+
function updateElementStyle(element, styles) {
|
|
332
|
+
for (const attrName in styles) {
|
|
333
|
+
element.style[attrName] = styles[attrName];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function once(fn, ctx = null) {
|
|
337
|
+
let res;
|
|
338
|
+
return ((...args) => {
|
|
339
|
+
if (fn) {
|
|
340
|
+
res = fn.apply(ctx, args);
|
|
341
|
+
fn = null;
|
|
342
|
+
}
|
|
343
|
+
return res;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
347
|
+
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
348
|
+
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
349
|
+
if (mode === 'time') {
|
|
350
|
+
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
return (date.getFullYear() +
|
|
354
|
+
'-' +
|
|
355
|
+
_completeValue(date.getMonth() + 1) +
|
|
356
|
+
'-' +
|
|
357
|
+
_completeValue(date.getDate()));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function callOptions(options, data) {
|
|
361
|
+
options = options || {};
|
|
362
|
+
if (typeof data === 'string') {
|
|
363
|
+
data = {
|
|
364
|
+
errMsg: data,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (/:ok$/.test(data.errMsg)) {
|
|
368
|
+
if (typeof options.success === 'function') {
|
|
369
|
+
options.success(data);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
if (typeof options.fail === 'function') {
|
|
374
|
+
options.fail(data);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (typeof options.complete === 'function') {
|
|
378
|
+
options.complete(data);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function getValueByDataPath(obj, path) {
|
|
382
|
+
if (!isString(path)) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
386
|
+
const parts = path.split('.');
|
|
387
|
+
let key = parts[0];
|
|
388
|
+
if (!obj) {
|
|
389
|
+
obj = {};
|
|
390
|
+
}
|
|
391
|
+
if (parts.length === 1) {
|
|
392
|
+
return obj[key];
|
|
393
|
+
}
|
|
394
|
+
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
395
|
+
}
|
|
396
|
+
|
|
299
397
|
function formatKey(key) {
|
|
300
398
|
return camelize(key.substring(5));
|
|
301
399
|
}
|
|
302
|
-
|
|
400
|
+
// question/139181,增加副作用,避免 initCustomDataset 在 build 下被 tree-shaking
|
|
401
|
+
const initCustomDatasetOnce = /*#__PURE__*/ once(() => {
|
|
303
402
|
const prototype = HTMLElement.prototype;
|
|
304
403
|
const setAttribute = prototype.setAttribute;
|
|
305
404
|
prototype.setAttribute = function (key, value) {
|
|
@@ -319,7 +418,7 @@ function initCustomDataset() {
|
|
|
319
418
|
}
|
|
320
419
|
removeAttribute.call(this, key);
|
|
321
420
|
};
|
|
322
|
-
}
|
|
421
|
+
});
|
|
323
422
|
function getCustomDataset(el) {
|
|
324
423
|
return extend({}, el.dataset, el.__uniDataset);
|
|
325
424
|
}
|
|
@@ -1059,101 +1158,6 @@ const ACTION_TYPE_ADD_WXS_EVENT = 12;
|
|
|
1059
1158
|
const ACTION_TYPE_PAGE_SCROLL = 15;
|
|
1060
1159
|
const ACTION_TYPE_EVENT = 20;
|
|
1061
1160
|
|
|
1062
|
-
function cache(fn) {
|
|
1063
|
-
const cache = Object.create(null);
|
|
1064
|
-
return (str) => {
|
|
1065
|
-
const hit = cache[str];
|
|
1066
|
-
return hit || (cache[str] = fn(str));
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
function cacheStringFunction(fn) {
|
|
1070
|
-
return cache(fn);
|
|
1071
|
-
}
|
|
1072
|
-
function getLen(str = '') {
|
|
1073
|
-
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
1074
|
-
}
|
|
1075
|
-
function hasLeadingSlash(str) {
|
|
1076
|
-
return str.indexOf('/') === 0;
|
|
1077
|
-
}
|
|
1078
|
-
function addLeadingSlash(str) {
|
|
1079
|
-
return hasLeadingSlash(str) ? str : '/' + str;
|
|
1080
|
-
}
|
|
1081
|
-
function removeLeadingSlash(str) {
|
|
1082
|
-
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
1083
|
-
}
|
|
1084
|
-
const invokeArrayFns = (fns, arg) => {
|
|
1085
|
-
let ret;
|
|
1086
|
-
for (let i = 0; i < fns.length; i++) {
|
|
1087
|
-
ret = fns[i](arg);
|
|
1088
|
-
}
|
|
1089
|
-
return ret;
|
|
1090
|
-
};
|
|
1091
|
-
function updateElementStyle(element, styles) {
|
|
1092
|
-
for (const attrName in styles) {
|
|
1093
|
-
element.style[attrName] = styles[attrName];
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
function once(fn, ctx = null) {
|
|
1097
|
-
let res;
|
|
1098
|
-
return ((...args) => {
|
|
1099
|
-
if (fn) {
|
|
1100
|
-
res = fn.apply(ctx, args);
|
|
1101
|
-
fn = null;
|
|
1102
|
-
}
|
|
1103
|
-
return res;
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
1107
|
-
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
1108
|
-
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
1109
|
-
if (mode === 'time') {
|
|
1110
|
-
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
1111
|
-
}
|
|
1112
|
-
else {
|
|
1113
|
-
return (date.getFullYear() +
|
|
1114
|
-
'-' +
|
|
1115
|
-
_completeValue(date.getMonth() + 1) +
|
|
1116
|
-
'-' +
|
|
1117
|
-
_completeValue(date.getDate()));
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
function callOptions(options, data) {
|
|
1121
|
-
options = options || {};
|
|
1122
|
-
if (typeof data === 'string') {
|
|
1123
|
-
data = {
|
|
1124
|
-
errMsg: data,
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
if (/:ok$/.test(data.errMsg)) {
|
|
1128
|
-
if (typeof options.success === 'function') {
|
|
1129
|
-
options.success(data);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
else {
|
|
1133
|
-
if (typeof options.fail === 'function') {
|
|
1134
|
-
options.fail(data);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
if (typeof options.complete === 'function') {
|
|
1138
|
-
options.complete(data);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
function getValueByDataPath(obj, path) {
|
|
1142
|
-
if (!isString(path)) {
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
1146
|
-
const parts = path.split('.');
|
|
1147
|
-
let key = parts[0];
|
|
1148
|
-
if (!obj) {
|
|
1149
|
-
obj = {};
|
|
1150
|
-
}
|
|
1151
|
-
if (parts.length === 1) {
|
|
1152
|
-
return obj[key];
|
|
1153
|
-
}
|
|
1154
|
-
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
1161
|
function debounce(fn, delay) {
|
|
1158
1162
|
let timeout;
|
|
1159
1163
|
const newFn = function () {
|
|
@@ -1343,4 +1347,4 @@ function getEnvLocale() {
|
|
|
1343
1347
|
return (lang && lang.replace(/[.:].*/, '')) || 'en';
|
|
1344
1348
|
}
|
|
1345
1349
|
|
|
1346
|
-
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, E$1 as Emitter, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVUE_BUILT_IN_TAGS, NVUE_U_BUILT_IN_TAGS, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, customizeEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultNVueRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath,
|
|
1350
|
+
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, E$1 as Emitter, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVUE_BUILT_IN_TAGS, NVUE_U_BUILT_IN_TAGS, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, customizeEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultNVueRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDatasetOnce, invokeArrayFns, isAppNVueNativeTag, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3031120220221001",
|
|
4
4
|
"description": "@dcloudio/uni-shared",
|
|
5
5
|
"main": "./dist/uni-shared.cjs.js",
|
|
6
6
|
"module": "./dist/uni-shared.es.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@vue/runtime-core": "3.2.
|
|
23
|
+
"@vue/runtime-core": "3.2.31"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vue/shared": "3.2.
|
|
26
|
+
"@vue/shared": "3.2.31"
|
|
27
27
|
}
|
|
28
28
|
}
|