@dcloudio/uni-shared 3.0.0-alpha-3030820220114007 → 3.0.0-alpha-3030820220114011
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 +165 -108
- package/dist/uni-shared.d.ts +15 -1
- package/dist/uni-shared.es.js +165 -109
- package/package.json +1 -1
package/dist/uni-shared.cjs.js
CHANGED
|
@@ -300,10 +300,106 @@ function formatLog(module, ...args) {
|
|
|
300
300
|
.join(' ')}`;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
function cache(fn) {
|
|
304
|
+
const cache = Object.create(null);
|
|
305
|
+
return (str) => {
|
|
306
|
+
const hit = cache[str];
|
|
307
|
+
return hit || (cache[str] = fn(str));
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function cacheStringFunction(fn) {
|
|
311
|
+
return cache(fn);
|
|
312
|
+
}
|
|
313
|
+
function getLen(str = '') {
|
|
314
|
+
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
315
|
+
}
|
|
316
|
+
function hasLeadingSlash(str) {
|
|
317
|
+
return str.indexOf('/') === 0;
|
|
318
|
+
}
|
|
319
|
+
function addLeadingSlash(str) {
|
|
320
|
+
return hasLeadingSlash(str) ? str : '/' + str;
|
|
321
|
+
}
|
|
322
|
+
function removeLeadingSlash(str) {
|
|
323
|
+
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
324
|
+
}
|
|
325
|
+
const invokeArrayFns = (fns, arg) => {
|
|
326
|
+
let ret;
|
|
327
|
+
for (let i = 0; i < fns.length; i++) {
|
|
328
|
+
ret = fns[i](arg);
|
|
329
|
+
}
|
|
330
|
+
return ret;
|
|
331
|
+
};
|
|
332
|
+
function updateElementStyle(element, styles) {
|
|
333
|
+
for (const attrName in styles) {
|
|
334
|
+
element.style[attrName] = styles[attrName];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function once(fn, ctx = null) {
|
|
338
|
+
let res;
|
|
339
|
+
return ((...args) => {
|
|
340
|
+
if (fn) {
|
|
341
|
+
res = fn.apply(ctx, args);
|
|
342
|
+
fn = null;
|
|
343
|
+
}
|
|
344
|
+
return res;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
348
|
+
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
349
|
+
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
350
|
+
if (mode === 'time') {
|
|
351
|
+
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
return (date.getFullYear() +
|
|
355
|
+
'-' +
|
|
356
|
+
_completeValue(date.getMonth() + 1) +
|
|
357
|
+
'-' +
|
|
358
|
+
_completeValue(date.getDate()));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function callOptions(options, data) {
|
|
362
|
+
options = options || {};
|
|
363
|
+
if (typeof data === 'string') {
|
|
364
|
+
data = {
|
|
365
|
+
errMsg: data,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (/:ok$/.test(data.errMsg)) {
|
|
369
|
+
if (typeof options.success === 'function') {
|
|
370
|
+
options.success(data);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
if (typeof options.fail === 'function') {
|
|
375
|
+
options.fail(data);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (typeof options.complete === 'function') {
|
|
379
|
+
options.complete(data);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function getValueByDataPath(obj, path) {
|
|
383
|
+
if (!shared.isString(path)) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
387
|
+
const parts = path.split('.');
|
|
388
|
+
let key = parts[0];
|
|
389
|
+
if (!obj) {
|
|
390
|
+
obj = {};
|
|
391
|
+
}
|
|
392
|
+
if (parts.length === 1) {
|
|
393
|
+
return obj[key];
|
|
394
|
+
}
|
|
395
|
+
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
396
|
+
}
|
|
397
|
+
|
|
303
398
|
function formatKey(key) {
|
|
304
399
|
return shared.camelize(key.substring(5));
|
|
305
400
|
}
|
|
306
|
-
|
|
401
|
+
// question/139181,增加副作用,避免 initCustomDataset 在 build 下被 tree-shaking
|
|
402
|
+
const initCustomDatasetOnce = /*#__PURE__*/ once(() => {
|
|
307
403
|
const prototype = HTMLElement.prototype;
|
|
308
404
|
const setAttribute = prototype.setAttribute;
|
|
309
405
|
prototype.setAttribute = function (key, value) {
|
|
@@ -323,7 +419,7 @@ function initCustomDataset() {
|
|
|
323
419
|
}
|
|
324
420
|
removeAttribute.call(this, key);
|
|
325
421
|
};
|
|
326
|
-
}
|
|
422
|
+
});
|
|
327
423
|
function getCustomDataset(el) {
|
|
328
424
|
return shared.extend({}, el.dataset, el.__uniDataset);
|
|
329
425
|
}
|
|
@@ -701,11 +797,13 @@ function parseEventName(name) {
|
|
|
701
797
|
return [shared.hyphenate(name.slice(2)), options];
|
|
702
798
|
}
|
|
703
799
|
|
|
704
|
-
const EventModifierFlags = {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
800
|
+
const EventModifierFlags = /*#__PURE__*/ (() => {
|
|
801
|
+
return {
|
|
802
|
+
stop: 1,
|
|
803
|
+
prevent: 1 << 1,
|
|
804
|
+
self: 1 << 2,
|
|
805
|
+
};
|
|
806
|
+
})();
|
|
709
807
|
function encodeModifier(modifiers) {
|
|
710
808
|
let flag = 0;
|
|
711
809
|
if (modifiers.includes('stop')) {
|
|
@@ -1061,101 +1159,6 @@ const ACTION_TYPE_ADD_WXS_EVENT = 12;
|
|
|
1061
1159
|
const ACTION_TYPE_PAGE_SCROLL = 15;
|
|
1062
1160
|
const ACTION_TYPE_EVENT = 20;
|
|
1063
1161
|
|
|
1064
|
-
function cache(fn) {
|
|
1065
|
-
const cache = Object.create(null);
|
|
1066
|
-
return (str) => {
|
|
1067
|
-
const hit = cache[str];
|
|
1068
|
-
return hit || (cache[str] = fn(str));
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function cacheStringFunction(fn) {
|
|
1072
|
-
return cache(fn);
|
|
1073
|
-
}
|
|
1074
|
-
function getLen(str = '') {
|
|
1075
|
-
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
1076
|
-
}
|
|
1077
|
-
function hasLeadingSlash(str) {
|
|
1078
|
-
return str.indexOf('/') === 0;
|
|
1079
|
-
}
|
|
1080
|
-
function addLeadingSlash(str) {
|
|
1081
|
-
return hasLeadingSlash(str) ? str : '/' + str;
|
|
1082
|
-
}
|
|
1083
|
-
function removeLeadingSlash(str) {
|
|
1084
|
-
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
1085
|
-
}
|
|
1086
|
-
const invokeArrayFns = (fns, arg) => {
|
|
1087
|
-
let ret;
|
|
1088
|
-
for (let i = 0; i < fns.length; i++) {
|
|
1089
|
-
ret = fns[i](arg);
|
|
1090
|
-
}
|
|
1091
|
-
return ret;
|
|
1092
|
-
};
|
|
1093
|
-
function updateElementStyle(element, styles) {
|
|
1094
|
-
for (const attrName in styles) {
|
|
1095
|
-
element.style[attrName] = styles[attrName];
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
function once(fn, ctx = null) {
|
|
1099
|
-
let res;
|
|
1100
|
-
return ((...args) => {
|
|
1101
|
-
if (fn) {
|
|
1102
|
-
res = fn.apply(ctx, args);
|
|
1103
|
-
fn = null;
|
|
1104
|
-
}
|
|
1105
|
-
return res;
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
1109
|
-
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
1110
|
-
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
1111
|
-
if (mode === 'time') {
|
|
1112
|
-
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
1113
|
-
}
|
|
1114
|
-
else {
|
|
1115
|
-
return (date.getFullYear() +
|
|
1116
|
-
'-' +
|
|
1117
|
-
_completeValue(date.getMonth() + 1) +
|
|
1118
|
-
'-' +
|
|
1119
|
-
_completeValue(date.getDate()));
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
function callOptions(options, data) {
|
|
1123
|
-
options = options || {};
|
|
1124
|
-
if (typeof data === 'string') {
|
|
1125
|
-
data = {
|
|
1126
|
-
errMsg: data,
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
if (/:ok$/.test(data.errMsg)) {
|
|
1130
|
-
if (typeof options.success === 'function') {
|
|
1131
|
-
options.success(data);
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
else {
|
|
1135
|
-
if (typeof options.fail === 'function') {
|
|
1136
|
-
options.fail(data);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
if (typeof options.complete === 'function') {
|
|
1140
|
-
options.complete(data);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
function getValueByDataPath(obj, path) {
|
|
1144
|
-
if (!shared.isString(path)) {
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
1148
|
-
const parts = path.split('.');
|
|
1149
|
-
let key = parts[0];
|
|
1150
|
-
if (!obj) {
|
|
1151
|
-
obj = {};
|
|
1152
|
-
}
|
|
1153
|
-
if (parts.length === 1) {
|
|
1154
|
-
return obj[key];
|
|
1155
|
-
}
|
|
1156
|
-
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
1162
|
function debounce(fn, delay) {
|
|
1160
1163
|
let timeout;
|
|
1161
1164
|
const newFn = function () {
|
|
@@ -1280,11 +1283,64 @@ const UniLifecycleHooks = [
|
|
|
1280
1283
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
|
|
1281
1284
|
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
|
|
1282
1285
|
];
|
|
1283
|
-
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1286
|
+
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
|
|
1287
|
+
return {
|
|
1288
|
+
onPageScroll: 1,
|
|
1289
|
+
onShareAppMessage: 1 << 1,
|
|
1290
|
+
onShareTimeline: 1 << 2,
|
|
1291
|
+
};
|
|
1292
|
+
})();
|
|
1293
|
+
|
|
1294
|
+
const E = function () {
|
|
1295
|
+
// Keep this empty so it's easier to inherit from
|
|
1296
|
+
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
|
1297
|
+
};
|
|
1298
|
+
E.prototype = {
|
|
1299
|
+
on: function (name, callback, ctx) {
|
|
1300
|
+
var e = this.e || (this.e = {});
|
|
1301
|
+
(e[name] || (e[name] = [])).push({
|
|
1302
|
+
fn: callback,
|
|
1303
|
+
ctx: ctx,
|
|
1304
|
+
});
|
|
1305
|
+
return this;
|
|
1306
|
+
},
|
|
1307
|
+
once: function (name, callback, ctx) {
|
|
1308
|
+
var self = this;
|
|
1309
|
+
function listener() {
|
|
1310
|
+
self.off(name, listener);
|
|
1311
|
+
callback.apply(ctx, arguments);
|
|
1312
|
+
}
|
|
1313
|
+
listener._ = callback;
|
|
1314
|
+
return this.on(name, listener, ctx);
|
|
1315
|
+
},
|
|
1316
|
+
emit: function (name) {
|
|
1317
|
+
var data = [].slice.call(arguments, 1);
|
|
1318
|
+
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
|
1319
|
+
var i = 0;
|
|
1320
|
+
var len = evtArr.length;
|
|
1321
|
+
for (i; i < len; i++) {
|
|
1322
|
+
evtArr[i].fn.apply(evtArr[i].ctx, data);
|
|
1323
|
+
}
|
|
1324
|
+
return this;
|
|
1325
|
+
},
|
|
1326
|
+
off: function (name, callback) {
|
|
1327
|
+
var e = this.e || (this.e = {});
|
|
1328
|
+
var evts = e[name];
|
|
1329
|
+
var liveEvents = [];
|
|
1330
|
+
if (evts && callback) {
|
|
1331
|
+
for (var i = 0, len = evts.length; i < len; i++) {
|
|
1332
|
+
if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
|
1333
|
+
liveEvents.push(evts[i]);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
// Remove event from queue to prevent memory leak
|
|
1337
|
+
// Suggested by https://github.com/lazd
|
|
1338
|
+
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
|
|
1339
|
+
liveEvents.length ? (e[name] = liveEvents) : delete e[name];
|
|
1340
|
+
return this;
|
|
1341
|
+
},
|
|
1342
|
+
};
|
|
1343
|
+
var E$1 = E;
|
|
1288
1344
|
|
|
1289
1345
|
function getEnvLocale() {
|
|
1290
1346
|
const { env } = process;
|
|
@@ -1320,6 +1376,7 @@ exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX;
|
|
|
1320
1376
|
exports.COMPONENT_PREFIX = COMPONENT_PREFIX;
|
|
1321
1377
|
exports.COMPONENT_SELECTOR_PREFIX = COMPONENT_SELECTOR_PREFIX;
|
|
1322
1378
|
exports.DATA_RE = DATA_RE;
|
|
1379
|
+
exports.Emitter = E$1;
|
|
1323
1380
|
exports.EventChannel = EventChannel;
|
|
1324
1381
|
exports.EventModifierFlags = EventModifierFlags;
|
|
1325
1382
|
exports.I18N_JSON_DELIMITERS = I18N_JSON_DELIMITERS;
|
|
@@ -1415,7 +1472,7 @@ exports.getCustomDataset = getCustomDataset;
|
|
|
1415
1472
|
exports.getEnvLocale = getEnvLocale;
|
|
1416
1473
|
exports.getLen = getLen;
|
|
1417
1474
|
exports.getValueByDataPath = getValueByDataPath;
|
|
1418
|
-
exports.
|
|
1475
|
+
exports.initCustomDatasetOnce = initCustomDatasetOnce;
|
|
1419
1476
|
exports.invokeArrayFns = invokeArrayFns;
|
|
1420
1477
|
exports.isAppNVueNativeTag = isAppNVueNativeTag;
|
|
1421
1478
|
exports.isAppNativeTag = isAppNativeTag;
|
package/dist/uni-shared.d.ts
CHANGED
|
@@ -164,6 +164,18 @@ declare type DictArray = [number, number][];
|
|
|
164
164
|
|
|
165
165
|
export declare function dynamicSlotName(name: string): string;
|
|
166
166
|
|
|
167
|
+
export declare interface Emitter {
|
|
168
|
+
e: Record<string, unknown>;
|
|
169
|
+
on: (name: EventName, callback: EventCallback, ctx?: any) => this;
|
|
170
|
+
once: (name: EventName, callback: EventCallback, ctx?: any) => this;
|
|
171
|
+
emit: (name: EventName, ...args: any[]) => this;
|
|
172
|
+
off: (name: EventName, callback?: EventCallback) => this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare const Emitter: new () => Emitter;
|
|
176
|
+
|
|
177
|
+
declare type EventCallback = Function;
|
|
178
|
+
|
|
167
179
|
export declare class EventChannel {
|
|
168
180
|
id?: number;
|
|
169
181
|
private listener;
|
|
@@ -188,6 +200,8 @@ export declare const EventModifierFlags: {
|
|
|
188
200
|
self: number;
|
|
189
201
|
};
|
|
190
202
|
|
|
203
|
+
declare type EventName = string;
|
|
204
|
+
|
|
191
205
|
export declare const forcePatchProp: (el: {
|
|
192
206
|
nodeName: string;
|
|
193
207
|
}, key: string) => boolean;
|
|
@@ -217,7 +231,7 @@ declare interface HTMLElementWithDataset extends HTMLElement {
|
|
|
217
231
|
|
|
218
232
|
export declare const I18N_JSON_DELIMITERS: [string, string];
|
|
219
233
|
|
|
220
|
-
export declare
|
|
234
|
+
export declare const initCustomDatasetOnce: () => void;
|
|
221
235
|
|
|
222
236
|
/**
|
|
223
237
|
* nodeId
|
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',
|
|
@@ -296,10 +296,106 @@ function formatLog(module, ...args) {
|
|
|
296
296
|
.join(' ')}`;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
function cache(fn) {
|
|
300
|
+
const cache = Object.create(null);
|
|
301
|
+
return (str) => {
|
|
302
|
+
const hit = cache[str];
|
|
303
|
+
return hit || (cache[str] = fn(str));
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function cacheStringFunction(fn) {
|
|
307
|
+
return cache(fn);
|
|
308
|
+
}
|
|
309
|
+
function getLen(str = '') {
|
|
310
|
+
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
311
|
+
}
|
|
312
|
+
function hasLeadingSlash(str) {
|
|
313
|
+
return str.indexOf('/') === 0;
|
|
314
|
+
}
|
|
315
|
+
function addLeadingSlash(str) {
|
|
316
|
+
return hasLeadingSlash(str) ? str : '/' + str;
|
|
317
|
+
}
|
|
318
|
+
function removeLeadingSlash(str) {
|
|
319
|
+
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
320
|
+
}
|
|
321
|
+
const invokeArrayFns = (fns, arg) => {
|
|
322
|
+
let ret;
|
|
323
|
+
for (let i = 0; i < fns.length; i++) {
|
|
324
|
+
ret = fns[i](arg);
|
|
325
|
+
}
|
|
326
|
+
return ret;
|
|
327
|
+
};
|
|
328
|
+
function updateElementStyle(element, styles) {
|
|
329
|
+
for (const attrName in styles) {
|
|
330
|
+
element.style[attrName] = styles[attrName];
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function once(fn, ctx = null) {
|
|
334
|
+
let res;
|
|
335
|
+
return ((...args) => {
|
|
336
|
+
if (fn) {
|
|
337
|
+
res = fn.apply(ctx, args);
|
|
338
|
+
fn = null;
|
|
339
|
+
}
|
|
340
|
+
return res;
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
344
|
+
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
345
|
+
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
346
|
+
if (mode === 'time') {
|
|
347
|
+
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
return (date.getFullYear() +
|
|
351
|
+
'-' +
|
|
352
|
+
_completeValue(date.getMonth() + 1) +
|
|
353
|
+
'-' +
|
|
354
|
+
_completeValue(date.getDate()));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function callOptions(options, data) {
|
|
358
|
+
options = options || {};
|
|
359
|
+
if (typeof data === 'string') {
|
|
360
|
+
data = {
|
|
361
|
+
errMsg: data,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if (/:ok$/.test(data.errMsg)) {
|
|
365
|
+
if (typeof options.success === 'function') {
|
|
366
|
+
options.success(data);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
if (typeof options.fail === 'function') {
|
|
371
|
+
options.fail(data);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (typeof options.complete === 'function') {
|
|
375
|
+
options.complete(data);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function getValueByDataPath(obj, path) {
|
|
379
|
+
if (!isString(path)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
383
|
+
const parts = path.split('.');
|
|
384
|
+
let key = parts[0];
|
|
385
|
+
if (!obj) {
|
|
386
|
+
obj = {};
|
|
387
|
+
}
|
|
388
|
+
if (parts.length === 1) {
|
|
389
|
+
return obj[key];
|
|
390
|
+
}
|
|
391
|
+
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
392
|
+
}
|
|
393
|
+
|
|
299
394
|
function formatKey(key) {
|
|
300
395
|
return camelize(key.substring(5));
|
|
301
396
|
}
|
|
302
|
-
|
|
397
|
+
// question/139181,增加副作用,避免 initCustomDataset 在 build 下被 tree-shaking
|
|
398
|
+
const initCustomDatasetOnce = /*#__PURE__*/ once(() => {
|
|
303
399
|
const prototype = HTMLElement.prototype;
|
|
304
400
|
const setAttribute = prototype.setAttribute;
|
|
305
401
|
prototype.setAttribute = function (key, value) {
|
|
@@ -319,7 +415,7 @@ function initCustomDataset() {
|
|
|
319
415
|
}
|
|
320
416
|
removeAttribute.call(this, key);
|
|
321
417
|
};
|
|
322
|
-
}
|
|
418
|
+
});
|
|
323
419
|
function getCustomDataset(el) {
|
|
324
420
|
return extend({}, el.dataset, el.__uniDataset);
|
|
325
421
|
}
|
|
@@ -697,11 +793,13 @@ function parseEventName(name) {
|
|
|
697
793
|
return [hyphenate(name.slice(2)), options];
|
|
698
794
|
}
|
|
699
795
|
|
|
700
|
-
const EventModifierFlags = {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
796
|
+
const EventModifierFlags = /*#__PURE__*/ (() => {
|
|
797
|
+
return {
|
|
798
|
+
stop: 1,
|
|
799
|
+
prevent: 1 << 1,
|
|
800
|
+
self: 1 << 2,
|
|
801
|
+
};
|
|
802
|
+
})();
|
|
705
803
|
function encodeModifier(modifiers) {
|
|
706
804
|
let flag = 0;
|
|
707
805
|
if (modifiers.includes('stop')) {
|
|
@@ -1057,101 +1155,6 @@ const ACTION_TYPE_ADD_WXS_EVENT = 12;
|
|
|
1057
1155
|
const ACTION_TYPE_PAGE_SCROLL = 15;
|
|
1058
1156
|
const ACTION_TYPE_EVENT = 20;
|
|
1059
1157
|
|
|
1060
|
-
function cache(fn) {
|
|
1061
|
-
const cache = Object.create(null);
|
|
1062
|
-
return (str) => {
|
|
1063
|
-
const hit = cache[str];
|
|
1064
|
-
return hit || (cache[str] = fn(str));
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
function cacheStringFunction(fn) {
|
|
1068
|
-
return cache(fn);
|
|
1069
|
-
}
|
|
1070
|
-
function getLen(str = '') {
|
|
1071
|
-
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
|
|
1072
|
-
}
|
|
1073
|
-
function hasLeadingSlash(str) {
|
|
1074
|
-
return str.indexOf('/') === 0;
|
|
1075
|
-
}
|
|
1076
|
-
function addLeadingSlash(str) {
|
|
1077
|
-
return hasLeadingSlash(str) ? str : '/' + str;
|
|
1078
|
-
}
|
|
1079
|
-
function removeLeadingSlash(str) {
|
|
1080
|
-
return hasLeadingSlash(str) ? str.substr(1) : str;
|
|
1081
|
-
}
|
|
1082
|
-
const invokeArrayFns = (fns, arg) => {
|
|
1083
|
-
let ret;
|
|
1084
|
-
for (let i = 0; i < fns.length; i++) {
|
|
1085
|
-
ret = fns[i](arg);
|
|
1086
|
-
}
|
|
1087
|
-
return ret;
|
|
1088
|
-
};
|
|
1089
|
-
function updateElementStyle(element, styles) {
|
|
1090
|
-
for (const attrName in styles) {
|
|
1091
|
-
element.style[attrName] = styles[attrName];
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
function once(fn, ctx = null) {
|
|
1095
|
-
let res;
|
|
1096
|
-
return ((...args) => {
|
|
1097
|
-
if (fn) {
|
|
1098
|
-
res = fn.apply(ctx, args);
|
|
1099
|
-
fn = null;
|
|
1100
|
-
}
|
|
1101
|
-
return res;
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
|
|
1105
|
-
const _completeValue = (value) => (value > 9 ? value : '0' + value);
|
|
1106
|
-
function formatDateTime({ date = new Date(), mode = 'date' }) {
|
|
1107
|
-
if (mode === 'time') {
|
|
1108
|
-
return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
|
|
1109
|
-
}
|
|
1110
|
-
else {
|
|
1111
|
-
return (date.getFullYear() +
|
|
1112
|
-
'-' +
|
|
1113
|
-
_completeValue(date.getMonth() + 1) +
|
|
1114
|
-
'-' +
|
|
1115
|
-
_completeValue(date.getDate()));
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
function callOptions(options, data) {
|
|
1119
|
-
options = options || {};
|
|
1120
|
-
if (typeof data === 'string') {
|
|
1121
|
-
data = {
|
|
1122
|
-
errMsg: data,
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
if (/:ok$/.test(data.errMsg)) {
|
|
1126
|
-
if (typeof options.success === 'function') {
|
|
1127
|
-
options.success(data);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
else {
|
|
1131
|
-
if (typeof options.fail === 'function') {
|
|
1132
|
-
options.fail(data);
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
if (typeof options.complete === 'function') {
|
|
1136
|
-
options.complete(data);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
function getValueByDataPath(obj, path) {
|
|
1140
|
-
if (!isString(path)) {
|
|
1141
|
-
return;
|
|
1142
|
-
}
|
|
1143
|
-
path = path.replace(/\[(\d+)\]/g, '.$1');
|
|
1144
|
-
const parts = path.split('.');
|
|
1145
|
-
let key = parts[0];
|
|
1146
|
-
if (!obj) {
|
|
1147
|
-
obj = {};
|
|
1148
|
-
}
|
|
1149
|
-
if (parts.length === 1) {
|
|
1150
|
-
return obj[key];
|
|
1151
|
-
}
|
|
1152
|
-
return getValueByDataPath(obj[key], parts.slice(1).join('.'));
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
1158
|
function debounce(fn, delay) {
|
|
1156
1159
|
let timeout;
|
|
1157
1160
|
const newFn = function () {
|
|
@@ -1276,11 +1279,64 @@ const UniLifecycleHooks = [
|
|
|
1276
1279
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
|
|
1277
1280
|
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
|
|
1278
1281
|
];
|
|
1279
|
-
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1282
|
+
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
|
|
1283
|
+
return {
|
|
1284
|
+
onPageScroll: 1,
|
|
1285
|
+
onShareAppMessage: 1 << 1,
|
|
1286
|
+
onShareTimeline: 1 << 2,
|
|
1287
|
+
};
|
|
1288
|
+
})();
|
|
1289
|
+
|
|
1290
|
+
const E = function () {
|
|
1291
|
+
// Keep this empty so it's easier to inherit from
|
|
1292
|
+
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
|
1293
|
+
};
|
|
1294
|
+
E.prototype = {
|
|
1295
|
+
on: function (name, callback, ctx) {
|
|
1296
|
+
var e = this.e || (this.e = {});
|
|
1297
|
+
(e[name] || (e[name] = [])).push({
|
|
1298
|
+
fn: callback,
|
|
1299
|
+
ctx: ctx,
|
|
1300
|
+
});
|
|
1301
|
+
return this;
|
|
1302
|
+
},
|
|
1303
|
+
once: function (name, callback, ctx) {
|
|
1304
|
+
var self = this;
|
|
1305
|
+
function listener() {
|
|
1306
|
+
self.off(name, listener);
|
|
1307
|
+
callback.apply(ctx, arguments);
|
|
1308
|
+
}
|
|
1309
|
+
listener._ = callback;
|
|
1310
|
+
return this.on(name, listener, ctx);
|
|
1311
|
+
},
|
|
1312
|
+
emit: function (name) {
|
|
1313
|
+
var data = [].slice.call(arguments, 1);
|
|
1314
|
+
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
|
1315
|
+
var i = 0;
|
|
1316
|
+
var len = evtArr.length;
|
|
1317
|
+
for (i; i < len; i++) {
|
|
1318
|
+
evtArr[i].fn.apply(evtArr[i].ctx, data);
|
|
1319
|
+
}
|
|
1320
|
+
return this;
|
|
1321
|
+
},
|
|
1322
|
+
off: function (name, callback) {
|
|
1323
|
+
var e = this.e || (this.e = {});
|
|
1324
|
+
var evts = e[name];
|
|
1325
|
+
var liveEvents = [];
|
|
1326
|
+
if (evts && callback) {
|
|
1327
|
+
for (var i = 0, len = evts.length; i < len; i++) {
|
|
1328
|
+
if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
|
1329
|
+
liveEvents.push(evts[i]);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
// Remove event from queue to prevent memory leak
|
|
1333
|
+
// Suggested by https://github.com/lazd
|
|
1334
|
+
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
|
|
1335
|
+
liveEvents.length ? (e[name] = liveEvents) : delete e[name];
|
|
1336
|
+
return this;
|
|
1337
|
+
},
|
|
1338
|
+
};
|
|
1339
|
+
var E$1 = E;
|
|
1284
1340
|
|
|
1285
1341
|
function getEnvLocale() {
|
|
1286
1342
|
const { env } = process;
|
|
@@ -1288,4 +1344,4 @@ function getEnvLocale() {
|
|
|
1288
1344
|
return (lang && lang.replace(/[.:].*/, '')) || 'en';
|
|
1289
1345
|
}
|
|
1290
1346
|
|
|
1291
|
-
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, 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,
|
|
1347
|
+
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