mazey 3.6.3 → 3.6.5

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/lib/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * mazey v3.6.3
2
+ * mazey v3.6.5
3
3
  * (c) 2018-2023 Mazey Chu
4
4
  * Released under the MIT License.
5
5
  */
@@ -2654,8 +2654,99 @@ _export({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== obje
2654
2654
  assign: objectAssign
2655
2655
  });
2656
2656
 
2657
+ var path = global_1;
2658
+
2659
+ var getOwnPropertyNames = objectGetOwnPropertyNames.f;
2660
+ var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
2657
2661
  var defineProperty$1 = objectDefineProperty.f;
2658
2662
 
2663
+ var trim = stringTrim.trim;
2664
+
2665
+ var NUMBER = 'Number';
2666
+ var NativeNumber = global_1[NUMBER];
2667
+ path[NUMBER];
2668
+ var NumberPrototype = NativeNumber.prototype;
2669
+ var TypeError$2 = global_1.TypeError;
2670
+ var stringSlice = functionUncurryThis(''.slice);
2671
+ var charCodeAt = functionUncurryThis(''.charCodeAt);
2672
+
2673
+ // `ToNumeric` abstract operation
2674
+ // https://tc39.es/ecma262/#sec-tonumeric
2675
+ var toNumeric = function (value) {
2676
+ var primValue = toPrimitive(value, 'number');
2677
+ return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
2678
+ };
2679
+
2680
+ // `ToNumber` abstract operation
2681
+ // https://tc39.es/ecma262/#sec-tonumber
2682
+ var toNumber = function (argument) {
2683
+ var it = toPrimitive(argument, 'number');
2684
+ var first, third, radix, maxCode, digits, length, index, code;
2685
+ if (isSymbol(it)) throw TypeError$2('Cannot convert a Symbol value to a number');
2686
+ if (typeof it == 'string' && it.length > 2) {
2687
+ it = trim(it);
2688
+ first = charCodeAt(it, 0);
2689
+ if (first === 43 || first === 45) {
2690
+ third = charCodeAt(it, 2);
2691
+ if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
2692
+ } else if (first === 48) {
2693
+ switch (charCodeAt(it, 1)) {
2694
+ case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
2695
+ case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
2696
+ default: return +it;
2697
+ }
2698
+ digits = stringSlice(it, 2);
2699
+ length = digits.length;
2700
+ for (index = 0; index < length; index++) {
2701
+ code = charCodeAt(digits, index);
2702
+ // parseInt parses a string to a first unavailable symbol
2703
+ // but ToNumber should return NaN if a string contains unavailable symbols
2704
+ if (code < 48 || code > maxCode) return NaN;
2705
+ } return parseInt(digits, radix);
2706
+ }
2707
+ } return +it;
2708
+ };
2709
+
2710
+ var FORCED$1 = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
2711
+
2712
+ var calledWithNew = function (dummy) {
2713
+ // includes check on 1..constructor(foo) case
2714
+ return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
2715
+ };
2716
+
2717
+ // `Number` constructor
2718
+ // https://tc39.es/ecma262/#sec-number-constructor
2719
+ var NumberWrapper = function Number(value) {
2720
+ var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
2721
+ return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
2722
+ };
2723
+
2724
+ NumberWrapper.prototype = NumberPrototype;
2725
+ if (FORCED$1 && !isPure) NumberPrototype.constructor = NumberWrapper;
2726
+
2727
+ _export({ global: true, constructor: true, wrap: true, forced: FORCED$1 }, {
2728
+ Number: NumberWrapper
2729
+ });
2730
+
2731
+ // Use `internal/copy-constructor-properties` helper in `core-js@4`
2732
+ var copyConstructorProperties = function (target, source) {
2733
+ for (var keys = descriptors ? getOwnPropertyNames(source) : (
2734
+ // ES3:
2735
+ 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
2736
+ // ES2015 (in case, if modules with ES2015 Number statics required before):
2737
+ 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
2738
+ // ESNext
2739
+ 'fromString,range'
2740
+ ).split(','), j = 0, key; keys.length > j; j++) {
2741
+ if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
2742
+ defineProperty$1(target, key, getOwnPropertyDescriptor$2(source, key));
2743
+ }
2744
+ }
2745
+ };
2746
+ if (FORCED$1 || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
2747
+
2748
+ var defineProperty = objectDefineProperty.f;
2749
+
2659
2750
 
2660
2751
 
2661
2752
  var TO_STRING_TAG = wellKnownSymbol('toStringTag');
@@ -2663,7 +2754,7 @@ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2663
2754
  var setToStringTag = function (target, TAG, STATIC) {
2664
2755
  if (target && !STATIC) target = target.prototype;
2665
2756
  if (target && !hasOwnProperty_1(target, TO_STRING_TAG)) {
2666
- defineProperty$1(target, TO_STRING_TAG, { configurable: true, value: TAG });
2757
+ defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
2667
2758
  }
2668
2759
  };
2669
2760
 
@@ -2827,7 +2918,7 @@ var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && typeof Pebb
2827
2918
 
2828
2919
  var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent);
2829
2920
 
2830
- var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
2921
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
2831
2922
  var macrotask = task$1.set;
2832
2923
 
2833
2924
 
@@ -2840,7 +2931,7 @@ var document$2 = global_1.document;
2840
2931
  var process$2 = global_1.process;
2841
2932
  var Promise$1 = global_1.Promise;
2842
2933
  // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
2843
- var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask');
2934
+ var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global_1, 'queueMicrotask');
2844
2935
  var microtask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
2845
2936
  var notify$1, toggle, node, promise, then;
2846
2937
 
@@ -3007,7 +3098,7 @@ var setInternalState = internalState.set;
3007
3098
  var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
3008
3099
  var PromiseConstructor = promiseNativeConstructor;
3009
3100
  var PromisePrototype = NativePromisePrototype$1;
3010
- var TypeError$2 = global_1.TypeError;
3101
+ var TypeError$1 = global_1.TypeError;
3011
3102
  var document$1 = global_1.document;
3012
3103
  var process$1 = global_1.process;
3013
3104
  var newPromiseCapability = newPromiseCapability$1.f;
@@ -3054,7 +3145,7 @@ var callReaction = function (reaction, state) {
3054
3145
  }
3055
3146
  }
3056
3147
  if (result === reaction.promise) {
3057
- reject(TypeError$2('Promise-chain cycle'));
3148
+ reject(TypeError$1('Promise-chain cycle'));
3058
3149
  } else if (then = isThenable(result)) {
3059
3150
  functionCall(then, result, resolve, reject);
3060
3151
  } else resolve(result);
@@ -3144,7 +3235,7 @@ var internalResolve = function (state, value, unwrap) {
3144
3235
  state.done = true;
3145
3236
  if (unwrap) state = unwrap;
3146
3237
  try {
3147
- if (state.facade === value) throw TypeError$2("Promise can't be resolved itself");
3238
+ if (state.facade === value) throw TypeError$1("Promise can't be resolved itself");
3148
3239
  var then = isThenable(value);
3149
3240
  if (then) {
3150
3241
  microtask_1(function () {
@@ -3544,11 +3635,11 @@ if (descriptors && !FUNCTION_NAME_EXISTS) {
3544
3635
  var nativeJoin = functionUncurryThis([].join);
3545
3636
 
3546
3637
  var ES3_STRINGS = indexedObject != Object;
3547
- var FORCED$1 = ES3_STRINGS || !arrayMethodIsStrict('join', ',');
3638
+ var FORCED = ES3_STRINGS || !arrayMethodIsStrict('join', ',');
3548
3639
 
3549
3640
  // `Array.prototype.join` method
3550
3641
  // https://tc39.es/ecma262/#sec-array.prototype.join
3551
- _export({ target: 'Array', proto: true, forced: FORCED$1 }, {
3642
+ _export({ target: 'Array', proto: true, forced: FORCED }, {
3552
3643
  join: function join(separator) {
3553
3644
  return nativeJoin(toIndexedObject(this), separator === undefined ? ',' : separator);
3554
3645
  }
@@ -3801,97 +3892,6 @@ _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes
3801
3892
  }
3802
3893
  });
3803
3894
 
3804
- var path = global_1;
3805
-
3806
- var getOwnPropertyNames = objectGetOwnPropertyNames.f;
3807
- var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
3808
- var defineProperty = objectDefineProperty.f;
3809
-
3810
- var trim = stringTrim.trim;
3811
-
3812
- var NUMBER = 'Number';
3813
- var NativeNumber = global_1[NUMBER];
3814
- path[NUMBER];
3815
- var NumberPrototype = NativeNumber.prototype;
3816
- var TypeError$1 = global_1.TypeError;
3817
- var stringSlice = functionUncurryThis(''.slice);
3818
- var charCodeAt = functionUncurryThis(''.charCodeAt);
3819
-
3820
- // `ToNumeric` abstract operation
3821
- // https://tc39.es/ecma262/#sec-tonumeric
3822
- var toNumeric = function (value) {
3823
- var primValue = toPrimitive(value, 'number');
3824
- return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
3825
- };
3826
-
3827
- // `ToNumber` abstract operation
3828
- // https://tc39.es/ecma262/#sec-tonumber
3829
- var toNumber = function (argument) {
3830
- var it = toPrimitive(argument, 'number');
3831
- var first, third, radix, maxCode, digits, length, index, code;
3832
- if (isSymbol(it)) throw TypeError$1('Cannot convert a Symbol value to a number');
3833
- if (typeof it == 'string' && it.length > 2) {
3834
- it = trim(it);
3835
- first = charCodeAt(it, 0);
3836
- if (first === 43 || first === 45) {
3837
- third = charCodeAt(it, 2);
3838
- if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
3839
- } else if (first === 48) {
3840
- switch (charCodeAt(it, 1)) {
3841
- case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
3842
- case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
3843
- default: return +it;
3844
- }
3845
- digits = stringSlice(it, 2);
3846
- length = digits.length;
3847
- for (index = 0; index < length; index++) {
3848
- code = charCodeAt(digits, index);
3849
- // parseInt parses a string to a first unavailable symbol
3850
- // but ToNumber should return NaN if a string contains unavailable symbols
3851
- if (code < 48 || code > maxCode) return NaN;
3852
- } return parseInt(digits, radix);
3853
- }
3854
- } return +it;
3855
- };
3856
-
3857
- var FORCED = isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'));
3858
-
3859
- var calledWithNew = function (dummy) {
3860
- // includes check on 1..constructor(foo) case
3861
- return objectIsPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); });
3862
- };
3863
-
3864
- // `Number` constructor
3865
- // https://tc39.es/ecma262/#sec-number-constructor
3866
- var NumberWrapper = function Number(value) {
3867
- var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
3868
- return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n;
3869
- };
3870
-
3871
- NumberWrapper.prototype = NumberPrototype;
3872
- if (FORCED && !isPure) NumberPrototype.constructor = NumberWrapper;
3873
-
3874
- _export({ global: true, constructor: true, wrap: true, forced: FORCED }, {
3875
- Number: NumberWrapper
3876
- });
3877
-
3878
- // Use `internal/copy-constructor-properties` helper in `core-js@4`
3879
- var copyConstructorProperties = function (target, source) {
3880
- for (var keys = descriptors ? getOwnPropertyNames(source) : (
3881
- // ES3:
3882
- 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
3883
- // ES2015 (in case, if modules with ES2015 Number statics required before):
3884
- 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
3885
- // ESNext
3886
- 'fromString,range'
3887
- ).split(','), j = 0, key; keys.length > j; j++) {
3888
- if (hasOwnProperty_1(source, key = keys[j]) && !hasOwnProperty_1(target, key)) {
3889
- defineProperty(target, key, getOwnPropertyDescriptor$1(source, key));
3890
- }
3891
- }
3892
- };
3893
- if (FORCED || isPure) copyConstructorProperties(path[NUMBER], NativeNumber);
3894
-
3895
3895
  var $TypeError$1 = TypeError;
3896
3896
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
3897
3897
  var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
@@ -3992,6 +3992,17 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3992
3992
  PERFORMANCE OF THIS SOFTWARE.
3993
3993
  ***************************************************************************** */
3994
3994
 
3995
+ var __assign = function() {
3996
+ __assign = Object.assign || function __assign(t) {
3997
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3998
+ s = arguments[i];
3999
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4000
+ }
4001
+ return t;
4002
+ };
4003
+ return __assign.apply(this, arguments);
4004
+ };
4005
+
3995
4006
  function __spreadArray(to, from) {
3996
4007
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
3997
4008
  to[j] = from[i];
@@ -4223,6 +4234,10 @@ function getHashQueryParam(param) {
4223
4234
  * ```
4224
4235
  * getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
4225
4236
  * getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
4237
+ * getDomain('http://example.com:7890/test/thanks', ['hostname']);
4238
+ * getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
4239
+ * getDomain('http://example.com:7890/test/thanks', ['origin']);
4240
+ * getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
4226
4241
  * ```
4227
4242
  *
4228
4243
  * Output:
@@ -4230,10 +4245,14 @@ function getHashQueryParam(param) {
4230
4245
  * ```
4231
4246
  * example.com
4232
4247
  * example.com/test/thanks
4248
+ * example.com
4249
+ * example.com:7890
4250
+ * http://example.com:7890
4251
+ * http://example.com:7890/test/thanks?id=1
4233
4252
  * ```
4234
4253
  *
4235
4254
  * @param {string} url
4236
- * @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
4255
+ * @param {array} rules Object.keys(location), ['href', 'origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
4237
4256
  * @category URL
4238
4257
  */
4239
4258
  function getDomain(url, rules) {
@@ -4251,34 +4270,50 @@ function getDomain(url, rules) {
4251
4270
  * Transfer CamelCase to KebabCase.
4252
4271
  *
4253
4272
  * ```
4254
- * camelCaseToKebabCase('ABC'); // a-b-c
4255
- * camelCaseToKebabCase('aBC'); // a-b-c
4273
+ * convertCamelToKebab('ABC'); // a-b-c
4274
+ * convertCamelToKebab('aBC'); // a-b-c
4256
4275
  * ```
4257
4276
  *
4258
4277
  * @param {string} camelCase 'aBC' or 'ABC'
4259
4278
  * @returns {string} 'a-b-c'
4260
4279
  * @category Util
4261
4280
  */
4262
- function camelCaseToKebabCase(camelCase) {
4281
+ function convertCamelToKebab(camelCase) {
4263
4282
  var kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
4264
4283
  return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
4265
4284
  }
4285
+ /**
4286
+ * Alias of convertCamelToKebab
4287
+ *
4288
+ * @hidden
4289
+ */
4290
+ function camelCaseToKebabCase(camelCase) {
4291
+ return convertCamelToKebab(camelCase);
4292
+ }
4266
4293
  /**
4267
4294
  * Transfer CamelCase to Underscore.
4268
4295
  *
4269
4296
  * ```
4270
- * camelCase2Underscore('ABC'); // a_b_c
4271
- * camelCase2Underscore('aBC'); // a_b_c
4297
+ * convertCamelToUnder('ABC'); // a_b_c
4298
+ * convertCamelToUnder('aBC'); // a_b_c
4272
4299
  * ```
4273
4300
  *
4274
4301
  * @param {string} camelCase 'aBC' or 'ABC'
4275
4302
  * @returns {string} 'a_b_c'
4276
4303
  * @category Util
4277
4304
  */
4278
- function camelCase2Underscore(camelCase) {
4305
+ function convertCamelToUnder(camelCase) {
4279
4306
  var kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
4280
4307
  return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
4281
4308
  }
4309
+ /**
4310
+ * Alias of convertCamelToUnder
4311
+ *
4312
+ * @hidden
4313
+ */
4314
+ function camelCase2Underscore(camelCase) {
4315
+ return convertCamelToUnder(camelCase);
4316
+ }
4282
4317
  /**
4283
4318
  * Remove leading and trailing whitespace or specified characters from string.
4284
4319
  *
@@ -4350,8 +4385,8 @@ function deepCopyObject(obj) {
4350
4385
  * Usage:
4351
4386
  *
4352
4387
  * ```
4353
- * isJsonString(`['a', 'b', 'c']`);
4354
- * isJsonString(`["a", "b", "c"]`);
4388
+ * isJSONString(`['a', 'b', 'c']`);
4389
+ * isJSONString(`["a", "b", "c"]`);
4355
4390
  * ```
4356
4391
  *
4357
4392
  * Output:
@@ -4365,7 +4400,7 @@ function deepCopyObject(obj) {
4365
4400
  * @returns {boolean} Return the result of checking.
4366
4401
  * @category Util
4367
4402
  */
4368
- function isJsonString(str) {
4403
+ function isJSONString(str) {
4369
4404
  try {
4370
4405
  if (_typeof(JSON.parse(str)) === 'object') {
4371
4406
  return true;
@@ -4375,6 +4410,14 @@ function isJsonString(str) {
4375
4410
  }
4376
4411
  return false;
4377
4412
  }
4413
+ /**
4414
+ * Alias of isJSONString
4415
+ *
4416
+ * @hidden
4417
+ */
4418
+ function isJsonString(str) {
4419
+ return isJSONString(str);
4420
+ }
4378
4421
  /**
4379
4422
  * Produce a random string of number, `generateRndNum(7)` => '7658495'.
4380
4423
  *
@@ -4652,16 +4695,26 @@ function debounce(func, wait, immediate) {
4652
4695
  return result;
4653
4696
  };
4654
4697
  }
4698
+ var defaultGetFriendlyIntervalOptions = {
4699
+ type: 'd'
4700
+ };
4655
4701
  /**
4656
- * @method friendlyInterval
4657
- * @description 获取间隔时间。
4702
+ * 获取间隔时间
4703
+ *
4704
+ * @example
4705
+ * ```js
4706
+ * console.log('getFriendlyInterval:', getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' })); // 1116
4707
+ * console.log('getFriendlyInterval:', getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' })); // 1116 天 10 时 44 分 33 秒
4708
+ * console.log('getFriendlyInterval:', getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' })); // 1116 天 10 时 44 分 33 秒
4709
+ * ```
4710
+ *
4658
4711
  * @param {number/Date} start 开始时间戳 1585325367122
4659
4712
  * @param {number/Date} end 结束时间戳 1585325367122
4660
4713
  * @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
4661
4714
  * @returns {string/number} 取决于 type
4662
4715
  * @category Util
4663
4716
  */
4664
- function friendlyInterval(start, end, options) {
4717
+ function getFriendlyInterval(start, end, options) {
4665
4718
  if (start === void 0) {
4666
4719
  start = 0;
4667
4720
  }
@@ -4669,14 +4722,13 @@ function friendlyInterval(start, end, options) {
4669
4722
  end = 0;
4670
4723
  }
4671
4724
  if (options === void 0) {
4672
- options = {
4673
- type: 'd'
4674
- };
4725
+ options = defaultGetFriendlyIntervalOptions;
4675
4726
  }
4727
+ options = Object.assign(defaultGetFriendlyIntervalOptions, options);
4676
4728
  var type = options.type;
4677
4729
  if (!isNumber(start)) start = new Date(start).getTime();
4678
4730
  if (!isNumber(end)) end = new Date(end).getTime();
4679
- var t = end - start;
4731
+ var t = Number(end) - Number(start);
4680
4732
  var ret = '';
4681
4733
  var _a = new Array(4).fill(0),
4682
4734
  d = _a[0],
@@ -5257,7 +5309,7 @@ function getCookie(name) {
5257
5309
  * Results:
5258
5310
  *
5259
5311
  * | Attribute | Description | Type | Values |
5260
- * | --- | --- | --- | --- |
5312
+ * | :------------ | :------------ | :------------ | :------------ |
5261
5313
  * | dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
5262
5314
  * | tcp_time | Connection Negotiation | number | connectEnd - connectStart |
5263
5315
  * | response_time | Requests and Responses | number | responseStart - requestStart |
@@ -5590,7 +5642,7 @@ function isSafePWAEnv() {
5590
5642
  * Results:
5591
5643
  *
5592
5644
  * | Attribute | Description | Type | Values |
5593
- * | --- | --- | --- | --- |
5645
+ * | :------------ | :------------ | :------------ | :------------ |
5594
5646
  * | **system** | System | string | android, ios, windows, macos, linux |
5595
5647
  * | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
5596
5648
  * | platform | Platform | string | desktop, mobile |
@@ -5613,23 +5665,44 @@ function isSafePWAEnv() {
5613
5665
  * @category Browser Information
5614
5666
  */
5615
5667
  function getBrowserInfo() {
5668
+ // Cache
5669
+ if (window.MAZEY_BROWSER_INFO && _typeof(window.MAZEY_BROWSER_INFO) === 'object') {
5670
+ // console.log('getBrowserInfo cache');
5671
+ return window.MAZEY_BROWSER_INFO;
5672
+ }
5673
+ var browserInfo = {
5674
+ engine: '',
5675
+ engineVs: '',
5676
+ platform: '',
5677
+ supporter: '',
5678
+ supporterVs: '',
5679
+ system: '',
5680
+ systemVs: ''
5681
+ };
5616
5682
  try {
5617
5683
  // 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
5618
5684
  var ua_1 = navigator.userAgent.toLowerCase();
5685
+ if (!ua_1) {
5686
+ return browserInfo;
5687
+ }
5619
5688
  var testUa = function testUa(regexp) {
5620
5689
  return regexp.test(ua_1);
5621
5690
  };
5622
5691
  var testVs = function testVs(regexp) {
5623
- var matchRes = ua_1.match(regexp);
5624
5692
  var ret = '';
5625
- if (matchRes) {
5626
- ret = matchRes.toString().replace(/[^0-9|_.]/g, '').replace(/_/g, '.');
5693
+ var matchRes = ua_1.match(regexp); // ['os 13_2_3']
5694
+ // Confirm the Safety of the match result
5695
+ if (matchRes && isNonEmptyArray(matchRes)) {
5696
+ ret = matchRes.toString();
5697
+ ret = ret.replace(/[^0-9|_.]/g, ''); // 1323
5698
+ ret = ret.replace(/_/g, '.'); // 13.2.3
5627
5699
  }
5700
+
5628
5701
  return ret;
5629
5702
  };
5630
- // 系统
5703
+ // System
5631
5704
  var system = '';
5632
- // Apple device type.
5705
+ // Apple Device Type
5633
5706
  var appleType = '';
5634
5707
  if (testUa(/windows|win32|win64|wow32|wow64/g)) {
5635
5708
  system = 'windows'; // windows系统
@@ -5651,7 +5724,11 @@ function getBrowserInfo() {
5651
5724
  appleType = 'ipod';
5652
5725
  }
5653
5726
  }
5654
- // 系统版本
5727
+ browserInfo = __assign(__assign({}, browserInfo), {
5728
+ system: system,
5729
+ appleType: appleType
5730
+ });
5731
+ // System Version
5655
5732
  var systemVs = '';
5656
5733
  if (system === 'windows') {
5657
5734
  if (testUa(/windows nt 5.0|windows 2000/g)) {
@@ -5674,18 +5751,26 @@ function getBrowserInfo() {
5674
5751
  } else if (system === 'macos') {
5675
5752
  systemVs = testVs(/os x [\d._]+/g);
5676
5753
  } else if (system === 'android') {
5677
- systemVs = testVs(/android [\d._]+/g);
5754
+ systemVs = testVs(/android [\d._]+/g); // 8.0
5678
5755
  } else if (system === 'ios') {
5679
- systemVs = testVs(/os [\d._]+/g);
5756
+ systemVs = testVs(/os [\d._]+/g); // 13.2.3 13.3
5680
5757
  }
5681
- // 平台
5758
+
5759
+ browserInfo = __assign(__assign({}, browserInfo), {
5760
+ systemVs: systemVs
5761
+ });
5762
+ // Platform
5682
5763
  var platform = '';
5683
5764
  if (system === 'windows' || system === 'macos' || system === 'linux') {
5684
5765
  platform = 'desktop'; // 桌面端
5685
5766
  } else if (system === 'android' || system === 'ios' || testUa(/mobile/g)) {
5686
5767
  platform = 'mobile'; // 移动端
5687
5768
  }
5688
- // 内核和载体
5769
+
5770
+ browserInfo = __assign(__assign({}, browserInfo), {
5771
+ platform: platform
5772
+ });
5773
+ // Engine and Shell
5689
5774
  var engine = '';
5690
5775
  var supporter = '';
5691
5776
  if (testUa(/applewebkit/g)) {
@@ -5709,7 +5794,12 @@ function getBrowserInfo() {
5709
5794
  engine = 'trident'; // trident内核
5710
5795
  supporter = 'iexplore'; // iexplore浏览器
5711
5796
  }
5712
- // 内核版本
5797
+
5798
+ browserInfo = __assign(__assign({}, browserInfo), {
5799
+ engine: engine,
5800
+ supporter: supporter
5801
+ });
5802
+ // Engine Version
5713
5803
  var engineVs = '';
5714
5804
  if (engine === 'webkit') {
5715
5805
  engineVs = testVs(/applewebkit\/[\d._]+/g);
@@ -5720,7 +5810,10 @@ function getBrowserInfo() {
5720
5810
  } else if (engine === 'trident') {
5721
5811
  engineVs = testVs(/trident\/[\d._]+/g);
5722
5812
  }
5723
- // 载体版本
5813
+ browserInfo = __assign(__assign({}, browserInfo), {
5814
+ engineVs: engineVs
5815
+ });
5816
+ // Supporter Version
5724
5817
  var supporterVs = '';
5725
5818
  if (supporter === 'chrome') {
5726
5819
  supporterVs = testVs(/chrome\/[\d._]+/g);
@@ -5735,7 +5828,10 @@ function getBrowserInfo() {
5735
5828
  } else if (supporter === 'edge') {
5736
5829
  supporterVs = testVs(/edge\/[\d._]+/g);
5737
5830
  }
5738
- // 外壳和外壳版本
5831
+ browserInfo = __assign(__assign({}, browserInfo), {
5832
+ supporterVs: supporterVs
5833
+ });
5834
+ // Shell Name and Shell Version
5739
5835
  var shell = '';
5740
5836
  var shellVs = '';
5741
5837
  if (testUa(/micromessenger/g)) {
@@ -5765,30 +5861,15 @@ function getBrowserInfo() {
5765
5861
  shell = 'bilibili'; // 哔哩哔哩
5766
5862
  }
5767
5863
 
5768
- return Object.assign({
5769
- engine: engine,
5770
- engineVs: engineVs,
5771
- platform: platform,
5772
- supporter: supporter,
5773
- supporterVs: supporterVs,
5774
- system: system,
5775
- systemVs: systemVs
5776
- }, {
5864
+ browserInfo = __assign(__assign({}, browserInfo), {
5777
5865
  shell: shell,
5778
- shellVs: shellVs,
5779
- appleType: appleType
5866
+ shellVs: shellVs
5780
5867
  });
5868
+ window.MAZEY_BROWSER_INFO = browserInfo;
5869
+ return browserInfo;
5781
5870
  } catch (err) {
5782
- console.warn('mazey:', err);
5783
- return {
5784
- engine: '',
5785
- engineVs: '',
5786
- platform: '',
5787
- supporter: '',
5788
- supporterVs: '',
5789
- system: '',
5790
- systemVs: ''
5791
- };
5871
+ console.warn('MazeyCon:', err);
5872
+ return browserInfo;
5792
5873
  }
5793
5874
  }
5794
5875
  /**
@@ -5802,15 +5883,15 @@ function clearHtml(str) {
5802
5883
  return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
5803
5884
  }
5804
5885
  /**
5805
- * @method cutCHSString
5806
- * @description 截取字符串,中文算2个字节
5886
+ * 截取字符串,中文算 2 个字节
5887
+ *
5807
5888
  * @param {string} str 要截取的字符串
5808
5889
  * @param {number} len
5809
5890
  * @param {boolean} hasDot
5810
5891
  * @returns {string} 返回截取后的字符串
5811
5892
  * @category Util
5812
5893
  */
5813
- function cutCHSString(str, len, hasDot) {
5894
+ function truncateZHString(str, len, hasDot) {
5814
5895
  if (hasDot === void 0) {
5815
5896
  hasDot = false;
5816
5897
  }
@@ -5841,6 +5922,17 @@ function cutCHSString(str, len, hasDot) {
5841
5922
  return newStr;
5842
5923
  }
5843
5924
  }
5925
+ /**
5926
+ * Alias of truncateZHString
5927
+ *
5928
+ * @hidden
5929
+ */
5930
+ function cutCHSString(str, len, hasDot) {
5931
+ if (hasDot === void 0) {
5932
+ hasDot = false;
5933
+ }
5934
+ return truncateZHString(str, len, hasDot);
5935
+ }
5844
5936
  /**
5845
5937
  * EN: Check whether the page is loaded successfully (Keepe the compatibility in case that browser's `load` event has been triggered).
5846
5938
  *
@@ -6478,6 +6570,44 @@ function convert10To26(num) {
6478
6570
  }
6479
6571
  return result;
6480
6572
  }
6573
+ /**
6574
+ * EN: Get the file type of the url.
6575
+ *
6576
+ * ZH: 获取文件后缀名
6577
+ *
6578
+ * @example
6579
+ * ```js
6580
+ * console.log(getUrlFileType('https://example.com/a/b/c.png')); // png
6581
+ * console.log(getUrlFileType('https://example.com/a/b/c.jpg')); // jpg
6582
+ * console.log(getUrlFileType('https://example.com/a/b/c.jpeg')); // jpeg
6583
+ * console.log(getUrlFileType('/a/b/c.jpeg')); // jpeg
6584
+ * console.log(getUrlFileType('https://example.com/a/b/c.v/a')); // ''
6585
+ * ```
6586
+ *
6587
+ * @param url
6588
+ * @returns
6589
+ * @category URL
6590
+ */
6591
+ function getUrlFileType(url) {
6592
+ var ret = '';
6593
+ if (typeof url != 'string' || url == '') {
6594
+ return ret;
6595
+ }
6596
+ var type = /\.[^/?#]+$/.exec(url);
6597
+ if (!type) {
6598
+ return ret;
6599
+ }
6600
+ if (type[0].length > 1) {
6601
+ ret = type[0].substring(1);
6602
+ }
6603
+ // if (ret.includes('?')) {
6604
+ // const arr = ret.split('?');
6605
+ // if (arr.length > 0) {
6606
+ // ret = arr[0];
6607
+ // }
6608
+ // }
6609
+ return ret;
6610
+ }
6481
6611
 
6482
6612
  exports.addClass = addClass;
6483
6613
  exports.addEvent = addEvent;
@@ -6489,6 +6619,8 @@ exports.camelCaseToKebabCase = camelCaseToKebabCase;
6489
6619
  exports.cancelBubble = cancelBubble;
6490
6620
  exports.clearHtml = clearHtml;
6491
6621
  exports.convert10To26 = convert10To26;
6622
+ exports.convertCamelToKebab = convertCamelToKebab;
6623
+ exports.convertCamelToUnder = convertCamelToUnder;
6492
6624
  exports.cutCHSString = cutCHSString;
6493
6625
  exports.debounce = debounce;
6494
6626
  exports.deepCopyObject = deepCopyObject;
@@ -6496,7 +6628,6 @@ exports.doFn = doFn;
6496
6628
  exports.floatFixed = floatFixed;
6497
6629
  exports.floatToPercent = floatToPercent;
6498
6630
  exports.formatDate = formatDate;
6499
- exports.friendlyInterval = friendlyInterval;
6500
6631
  exports.genCustomConsole = genCustomConsole;
6501
6632
  exports.genHashCode = genHashCode;
6502
6633
  exports.generateRndNum = generateRndNum;
@@ -6506,15 +6637,18 @@ exports.getCookie = getCookie;
6506
6637
  exports.getDefineListeners = getDefineListeners;
6507
6638
  exports.getDomain = getDomain;
6508
6639
  exports.getFileSize = getFileSize;
6640
+ exports.getFriendlyInterval = getFriendlyInterval;
6509
6641
  exports.getHashQueryParam = getHashQueryParam;
6510
6642
  exports.getLocalStorage = getLocalStorage;
6511
6643
  exports.getPerformance = getPerformance;
6512
6644
  exports.getQueryParam = getQueryParam;
6513
6645
  exports.getSessionStorage = getSessionStorage;
6646
+ exports.getUrlFileType = getUrlFileType;
6514
6647
  exports.getUrlParam = getUrlParam;
6515
6648
  exports.hasClass = hasClass;
6516
6649
  exports.inRate = inRate;
6517
6650
  exports.invokeEvent = invokeEvent;
6651
+ exports.isJSONString = isJSONString;
6518
6652
  exports.isJsonString = isJsonString;
6519
6653
  exports.isNonEmptyArray = isNonEmptyArray;
6520
6654
  exports.isNumber = isNumber;
@@ -6535,6 +6669,7 @@ exports.setCookie = setCookie;
6535
6669
  exports.setLocalStorage = setLocalStorage;
6536
6670
  exports.setSessionStorage = setSessionStorage;
6537
6671
  exports.throttle = throttle;
6672
+ exports.truncateZHString = truncateZHString;
6538
6673
  exports.updateQueryParam = updateQueryParam;
6539
6674
  exports.windowLoaded = windowLoaded;
6540
6675
  exports.zAxiosIsValidRes = zAxiosIsValidRes;