Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@type-dom/utils

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@type-dom/utils - npm Package Compare versions

Comparing version
0.1.4
to
0.1.5
+64
dist/index.d.ts
/**
* 类
*/
export { Ratio } from './ratio';
export { SimpleSet } from './lib/simple-set';
export type { ISimpleSet } from './lib/simple-set';
export { Base64 } from './lib/base64';
export { Cookie } from './lib/cookie';
export { LocalStorage } from './lib/local-storage';
export { I18n } from './lib/I18n';
/**
* 常量
*/
export { isWindows } from './lib/isWindows';
export { isMac } from './lib/isMac';
export { isLikelyNode } from './lib/isLikelyNode';
export { EMPTY_OBJECT } from './lib/EMPTY_OBJECT';
export { XMLEntities } from './lib/XMLEntities';
export { XMLParserErrorCode } from './lib/XMLParserErrorCode';
/**
* 函数
*/
export * from './lib/basics';
export * from './ui/error';
export { mustache } from './lib/mustache';
export { toHump } from './lib/to-hump';
export { camelToDash } from './lib/camelToDash';
export { clone } from './lib/clone';
export { colorFormat } from './lib/colorFormat';
export { dashToCamel } from './lib/dashToCamel';
export { dashToPascal } from './lib/dashToPascal';
export { deepClone } from './lib/deepClone';
export { deepCopy } from './lib/deepCopy';
export { deepMerge } from './lib/deepMerge';
export { getScroll } from './lib/getScroll';
export { pxToRem } from './lib/pxToRem';
export { isWhitespace } from './lib/isWhitespace';
export { isWhitespaceString } from './lib/isWhitespaceString';
export { encodeToXmlString } from './lib/encodeToXmlString';
export { Uint8ArrayToHexString } from './lib/Uint8ArrayToHexString';
export { formatFloat } from './lib/formatFloat';
export { createRotatableElement } from './lib/animation';
export { throttleByRaf } from './ui/throttleByRaf';
export { throttle } from './lib/throttle';
export { debounce } from './lib/debounce';
export { md5 } from './lib/md5';
export { anonymizeData } from './lib/anonymizeData';
export { fromPairs } from './lib/fromPairs';
export { isEqual } from './lib/isEqual';
export { pick } from './lib/pick';
export { genNumArr } from './lib/genNumArr';
/**
* 接口
*/
/**
* 集成库
*/
export * from './lib/env';
export * from './lib/browser';
export * from './lib/casing';
export * from './util';
export * from './ui/index';
export type * from './interface';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;GAEG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;GAEG;AAEH;;GAEG;AAGH,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,mBAAmB,aAAa,CAAC"}
// export * from './test-dts/utils';
/**
* 类
*/
export { Ratio } from './ratio';
export { SimpleSet } from './lib/simple-set';
export { Base64 } from './lib/base64';
export { Cookie } from './lib/cookie';
export { LocalStorage } from './lib/local-storage';
export { I18n } from './lib/I18n';
/**
* 常量
*/
export { isWindows } from './lib/isWindows';
export { isMac } from './lib/isMac';
export { isLikelyNode } from './lib/isLikelyNode';
export { EMPTY_OBJECT } from './lib/EMPTY_OBJECT';
export { XMLEntities } from './lib/XMLEntities';
export { XMLParserErrorCode } from './lib/XMLParserErrorCode';
/**
* 函数
*/
export * from './lib/basics';
export * from './ui/error';
export { mustache } from './lib/mustache';
export { toHump } from './lib/to-hump';
export { camelToDash } from './lib/camelToDash';
export { clone } from './lib/clone';
export { colorFormat } from './lib/colorFormat';
export { dashToCamel } from './lib/dashToCamel';
export { dashToPascal } from './lib/dashToPascal';
export { deepClone } from './lib/deepClone';
export { deepCopy } from './lib/deepCopy';
export { deepMerge } from './lib/deepMerge';
export { getScroll } from './lib/getScroll';
export { pxToRem } from './lib/pxToRem';
export { isWhitespace } from './lib/isWhitespace';
export { isWhitespaceString } from './lib/isWhitespaceString';
export { encodeToXmlString } from './lib/encodeToXmlString';
export { Uint8ArrayToHexString } from './lib/Uint8ArrayToHexString';
export { formatFloat } from './lib/formatFloat';
export { createRotatableElement } from './lib/animation';
export { throttleByRaf } from './ui/throttleByRaf';
export { throttle } from './lib/throttle';
export { debounce } from './lib/debounce';
export { md5 } from './lib/md5';
export { anonymizeData } from './lib/anonymizeData';
export { fromPairs } from './lib/fromPairs';
export { isEqual } from './lib/isEqual';
export { pick } from './lib/pick';
export { genNumArr } from './lib/genNumArr';
/**
* 接口
*/
/**
* 集成库
*/
// export * from './console';
// export * from './currency';
export * from './lib/env';
export * from './lib/browser';
export * from './lib/casing';
export * from './util';
export * from './ui/index';
export type IPrimitive = null | undefined | string | number | boolean | symbol | bigint;
export type IBrowserNativeObject = Date | FileList | File | Blob | RegExp;
/**
* Void function
*/
export type Fn = () => void;
/**
* Any function
*/
export type AnyFn = (...args: any[]) => any;
//# sourceMappingURL=interface.d.ts.map
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AACX,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,IAAI,CAAA;AAE3B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA"}
export {};
export declare function createRotatableElement(element: HTMLElement, initialRotation?: number, speed?: number): {
start: () => void;
stop: () => void;
setSpeed: (newSpeed: number) => void;
getSpeed: () => number;
};
//# sourceMappingURL=animation.d.ts.map
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/lib/animation.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,WAAW,EACpB,eAAe,SAAI,EACnB,KAAK,SAAI;;;yBAmDc,MAAM;;EAK9B"}
export function createRotatableElement(element, initialRotation = 0, speed = 4) {
let currentRotation = initialRotation;
let lastFrameTime;
let isRotating = false;
function animate(now) {
// ...(保持原有animate函数内容不变)
if (!lastFrameTime) {
lastFrameTime = now;
}
const deltaTime = now - lastFrameTime;
lastFrameTime = now;
if (isRotating) {
currentRotation += (speed * deltaTime) / 1000;
while (currentRotation >= 360) {
currentRotation -= 360;
}
while (currentRotation < 0) {
currentRotation += 360;
}
element.style.transform = `rotate(${currentRotation}deg)`;
}
if (isRotating) {
requestAnimationFrame(animate);
}
}
// function toggleRotation() {
// // ...(保持原有toggleRotation函数内容不变)
// isRotating = !isRotating;
// if (isRotating) {
// requestAnimationFrame(animate);
// }
// }
// 绑定点击事件以触发旋转
// element.addEventListener("click", toggleRotation);
return {
start: () => {
isRotating = true;
requestAnimationFrame(animate);
},
stop: () => {
isRotating = false;
},
setSpeed: (newSpeed) => {
speed = newSpeed;
},
getSpeed: () => speed,
};
}
// const element1 = document.createElement('div');
// const rotatingElementController = createRotatableElement(element1);
// // 启动旋转
// rotatingElementController.start();
// // 更改旋转速度
// rotatingElementController.setSpeed(2);
export declare function anonymizeData(data: Record<string, string>): {
name: string;
address: string;
phoneNumber: string;
faxNumber: string;
email: string;
socialId: string;
};
//# sourceMappingURL=anonymizeData.d.ts.map
{"version":3,"file":"anonymizeData.d.ts","sourceRoot":"","sources":["../../src/lib/anonymizeData.ts"],"names":[],"mappings":"AACA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;EASzD"}
export function anonymizeData(data) {
return {
name: anonymizeName(data.name),
address: anonymizeAddress(data.address),
phoneNumber: anonymizePhoneNumber(data.phoneNumber),
faxNumber: anonymizeFaxNumber(data.faxNumber),
email: anonymizeEmail(data.email),
socialId: anonymizeSocialId(data.socialId)
};
}
// 现在是中文名,需要根据实际场景修改。英文名等需要修改。
function anonymizeName(name) {
console.warn('name is ', name);
const parts = name.split(' ');
if (parts.length === 1) {
if (parts[0].length === 2) {
return parts[0].charAt(0) + '*';
}
else {
return parts[0].charAt(0) + '**';
}
}
else {
return parts[0] + '**';
}
}
/**
* 地址匿名化
* todo 针对Itas的地址格式,需要根据实际场景修改。
* @example 北京市海淀区上地小区信息路3号华为大厦6楼
* @param address
*/
function anonymizeAddress(address) {
console.log('anonymizeAddress . address is ', address);
// 定义正则表达式匹配地址的各个部分
const regex = /(.*市)(.*?[区|镇|县])(.*?)(.*?路)(\d+号)(.*)$/;
const match = address.match(regex);
// 确保地址格式正确
if (!match) {
throw new Error('地址格式不正确');
}
// 提取匹配的部分
const [_, city, district, subdistrict, road, number, rest] = match;
// 将路名部分替换为星号
const maskedRoad = '*'.repeat(road.length - 1);
// 获取并处理门牌号
const maskedNumber = '*'.repeat(number.length - 1);
// 将号后面的所有内容替换为星号
const maskedRest = '*'.repeat(rest.length);
// 拼接新的地址
return `${city}${district}${subdistrict}${maskedRoad}路${maskedNumber}号${maskedRest}`;
}
function anonymizePhoneNumber(phoneNumber) {
return phoneNumber.slice(0, 3) + '****' + phoneNumber.slice(-4);
}
function anonymizeFaxNumber(faxNumber) {
return faxNumber ? 'NA' : '';
}
function anonymizeEmail(email) {
const [local, domain] = email.split('@');
const localPart = local.charAt(0) + '***';
return localPart + '@' + domain;
}
function anonymizeSocialId(socialId) {
return socialId.slice(0, 6) + '************';
}
//
// // 示例用法
// const data = {
// name: '张小明',
// address: '北京市海淀区上地信息路3号华为大厦6楼',
// phoneNumber: '12345678911',
// faxNumber: '1234567890',
// email: 'tom123@aabbcc.com',
// socialId: '123456196010201234'
// };
//
// const anonymizedData = anonymizeData(data);
// console.log(anonymizedData);
export declare const arrayMethods: any;
//# sourceMappingURL=array.d.ts.map
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/lib/array.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,KAA4B,CAAC"}
/*
* not type checking this file because flow doesn't play well with
* dynamically accessing methods on Array prototype
*/
// import { TriggerOpTypes } from '../../v3'
// import { def } from '../util/index'
const arrayProto = Array.prototype;
export const arrayMethods = Object.create(arrayProto);
const methodsToPatch = [
'push',
'pop',
'shift',
'unshift',
'splice',
'sort',
'reverse'
];
/**
* Intercept mutating methods and emit events
*/
methodsToPatch.forEach(function (method) {
// cache original method
// const original = arrayProto[method];
// def(arrayMethods, method, function mutator(...args: any[]) {
// const result = original.apply(this, args)
// const ob = this.__ob__
// let inserted
// switch (method) {
// case 'push':
// case 'unshift':
// inserted = args
// break
// case 'splice':
// inserted = args.slice(2)
// break
// }
// if (inserted) ob.observeArray(inserted)
// // notify change
// if (__DEV__) {
// ob.dep.notify({
// type: TriggerOpTypes.ARRAY_MUTATION,
// target: this,
// key: method
// })
// } else {
// ob.dep.notify()
// }
// return result
// })
});
/**
* base64.ts
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*
* @author Dan Kogai (https://github.com/dankogai)
*/
export declare class Base64 {
static encode(input: string): string;
static decode(input: string): string;
}
//# sourceMappingURL=base64.d.ts.map
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/lib/base64.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,MAAM;IACjB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM;IAO3B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM;CAO5B"}
/**
* base64.ts
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*
* @author Dan Kogai (https://github.com/dankogai)
*/
export class Base64 {
static encode(input) {
// 对输入的字符串进行Base64编码
if (typeof btoa === 'undefined') {
return encode(input);
}
return btoa(unescape(encodeURIComponent(input)));
}
static decode(input) {
// 对输入的字符串进行Base64解码
if (typeof atob === 'undefined') {
return decode(input);
}
return decodeURIComponent(escape(atob(input)));
}
}
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* 将字符串进行 Base64 编码
* @param input 需要编码的字符串
* @returns 编码后的 Base64 字符串
*/
function encode(input) {
const str = String(input);
let output = '';
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
let i = 0;
while (i < str.length) {
chr1 = str.charCodeAt(i++);
chr2 = str.charCodeAt(i++);
chr3 = str.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
}
else if (isNaN(chr3)) {
enc4 = 64;
}
output += chars.charAt(enc1) + chars.charAt(enc2) + chars.charAt(enc3) + chars.charAt(enc4);
}
return output;
}
/**
* 将 Base64 编码的字符串进行解码
* @param input 需要解码的 Base64 字符串
* @returns 解码后的字符串
*/
function decode(input) {
const str = String(input).replace(/[^A-Za-z0-9+/=]/g, '');
let output = '';
let chr1, chr2, chr3;
let enc1, enc2, enc3, enc4;
let i = 0;
if (str.length % 4 !== 0) {
throw new Error('Invalid Base64 string length');
}
while (i < str.length) {
enc1 = chars.indexOf(str.charAt(i++));
enc2 = chars.indexOf(str.charAt(i++));
enc3 = chars.indexOf(str.charAt(i++));
enc4 = chars.indexOf(str.charAt(i++));
if (enc1 === -1 || enc2 === -1 || enc3 === -1 || enc4 === -1) {
throw new Error('Invalid Base64 character');
}
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output += String.fromCharCode(chr1);
if (enc3 !== 64) {
output += String.fromCharCode(chr2);
}
if (enc4 !== 64) {
output += String.fromCharCode(chr3);
}
}
return output;
}
//# sourceMappingURL=baseGetTag.d.ts.map
{"version":3,"file":"baseGetTag.d.ts","sourceRoot":"","sources":["../../src/lib/baseGetTag.ts"],"names":[],"mappings":""}
"use strict";
// import { nullTag, symToStringTag, undefinedTag } from './lodash';
//
// /**
// * The base implementation of `getTag` without fallbacks for buggy environments.
// *
// * @private
// * @param {*} value The value to query.
// * @returns {string} Returns the `toStringTag`.
// */
// function baseGetTag(value: unknown) {
// if (value == null) {
// return value === undefined ? undefinedTag : nullTag;
// }
// return (symToStringTag && symToStringTag in Object(value))
// ? getRawTag(value)
// : objectToString(value);
// }
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
//# sourceMappingURL=baseIsEqual.d.ts.map
{"version":3,"file":"baseIsEqual.d.ts","sourceRoot":"","sources":["../../src/lib/baseIsEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
"use strict";
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
// function baseIsEqual(value: unknown, other: unknown, bitmask: unknown, customizer: unknown, stack: unknown) {
// if (value === other) {
// return true;
// }
// if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
// return value !== value && other !== other;
// }
// return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
// }
//# sourceMappingURL=baseIsEqualDeep.d.ts.map
{"version":3,"file":"baseIsEqualDeep.d.ts","sourceRoot":"","sources":["../../src/lib/baseIsEqualDeep.ts"],"names":[],"mappings":""}
"use strict";
// /**
// * A specialized version of `baseIsEqual` for arrays and objects which performs
// * deep comparisons and tracks traversed objects enabling objects with circular
// * references to be compared.
// *
// * @private
// * @param {Object} object The object to compare.
// * @param {Object} other The other object to compare.
// * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
// * @param {Function} customizer The function to customize comparisons.
// * @param {Function} equalFunc The function to determine equivalents of values.
// * @param {Object} [stack] Tracks traversed `object` and `other` objects.
// * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
// */
// function baseIsEqualDeep(object: unknown, other: unknown, bitmask: unknown, customizer: unknown, equalFunc: unknown, stack: unknown) {
// var objIsArr = isArray(object),
// othIsArr = isArray(other),
// objTag = objIsArr ? arrayTag : getTag(object),
// othTag = othIsArr ? arrayTag : getTag(other);
//
// objTag = objTag == argsTag ? objectTag : objTag;
// othTag = othTag == argsTag ? objectTag : othTag;
//
// var objIsObj = objTag == objectTag,
// othIsObj = othTag == objectTag,
// isSameTag = objTag == othTag;
//
// if (isSameTag && isBuffer(object)) {
// if (!isBuffer(other)) {
// return false;
// }
// objIsArr = true;
// objIsObj = false;
// }
// if (isSameTag && !objIsObj) {
// stack || (stack = new Stack);
// return (objIsArr || isTypedArray(object))
// ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
// : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
// }
// if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
// var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
// othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
//
// if (objIsWrapped || othIsWrapped) {
// var objUnwrapped = objIsWrapped ? object.value() : object,
// othUnwrapped = othIsWrapped ? other.value() : other;
//
// stack || (stack = new Stack);
// return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
// }
// }
// if (!isSameTag) {
// return false;
// }
// stack || (stack = new Stack);
// return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
// }
/**
* 检查字符串是否为Mustache模板
* @param str 需要检查的字符串
* @returns {boolean} 如果字符串包含Mustache模板,则返回true;否则返回false。
*/
export declare function isMustache(str: string): boolean;
export declare function isTrue(v: unknown): v is true;
export declare function isFalse(v: unknown): boolean;
export declare const isString: (val: unknown) => val is string;
export declare const isDate: (val: unknown) => val is Date;
export declare const isNil: (val: unknown) => val is null | undefined;
/**
* Check if value is primitive.
*/
export declare function isPrimitive(value: any): boolean;
export declare const isArray: (arg: any) => arg is any[];
/**
* Quick object check - this is primarily used to tell
* objects from primitive values when we know the value
* is a JSON-compliant type.
*/
export declare const isObject: (val: unknown) => val is object;
export declare function isFunction(value: any): value is (...args: any[]) => any;
export declare const emptyObject: Record<string, any>;
export declare function toRawType(value: unknown): string;
/**
* Strict object type check. Only returns true
* for plain JavaScript objects.
*/
export declare function isPlainObject(obj: unknown): boolean;
export declare function isRegExp(v: unknown): v is RegExp;
/**
* Check if val is a valid array index.
*/
export declare function isValidArrayIndex(val: unknown): boolean;
export declare function isDef<T>(v: T): v is NonNullable<T>;
export declare function isPromise(val: any): val is Promise<unknown>;
/**
* Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
export declare function toNumber(val: string): number | string;
/**
* Convert a value to a string that is actually rendered.
*/
export declare function toString(val: unknown): string;
export declare function changeCssVar(key: string, newValue: string): void;
//# sourceMappingURL=basics.d.ts.map
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/lib/basics.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C;AAYD,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,IAAI,CAE5C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE3C;AAGD,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAiC,CAAC;AACjF,eAAO,MAAM,MAAM,QAAS,OAAO,gBAAwB,CAAC;AAM5D,eAAO,MAAM,KAAK,QAAS,OAAO,KAAG,GAAG,IAAI,IAAI,GAAG,SAElD,CAAC;AAaF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAY/C;AAED,eAAO,MAAM,OAAO,4BAAgB,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAsE,CAAC;AAMtH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAEvE;AAMD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAqB,CAAC;AAOlE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGvD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAElD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAM3D;AAUD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAM7C;AAgBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAGzD"}
// 第一个表达式较为宽松,匹配所有双大括号内的内容。
// const mustachePattern = /\{\{.*?\}\}/g; // 匹配Mustache模板语法的正则表达式
// /(^|\s){{([\w\s\.]+)}}($|\s)|^\{{2}([\w\s\.]+)\}{2}$/g;
// 第二个表达式较为严格,仅匹配由字母数字、空白字符或点号组成的内容,并且也是全局搜索。它更适合用于寻找符合某种特定格式的Mustache变量名或路径表达式。
// 定义用于匹配Mustache模板语法的正则表达式,重点匹配由字母数字、空白字符或点号组成的内容
// const pattern = /\{\{([\w\s\.]+)\}\}/g;
// 不能设置成全局变量,调用会有问题的。
// export const mustachePattern = /\{\{([\w\s\\.]+)\}\}/g;
/**
* 检查字符串是否为Mustache模板
* @param str 需要检查的字符串
* @returns {boolean} 如果字符串包含Mustache模板,则返回true;否则返回false。
*/
export function isMustache(str) {
const pattern = /\{\{([\w\s\\.]+)\}\}/g;
return pattern.test(str);
}
// // 使用示例
// let templateString = "Hello, {{name}}!";
// console.log(isMustacheTemplate(templateString)); // 输出:true
//
// let plainString = "Hello, World!";
// console.log(isMustacheTemplate(plainString)); // 输出:false
// export const isUndefined = (val: unknown): val is undefined => val === undefined;
// export const isBoolean = (val: unknown): val is boolean => 'boolean' === typeof val;
export function isTrue(v) {
return v === true;
}
export function isFalse(v) {
return v === false;
}
// export const isNumber = (val: unknown): val is number => typeof val === 'number';
export const isString = (val) => typeof val === 'string';
export const isDate = (val) => val instanceof Date;
// export const isElement = (e: unknown): e is Element => {
// if (typeof Element === 'undefined') return false;
// return e instanceof Element;
// };
export const isNil = (val) => {
return val === null || val === undefined;
};
// export const isPropAbsent = (prop: unknown): prop is null | undefined => {
// return isNil(prop);
// };
// export const isStringNumber = (val: unknown): val is string => {
// if (!isString(val)) {
// return false;
// }
// return !Number.isNaN(Number(val));
// };
/**
* Check if value is primitive.
*/
export function isPrimitive(value) {
return (value === null ||
value === undefined ||
typeof value === 'string' ||
typeof value === 'number' ||
typeof value === 'bigint' ||
// $flow-disable-line
(typeof Symbol !== 'undefined' && typeof value === 'symbol') ||
typeof value === 'boolean' ||
(typeof value !== 'object' && typeof value !== 'function') // add by me
);
}
export const isArray = Array.isArray;
/**
* Quick object check - this is primarily used to tell
* objects from primitive values when we know the value
* is a JSON-compliant type.
*/
export const isObject = (val) => val !== null && val !== undefined && typeof val === 'object';
// export const isEmpty = (val: unknown) =>
// (!val && val !== 0) ||
// (isArray(val) && val.length === 0) ||
// (isObject(val) && !Object.keys(val).length);
export function isFunction(value) {
return typeof value === 'function';
}
// export const isWindow = (val: unknown): val is Window => {
// return val === window;
// };
export const emptyObject = Object.freeze({});
/**
* Get the raw type string of a value, e.g., [object Object].
*/
const _toString = Object.prototype.toString;
export function toRawType(value) {
return _toString.call(value).slice(8, -1);
}
/**
* Strict object type check. Only returns true
* for plain JavaScript objects.
*/
export function isPlainObject(obj) {
return _toString.call(obj) === '[object Object]';
}
export function isRegExp(v) {
return _toString.call(v) === '[object RegExp]';
}
/**
* Check if val is a valid array index.
*/
export function isValidArrayIndex(val) {
const n = parseFloat(String(val));
return n >= 0 && Math.floor(n) === n && isFinite(val);
}
export function isDef(v) {
return v !== undefined && v !== null;
}
export function isPromise(val) {
return (isDef(val) &&
typeof val.then === 'function' &&
typeof val.catch === 'function');
}
function replacer(_key, val) {
// avoid circular deps from v3
if (val && val.__v_isRef) {
return val.value;
}
return val;
}
/**
* Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
export function toNumber(val) {
const n = parseFloat(val);
return isNaN(n) ? val : n;
}
/**
* Convert a value to a string that is actually rendered.
*/
export function toString(val) {
return val == null
? ''
: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
? JSON.stringify(val, replacer, 2)
: String(val);
}
// export function addUnit(value?: string | number, defaultUnit = 'px'): string {
// if (!value) {
// return '';
// }
// if (isNumber(value) || isStringNumber(value)) {
// return `${value}${defaultUnit}`;
// } else if (isString(value)) {
// return value;
// } else {
// throw Error('binding value must be a string or number');
// }
// }
// 定义一个函数来改变CSS变量的值
export function changeCssVar(key, newValue) {
const root = document.documentElement;
root.style.setProperty('--' + key, newValue);
}
// 调用函数,改变背景颜色
// changeBackgroundColor('salmon');
//
// export const keysOf = <T>(arr: T) => Object.keys(arr as object) as Array<keyof T>;
// export const entriesOf = <T>(arr: T) => Object.entries(arr as object); // as Entries<T>
export declare const inBrowser: boolean;
export declare const UA: string | false;
export declare const isClient: boolean;
export declare const isIE: boolean | "";
export declare const isIE9: boolean | "";
export declare const isEdge: boolean | "";
export declare const isAndroid: boolean | "";
export declare const isChrome: boolean | "";
export declare const isPhantomJS: boolean | "";
export declare const isFireFox: false | "" | RegExpMatchArray | null;
export declare const isFirefox: () => boolean;
export declare const isIOS: boolean | "";
export declare function isChromeBelow80(): boolean;
export declare function isChromeAbove80(): boolean;
export declare function supportsSameSite(): boolean;
//# sourceMappingURL=browser.d.ts.map
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/lib/browser.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,SAAgC,CAAC;AACvD,eAAO,MAAM,EAAE,gBAAwD,CAAC;AACxE,eAAO,MAAM,QAAQ,SAC6C,CAAC;AACnE,eAAO,MAAM,IAAI,cAAgC,CAAC;AAClD,eAAO,MAAM,KAAK,cAAmC,CAAC;AACtD,eAAO,MAAM,MAAM,cAAgC,CAAC;AACpD,eAAO,MAAM,SAAS,cAAkC,CAAC;AAEzD,eAAO,MAAM,QAAQ,cAA0C,CAAC;AAChE,eAAO,MAAM,WAAW,cAA6B,CAAC;AACtD,eAAO,MAAM,SAAS,sCAAmC,CAAC;AAE1D,eAAO,MAAM,SAAS,QAAO,OAC4B,CAAA;AAEzD,eAAO,MAAM,KAAK,cAA6B,CAAC;AAehD,wBAAgB,eAAe,YAe9B;AAGD,wBAAgB,eAAe,YAe9B;AAED,wBAAgB,gBAAgB,YA8C/B"}
// Browser environment sniffing
export const inBrowser = typeof window !== 'undefined';
export const UA = inBrowser && window.navigator.userAgent.toLowerCase();
export const isClient = typeof window !== 'undefined' && typeof document !== 'undefined';
export const isIE = UA && /msie|trident/.test(UA);
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
export const isEdge = UA && UA.indexOf('edge/') > 0;
export const isAndroid = UA && UA.indexOf('android') > 0;
// export const isIOS = UA && /iphone|ipad|ipod|ios/.test-dts(UA);
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
export const isPhantomJS = UA && /phantomjs/.test(UA);
export const isFireFox = UA && UA.match(/firefox\/(\d+)/);
export const isFirefox = () => isClient && /firefox/i.test(window.navigator.userAgent);
export const isIOS = /* #__PURE__ */ getIsIOS();
function getIsIOS() {
var _a, _b;
return (isClient &&
((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) &&
(/iP(?:ad|hone|od)/.test(window.navigator.userAgent) ||
// The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.
// https://github.com/vueuse/vueuse/issues/3577
(((_b = window === null || window === void 0 ? void 0 : window.navigator) === null || _b === void 0 ? void 0 : _b.maxTouchPoints) > 2 &&
/iPad|Macintosh/.test(window === null || window === void 0 ? void 0 : window.navigator.userAgent))));
}
// 判断 Chrome 浏览器版本是否 < 80 sameSite策略不同
export function isChromeBelow80() {
const ua = navigator.userAgent;
// 1. 识别 Chrome 且排除基于 Chromium 的 Edge/Opera 等浏览器
const isChrome = /Chrome/.test(ua) && !/(Edg|OPR)/.test(ua);
if (isChrome) {
// 2. 提取版本号(示例 UA: "Chrome/84.0.4147.89")
const versionMatch = ua.match(/Chrome\/(\d+)/);
if (versionMatch) {
const version = parseInt(versionMatch[1], 10);
return version < 80;
}
}
return false;
}
// 判断 Chrome 浏览器版本是否 > 80 sameSite策略不同
export function isChromeAbove80() {
const ua = navigator.userAgent;
// 识别 Chrome 且排除基于 Chromium 的 Edge/Opera 等浏览器
const isChrome = /Chrome/.test(ua) && !/(Edg|OPR)/.test(ua);
if (isChrome) {
// 提取版本号(示例 UA: "Chrome/84.0.4147.89")
const versionMatch = ua.match(/Chrome\/(\d+)/);
if (versionMatch) {
const version = parseInt(versionMatch[1], 10);
return version > 80; // 修改比较运算符为大于号
}
}
return false;
}
export function supportsSameSite() {
const ua = navigator.userAgent;
// 1. 检测 Chrome 及 Chromium 内核浏览器(Chrome >=51 支持 SameSite)
if (/Chrome\/(\d+)/.test(ua) && !/(Edg|OPR)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 51; // Chrome 51+ 支持 SameSite
}
// 2. 检测 Edge Chromium(Edge >=80 支持 SameSite)
if (/Edg\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 80; // Edge 80+ 基于 Chromium
}
// 3. 检测 Safari(Safari >=13.1 支持 SameSite)
if (/Version\/(\d+\.\d+).*Safari/.test(ua)) {
const majorVersion = parseFloat(RegExp.$1);
return majorVersion >= 13.1; // macOS Safari 13.1+ 或 iOS 13+
}
// 4. 检测 Firefox(Firefox >=60 支持 SameSite)
if (/Firefox\/(\d+)/.test(ua)) {
return parseInt(RegExp.$1, 10) >= 60;
}
// 5. 检测 Opera(Opera >=71 支持 SameSite)
if (/Opera\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 71;
}
// 6. 检测 Samsung Internet(Samsung Internet >=5 支持 SameSite)
if (/SamsungInternet\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 5;
}
// 7. 检测 UC Browser for Android(UC Browser >=12.1 支持 SameSite)
if (/UCBrowser\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 12.1;
}
// 8. 其他浏览器保守返回 false
return false;
}
/**
* 将驼峰命名转换为短横线命名。
*
* 此函数主要用于将JavaScript或TypeScript中常用的驼峰命名法转换为短横线分隔的命名方式。
* 这种转换在某些场合下是必要的,比如将JavaScript类名转换为对应的CSS类名,或者将API接口的驼峰命名转换为URL参数的格式。
*
* @param camelString 驼峰命名的字符串。
* @returns 转换为短横线分隔的字符串。
*/
export declare function camelToDash(camelString: string): string;
//# sourceMappingURL=camelToDash.d.ts.map
{"version":3,"file":"camelToDash.d.ts","sourceRoot":"","sources":["../../src/lib/camelToDash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAevD"}
/**
* 将驼峰命名转换为短横线命名。
*
* 此函数主要用于将JavaScript或TypeScript中常用的驼峰命名法转换为短横线分隔的命名方式。
* 这种转换在某些场合下是必要的,比如将JavaScript类名转换为对应的CSS类名,或者将API接口的驼峰命名转换为URL参数的格式。
*
* @param camelString 驼峰命名的字符串。
* @returns 转换为短横线分隔的字符串。
*/
export function camelToDash(camelString) {
var _a, _b;
if (camelString === undefined) {
// console.error('camelString is undefined . ');
throw Error('camelString is undefined . ');
}
// 使用正则表达式匹配并替换字符串中的驼峰命名。
// 第一个正则表达式用于匹配单词之间的大写字母,例如"camelCase"中的"C"。
// 第二个正则表达式用于匹配单词末尾和大写字母之间的边界,例如"getHTTPRequest"中的"HTTP"。
// 替换规则是插入一个短横线,并将所有字母转换为小写。
// 使用正则表达式匹配大写字母,并在其前添加中划线,然后将整个字符串转换为小写
// 确保非首字母大写前添加中划线,并忽略原本就存在的中划线前的大写字母
return (_b = (_a = camelString === null || camelString === void 0 ? void 0 : camelString.replace(/(.)([A-Z][a-z]+)/g, '$1-$2')) === null || _a === void 0 ? void 0 : _a.replace(/([a-z0-9])([A-Z])/g, '$1-$2')) === null || _b === void 0 ? void 0 : _b.toLowerCase();
}
/**
* 将kebab-case格式的字符串转换为PascalCase格式。
* kebab-case格式的字符串是一种命名规范,也称为短线连接命名法、短横线命名法或中横线命名法。
* 在这种格式中,字符串中的每个单词以小写字母书写,并且单词之间用短横线(-)分隔。
* 这种命名风格常见于HTML的class属性、CSS的类名、以及某些编程语言或框架(如Vue.js的非字符串模板属性)中。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的PascalCase格式字符串
*/
export declare function toPascalCase(kebabCase: string): string;
/**
* 将给定的属性名转换为带有供应商前缀的格式。
* @param property 输入的属性名
* @returns 转换后的带有供应商前缀的属性名
*/
export declare function toVendorPrefixCase(property: string): string;
/**
* 将kebab-case格式的字符串转换为camelCase格式。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的camelCase格式字符串
*/
export declare function toCamelCase(kebabCase: string): string;
/**
* 替换函数,将匹配到的子字符串转换为大写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为大写的字符串
*/
export declare function toUpperReplacer(substring: string, ...args: string[]): string;
/**
* 替换函数,将匹配到的子字符串转换为小写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为小写的字符串
*/
export declare function toLowerReplacer(substring: string, ...args: string[]): string;
//# sourceMappingURL=casing.d.ts.map
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/lib/casing.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,UAM7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAKlD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,UAK5C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE5E"}
// 正则表达式,用于匹配字符串的首字母
const REGEX_LEADING_LETTER = /^(\w)/;
// 正则表达式,用于匹配kebab-case中的分隔符并捕获其后的字符
const REGEX_KEBAB_SEPARATOR = /-(\w)/g;
// 正则表达式,用于匹配带有供应商前缀的字符串
const REGEX_VENDOR_PREFIXED = /^-(\w)/;
// 正则表达式,专门用于匹配以"-ms-"为前缀的字符串
const REGEX_MS_PREFIXED = /^-ms-/;
/**
* 将kebab-case格式的字符串转换为PascalCase格式。
* kebab-case格式的字符串是一种命名规范,也称为短线连接命名法、短横线命名法或中横线命名法。
* 在这种格式中,字符串中的每个单词以小写字母书写,并且单词之间用短横线(-)分隔。
* 这种命名风格常见于HTML的class属性、CSS的类名、以及某些编程语言或框架(如Vue.js的非字符串模板属性)中。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的PascalCase格式字符串
*/
export function toPascalCase(kebabCase) {
// 替换供应商前缀、首字母和kebab-case中的连字符,将其转换为大写
return kebabCase
.replace(REGEX_VENDOR_PREFIXED, toUpperReplacer)
.replace(REGEX_LEADING_LETTER, toUpperReplacer)
.replace(REGEX_KEBAB_SEPARATOR, toUpperReplacer);
}
/**
* 将给定的属性名转换为带有供应商前缀的格式。
* @param property 输入的属性名
* @returns 转换后的带有供应商前缀的属性名
*/
export function toVendorPrefixCase(property) {
// 如果属性名以"-ms-"开头,将其转换为"ms"加上转换后的PascalCase格式字符串;否则直接转换为PascalCase格式
return REGEX_MS_PREFIXED.test(property)
? 'ms' + toPascalCase(property.slice(4))
: toPascalCase(property);
}
/**
* 将kebab-case格式的字符串转换为camelCase格式。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的camelCase格式字符串
*/
export function toCamelCase(kebabCase) {
// 替换供应商前缀和kebab-case中的连字符,将其转换为合适的形式
return kebabCase
.replace(REGEX_VENDOR_PREFIXED, toLowerReplacer)
.replace(REGEX_KEBAB_SEPARATOR, toUpperReplacer);
}
/**
* 替换函数,将匹配到的子字符串转换为大写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为大写的字符串
*/
export function toUpperReplacer(substring, ...args) {
return args[0].toUpperCase();
}
/**
* 替换函数,将匹配到的子字符串转换为小写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为小写的字符串
*/
export function toLowerReplacer(substring, ...args) {
return args[0].toLowerCase();
}
/**
* Creates a shallow copy of the given obejct/value.
* @param {*} obj value to clone
* @returns {*} shallow clone of the given value
*/
export declare const clone: <T>(obj: T) => T;
//# sourceMappingURL=clone.d.ts.map
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/lib/clone.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,OAAO,CAAC,KAAG,CAwBjC,CAAA"}
import { isPrimitive } from './basics';
/**
* Creates a shallow copy of the given obejct/value.
* @param {*} obj value to clone
* @returns {*} shallow clone of the given value
*/
export const clone = (obj) => {
// Primitive values do not need cloning.
if (isPrimitive(obj)) {
return obj;
}
// Binding a function to an empty object creates a
// copy function.
if (typeof obj === 'function') {
return obj.bind({});
}
// Access the constructor and create a new object.
// This method can create an array as well.
const newObj = new obj.constructor();
// Assign the props.
Object.getOwnPropertyNames(obj).forEach(prop => {
// Bypass type checking since the primitive cases
// are already checked in the beginning
newObj[prop] = obj[prop];
});
return newObj;
};
/**
* 解析颜色值
*
* 此函数支持解析两种颜色格式:RGB/RGBA和十六进制颜色值
* 对于十六进制颜色值,支持3位、6位以及带附加位的格式
* 对于RGB/RGBA颜色值,支持透明度的解析,并将其转换为整数格式
*
* @param value 颜色值字符串,可以是RGB/RGBA或十六进制格式, white 这种单词颜色;
* @returns 返回一个字符串,表示解析后的颜色值,格式为 'R G B A', 如果是单词颜色,则返回原字符串;
*/
export declare function colorFormat(value: string): string;
//# sourceMappingURL=colorFormat.d.ts.map
{"version":3,"file":"colorFormat.d.ts","sourceRoot":"","sources":["../../src/lib/colorFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA2DjD"}
/**
* 解析颜色值
*
* 此函数支持解析两种颜色格式:RGB/RGBA和十六进制颜色值
* 对于十六进制颜色值,支持3位、6位以及带附加位的格式
* 对于RGB/RGBA颜色值,支持透明度的解析,并将其转换为整数格式
*
* @param value 颜色值字符串,可以是RGB/RGBA或十六进制格式, white 这种单词颜色;
* @returns 返回一个字符串,表示解析后的颜色值,格式为 'R G B A', 如果是单词颜色,则返回原字符串;
*/
export function colorFormat(value) {
// 检查是否为十六进制颜色值
if (/^#([a-f\d]{3}|[a-f\d]{6})[a-f\d]?$/i.test(value)) {
// #号开头的颜色值 3位或6位
if (value.length < 7) {
// 展开3位十六进制颜色值
return value
.replace(/([\w])/gi, (hex) => ` ${parseInt(`${hex}${hex}`, 16)}`)
.substr(2);
}
else if (value.length === 7) {
// 直接使用6位十六进制颜色值
return value
.replace(/([\w]{2})/gi, (hex) => ` ${parseInt(hex, 16)}`)
.substr(2);
}
else if (value.length === 9) {
// 8位带透明度的十六进制颜色值
const alpha = parseInt(value.substr(7), 16);
return `${value
.replace(/([\w]{2})/gi, (hex) => ` ${parseInt(hex, 16)}`)
.substr(2)} ${alpha}`;
}
}
else if (/^rgba?\(\s*((2(5[0-5]|[0-4]\d)|1?\d{1,2})\s*,?\s*){3}(,\s*(\d+)?(\.\d+)?)?\)$/.test(value)) {
// 检查是否为RGB或RGBA颜色值
// 提取颜色值并转换为数字
const color = value
.replace(/[a-z()\s]/g, '')
.split(',')
.map((item) => Number(item));
// 处理RGBA颜色值的透明度
if (color.length === 4) {
color[3] = Math.min(255, Math.round(color[3] * 255));
if (isNaN(color[3])) {
color[3] = 0;
}
}
// 返回解析后的颜色值
return color.join(' ');
}
else if (/^hsla?\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*(,\s*(\d+)?(\.\d+)?)?\)$/.test(value)) {
// 检查是否为HSL或HSLA颜色值
const hsl = value.match(/^hsla?\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*(,\s*(\d+)?(\.\d+)?)?\)$/);
if (hsl) {
const hue = parseInt(hsl[1], 10);
const saturation = parseInt(hsl[2], 10) / 100;
const lightness = parseInt(hsl[3], 10) / 100;
const alpha = hsl[5] ? parseFloat(hsl[5]) : 1;
const color = hslToRgb(hue, saturation, lightness);
return color.join(' ') + ' ' + alpha;
}
}
// 返回单词颜色值
return value;
}
// 转换HSL到RGB
function hslToRgb(h, s, l) {
const c = (1 - Math.abs(2 * l - 1)) * s;
const x = c * (1 - Math.abs((h / 60) % 2 - 1));
const m = l - c / 2;
let r, g, b;
if (h < 60) {
r = c, g = x, b = 0;
}
else if (h < 120) {
r = x, g = c, b = 0;
}
else if (h < 180) {
r = 0, g = c, b = x;
}
else if (h < 240) {
r = 0, g = x, b = c;
}
else if (h < 300) {
r = x, g = 0, b = c;
}
else {
r = c, g = 0, b = x;
}
r = Math.round((r + m) * 255);
g = Math.round((g + m) * 255);
b = Math.round((b + m) * 255);
return [r, g, b];
}
export declare class Cookie {
/**
* 设置 cookie
*
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @static
*/
static set(name: string, value: string): void;
/**
* 设置 cookie, 默认30天过期时间
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @param {String} expires 单位(秒)
* @static
*/
static setExpires(name: string, value: string, expires: number): void;
/**
* 获取 cookie
* @param {String} name Cookie名称
* @return {Object} Cookie值,没有返回null
* @static
*/
static get(name: string): string | null;
/**
* 删除 cookie
* @param {String} name Cookie名称
* @static
*/
static del(name: string): void;
/**
* 清理cookie
*/
static clear(): void;
}
//# sourceMappingURL=cookie.d.ts.map
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/lib/cookie.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAItC;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAW9D;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM;IASvB;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM;IAUvB;;OAEG;IACH,MAAM,CAAC,KAAK;CAcb"}
import { isEmpty } from 'lodash-es';
export class Cookie {
/**
* 设置 cookie
*
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @static
*/
static set(name, value) {
document.cookie = name + '=' + escape(value);
}
/**
* 设置 cookie, 默认30天过期时间
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @param {String} expires 单位(秒)
* @static
*/
static setExpires(name, value, expires) {
const days = 30; //cookie 将被保存 30 天
const exp = new Date();
if (isEmpty(expires)) {
exp.setTime(exp.getTime() + days * 24 * 60 * 60);
}
else {
exp.setTime(exp.getTime() + expires);
}
document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
}
/**
* 获取 cookie
* @param {String} name Cookie名称
* @return {Object} Cookie值,没有返回null
* @static
*/
static get(name) {
const arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
if (arr !== null) {
return unescape(arr[2]);
}
return null;
}
/**
* 删除 cookie
* @param {String} name Cookie名称
* @static
*/
static del(name) {
const exp = new Date();
exp.setTime(exp.getTime() - 1);
const cookieVal = this.get(name);
if (cookieVal !== null) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT';
}
}
/**
* 清理cookie
*/
static clear() {
// debugger;
// 获取所有cookie
const cookies = document.cookie.split(';');
// 遍历所有cookie并删除它们
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i];
// 分割cookie名称和值
const eqPos = cookie.indexOf('=');
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
}
}
}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export declare function dashToCamel(dashStr: string): string;
//# sourceMappingURL=dashToCamel.d.ts.map
{"version":3,"file":"dashToCamel.d.ts","sourceRoot":"","sources":["../../src/lib/dashToCamel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,UAO1C"}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export function dashToCamel(dashStr) {
// 使用连字符分割字符串,并对每个部分进行处理
// 分割字符串,然后对除了第一个部分之外的每个部分首字母大写并拼接
return dashStr.split('-').map((word, index) =>
// 对第一个部分保持原样,对其他部分首字母大写
index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('');
}
// 示例
// console.log(dashToCamel('dash-to-camel')); // 输出: dashToCamel
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用,因为这两种情况下,连字符分隔的字符串常常需要转换为驼峰式。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export declare function dashToPascal(dashStr: string): string;
//# sourceMappingURL=dashToPascal.d.ts.map
{"version":3,"file":"dashToPascal.d.ts","sourceRoot":"","sources":["../../src/lib/dashToPascal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,UAM3C"}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用,因为这两种情况下,连字符分隔的字符串常常需要转换为驼峰式。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export function dashToPascal(dashStr) {
// 使用split方法将字符串按连字符分割成单词数组。
return dashStr.split('-').map(word =>
// 对每个单词,将首字母转换为大写,然后将剩余的字母与之拼接,形成驼峰式字符串。
word.charAt(0).toUpperCase() + word.slice(1)).join('');
}
// 示例
// console.log(dashToPascal('dash-to-pascal')); // 输出: DashToPascal
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): T;
//# sourceMappingURL=debounce.d.ts.map
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/lib/debounce.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAWpF"}
export function debounce(func, wait) {
let timeoutId = null;
return ((...args) => {
if (timeoutId !== null) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
func(...args);
timeoutId = null;
}, wait);
});
}
// const handleInput = debounce((value: string) => {
// console.log('输入值:', value);
// // 这里可以放置处理逻辑,比如发起网络请求
// }, 300); // 300毫秒内没有新的输入才会执行
//
// const onInputChange = (event: Event) => {
// const target = event.target as HTMLInputElement;
// handleInput(target.value);
// };
/**
* 引用类型与非引用类型 深拷贝方法
* @param source
*/
export declare function deepClone<T>(source: T): T;
//# sourceMappingURL=deepClone.d.ts.map
{"version":3,"file":"deepClone.d.ts","sourceRoot":"","sources":["../../src/lib/deepClone.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA4BzC"}
import { isLikelyNode } from '../index';
/**
* 引用类型与非引用类型 深拷贝方法
* @param source
*/
export function deepClone(source) {
if (typeof source !== 'object' ||
typeof source === 'function' ||
source === null) {
return source;
}
else if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
return source;
}
let destination;
if (Array.isArray(source)) {
destination = [];
}
else {
destination = {};
}
for (const prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
if (prop === 'parent' || prop === 'parentNode') {
// 处理自定义的虚拟dom
destination[prop] = source[prop];
}
else {
destination[prop] = deepClone(source[prop]);
}
}
}
return destination;
}
// function deepClone1(obj: any, hash = new WeakMap()) {
// // 处理函数
// if (typeof obj === 'function') {
// return obj.bind({});
// }
//
// // 基本类型和特殊对象处理
// if (obj === null || typeof obj !== 'object') {
// return obj;
// }
//
// // 处理特殊对象类型
// if (obj instanceof Date) return new Date(obj);
// if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
// if (obj instanceof Symbol) return Symbol(obj.description);
//
// // 处理 Set
// if (obj instanceof Set) {
// const newSet = new Set();
// obj.forEach(val => {
// newSet.add(deepClone1(val, hash));
// });
// return newSet;
// }
//
// // 处理 Map
// if (obj instanceof Map) {
// const newMap = new Map();
// obj.forEach((val, key) => {
// newMap.set(key, deepClone1(val, hash));
// });
// return newMap;
// }
//
// // 避免重复处理
// if (hash.has(obj)) {
// return hash.get(obj);
// }
//
// // 使用 Object.getOwnPropertyDescriptors 获取所有属性,包括不可枚举属性
// const descriptors = Object.getOwnPropertyDescriptors(obj);
// const clonedObj = Object.create(Object.getPrototypeOf(obj));
//
// Object.keys(descriptors).forEach(key => {
// const descriptor = descriptors[key];
//
// // 特殊处理访问器属性
// if (descriptor.get || descriptor.set) {
// Object.defineProperty(clonedObj, key, {
// get: descriptor.get && deepClone1(descriptor.get),
// set: descriptor.set && deepClone1(descriptor.set),
// enumerable: descriptor.enumerable,
// configurable: descriptor.configurable
// });
// } else {
// descriptor.value = deepClone1(descriptor.value, hash);
// Object.defineProperty(clonedObj, key, descriptor);
// }
// });
//
// return clonedObj;
// }
// function deepClone2(obj, hash = new WeakMap()) {
// // 处理基本类型
// if (obj === null || typeof obj !== 'object') {
// return obj;
// }
//
// // // 处理特殊对象类型
// // if (obj instanceof Date) return new Date(obj);
// // if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
// // if (obj instanceof Symbol) return Symbol(obj.description);
// //
// // // 处理 Set
// // if (obj instanceof Set) {
// // const newSet = new Set();
// // obj.forEach(val => {
// // newSet.add(deepClone(val, hash));
// // });
// // return newSet;
// // }
// //
// // // 处理 Map
// // if (obj instanceof Map) {
// // const newMap = new Map();
// // obj.forEach((val, key) => {
// // newMap.set(key, deepClone(val, hash));
// // });
// // return newMap;
// // }
// //
// // // 避免重复处理
// // if (hash.has(obj)) {
// // return hash.get(obj);
// // }
//
// const result = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
// hash.set(obj, result);
//
// // 复制自有属性和原型属性
// const keys = [
// ...Object.getOwnPropertyNames(obj),
// ...Object.getOwnPropertySymbols(obj)
// ];
//
// for (const key of keys) {
// const descriptor = Object.getOwnPropertyDescriptor(obj, key);
// if (descriptor) {
// // 保留属性描述符
// Object.defineProperty(result, key, {
// ...descriptor,
// value: deepClone(descriptor.value, hash)
// });
// }
// }
//
// return result;
// }
export declare function deepCopy<T>(destination: T, source: T, deep?: boolean): T;
//# sourceMappingURL=deepCopy.d.ts.map
{"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/lib/deepCopy.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,CAAC,CAoCxE"}
import { isLikelyNode } from './isLikelyNode';
export function deepCopy(destination, source, deep) {
// JScript DontEnum bug is not taken care of
// the deep clone is for internal use, is not meant to avoid
// javascript traps or cloning html element or self referenced objects.
if (deep) {
if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
destination = source;
}
else if (source instanceof Array) {
destination = [];
for (let i = 0, len = source.length; i < len; i++) {
destination[i] = deepCopy({}, source[i], deep);
}
}
else if (source && typeof source === 'object') {
for (const property in source) {
if (property === 'canvas') {
destination[property] = deepCopy({}, source[property]);
}
else if (property === 'parent' || property === 'parentNode') {
// 直接赋值 处理XNode,XElement等虚拟dom的深拷贝
destination[property] = source[property];
}
else if (Object.prototype.hasOwnProperty.call(source, property)) {
destination[property] = deepCopy({}, source[property], deep);
}
}
}
else {
// this sounds odd for an extend but is ok for recursive use
destination = source;
}
}
else {
for (const property in source) {
if (property) {
destination[property] = source[property];
}
}
}
return destination;
}
export declare function deepMerge<T>(target: T, source: T): T;
//# sourceMappingURL=deepMerge.d.ts.map
{"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/lib/deepMerge.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KA6BhD"}
import { isLikelyNode } from './isLikelyNode';
// todo 可能有问题
export function deepMerge(target, source) {
console.warn('target is ', target, ' source is ', source);
if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
target = source;
}
else if (source instanceof Array) {
target = [];
for (let i = 0, len = source.length; i < len; i++) {
target[i] = deepMerge(target[i], source[i]);
}
}
else if (source && typeof source === 'object') {
for (const key in source) {
if (key === 'canvas') {
target[key] = deepMerge(target[key] || {}, source[key]);
}
else if (key === 'parent' || key === 'parentNode') {
// 直接赋值 处理XNode,XElement等虚拟dom的深拷贝
target[key] = source[key];
}
else if (Object.prototype.hasOwnProperty.call(source, key)) {
if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {
if (!target[key])
target[key] = {};
deepMerge(target[key], source[key]);
}
else {
target[key] = source[key];
}
}
}
}
return target;
}
// const target = { a: { b: 1 } };
// const source = { a: { c: 2 } };
//
// // 使用 deepMerge() 进行深合并
// const result = deepMerge(_.cloneDeep(target), source);
//
// console.log(result); // 输出: { a: { b: 1, c: 2 } }
/**
* Collect dependencies on array elements when the array is touched, since
* we cannot intercept array element access like property getters.
*/
export declare function dependArray(value: Array<any>): void;
//# sourceMappingURL=dependArray.d.ts.map
{"version":3,"file":"dependArray.d.ts","sourceRoot":"","sources":["../../src/lib/dependArray.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,QAU5C"}
import { isArray } from './isArray';
/**
* Collect dependencies on array elements when the array is touched, since
* we cannot intercept array element access like property getters.
*/
export function dependArray(value) {
for (let e, i = 0, l = value.length; i < l; i++) {
e = value[i];
if (e && e.__ob__) {
e.__ob__.dep.depend();
}
if (isArray(e)) {
dependArray(e);
}
}
}
export declare const EMPTY_OBJECT: {};
//# sourceMappingURL=EMPTY_OBJECT.d.ts.map
{"version":3,"file":"EMPTY_OBJECT.d.ts","sourceRoot":"","sources":["../../src/lib/EMPTY_OBJECT.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,IAAkB,CAAC"}
export const EMPTY_OBJECT = Object.seal({});
/**
* 转为xml字符串
* @param value
*/
export declare function encodeToXmlString(value?: string | number | boolean): string;
//# sourceMappingURL=encodeToXmlString.d.ts.map
{"version":3,"file":"encodeToXmlString.d.ts","sourceRoot":"","sources":["../../src/lib/encodeToXmlString.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,GAAE,MAAM,GAAG,MAAM,GAAG,OAAY,GACpC,MAAM,CAuCR"}
import { XMLEntities } from './XMLEntities';
/**
* 转为xml字符串
* @param value
*/
export function encodeToXmlString(value = '') {
const buffer = [];
let start = 0;
const str = String(value);
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.codePointAt(i);
if (char === undefined) {
throw Error('char is undefined . ');
}
if (0x20 <= char && char <= 0x7e) {
// ascii
const entity = XMLEntities[char];
if (entity) {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(entity);
start = i + 1;
}
}
else {
if (start < i) {
buffer.push(str.substring(start, i));
}
// todo 为什么转码 ??????
buffer.push(`&#x${char.toString(16).toUpperCase()};`);
if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
// char is represented by two u16
i++;
}
start = i + 1;
}
}
if (buffer.length === 0) {
return str;
}
if (start < str.length) {
buffer.push(str.substring(start, str.length));
}
return buffer.join('');
}
export declare const hasProto: boolean;
export declare const nativeWatch: any;
export declare let supportsPassive: boolean;
export declare function isNative(Ctor: any): boolean;
export declare const hasSymbol: boolean;
//# sourceMappingURL=env.d.ts.map
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/lib/env.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,SAAoB,CAAC;AAI1C,eAAO,MAAM,WAAW,KAAW,CAAC;AAEpC,eAAO,IAAI,eAAe,SAAQ,CAAC;AAiBnC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAE3C;AAED,eAAO,MAAM,SAAS,SAIK,CAAC"}
// can we use __proto__?
import { inBrowser } from './browser';
export const hasProto = '__proto__' in {};
// Firefox has a "watch" function on Object.prototype...
// @ts-expect-error firebox support
export const nativeWatch = {}.watch;
export let supportsPassive = false;
if (inBrowser) {
try {
const opts = {};
Object.defineProperty(opts, 'passive', {
get() {
/* istanbul ignore next */
supportsPassive = true;
},
}); // https://github.com/facebook/flow/issues/285
window.addEventListener('test-dts-passive', null, opts);
}
catch (e) {
// no support
}
}
/* istanbul ignore next */
export function isNative(Ctor) {
return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
}
export const hasSymbol = typeof Symbol !== 'undefined' &&
isNative(Symbol) &&
typeof Reflect !== 'undefined' &&
isNative(Reflect.ownKeys);
export declare function formatFloat(src: string | number, pos?: number): number;
//# sourceMappingURL=formatFloat.d.ts.map
{"version":3,"file":"formatFloat.d.ts","sourceRoot":"","sources":["../../src/lib/formatFloat.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAI,GAAG,MAAM,CAOjE"}
// 转为保留pos位的小数,默认为6位
// todo 带字符串怎么处理的
export function formatFloat(src, pos = 6) {
if (isNaN(parseFloat(String(src)))) {
console.error('src is ', src);
throw Error('src 不是数字');
}
// return Math.round(Number(src) * Math.pow(10, pos)) / Math.pow(10, pos);
return Number(parseFloat(src).toFixed(pos));
}
export declare function fromPairs<T extends any[]>(pairs: T[]): {
[K in T[0]]: T[1];
};
//# sourceMappingURL=fromPairs.d.ts.map
{"version":3,"file":"fromPairs.d.ts","sourceRoot":"","sources":["../../src/lib/fromPairs.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAa5E"}
// 将 pairs 数组转换为一个对象,并将其绑定到模板中显示。
export function fromPairs(pairs) {
let index = -1;
const length = pairs == null ? 0 : pairs.length;
const result = {};
while (++index < length) {
const pair = pairs[index];
if (Array.isArray(pair) && pair.length === 2) {
result[pair[0]] = pair[1];
}
}
return result;
}
export declare function genNumArr(len?: number): number[];
//# sourceMappingURL=genNumArr.d.ts.map
{"version":3,"file":"genNumArr.d.ts","sourceRoot":"","sources":["../../src/lib/genNumArr.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAGhD"}
export function genNumArr(len) {
if (!len)
return [];
return Array.from({ length: len }, (_, i) => i + 1);
}
export declare function getScroll(area?: Element): {
x: number;
y: number;
};
//# sourceMappingURL=getScroll.d.ts.map
{"version":3,"file":"getScroll.d.ts","sourceRoot":"","sources":["../../src/lib/getScroll.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAelE"}
export function getScroll(area) {
const body = {
top: document.body.scrollTop > 0
? document.body.scrollTop
: document.documentElement.scrollTop,
left: document.body.scrollLeft > 0
? document.body.scrollLeft
: document.documentElement.scrollLeft,
};
return {
y: area && area.scrollTop >= 0 ? area.scrollTop : body.top,
x: area && area.scrollLeft >= 0 ? area.scrollLeft : body.left,
};
}
interface IInfo {
keys: Record<string, string>;
bundles: Record<string, Record<string, string>>;
}
/**
* I18n helper.
*
* @since 1.0
*/
export declare class I18n {
/**
* @private
* @property {Object}
*/
static keys: Record<string, string>;
/**
* @private
* @property {Object}
*/
static bundles: Record<string, Record<string, string>>;
/**
* @public
* @param {Object} strings
*/
register(strings: IInfo): void;
/**
* Resolves a string from a key.
*
* If the key begins with '@' then the remainder is assumed to be a reference to another key and will be resolved.
*
* @public
* @param {String} key
* @param defaultText
*/
static get(key: string, defaultText?: string): string;
/**
* @public
* @param {String} key
* @returns {String}
*/
static format(key: string): string;
/**
* Render a bundle string.
*
* @param {Object/String} bundle
* @param {String} key
* @returns {String}
*/
static render(bundle: string, key: string): string | undefined;
}
export {};
//# sourceMappingURL=I18n.d.ts.map
{"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../../src/lib/I18n.ts"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AACD;;;;GAIG;AACH,qBAAa,IAAI;IACf;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkElC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAK;IAE3D;;;OAGG;IACH,QAAQ,CAAE,OAAO,EAAE,KAAK;IAKxB;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;IAuBrD;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAE,GAAG,EAAE,MAAM;IAa1B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CA0D/D"}
import { isObject } from './typed';
/**
* I18n helper.
*
* @since 1.0
*/
export class I18n {
/**
* @public
* @param {Object} strings
*/
register(strings) {
Object.assign(I18n.keys, strings.keys);
Object.assign(I18n.bundles, strings.bundles);
}
/**
* Resolves a string from a key.
*
* If the key begins with '@' then the remainder is assumed to be a reference to another key and will be resolved.
*
* @public
* @param {String} key
* @param defaultText
*/
static get(key, defaultText) {
// console.log('this.keys is ', this.keys);
// debugger;
const text = I18n.keys[key];
if (text === null || text === undefined) {
// 初始化表单验证 todo 如何加载所有的自定义的表单验证 无效 报错 ?????
// ITAS.form.Validator.init();
if (text === null || text === undefined || text === '') {
if (defaultText) {
return defaultText;
}
else {
return 'MISSING_I18N:' + key;
}
}
}
// resolve references
if (text.charAt(0) === '@') {
return I18n.get(text.substring(1, text.length));
}
else {
return text;
}
}
/**
* @public
* @param {String} key
* @returns {String}
*/
static format(key) {
let text = I18n.get(key);
if (text) {
const params = Array.prototype.slice.call(arguments);
// replace first element with text
params.shift();
params.unshift(text);
// text = Ext.String.format.apply(this, params);
text = strFormat(...params);
}
return text;
}
/**
* Render a bundle string.
*
* @param {Object/String} bundle
* @param {String} key
* @returns {String}
*/
static render(bundle, key) {
let resources, text, params;
// resolve bundle
if (isObject(bundle)) {
// bundle = Ext.getClassName(bundle);
}
//<if debug>
// this.logTrace('Resolving bundle:', bundle, 'key:', key);
//</if>
resources = I18n.bundles[bundle];
if (resources === undefined) {
console.warn('Missing I18n bundle:', bundle);
return 'MISSING_I18N:' + bundle + ':' + key;
}
// resolve text
text = resources[key];
if (text === undefined) {
// handle bundle extension
const extend = resources['$extend'];
if (extend !== undefined) {
params = Array.prototype.slice.call(arguments, 1);
params.unshift(extend);
// return this.render.apply(this, params);
return I18n.render(params[0], params[1]);
}
console.warn('Missing I18n bundle key:', bundle, ':', key);
return 'MISSING_I18N:' + bundle + ':' + key;
}
// resolve references
if (text.charAt(0) === '@') {
if (text.indexOf(':') !== -1) {
// bundle ref <bundle>:[key]
const items = text.substring(1, text.length).split(':', 2);
// default to given key if ref missing key
if (items[1] === '') {
items[1] = key;
}
params = Array.prototype.slice.call(arguments, 2);
params.unshift(items[1]);
params.unshift(items[0]);
// return this.render.apply(this, params);
return I18n.render(params[0], params[1]);
}
else {
// key ref <key>
text = I18n.get(text.substring(1, text.length));
}
}
// optionally format with parameters
if (arguments.length > 2) {
params = Array.prototype.slice.call(arguments, 2);
params.unshift(text);
// text = Ext.String.format.apply(this, params);
text = strFormat(...params);
}
return text;
}
}
/**
* @private
* @property {Object}
*/
I18n.keys = {
// dialogs tip title
// Dialogs
Dialogs_Info_Title: 'Information',
Dialogs_Error_Title: 'Error',
Dialogs_Error_Message: 'Operation failed',
Dialogs_Tip_Title: 'Friendly reminder',
Dialogs_Login_Expire_Message: 'Login information has expired. Please log in again.',
Dialog_Service_Error_Message: 'The system is not ready and unable to provide services. Please contact the administrator.',
// Message Operate
Message_Operate_Success: 'Successful',
Message_Operate_Failed: 'Failed',
Message_Selected_Data_Tip: 'Please select data',
// Action Title
Delete: 'Delete',
Are_You_Sure_Delete: 'Are you sure to delete it?',
Tree_Tools_Refresh_Tip: 'refresh',
Tree_Tools_ExpandAll_Text: 'Expand All',
Tree_Tools_CollapseAll_Text: 'Collapse All',
// Field validation messages
Util_Validator_Text: 'Only letters, digits, underscores(_), hyphens(-), and dots(.) are allowed and may not start with underscore or dot.',
Util_Validator_Hostname: 'Hostname must be valid',
Util_Validator_Trim: 'This field may not start or end with a space',
Util_Validator_Url: 'This field should be a URL in the format "http://www.example.com"',
Util_Validator_Subdomain_Text: 'Subdomain field must be a minimum of 1 and maximum of 63 characters (letters, numbers, and dashes) and must start with a letter and end with a letter or digit',
/**
* email验证错误提示语国际化设置。
* 国际化设置中Util_Validator_Email对应objId,
* 'email format is error'对应objName
* 其它需要国际化的错误提示语,按email的方式配置。
*/
Util_Validator_Email: 'This field should be email format . ',
Util_Validator_Blank: 'This field is required . ',
Util_Validator_ConfirmPwd: 'Inconsistent passwords before and after',
/**
* 纳税人识别号提示信息
*/
Util_Validator_TaxpayerIdentificationNumber: 'Please enter the correct taxpayer identification number',
/**
* 联系方式提示信息
*/
Util_Validator_Cellphone: 'Please enter the correct cellphone number',
Util_Validator_Telephone: 'Please enter the correct telephone number',
Util_Validator_Fax: 'Please enter the correct fax number',
/**
* 表格提示信息
*/
Grid_Record_Not_Exist: 'The record does not exist.',
Record_Not_Select: 'Please select the items you want to operate.',
Select_Only_One_Notification: 'Please select Only One record',
/**
* 附件提示
*/
Document_Download_Fail: 'Document download fail!',
Document_Download_Wait: 'Document is prepared for export. Please wait ...',
Document_Upload_Type_Not_Allow: 'Please upload a file in the required format',
Documnet_Size_Exceeds_Limit: 'Please select file of size smaller than',
/**
* 导出文件标题
*/
Data_Information: 'Data Information'
};
/**
* @private
* @property {Object}
*/
I18n.bundles = {};
const strFormat = function (...args) {
// const args = arguments;
return args[0].replace(/\{(\d+)\}/g, function (match, number) {
return typeof args[number + 1] !== 'undefined' ? args[number + 1] : match;
});
};
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
export declare const isArray: (arg: any) => arg is any[];
//# sourceMappingURL=isArray.d.ts.map
{"version":3,"file":"isArray.d.ts","sourceRoot":"","sources":["../../src/lib/isArray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,OAAO,4BAAgB,CAAC"}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
export const isArray = Array.isArray;
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
export declare const isEqual: <TType>(x: TType, y: TType) => boolean;
//# sourceMappingURL=isEqual.d.ts.map
{"version":3,"file":"isEqual.d.ts","sourceRoot":"","sources":["../../src/lib/isEqual.ts"],"names":[],"mappings":"AAqIA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,eAAO,MAAM,OAAO,GAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAG,OAwBnD,CAAA"}
// import { isObject } from './basics';
// function isDOMElement(obj: any): boolean {
// return obj instanceof HTMLElement || obj instanceof Element || obj instanceof DocumentFragment;
// }
//
// function removeDOMElements(obj: any): any {
// if (Array.isArray(obj)) {
// return obj.filter(item => !isDOMElement(item)).map(removeDOMElements);
// } else if (typeof obj === 'object' && obj !== null) {
// const newObj: { [key: string]: any } = {};
// for (const key in obj) {
// if (key === 'dom') {
// continue;
// }
// if (!isDOMElement(obj[key])) {
// newObj[key] = removeDOMElements(obj[key]);
// }
// }
// return newObj;
// }
// return obj;
// }
// function isEqualWithoutDOM(a: any, b: any): boolean {
// const aCleaned = removeDOMElements(a);
// const bCleaned = removeDOMElements(b);
// return JSON.stringify(aCleaned) === JSON.stringify(bCleaned);
// }
// // todo
// export function isEqual(value: any, other: any, ) {
// if (value === other) {
// return true;
// }
// if (isObject(value) && isObject(other)) { // todo 如果有dom,可能会报错
// try {
// return isEqualWithoutDOM(value, other);
// } catch (e) {
// console.error('isEqual error is ', e, ' value is ', value);
// return false;
// }
//
// }
// if (value == null || other == null || (!isObject(value) && !isObject(other))) {
// return value !== value && other !== other;
// }
// return false;
// }
//
// const Stack = require('./_Stack'),
// equalArrays = require('./_equalArrays'),
// equalByTag = require('./_equalByTag'),
// equalObjects = require('./_equalObjects'),
// getTag = require('./_getTag'),
// isArray = require('./isArray'),
// isBuffer = require('./isBuffer'),
// isTypedArray = require('./isTypedArray');
//
// /** Used to compose bitmasks for value comparisons. */
// const COMPARE_PARTIAL_FLAG = 1;
//
// /** `Object#toString` result references. */
// const argsTag = '[object Arguments]',
// arrayTag = '[object Array]',
// objectTag = '[object Object]';
//
// /** Used for built-in method references. */
// const objectProto = Object.prototype;
//
// /** Used to check objects for own properties. */
// const hasOwnProperty = objectProto.hasOwnProperty;
//
// /**
// * A specialized version of `baseIsEqual` for arrays and objects which performs
// * deep comparisons and tracks traversed objects enabling objects with circular
// * references to be compared.
// *
// * @private
// * @param {Object} object The object to compare.
// * @param {Object} other The other object to compare.
// * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
// * @param {Function} customizer The function to customize comparisons.
// * @param {Function} equalFunc The function to determine equivalents of values.
// * @param {Object} [stack] Tracks traversed `object` and `other` objects.
// * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
// */
// function baseIsEqualDeep(object: { value: () => any; }, other: {
// value: () => any;
// }, bitmask: number, customizer: any, equalFunc: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any) => any, stack: any) {
// let objIsArr = isArray(object),
// othIsArr = isArray(other),
// objTag = objIsArr ? arrayTag : getTag(object),
// othTag = othIsArr ? arrayTag : getTag(other);
//
// objTag = objTag == argsTag ? objectTag : objTag;
// othTag = othTag == argsTag ? objectTag : othTag;
//
// let objIsObj = objTag == objectTag,
// othIsObj = othTag == objectTag,
// isSameTag = objTag == othTag;
//
// if (isSameTag && isBuffer(object)) {
// if (!isBuffer(other)) {
// return false;
// }
// objIsArr = true;
// objIsObj = false;
// }
// if (isSameTag && !objIsObj) {
// stack || (stack = new Stack);
// return (objIsArr || isTypedArray(object))
// ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
// : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
// }
// if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
// const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
// othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
//
// if (objIsWrapped || othIsWrapped) {
// const objUnwrapped = objIsWrapped ? object.value() : object,
// othUnwrapped = othIsWrapped ? other.value() : other;
//
// stack || (stack = new Stack);
// return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
// }
// }
// if (!isSameTag) {
// return false;
// }
// stack || (stack = new Stack);
// return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
// }
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
// function isEqual(value: unknown, other: unknown) {
// return baseIsEqual(value, other);
// }
export const isEqual = (x, y) => {
if (Object.is(x, y))
return true;
if (x instanceof Date && y instanceof Date) {
return x.getTime() === y.getTime();
}
if (x instanceof RegExp && y instanceof RegExp) {
return x.toString() === y.toString();
}
if (typeof x !== 'object' ||
x === null ||
typeof y !== 'object' ||
y === null) {
return false;
}
const keysX = Reflect.ownKeys(x);
const keysY = Reflect.ownKeys(y);
if (keysX.length !== keysY.length)
return false;
for (let i = 0; i < keysX.length; i++) {
if (!Reflect.has(y, keysX[i]))
return false;
if (!isEqual(x[keysX[i]], y[keysX[i]]))
return false;
}
return true;
};
/**
* 判断当前环境是否为 Node 环境。
* 该函数通过检测 Buffer 是否定义以及 window 是否未定义来判断。
*
* @returns {boolean} 如果当前环境为 Node 环境,则返回 true;否则返回 false。
*/
export declare const isLikelyNode: boolean;
//# sourceMappingURL=isLikelyNode.d.ts.map
{"version":3,"file":"isLikelyNode.d.ts","sourceRoot":"","sources":["../../src/lib/isLikelyNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SACuC,CAAC"}
/**
* 判断当前环境是否为 Node 环境。
* 该函数通过检测 Buffer 是否定义以及 window 是否未定义来判断。
*
* @returns {boolean} 如果当前环境为 Node 环境,则返回 true;否则返回 false。
*/
export const isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined';
export declare const isMac: boolean;
//# sourceMappingURL=isMac.d.ts.map
{"version":3,"file":"isMac.d.ts","sourceRoot":"","sources":["../../src/lib/isMac.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,SAAsC,CAAC"}
export const isMac = /mac os/i.test(navigator.userAgent);
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
declare function isObjectLike(value: unknown): value is object;
//# sourceMappingURL=isObjectLike.d.ts.map
{"version":3,"file":"isObjectLike.d.ts","sourceRoot":"","sources":["../../src/lib/isObjectLike.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,mBAEnC"}
"use strict";
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/**
* 是否空格
* Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
* @param str
* @param index
*/
export declare function isWhitespace(str: string, index: number): boolean;
//# sourceMappingURL=isWhitespace.d.ts.map
{"version":3,"file":"isWhitespace.d.ts","sourceRoot":"","sources":["../../src/lib/isWhitespace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAIhE"}
/**
* 是否空格
* Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
* @param str
* @param index
*/
export function isWhitespace(str, index) {
const ch = str[index];
return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
// return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
}
/**
* 是否连续的空格符
* @param str
*/
export declare function isWhitespaceString(str: string): boolean;
//# sourceMappingURL=isWhitespaceString.d.ts.map
{"version":3,"file":"isWhitespaceString.d.ts","sourceRoot":"","sources":["../../src/lib/isWhitespaceString.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOvD"}
import { isWhitespace } from './isWhitespace';
/**
* 是否连续的空格符
* @param str
*/
export function isWhitespaceString(str) {
for (let i = 0, ii = str.length; i < ii; i++) {
if (!isWhitespace(str, i)) {
return false;
}
}
return true;
}
export declare const isWindows: boolean;
//# sourceMappingURL=isWindows.d.ts.map
{"version":3,"file":"isWindows.d.ts","sourceRoot":"","sources":["../../src/lib/isWindows.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAA+C,CAAC"}
export const isWindows = /win(dows|32|64)/i.test(navigator.userAgent);
interface IParams {
id: string;
}
export declare class LocalStorage {
private readonly id;
constructor(params: IParams);
getItem(key: string): string | null;
setItem(key: string, value: string): void;
removeItem(key: string): void;
}
export {};
//# sourceMappingURL=local-storage.d.ts.map
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/lib/local-storage.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;gBAChB,MAAM,EAAE,OAAO;IAI3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIlC,UAAU,CAAC,GAAG,EAAE,MAAM;CAGvB"}
export class LocalStorage {
constructor(params) {
this.id = params.id;
}
getItem(key) {
return localStorage.getItem(this.id + '-' + key);
}
setItem(key, value) {
localStorage.setItem(this.id + '-' + key, value);
}
removeItem(key) {
localStorage.removeItem(this.id + '-' + key);
}
}
export declare const undefinedTag = "[object Undefined]";
export declare const nullTag = "[object Null]";
export declare const symToStringTag: typeof Symbol.toStringTag | undefined;
//# sourceMappingURL=lodash.d.ts.map
{"version":3,"file":"lodash.d.ts","sourceRoot":"","sources":["../../src/lib/lodash.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,uBAAuB,CAAC;AACjD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAEvC,eAAO,MAAM,cAAc,uCAA0C,CAAC"}
export const undefinedTag = '[object Undefined]';
export const nullTag = '[object Null]';
export const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
export declare function md5(inStr: string): string;
//# sourceMappingURL=md5.d.ts.map
{"version":3,"file":"md5.d.ts","sourceRoot":"","sources":["../../src/lib/md5.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,UAkXhC"}
export function md5(inStr) {
let hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
// let b64pad = ''; /* base-64 pad character. "=" for strict RFC compliance */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s) {
return rstr2hex(rstr_md5(str2rstr_utf8(s)));
}
// function b64_md5(s: string) {
// return rstr2b64(rstr_md5(str2rstr_utf8(s)));
// }
// function any_md5(s: string, e: string) {
// return rstr2any(rstr_md5(str2rstr_utf8(s)), e);
// }
//
// function hex_hmac_md5(k: string, d: string) {
// return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
// }
// function b64_hmac_md5(k: string, d: string) {
// return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
// }
//
// function any_hmac_md5(k: string, d: string, e: string) {
// return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e);
// }
/*
* Perform a simple self-test-dts to see if the VM is working
*/
// function md5_vm_test() {
// return hex_md5('abc').toLowerCase() == '900150983cd24fb0d6963f7d28e17f72';
// }
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
// function rstr_hmac_md5(key: string, data: string) {
// let bkey = rstr2binl(key);
// if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
//
// const ipad = Array(16), opad = Array(16);
// for (let i = 0; i < 16; i++) {
// ipad[i] = bkey[i] ^ 0x36363636;
// opad[i] = bkey[i] ^ 0x5C5C5C5C;
// }
//
// const hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
// return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
// }
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
hexcase;
}
catch (e) {
hexcase = 0;
}
const hex_tab = hexcase ? '0123456789ABCDEF' : '0123456789abcdef';
let output = '';
let x;
for (let i = 0; i < input.length; i++) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F)
+ hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Convert a raw string to a base-64 string
*/
// function rstr2b64(input: string) {
// try {
// b64pad;
// } catch (e) {
// b64pad = '';
// }
// const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// let output = '';
// const len = input.length;
// for (let i = 0; i < len; i += 3) {
// const triplet = (input.charCodeAt(i) << 16)
// | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0)
// | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
// for (let j = 0; j < 4; j++) {
// if (i * 8 + j * 6 > input.length * 8) output += b64pad;
// else output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
// }
// }
// return output;
// }
/*
* Convert a raw string to an arbitrary string encoding
*/
// function rstr2any(input: string, encoding: string) {
// const divisor = encoding.length;
// let i, j, q, x, quotient;
//
// /* Convert to an array of 16-bit big-endian values, forming the dividend */
// let dividend = Array(Math.ceil(input.length / 2));
// for (i = 0; i < dividend.length; i++) {
// dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
// }
//
// /*
// * Repeatedly perform a long division. The binary array forms the dividend,
// * the length of the encoding is the divisor. Once computed, the quotient
// * forms the dividend for the next step. All remainders are stored for later
// * use.
// */
// const full_length = Math.ceil(input.length * 8 /
// (Math.log(encoding.length) / Math.log(2)));
// const remainders = Array(full_length);
// for (j = 0; j < full_length; j++) {
// quotient = [];
// x = 0;
// for (i = 0; i < dividend.length; i++) {
// x = (x << 16) + dividend[i];
// q = Math.floor(x / divisor);
// x -= q * divisor;
// if (quotient.length > 0 || q > 0)
// quotient[quotient.length] = q;
// }
// remainders[j] = x;
// dividend = quotient;
// }
//
// /* Convert the remainders to the output string */
// let output = '';
// for (i = remainders.length - 1; i >= 0; i--)
// output += encoding.charAt(remainders[i]);
//
// return output;
// }
/*
* Encode a string as utf-8.
* For efficiency, this assumes the input is valid utf-16.
*/
function str2rstr_utf8(input) {
let output = '';
let i = -1;
let x, y;
while (++i < input.length) {
/* Decode utf-16 surrogate pairs */
x = input.charCodeAt(i);
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i++;
}
/* Encode output as utf-8 */
if (x <= 0x7F)
output += String.fromCharCode(x);
else if (x <= 0x7FF)
output += String.fromCharCode(0xC0 | ((x >>> 6) & 0x1F), 0x80 | (x & 0x3F));
else if (x <= 0xFFFF)
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
else if (x <= 0x1FFFFF)
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
}
return output;
}
/*
* Encode a string as utf-16
*/
// function str2rstr_utf16le(input: string) {
// let output = '';
// for (let i = 0; i < input.length; i++)
// output += String.fromCharCode(input.charCodeAt(i) & 0xFF,
// (input.charCodeAt(i) >>> 8) & 0xFF);
// return output;
// }
//
// function str2rstr_utf16be(input: string) {
// let output = '';
// for (let i = 0; i < input.length; i++)
// output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
// input.charCodeAt(i) & 0xFF);
// return output;
// }
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
const output = Array(input.length >> 2);
for (let i = 0; i < output.length; i++) {
output[i] = 0;
}
for (let i = 0; i < input.length * 8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
let output = '';
for (let i = 0; i < input.length * 32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
let a = 1732584193;
let b = -271733879;
let c = -1732584194;
let d = 271733878;
for (let i = 0; i < x.length; i += 16) {
const olda = a;
const oldb = b;
const oldc = c;
const oldd = d;
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y) {
const lsw = (x & 0xFFFF) + (y & 0xFFFF);
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
return hex_md5(inStr);
}
/**
* 使用提供的数据渲染mustache模板。
* @param template 要渲染的mustache模板字符串。
* @param data 包含模板中要替换的键值对的数据对象。
* @returns 渲染后的字符串结果。
*/
export declare function mustache(template: string, data: Record<string, string>): string;
//# sourceMappingURL=mustache.d.ts.map
{"version":3,"file":"mustache.d.ts","sourceRoot":"","sources":["../../src/lib/mustache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAmBtE"}
/**
* 使用提供的数据渲染mustache模板。
* @param template 要渲染的mustache模板字符串。
* @param data 包含模板中要替换的键值对的数据对象。
* @returns 渲染后的字符串结果。
*/
export function mustache(template, data) {
const pattern = /\{\{([\w\s\\.]+)\}\}/g;
let result = template;
let match;
while ((match = pattern.exec(template))) {
const keys = match[1].trim().split('.');
let value = data[keys[0]];
for (let i = 1; i < keys.length; i++) {
value = value[keys[i]];
}
if (value !== undefined) {
if (value.value) {
result = result.replace(match[0], value.value);
}
else {
result = result.replace(match[0], value);
}
}
}
return result;
}
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
};
export declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
export {};
//# sourceMappingURL=pick.d.ts.map
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/lib/pick.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI;KAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACf,CAAC;AAEF,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAOxE"}
export function pick(obj, keys) {
return keys.reduce((acc, key) => {
if (obj && Object.prototype.hasOwnProperty.call(obj, key)) {
acc[key] = obj[key];
}
return acc;
}, {});
}
// 示例用法
// interface Item {
// id: number;
// label: string;
// value: string;
// }
// const item: Item = { id: 1, label: 'Option 1', value: 'A' };
// const pickedItem = pick(item, ['id', 'value']);
//
// console.log(pickedItem); // 输出: { id: 1, value: 'A' }
export declare function pxToRem(str: string): string;
//# sourceMappingURL=pxToRem.d.ts.map
{"version":3,"file":"pxToRem.d.ts","sourceRoot":"","sources":["../../src/lib/pxToRem.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3C"}
export function pxToRem(str) {
// 匹配:20px或: 20px不区分大小写
const reg = /(\:|: )+(\d)+(px)/gi;
return str.replace(reg, function (char) {
const x = char.replace(/(\:|: )/, '').replace(/px/i, '');
return ':' + parseFloat(x) / 100 + 'rem';
});
}
declare function setProperty(target: any, propertyKey: string, value: any, receiver?: any): boolean;
declare const obj: any;
//# sourceMappingURL=setProperty.d.ts.map
{"version":3,"file":"setProperty.d.ts","sourceRoot":"","sources":["../../src/lib/setProperty.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAClB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,GAAG,EACV,QAAQ,MAAS,WA4BlB;AAED,QAAA,MAAM,GAAG,EAAE,GAST,CAAC"}
"use strict";
function setProperty(target, propertyKey, value, receiver = target) {
if (typeof target !== 'object' && typeof target !== 'function') {
throw new TypeError('target must be an object');
}
const descriptor = Object.getOwnPropertyDescriptor(target, propertyKey);
if (descriptor &&
(descriptor.writable === false || !descriptor.configurable)) {
return false;
}
try {
// 检查是否存在访问器属性,并尝试调用set访问器
if (descriptor && typeof descriptor.set === 'function') {
descriptor.set.call(receiver, value);
return true;
}
// 如果是常规属性或没有set访问器,则直接设置值
target[propertyKey] = value;
return true;
}
catch (error) {
return false;
}
}
const obj = Object.defineProperty({}, 'name', {
configurable: true,
enumerable: true,
get: function () {
return this._name;
},
set: function (value) {
this._name = value;
},
});
setProperty(obj, 'name', 'John Doe');
console.log(obj.name); // 输出: John Doe
/**
* 简单集合类,实现了ISimpleSet接口。
*/
export declare class SimpleSet implements ISimpleSet {
set: Record<string, boolean>;
/**
* 检查集合中是否存在指定元素。
* @param key 要检查的元素,可以是字符串或数字。
* @returns {boolean} 如果元素存在,则返回true;否则返回false。
*/
has(key: string | number): boolean;
/**
* 向集合中添加元素。
* @param key 要添加的元素,可以是字符串或数字。
*/
add(key: string | number): void;
/**
* 清空集合,移除所有元素。
*/
clear(): void;
}
export interface ISimpleSet {
has(key: string | number): boolean;
add(key: string | number): any;
clear(): void;
}
//# sourceMappingURL=simple-set.d.ts.map
{"version":3,"file":"simple-set.d.ts","sourceRoot":"","sources":["../../src/lib/simple-set.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,YAAW,UAAU;IAE1C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAuB;IAEnD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIxB;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIxB;;OAEG;IACH,KAAK;CAGN;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAEnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE/B,KAAK,IAAI,IAAI,CAAC;CACf"}
/**
* 简单集合类,实现了ISimpleSet接口。
*/
export class SimpleSet {
constructor() {
// 使用记录类型存储集合中的元素,键为元素值,值为布尔类型标记存在与否
this.set = Object.create(null);
}
/**
* 检查集合中是否存在指定元素。
* @param key 要检查的元素,可以是字符串或数字。
* @returns {boolean} 如果元素存在,则返回true;否则返回false。
*/
has(key) {
return this.set[key] === true;
}
/**
* 向集合中添加元素。
* @param key 要添加的元素,可以是字符串或数字。
*/
add(key) {
this.set[key] = true;
}
/**
* 清空集合,移除所有元素。
*/
clear() {
this.set = Object.create(null);
}
}
export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): T;
//# sourceMappingURL=throttle.d.ts.map
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/lib/throttle.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAoBrF"}
export function throttle(func, limit) {
console.log('throttle . ');
let inThrottle = false;
let lastArgs = null;
return ((...args) => {
if (!inThrottle) {
func(...args);
inThrottle = true;
setTimeout(() => {
inThrottle = false;
if (lastArgs) {
const tempArgs = lastArgs;
lastArgs = null;
throttle(func, limit)(...tempArgs);
}
}, limit);
}
else {
lastArgs = args; // 如果在限制时间内再次调用,则记录下这次调用的参数
}
});
}
/**
* hello-world- to HelloWorldMinus
* @param str 字符串
* @param separator 分割符(默认"-")
* @param topIsCapital 开头是否大写(默认是)
*/
export declare function toHump(str: string, separator?: string, topIsCapital?: boolean): string;
//# sourceMappingURL=to-hump.d.ts.map
{"version":3,"file":"to-hump.d.ts","sourceRoot":"","sources":["../../src/lib/to-hump.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAM,EAAE,YAAY,UAAO,UAiBvE"}
/**
* hello-world- to HelloWorldMinus
* @param str 字符串
* @param separator 分割符(默认"-")
* @param topIsCapital 开头是否大写(默认是)
*/
export function toHump(str, separator = '-', topIsCapital = true) {
if (str.endsWith(separator)) {
// 最后是减号的处理
str = str + 'minus';
}
const strArray = str.split(separator);
return strArray
.map((item, index) => {
if (!topIsCapital && index === 0)
return item;
if (item.match(/^./)) {
return item.replace(/^./, function (match) {
return match.toUpperCase();
});
}
return item;
})
.join('');
}
export declare const isSymbol: (value: any) => value is symbol;
export declare const isObject: (value: any) => value is object;
/**
* Checks if the given value is primitive.
*
* Primitive Types: number , string , boolean , symbol, bigint, undefined, null
*
* @param {*} value value to check
* @returns {boolean} result
*/
export declare const isPrimitive: (value: any) => boolean;
export declare const isFunction: (value: any) => value is Function;
export declare const isString: (value: any) => value is string;
export declare const isInt: (value: any) => value is number;
export declare const isFloat: (value: any) => value is number;
export declare const isNumber: (value: any) => value is number;
export declare const isDate: (value: any) => value is Date;
/**
* This is really a _best guess_ promise checking. You
* should probably use Promise.resolve(value) to be 100%
* sure you're handling it correctly.
*/
export declare const isPromise: (value: any) => value is Promise<any>;
export declare const isEmpty: (value: any) => boolean;
export declare const isEqual: <TType>(x: TType, y: TType) => boolean;
//# sourceMappingURL=typed.d.ts.map
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/lib/typed.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,GAAG,KAAG,OAMxC,CAAA;AAGD,eAAO,MAAM,UAAU,UAAW,GAAG,KAAG,KAAK,IAAI,QAEhD,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED,eAAO,MAAM,KAAK,UAAW,GAAG,KAAG,KAAK,IAAI,MAE3C,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,GAAG,KAAG,KAAK,IAAI,MAE7C,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAM9C,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,GAAG,KAAG,KAAK,IAAI,IAE5C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,GAAG,KAAG,KAAK,IAAI,OAAO,CAAC,GAAG,CAK1D,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,GAAG,YAajC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAG,OAwBnD,CAAA"}
// from radash
export const isSymbol = (value) => {
return !!value && value.constructor === Symbol;
};
export const isObject = (value) => {
return !!value && value.constructor === Object;
};
/**
* Checks if the given value is primitive.
*
* Primitive Types: number , string , boolean , symbol, bigint, undefined, null
*
* @param {*} value value to check
* @returns {boolean} result
*/
export const isPrimitive = (value) => {
return (value === undefined ||
value === null ||
(typeof value !== 'object' && typeof value !== 'function'));
};
// eslint-disable-next-line @typescript-eslint/ban-types
export const isFunction = (value) => {
return !!(value && value.constructor && value.call && value.apply);
};
export const isString = (value) => {
return typeof value === 'string' || value instanceof String;
};
export const isInt = (value) => {
return isNumber(value) && value % 1 === 0;
};
export const isFloat = (value) => {
return isNumber(value) && value % 1 !== 0;
};
export const isNumber = (value) => {
try {
return Number(value) === value;
}
catch (_a) {
return false;
}
};
export const isDate = (value) => {
return Object.prototype.toString.call(value) === '[object Date]';
};
/**
* This is really a _best guess_ promise checking. You
* should probably use Promise.resolve(value) to be 100%
* sure you're handling it correctly.
*/
export const isPromise = (value) => {
if (!value)
return false;
if (!value.then)
return false;
if (!isFunction(value.then))
return false;
return true;
};
export const isEmpty = (value) => {
if (value === true || value === false)
return true;
if (value === null || value === undefined)
return true;
if (isNumber(value))
return value === 0;
if (isDate(value))
return isNaN(value.getTime());
if (isFunction(value))
return false;
if (isSymbol(value))
return false;
const length = value.length;
if (isNumber(length))
return length === 0;
const size = value.size;
if (isNumber(size))
return size === 0;
const keys = Object.keys(value).length;
return keys === 0;
};
export const isEqual = (x, y) => {
if (Object.is(x, y))
return true;
if (x instanceof Date && y instanceof Date) {
return x.getTime() === y.getTime();
}
if (x instanceof RegExp && y instanceof RegExp) {
return x.toString() === y.toString();
}
if (typeof x !== 'object' ||
x === null ||
typeof y !== 'object' ||
y === null) {
return false;
}
const keysX = Reflect.ownKeys(x);
const keysY = Reflect.ownKeys(y);
if (keysX.length !== keysY.length)
return false;
for (let i = 0; i < keysX.length; i++) {
if (!Reflect.has(y, keysX[i]))
return false;
if (!isEqual(x[keysX[i]], y[keysX[i]]))
return false;
}
return true;
};
export declare function Uint8ArrayToHexString(arr: Uint8Array): string;
//# sourceMappingURL=Uint8ArrayToHexString.d.ts.map
{"version":3,"file":"Uint8ArrayToHexString.d.ts","sourceRoot":"","sources":["../../src/lib/Uint8ArrayToHexString.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAe7D"}
export function Uint8ArrayToHexString(arr) {
const words = [];
let j = 0;
for (let i = 0; i < arr.length * 2; i += 2) {
words[i >>> 3] |= parseInt(String(arr[j]), 10) << (24 - (i % 8) * 4);
j++;
}
// 转换到16进制
const hexChars = [];
for (let i = 0; i < arr.length; i++) {
const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
}
export declare const XMLEntities: {
60: string;
62: string;
38: string;
34: string;
39: string;
};
//# sourceMappingURL=XMLEntities.d.ts.map
{"version":3,"file":"XMLEntities.d.ts","sourceRoot":"","sources":["../../src/lib/XMLEntities.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAC"}
export const XMLEntities = {
/* < */ 0x3c: '&lt;',
/* > */ 0x3e: '&gt;',
/* & */ 0x26: '&amp;',
/* " */ 0x22: '&quot;',
/* ' */ 0x27: '&apos;',
};
export declare const XMLParserErrorCode: {
NoError: number;
EndOfDocument: number;
UnterminatedCdat: number;
UnterminatedXmlDeclaration: number;
UnterminatedDoctypeDeclaration: number;
UnterminatedComment: number;
MalformedElement: number;
OutOfMemory: number;
UnterminatedAttributeValue: number;
UnterminatedElement: number;
ElementNeverBegun: number;
};
//# sourceMappingURL=XMLParserErrorCode.d.ts.map
{"version":3,"file":"XMLParserErrorCode.d.ts","sourceRoot":"","sources":["../../src/lib/XMLParserErrorCode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAY9B,CAAC"}
export const XMLParserErrorCode = {
NoError: 0,
EndOfDocument: -1,
UnterminatedCdat: -2,
UnterminatedXmlDeclaration: -3,
UnterminatedDoctypeDeclaration: -4,
UnterminatedComment: -5,
MalformedElement: -6,
OutOfMemory: -7,
UnterminatedAttributeValue: -8,
UnterminatedElement: -9,
ElementNeverBegun: -10,
};
{
"name": "@type-dom/utils",
"version": "0.1.5",
"type": "module",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"development": "./src/index.ts",
"types": "./index.d.ts",
"import": "./index.js",
"default": "./index.js"
}
},
"files": [
"dist",
"!**/*.tsbuildinfo"
],
"dependencies": {
"tslib": "^2.3.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/type-dom/utils.git"
},
"module": "./../../../index.js"
}
/**
* 单位换算率
* 一英寸等于25.4mm
* dpi (dot per inch)输出分辨率
* twip (twentieth of a point)
*/
export declare class Ratio {
static _dpi?: number;
static get dpi(): number;
static getDPI(): number[];
static inch2twip: number;
static inch2cm: number;
static inch2mm: number;
static inch2pt: number;
static mm2twip: number;
static mm2pt: number;
static get mm2px(): number;
static get pt2twip(): number;
static get pt2pxRatio(): number;
static px2pt: number;
static px2twip: number;
}
//# sourceMappingURL=ratio.d.ts.map
{"version":3,"file":"ratio.d.ts","sourceRoot":"","sources":["../src/ratio.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qBAAa,KAAK;IAChB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,KAAK,GAAG,WAQb;IAGD,MAAM,CAAC,MAAM;IAwBb,MAAM,CAAC,SAAS,SAAQ;IACxB,MAAM,CAAC,OAAO,SAAQ;IACtB,MAAM,CAAC,OAAO,SAAqB;IAEnC,MAAM,CAAC,OAAO,SAAM;IACpB,MAAM,CAAC,OAAO,SAA2D;IAEzE,MAAM,CAAC,KAAK,SAAyD;IAGrE,MAAM,KAAK,KAAK,WAGf;IAED,MAAM,KAAK,OAAO,WAEjB;IAED,MAAM,KAAK,UAAU,WAEpB;IAED,MAAM,CAAC,KAAK,SAA2B;IAEvC,MAAM,CAAC,OAAO,SAA6B;CAG5C"}
var _a;
import { formatFloat } from './lib/formatFloat';
/**
* 单位换算率
* 一英寸等于25.4mm
* dpi (dot per inch)输出分辨率
* twip (twentieth of a point)
*/
export class Ratio {
static get dpi() {
if (this._dpi === undefined) {
const dpiArr = _a.getDPI();
this._dpi = dpiArr[0]; // window.devicePixelRatio * 96;
}
// console.log('dpi is ', this._dpi);
// console.log('dpr is ', window.devicePixelRatio);
return this._dpi;
}
// windows默认dpi 96
static getDPI() {
var _b;
const arrDPI = [];
const screen = window.screen;
if (screen.deviceXDPI !== undefined) {
// ie 9
arrDPI[0] = screen.deviceXDPI;
arrDPI[1] = screen.deviceYDPI;
}
else {
// chrome firefox
const tmpNode = document.createElement('div');
tmpNode.style.cssText =
'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
document.body.appendChild(tmpNode);
arrDPI[0] = tmpNode.offsetWidth;
arrDPI[1] = tmpNode.offsetHeight;
(_b = tmpNode.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(tmpNode);
}
return arrDPI;
}
// console.log('mm2ptRatio is ', mm2ptRatio);
// window.devicePixelRatio dpr是设备像素比,dpi是每英寸的点数,不一样的
static get mm2px() {
// console.log('mm2px is ', formatFloat(Ratio.dpi / this.inch2mm));
return formatFloat(_a.dpi / this.inch2mm, 2);
} // 3.78
// console.log('mm2pxRatio is ', mm2pxRatio);
static get pt2twip() {
return this.inch2twip / this.inch2pt; // 20
}
static get pt2pxRatio() {
return Math.round((this.dpi / this.inch2pt) * 10000) / 10000;
} // 1.3333
}
_a = Ratio;
// Twip - twentieths of a point
Ratio.inch2twip = 1440;
Ratio.inch2cm = 2.54;
Ratio.inch2mm = _a.inch2cm * 10; // 25.4
// console.log('inch2mmRatio is ', inch2mmRatio);
Ratio.inch2pt = 72;
Ratio.mm2twip = Math.round((_a.inch2twip / _a.inch2mm) * 100) / 100; // 56.69
// console.log('mm2twipRation is ', mm2twipRatio);
Ratio.mm2pt = Math.round((_a.inch2pt / _a.inch2mm) * 100) / 100; // 2.83
// console.log('pt2pxRatio is ', pt2pxRatio);
Ratio.px2pt = _a.inch2pt / _a.dpi; // 0.75 72/96
// console.log('px2ptRatio is ', px2ptRatio);
Ratio.px2twip = _a.pt2twip * _a.px2pt; // 20 * 0.75 = 15
# utils
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build utils` to build the library.
## Running unit tests
Run `nx test utils` to execute the unit tests via [Jest](https://jestjs.io).
export declare const unique: <T>(arr: T[]) => T[];
type Many<T> = T | ReadonlyArray<T>;
/** like `_.castArray`, except falsy value returns empty array. */
export declare const castArray: <T>(arr: Many<T> | T) => T[];
export declare const ensureArray: <T>(arr: Many<T> | T) => T[];
export {};
//# sourceMappingURL=arrays.d.ts.map
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/ui/arrays.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,GAAI,CAAC,OAAO,CAAC,EAAE,QAAsB,CAAA;AAExD,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAEnC,kEAAkE;AAClE,eAAO,MAAM,SAAS,GAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,CAAC,EAGhD,CAAA;AACD,eAAO,MAAM,WAAW,GAJE,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,CAAC,EAIb,CAAC"}
// import { isArray } from './types'
import { isArray } from '../lib/isArray';
export const unique = (arr) => [...new Set(arr)];
// TODO: rename to `ensureArray`
/** like `_.castArray`, except falsy value returns empty array. */
export const castArray = (arr) => {
if (!arr && arr !== 0)
return [];
return isArray(arr) ? arr : [arr];
};
export const ensureArray = castArray;
// TODO: remove import alias
// avoid naming conflicts
// export { castArray as ensureArray } from 'lodash-unified'
/**
* Determine if the testing element is visible on screen no matter if its on the viewport or not
*/
export declare const isVisible: (element: HTMLElement) => boolean;
export declare const obtainAllFocusableElements: (element: HTMLElement) => HTMLElement[];
/**
* @desc Determine if target element is focusable
* @param element {HTMLElement}
* @returns {Boolean} true if it is focusable
*/
export declare const isFocusable: (element: HTMLElement) => boolean;
/**
* @desc Set Attempt to set focus on the current node.
* @param element
* The node to attempt to focus on.
* @returns
* true if element is focused.
*/
export declare const attemptFocus: (element: HTMLElement) => boolean;
/**
* Trigger an event
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
* @param {HTMLElement} elm
* @param {String} name
* @param {*} opts
*/
export declare const triggerEvent: (elm: HTMLElement, name: string, ...opts: Array<boolean>) => HTMLElement;
export declare const isLeaf: (el: HTMLElement) => boolean;
export declare const getSibling: (el: HTMLElement, distance: number, elClass: string) => Element | null;
export declare const focusNode: (el: HTMLElement) => void;
//# sourceMappingURL=aria.d.ts.map
{"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/aria.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,YAAa,WAAW,YAM7C,CAAA;AAED,eAAO,MAAM,0BAA0B,YAC5B,WAAW,KACnB,WAAW,EAIb,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAa,WAAW,KAAG,OAsClD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,YAAa,WAAW,KAAG,OAOnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAClB,WAAW,QACV,MAAM,WACH,KAAK,CAAC,OAAO,CAAC,KACtB,WAeF,CAAA;AAED,eAAO,MAAM,MAAM,OAAQ,WAAW,YAAkC,CAAA;AAExE,eAAO,MAAM,UAAU,OACjB,WAAW,YACL,MAAM,WACP,MAAM,mBAOhB,CAAA;AAED,eAAO,MAAM,SAAS,OAAQ,WAAW,SAIxC,CAAA"}
const FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex="-1"]),input:not([disabled]),input:not([type="hidden"]),select:not([disabled]),textarea:not([disabled])`;
/**
* Determine if the testing element is visible on screen no matter if its on the viewport or not
*/
export const isVisible = (element) => {
if (process.env.NODE_ENV === 'test')
return true;
const computed = getComputedStyle(element);
// element.offsetParent won't work on fix positioned
// WARNING: potential issue here, going to need some expert advices on this issue
return computed.position === 'fixed' ? false : element.offsetParent !== null;
};
export const obtainAllFocusableElements = (element) => {
return Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter((item) => isFocusable(item) && isVisible(item));
};
/**
* @desc Determine if target element is focusable
* @param element {HTMLElement}
* @returns {Boolean} true if it is focusable
*/
export const isFocusable = (element) => {
if (element.tabIndex > 0 ||
(element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)) {
return true;
}
if (element.tabIndex < 0 ||
element.hasAttribute('disabled') ||
element.getAttribute('aria-disabled') === 'true') {
return false;
}
switch (element.nodeName) {
case 'A': {
// casting current element to Specific HTMLElement in order to be more type precise
return (!!element.href &&
element.rel !== 'ignore');
}
case 'INPUT': {
return !(element.type === 'hidden' ||
element.type === 'file');
}
case 'BUTTON':
case 'SELECT':
case 'TEXTAREA': {
return true;
}
default: {
return false;
}
}
};
/**
* @desc Set Attempt to set focus on the current node.
* @param element
* The node to attempt to focus on.
* @returns
* true if element is focused.
*/
export const attemptFocus = (element) => {
var _a;
if (!isFocusable(element)) {
return false;
}
// Remove the old try catch block since there will be no error to be thrown
(_a = element.focus) === null || _a === void 0 ? void 0 : _a.call(element);
return document.activeElement === element;
};
/**
* Trigger an event
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
* @param {HTMLElement} elm
* @param {String} name
* @param {*} opts
*/
export const triggerEvent = function (elm, name, ...opts) {
let eventName;
if (name.includes('mouse') || name.includes('click')) {
eventName = 'MouseEvents';
}
else if (name.includes('key')) {
eventName = 'KeyboardEvent';
}
else {
eventName = 'HTMLEvents';
}
const evt = document.createEvent(eventName);
evt.initEvent(name, ...opts);
elm.dispatchEvent(evt);
return elm;
};
export const isLeaf = (el) => !el.getAttribute('aria-owns');
export const getSibling = (el, distance, elClass) => {
const { parentNode } = el;
if (!parentNode)
return null;
const siblings = parentNode.querySelectorAll(elClass);
const index = Array.prototype.indexOf.call(siblings, el);
return siblings[index + distance] || null;
};
export const focusNode = (el) => {
if (!el)
return;
el.focus();
!isLeaf(el) && el.click();
};
type GetElement = <T extends string | HTMLElement | Window | null | undefined>(target: T) => T extends string ? HTMLElement | null : T;
export declare const getElement: GetElement;
export {};
//# sourceMappingURL=element.d.ts.map
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/element.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3E,MAAM,EAAE,CAAC,KACN,CAAC,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,CAAC,CAAA;AAE9C,eAAO,MAAM,UAAU,EAYjB,UAAU,CAAA"}
// import { isString } from '../types'
// import { isClient } from '../browser'
import { isClient, isString } from '../../index';
export const getElement = ((target) => {
if (!isClient || target === '')
return null;
if (isString(target)) {
try {
return document.querySelector(target);
}
catch (_a) {
return null;
}
}
return target;
});
export declare const composeEventHandlers: <E>(theirsHandler?: (event?: E) => boolean | void, oursHandler?: (event?: E) => void, { checkForDefaultPrevented }?: {
checkForDefaultPrevented?: boolean | undefined;
}) => (event?: E) => void;
type WhenMouseHandler = (e: PointerEvent) => any;
export declare const whenMouse: (handler: WhenMouseHandler) => WhenMouseHandler;
export {};
//# sourceMappingURL=event.d.ts.map
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/event.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,CAAC,kBACpB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,gBAC/B,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI;;eAIJ,CAAC,SAU/B,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,CAAC,EAAE,YAAY,KAAK,GAAG,CAAA;AAChD,eAAO,MAAM,SAAS,YAAa,gBAAgB,KAAG,gBAGrD,CAAC"}
export const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
// console.log('composeEventHandlers, theirsHandler is ', theirsHandler);
const handleEvent = (event) => {
// console.log('composeEventHandlers, event is ', event);
const shouldPrevent = theirsHandler === null || theirsHandler === void 0 ? void 0 : theirsHandler(event);
if (checkForDefaultPrevented === false ||
!shouldPrevent) {
return oursHandler === null || oursHandler === void 0 ? void 0 : oursHandler(event);
}
};
return handleEvent;
};
export const whenMouse = (handler) => {
return (e) => e.pointerType === 'mouse' ? handler(e) : undefined;
};
export * from './aria';
export * from './event';
export * from './position';
export * from './scroll';
export * from './style';
export * from './element';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
export * from './aria';
export * from './event';
export * from './position';
export * from './scroll';
export * from './style';
export * from './element';
export declare const isInContainer: (el?: Element, container?: Element | Window) => boolean;
export declare const getOffsetTop: (el: HTMLElement) => number;
export declare const getOffsetTopDistance: (el: HTMLElement, containerEl: HTMLElement) => number;
export declare const getClientXY: (event: MouseEvent | TouchEvent) => {
clientX: number;
clientY: number;
};
//# sourceMappingURL=position.d.ts.map
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/position.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QACnB,OAAO,cACA,OAAO,GAAG,MAAM,KAC3B,OAsBF,CAAA;AAED,eAAO,MAAM,YAAY,OAAQ,WAAW,WAU3C,CAAA;AAED,eAAO,MAAM,oBAAoB,OAC3B,WAAW,eACF,WAAW,WAGzB,CAAA;AAED,eAAO,MAAM,WAAW,UAAW,UAAU,GAAG,UAAU;;;CAiBzD,CAAA"}
// import { isClient } from '../browser'
import { isClient } from '../../index';
export const isInContainer = (el, container) => {
if (!isClient || !el || !container)
return false;
const elRect = el.getBoundingClientRect();
let containerRect;
if (container instanceof Element) {
containerRect = container.getBoundingClientRect();
}
else {
containerRect = {
top: 0,
right: window.innerWidth,
bottom: window.innerHeight,
left: 0,
};
}
return (elRect.top < containerRect.bottom &&
elRect.bottom > containerRect.top &&
elRect.right > containerRect.left &&
elRect.left < containerRect.right);
};
export const getOffsetTop = (el) => {
let offset = 0;
let parent = el;
while (parent) {
offset += parent.offsetTop;
parent = parent.offsetParent;
}
return offset;
};
export const getOffsetTopDistance = (el, containerEl) => {
return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl));
};
export const getClientXY = (event) => {
let clientX;
let clientY;
if (event.type === 'touchend') {
clientY = event.changedTouches[0].clientY;
clientX = event.changedTouches[0].clientX;
}
else if (event.type.startsWith('touch')) {
clientY = event.touches[0].clientY;
clientX = event.touches[0].clientX;
}
else {
clientY = event.clientY;
clientX = event.clientX;
}
return {
clientX,
clientY,
};
};
export declare const isScroll: (el: HTMLElement, isVertical?: boolean) => boolean;
export declare const getScrollContainer: (el: HTMLElement, isVertical?: boolean) => Window | HTMLElement | undefined;
export declare const getScrollBarWidth: (namespace: string) => number;
/**
* Scroll with in the container element, positioning the **selected** element at the top
* of the container
*/
export declare function scrollIntoView(container: HTMLElement, selected: HTMLElement): void;
export declare function animateScrollTo(container: HTMLElement | Window, from: number, to: number, duration: number, callback?: unknown): () => void;
export declare const getScrollElement: (target: HTMLElement, container: HTMLElement | Window) => HTMLElement;
export declare const getScrollTop: (container: HTMLElement | Window) => number;
//# sourceMappingURL=scroll.d.ts.map
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/scroll.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,OAAQ,WAAW,eAAe,OAAO,KAAG,OAYhE,CAAA;AAED,eAAO,MAAM,kBAAkB,OACzB,WAAW,eACF,OAAO,KACnB,MAAM,GAAG,WAAW,GAAG,SAkBzB,CAAA;AAGD,eAAO,MAAM,iBAAiB,cAAe,MAAM,KAAG,MAwBrD,CAAA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,WAAW,GACpB,IAAI,CA8BN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,GAAG,MAAM,EAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,OAAO,cAgCnB;AAED,eAAO,MAAM,gBAAgB,WACnB,WAAW,aACR,WAAW,GAAG,MAAM,gBAMhC,CAAA;AAED,eAAO,MAAM,YAAY,cAAe,WAAW,GAAG,MAAM,WAK3D,CAAA"}
// import { isClient } from '../browser'
import { isFunction } from '../../lib/basics';
import { isClient } from '../../lib/browser';
import { easeInOutCubic } from '../easings';
import { isWindow } from '../types';
import { cAF, rAF } from '../raf';
import { getStyle } from './style';
export const isScroll = (el, isVertical) => {
if (!isClient)
return false;
const key = {
undefined: 'overflow',
true: 'overflow-y',
false: 'overflow-x',
}[String(isVertical)];
const overflow = getStyle(el, key);
return ['scroll', 'auto', 'overlay'].some((s) => overflow.includes(s));
};
export const getScrollContainer = (el, isVertical) => {
// console.warn('getScrollContainer el is ', el);
if (!isClient)
return;
let parent = el;
while (parent) {
if ([window, document, document.documentElement].includes(parent)) {
return window;
}
if (isScroll(parent, isVertical)) {
return parent;
}
parent = parent.parentNode;
}
return parent;
};
let scrollBarWidth;
export const getScrollBarWidth = (namespace) => {
var _a;
if (!isClient)
return 0;
if (scrollBarWidth !== undefined)
return scrollBarWidth;
const outer = document.createElement('div');
outer.className = `${namespace}-scrollbar__wrap`;
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.position = 'absolute';
outer.style.top = '-9999px';
document.body.appendChild(outer);
const widthNoScroll = outer.offsetWidth;
outer.style.overflow = 'scroll';
const inner = document.createElement('div');
inner.style.width = '100%';
outer.appendChild(inner);
const widthWithScroll = inner.offsetWidth;
(_a = outer.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(outer);
scrollBarWidth = widthNoScroll - widthWithScroll;
return scrollBarWidth;
};
/**
* Scroll with in the container element, positioning the **selected** element at the top
* of the container
*/
export function scrollIntoView(container, selected) {
if (!isClient)
return;
if (!selected) {
container.scrollTop = 0;
return;
}
const offsetParents = [];
let pointer = selected.offsetParent;
while (pointer !== null &&
container !== pointer &&
container.contains(pointer)) {
offsetParents.push(pointer);
pointer = pointer.offsetParent;
}
const top = selected.offsetTop +
offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
const bottom = top + selected.offsetHeight;
const viewRectTop = container.scrollTop;
const viewRectBottom = viewRectTop + container.clientHeight;
if (top < viewRectTop) {
container.scrollTop = top;
}
else if (bottom > viewRectBottom) {
container.scrollTop = bottom - container.clientHeight;
}
}
export function animateScrollTo(container, from, to, duration, callback) {
const startTime = Date.now();
let handle;
const scroll = () => {
const timestamp = Date.now();
const time = timestamp - startTime;
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, from, to, duration);
if (isWindow(container)) {
container.scrollTo(window.pageXOffset, nextScrollTop);
}
else {
container.scrollTop = nextScrollTop;
}
if (time < duration) {
handle = rAF(scroll);
}
else if (isFunction(callback)) {
callback();
}
};
scroll();
return () => {
handle && cAF(handle);
};
}
export const getScrollElement = (target, container) => {
if (isWindow(container)) {
return target.ownerDocument.documentElement;
}
return container;
};
export const getScrollTop = (container) => {
if (isWindow(container)) {
return window.scrollY;
}
return container.scrollTop;
};
import { IStyle } from '@type-dom/css-type';
export declare const classNameToArray: (cls?: string) => string[];
export declare const hasClass: (el: Element, cls: string) => boolean;
export declare const addClass: (el?: Element, cls?: string | string[]) => void;
export declare const removeClass: (el: Element, cls: string) => void;
export declare const getStyle: (element: HTMLElement | SVGElement, styleName: keyof IStyle) => string;
export type StyleValue = string | undefined | IStyle | Array<StyleValue | undefined>;
export declare const setStyle: (element: HTMLElement | SVGElement, styleName: StyleValue, value?: string | number) => void;
export declare const removeStyle: (element: HTMLElement | SVGElement, style: IStyle | keyof IStyle) => void;
export declare function addUnit(value?: string | number, defaultUnit?: string): string;
//# sourceMappingURL=style.d.ts.map
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAY5C,eAAO,MAAM,gBAAgB,4BACmB,CAAC;AAEjD,eAAO,MAAM,QAAQ,OAAQ,OAAO,OAAO,MAAM,KAAG,OAInD,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAS,OAAO,QAAQ,MAAM,GAAG,MAAM,EAAE,SA2B7D,CAAC;AAEF,eAAO,MAAM,WAAW,OAAQ,OAAO,OAAO,MAAM,SAGnD,CAAC;AAEF,eAAO,MAAM,QAAQ,YACV,WAAW,GAAG,UAAU,aACtB,MAAM,MAAM,KACtB,MAaF,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;AACpF,eAAO,MAAM,QAAQ,YACV,WAAW,GAAG,UAAU,aACtB,UAAU,UACb,MAAM,GAAG,MAAM,SA0CxB,CAAC;AAEF,eAAO,MAAM,WAAW,YACb,WAAW,GAAG,UAAU,SAC1B,MAAM,GAAG,MAAM,MAAM,SAS7B,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAAW,SAAO,GAAG,MAAM,CAS3E"}
// import { isClient } from '../browser'
import { camelize, camelToDash, debugWarn, isClient, isObject, isString } from '../../index';
import { isArray } from '../../lib/isArray';
import { keysOf } from '../objects';
import { isNumber, isStringNumber } from '../types';
// import { debugWarn } from '../error'
// import type { CSSProperties } from 'vue'
const SCOPE = 'utils/dom/style';
export const classNameToArray = (cls = '') => cls.split(' ').filter((item) => !!item.trim());
export const hasClass = (el, cls) => {
if (!el || !cls)
return false;
if (cls.includes(' '))
throw new Error('className should not contain space.');
return el.classList.contains(cls);
};
export const addClass = (el, cls) => {
// if (typeof cls !== 'string') {
// console.warn('cls is not string');
// return;
// }
// console.warn('addClass . cls is ', cls);
if (!el)
return; // todo || !cls?.trim()
// el.className = ''; // 不兼容 SVGElement
// 清空现有类名
el.classList.remove(...Array.from(el.classList));
if (isString(cls)) {
el.classList.add(...classNameToArray(cls.trim()));
}
else if (isArray(cls)) {
const hasSpace = cls.some(item => /\s/.test(item));
// 使用 \s 正则表达式可匹配空格、制表符等空白字符
if (hasSpace) {
// console.warn('cls hasSpace . ');
cls = cls.flatMap(className => className.trim().split(/\s+/) // 拆分子项并展平
);
// console.log('cls is ', cls);
}
el.classList.add(...cls);
}
else {
console.error('cls is undefined ');
}
};
export const removeClass = (el, cls) => {
if (!el || !isString(cls) || !cls.trim())
return;
el.classList.remove(...classNameToArray(cls));
};
export const getStyle = (element, styleName) => {
var _a;
if (!isClient || !element || !styleName)
return '';
let key = camelize(styleName);
if (key === 'float')
key = 'cssFloat';
try {
const style = element.style[key];
if (style)
return style;
const computed = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(element, '');
return computed ? computed[key] : '';
}
catch (_b) {
return element.style[key];
}
};
export const setStyle = (element, styleName, value) => {
var _a;
if (!element || !styleName)
return;
if (isArray(styleName)) {
// console.warn('styleName is array . ', styleName);
for (const s of styleName) {
if (isObject(s)) {
setStyle(element, s);
}
else {
console.error('styleName is ', styleName);
}
}
}
else if (isObject(styleName)) { // todo Record<string, IStyle> ??????
// entriesOf(styleName).forEach(([prop, value]) =>
// setStyle(element, prop as IStyle | keyof IStyle, value)
// );
for (const s in styleName) {
if (isString(styleName[s])) {
setStyle(element, s, styleName[s]);
}
else {
console.error('styleName is ', styleName);
}
}
}
else if (isString(styleName)) {
// --td-image-size: 50px -webkit-inline-box value is 2, need not addUnit px
if (styleName.startsWith('-')) {
// 自定义样式
// element.style[styleName as keyof CSSStyleDeclaration] = value;
element.style.setProperty(styleName, (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '');
}
else {
const key = camelize(styleName);
// (element.style as any)[key] = value;
// element.style.setProperty:使用短横线分隔的字符串作为属性名称。
// element.style 对象:使用驼峰命名法作为属性名称。
if (value === undefined)
return;
// addUnit(value) only key is with, height as ....
element.style.setProperty(camelToDash(key), value === null || value === void 0 ? void 0 : value.toString());
}
}
else {
console.error('error styleName is ', styleName);
}
};
export const removeStyle = (element, style) => {
if (!element || !style)
return;
if (isObject(style)) {
keysOf(style).forEach((prop) => removeStyle(element, prop));
}
else {
setStyle(element, style, '');
}
};
export function addUnit(value, defaultUnit = 'px') {
if (!value)
return '';
if (isNumber(value) || isStringNumber(value)) {
return `${value}${defaultUnit}`;
}
else if (isString(value)) {
return value;
}
debugWarn(SCOPE, 'binding value must be a string or number');
return '';
}
export declare function easeInOutCubic(t: number, b: number, c: number, d: number): number;
//# sourceMappingURL=easings.d.ts.map
{"version":3,"file":"easings.d.ts","sourceRoot":"","sources":["../../src/ui/easings.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAOxE"}
export function easeInOutCubic(t, b, c, d) {
const cc = c - b;
t /= d / 2;
if (t < 1) {
return (cc / 2) * t * t * t + b;
}
return (cc / 2) * ((t -= 2) * t * t + 2) + b;
}
export declare function throwError(scope: string, m: string): never;
export declare function debugWarn(err: Error): void;
export declare function debugWarn(scope: string, message: string): void;
//# sourceMappingURL=error.d.ts.map
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/ui/error.ts"],"names":[],"mappings":"AASA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAE1D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;AAC3C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA"}
import { isString } from '../lib/basics';
class ElementPlusError extends Error {
constructor(m) {
super(m);
this.name = 'ElementPlusError';
}
}
export function throwError(scope, m) {
throw new ElementPlusError(`[${scope}] ${m}`);
}
export function debugWarn(scope, message) {
if (process.env.NODE_ENV !== 'production') {
const error = isString(scope)
? new ElementPlusError(`[${scope}] ${message}`)
: scope;
// eslint-disable-next-line no-console
console.warn(error);
}
}
export declare const isKorean: (text: string) => boolean;
//# sourceMappingURL=i18n.d.ts.map
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/ui/i18n.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAU,MAAM,YACW,CAAA"}
export const isKorean = (text) => /([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(text);
export * from './dom';
export * from './arrays';
export * from './error';
export * from './i18n';
export * from './objects';
export * from './raf';
export * from './rand';
export * from './strings';
export * from './types';
export * from './typescript';
export * from './throttleByRaf';
export * from './easings';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AACA,cAAc,OAAO,CAAA;AAErB,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AAEvB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA"}
// Internal code, don't use in your app!
export * from './dom';
// export * from './vue'
export * from './arrays';
// export * from './browser'
export * from './error';
// export * from './functions'
export * from './i18n';
export * from './objects';
export * from './raf';
export * from './rand';
export * from './strings';
export * from './types';
export * from './typescript';
export * from './throttleByRaf';
export * from './easings';
import { Arrayable } from './typescript';
export declare const keysOf: <T extends object>(arr: T) => Array<keyof T>;
export declare const entriesOf: <T extends object>(arr: T) => [string, any][];
export declare const getProp: <T = any>(obj: Record<string, any>, path: Arrayable<string>, defaultValue?: any) => {
value: T;
};
//# sourceMappingURL=objects.d.ts.map
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/ui/objects.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,OAAO,CAAC,KACzB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AACpC,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,OAAO,CAAC,oBAC7B,CAAA;AAErB,eAAO,MAAM,OAAO,GAAI,CAAC,aAClB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAClB,SAAS,CAAC,MAAM,CAAC,iBACR,GAAG,KACjB;IAAE,KAAK,EAAE,CAAC,CAAA;CASZ,CAAA"}
// import { get, set } from 'lodash-unified'
// import type { Entries } from 'type-fest'
// import type { Arrayable } from '.'
// export { hasOwn } from '@vue/shared'
import { get, set } from 'lodash';
export const keysOf = (arr) => Object.keys(arr);
export const entriesOf = (arr) => Object.entries(arr);
export const getProp = (obj, path, defaultValue) => {
return {
get value() {
return get(obj, path, defaultValue);
},
set value(val) {
set(obj, path, val);
},
};
};
export declare const rAF: (fn: () => void) => number;
export declare const cAF: (handle: number) => void;
//# sourceMappingURL=raf.d.ts.map
{"version":3,"file":"raf.d.ts","sourceRoot":"","sources":["../../src/ui/raf.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,OAAQ,MAAM,IAAI,WAGa,CAAC;AAEhD,eAAO,MAAM,GAAG,WAAY,MAAM,SACqC,CAAC"}
import { isClient } from '../lib/browser';
export const rAF = (fn) => isClient
? window.requestAnimationFrame(fn)
: setTimeout(fn, 16);
export const cAF = (handle) => isClient ? window.cancelAnimationFrame(handle) : clearTimeout(handle);
/**
* @deprecated Use `useId` `useIdInjection` instead
* Generate random number in range [0, 1000]
* Maybe replace with [uuid](https://www.npmjs.com/package/uuid)
*/
export declare const generateId: () => number;
/**
* @deprecated
* Generating a random int in range (0, max - 1)
* @param max {number}
*/
export declare const getRandomInt: (max: number) => number;
//# sourceMappingURL=rand.d.ts.map
{"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../../src/ui/rand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAA2C,CAAA;AAEzE;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,WACK,CAAA"}
/**
* @deprecated Use `useId` `useIdInjection` instead
* Generate random number in range [0, 1000]
* Maybe replace with [uuid](https://www.npmjs.com/package/uuid)
*/
export const generateId = () => Math.floor(Math.random() * 10000);
/**
* @deprecated
* Generating a random int in range (0, max - 1)
* @param max {number}
*/
export const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export declare const escapeStringRegexp: (string?: string) => string;
/**
* Splits a string of space separated words into an array, trimming as needed. If the
* words are already an array, it is returned.
*
* @param {String/Array} words
*/
export declare function splitWords(words?: string | string[]): string[];
/**
* Creates a map (object) keyed by the elements of the given array. The values in
* the map are the index+1 of the array element. For example:
*
* var map = Ext.Array.toMap(['a','b','c']);
*
* // map = { a: 1, b: 2, c: 3 };
*
* Or a key property can be specified:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], 'name');
*
* // map = { a: 1, b: 2, c: 3 };
*
* Lastly, a key extractor can be provided:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], function(obj) { return obj.name.toUpperCase(); });
*
* // map = { A: 1, B: 2, C: 3 };
*
* @param {String/String[]} strings The strings from which to create the map.
* @param {String/Function} [getKey] Name of the object property to use
* as a key or a function to extract the key.
* @param {Object} [scope] Value of `this` inside callback specified for `getKey`.
* @return {Object} The resulting map.
*/
export declare function toMap<T extends Record<string, string>>(strings?: string | (string | T)[], getKey?: string | ((obj: T) => string), scope?: any): Record<string, number> | null;
//# sourceMappingURL=strings.d.ts.map
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/ui/strings.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,kBAAkB,6BACuC,CAAA;AAQtE;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,YAMnD;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,iCA6B7I"}
// import { capitalize as toCapitalize } from '@vue/shared'
// export {
// camelize,
// hyphenate,
// hyphenate as kebabCase, // alias
// } from '@vue/shared'
// import { capitalize as toCapitalize } from '@type-dom/utils';
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export const escapeStringRegexp = (string = '') => string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
// NOTE: improve capitalize types. Restore previous code after the [PR](https://github.com/vuejs/core/pull/6212) merge
// export const capitalize = <T extends string>(str: T) =>
// toCapitalize(str) as Capitalize<T>
const basicTrimRe = /^\s+|\s+$/g;
const whitespaceRe = /\s+/;
/**
* Splits a string of space separated words into an array, trimming as needed. If the
* words are already an array, it is returned.
*
* @param {String/Array} words
*/
export function splitWords(words) {
if (!words)
return [];
if (words && typeof words === 'string') {
return words.replace(basicTrimRe, '').split(whitespaceRe);
}
return words || [];
}
/**
* Creates a map (object) keyed by the elements of the given array. The values in
* the map are the index+1 of the array element. For example:
*
* var map = Ext.Array.toMap(['a','b','c']);
*
* // map = { a: 1, b: 2, c: 3 };
*
* Or a key property can be specified:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], 'name');
*
* // map = { a: 1, b: 2, c: 3 };
*
* Lastly, a key extractor can be provided:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], function(obj) { return obj.name.toUpperCase(); });
*
* // map = { A: 1, B: 2, C: 3 };
*
* @param {String/String[]} strings The strings from which to create the map.
* @param {String/Function} [getKey] Name of the object property to use
* as a key or a function to extract the key.
* @param {Object} [scope] Value of `this` inside callback specified for `getKey`.
* @return {Object} The resulting map.
*/
export function toMap(strings, getKey, scope) {
const map = {};
if (!strings) {
return null;
}
let i = strings.length;
if (typeof strings === 'string') {
map[strings] = 1;
}
else if (!getKey) { // getKey不存在时,strings为数组,是string[];
while (i--) {
map[strings[i]] = i + 1;
}
}
else if (typeof getKey === 'string') {
while (i--) {
map[strings[i][getKey]] = i + 1;
}
}
else {
while (i--) {
map[getKey.call(scope, strings[i])] = i + 1;
}
}
return map;
}
export declare function throttleByRaf(cb: (...args: any[]) => void): {
(...args: any[]): void;
cancel(): void;
};
//# sourceMappingURL=throttleByRaf.d.ts.map
{"version":3,"file":"throttleByRaf.d.ts","sourceRoot":"","sources":["../../src/ui/throttleByRaf.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;cAG7B,GAAG,EAAE,GAAG,IAAI;;EAgBxC"}
import { cAF, rAF } from './raf';
export function throttleByRaf(cb) {
let timer = 0;
const throttle = (...args) => {
if (timer) {
cAF(timer);
}
timer = rAF(() => {
cb(...args);
timer = 0;
});
};
throttle.cancel = () => {
cAF(timer);
timer = 0;
};
return throttle;
}
export declare const isUndefined: (val: any) => val is undefined;
export declare const isBoolean: (val: any) => val is boolean;
export declare const isNumber: (val: any) => val is number;
export declare const isEmpty: (val: unknown) => boolean;
export declare const isElement: (e: unknown) => e is Element;
export declare const isPropAbsent: (prop: unknown) => prop is null | undefined;
export declare const isStringNumber: (val: string) => boolean;
export declare const isWindow: (val: unknown) => val is Window;
//# sourceMappingURL=types.d.ts.map
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAAS,GAAG,KAAG,GAAG,IAAI,SAA8B,CAAA;AAC5E,eAAO,MAAM,SAAS,QAAS,GAAG,KAAG,GAAG,IAAI,OAAmC,CAAA;AAC/E,eAAO,MAAM,QAAQ,QAAS,GAAG,KAAG,GAAG,IAAI,MAAiC,CAAA;AAE5E,eAAO,MAAM,OAAO,QAAS,OAAO,YAGS,CAAA;AAE7C,eAAO,MAAM,SAAS,MAAO,OAAO,KAAG,CAAC,IAAI,OAG3C,CAAA;AAED,eAAO,MAAM,YAAY,SAAU,OAAO,KAAG,IAAI,IAAI,IAAI,GAAG,SAE3D,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,OAK5C,CAAA;AAED,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAE9C,CAAA"}
import { isNil } from '../lib/basics';
import { isArray } from '../lib/isArray';
import { isObject, isString } from '../lib/typed';
export const isUndefined = (val) => val === undefined;
export const isBoolean = (val) => typeof val === 'boolean';
export const isNumber = (val) => typeof val === 'number';
export const isEmpty = (val) => (!val && val !== 0) ||
(isArray(val) && val.length === 0) ||
(isObject(val) && !Object.keys(val).length);
export const isElement = (e) => {
if (typeof Element === 'undefined')
return false;
return e instanceof Element;
};
export const isPropAbsent = (prop) => {
return isNil(prop);
};
export const isStringNumber = (val) => {
if (!isString(val)) {
return false;
}
return !Number.isNaN(Number(val));
};
export const isWindow = (val) => {
return val === window;
};
export declare const mutable: <T extends readonly any[] | Record<string, unknown>>(val: T) => Mutable<typeof val>;
export type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
export type HTMLElementCustomized<T> = HTMLElement & T;
/**
* @deprecated stop to use null
* @see {@link https://github.com/sindresorhus/meta/discussions/7}
*/
export type Nullable<T> = T | null;
export type Arrayable<T> = T | T[];
export type Awaitable<T> = Promise<T> | T;
//# sourceMappingURL=typescript.d.ts.map
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/ui/typescript.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACnE,CAAC,KACI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAA;AAC/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAE3D,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,WAAW,GAAG,CAAC,CAAA;AAEtD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAElC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAClC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
export const mutable = (val) => val;
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => true | undefined;
/**
* Check if a tag is a built-in tag.
*/
export declare const isBuiltInTag: (key: string) => true | undefined;
/**
* Check if an attribute is a reserved attribute.
*/
export declare const isReservedAttribute: (key: string) => true | undefined;
/**
* Remove an item from an array.
*/
export declare function remove(arr: Array<any>, item: any): Array<any> | void;
export declare function hasOwn(obj: object | Array<any>, key: string): boolean;
/**
* Create a cached version of a pure function.
*/
export declare function cached<R>(fn: (str: string) => R): (sr: string) => R;
export declare const camelize: (sr: string) => string;
/**
* Capitalize a string.
*/
export declare const capitalize: (sr: string) => string;
export declare const hyphenate: (sr: string) => string;
/**
* Simple bind polyfill for environments that do not support it,
* e.g., PhantomJS 1.x. Technically, we don't need this anymore
* since native bind is now performant enough in most browsers.
* But removing it would mean breaking code that was able to run in
* PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/**
* Convert an Array-like object to a real Array.
*/
/**
* Mix properties into target object.
*/
export declare function extend(to: Record<PropertyKey, any>, _from?: Record<PropertyKey, any>): Record<PropertyKey, any>;
/**
* Merge an Array of Objects into a single Object.
*/
export declare function toObject(arr: Array<any>): object;
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
export declare function noop(a?: any, b?: any, c?: any): void;
export declare const NOOP: () => void;
/**
* Always return false.
*/
export declare const no: (a?: any, b?: any, c?: any) => boolean;
/**
* Return the same value.
*/
export declare const identity: (_: any) => any;
/**
* Generate a string containing static keys from compiler modules.
*/
export declare function genStaticKeys(modules: Array<{
staticKeys?: string[];
}>): string;
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export declare function looseEqual(a: any, b: any): boolean;
/**
* Return the first index at which a loosely equal value can be
* found in the array (if value is a plain object, the array must
* contain an object of the same shape), or -1 if it is not present.
*/
export declare function looseIndexOf(arr: Array<unknown>, val: unknown): number;
/**
* Ensure a function is called only once.
*/
export declare function once<T extends (...args: any[]) => any>(fn: T): T;
export declare function hasChanged(x: unknown, y: unknown): boolean;
//# sourceMappingURL=util.d.ts.map
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,gBAAgB,CAAC,EAAE,OAAO,GACzB,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAOnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,QAZhB,MAAM,KAAK,IAAI,GAAG,SAYgC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAjBvB,MAAM,KAAK,IAAI,GAAG,SAiB6C,CAAC;AAEzE;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAapE;AAOD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAErE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,CAAC,CAMnE;AAMD,eAAO,MAAM,QAAQ,OAZmC,MAAM,WAc5D,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,OAnBiC,MAAM,WAqB5D,CAAC;AAMH,eAAO,MAAM,SAAS,OA3BkC,MAAM,WA6B5D,CAAC;AAEH;;;;;;GAMG;AAuBH;;GAEG;AAWH;;GAEG;AACH,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,GAC/B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAK1B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAQhD;AAID;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,QAE7C;AAED,eAAO,MAAM,IAAI,QAAO,IAAU,CAAA;AAClC;;GAEG;AACH,eAAO,MAAM,EAAE,OAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,YAAU,CAAC;AAIvD;;GAEG;AACH,eAAO,MAAM,QAAQ,MAAO,GAAG,QAAM,CAAC;AAEtC;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,KAAK,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAqB,GAC5D,MAAM,CAIR;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAwClD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAKtE;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAUhE;AAGD,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAM1D"}
import { isObject } from './lib/typed';
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
export function makeMap(str, expectsLowerCase) {
const map = Object.create({});
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => map[val.toLowerCase()] : (val) => map[val];
}
/**
* Check if a tag is a built-in tag.
*/
export const isBuiltInTag = makeMap('slot,component', true);
/**
* Check if an attribute is a reserved attribute.
*/
export const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
* Remove an item from an array.
*/
export function remove(arr, item) {
const len = arr.length;
if (len) {
// fast path for the only / last item
if (item === arr[len - 1]) {
arr.length = len - 1;
return;
}
const index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1);
}
}
}
/**
* Check whether an object has the property.
*/
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
}
/**
* Create a cached version of a pure function.
*/
export function cached(fn) {
const cache = Object.create({});
return function cachedFn(str) {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
}
/**
* Camelize a hyphen-delimited string.
*/
const camelizeRE = /-(\w)/g;
export const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
});
/**
* Capitalize a string.
*/
export const capitalize = cached((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
/**
* Hyphenate a camelCase string.
*/
const hyphenateRE = /\B([A-Z])/g;
export const hyphenate = cached((str) => {
return str.replace(hyphenateRE, '-$1').toLowerCase();
});
/**
* Simple bind polyfill for environments that do not support it,
* e.g., PhantomJS 1.x. Technically, we don't need this anymore
* since native bind is now performant enough in most browsers.
* But removing it would mean breaking code that was able to run in
* PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
// function polyfillBind(fn: Function, ctx: Object): Function {
// function boundFn(a: any) {
// const l = arguments.length
// return l
// ? l > 1
// ? fn.apply(ctx, arguments)
// : fn.call(ctx, a)
// : fn.call(ctx)
// }
//
// boundFn._length = fn.length
// return boundFn
// }
// function nativeBind(fn: Function, ctx: Object): Function {
// return fn.bind(ctx)
// }
// export const bind = Function.prototype.bind ? nativeBind : polyfillBind
/**
* Convert an Array-like object to a real Array.
*/
// export function toArray(list: any, start?: number): Array<any> {
// start = start || 0;
// let i = list.length - start;
// const ret: Array<any> = new Array(i);
// while (i--) {
// ret[i] = list[i + start];
// }
// return ret;
// }
/**
* Mix properties into target object.
*/
export function extend(to, _from) {
for (const key in _from) {
to[key] = _from === null || _from === void 0 ? void 0 : _from[key];
}
return to;
}
/**
* Merge an Array of Objects into a single Object.
*/
export function toObject(arr) {
const res = {};
for (let i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res;
}
/* eslint-disable no-unused-vars */
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
export function noop(a, b, c) {
/* empty */
}
export const NOOP = () => { };
/**
* Always return false.
*/
export const no = (a, b, c) => false;
/* eslint-enable no-unused-vars */
/**
* Return the same value.
*/
export const identity = (_) => _;
/**
* Generate a string containing static keys from compiler modules.
*/
export function genStaticKeys(modules) {
return modules
.reduce((keys, m) => keys.concat(m.staticKeys || []), [])
.join(',');
}
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export function looseEqual(a, b) {
if (a === b)
return true;
const isObjectA = isObject(a);
const isObjectB = isObject(b);
if (isObjectA && isObjectB) {
try {
const isArrayA = Array.isArray(a);
const isArrayB = Array.isArray(b);
if (isArrayA && isArrayB) {
return (a.length === b.length &&
a.every((e, i) => {
return looseEqual(e, b[i]);
}));
}
else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime();
}
else if (!isArrayA && !isArrayB) {
const keysA = Object.keys(a);
const keysB = Object.keys(b);
return (keysA.length === keysB.length &&
keysA.every((key) => {
// @ts-ignore
return looseEqual(a[key], b[key]);
}));
}
else {
/* istanbul ignore next */
return false;
}
}
catch (e) {
/* istanbul ignore next */
return false;
}
}
else if (!isObjectA && !isObjectB) {
return String(a) === String(b);
}
else {
return false;
}
}
/**
* Return the first index at which a loosely equal value can be
* found in the array (if value is a plain object, the array must
* contain an object of the same shape), or -1 if it is not present.
*/
export function looseIndexOf(arr, val) {
for (let i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val))
return i;
}
return -1;
}
/**
* Ensure a function is called only once.
*/
export function once(fn) {
let called = false;
return function () {
if (!called) {
called = true;
// @ts-ignore
fn.apply(this, arguments);
}
};
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
export function hasChanged(x, y) {
if (x === y) {
return x === 0 && 1 / x !== 1 / y;
}
else {
return x === x || y === y;
}
}
+12
-9
{
"name": "@type-dom/utils",
"version": "0.1.4",
"version": "0.1.5",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {

@@ -11,7 +11,11 @@ "./package.json": "./package.json",

"development": "./src/index.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
"types": "./index.d.ts",
"import": "./index.js",
"default": "./index.js"
}
},
"files": [
"dist",
"!**/*.tsbuildinfo"
],
"dependencies": {

@@ -23,4 +27,3 @@ "tslib": "^2.3.0"

"url": "git+https://github.com/type-dom/utils.git"
},
"module": "./../../../index.js"
}
}
}
/**
* 类
*/
export { Ratio } from './ratio';
export { SimpleSet } from './lib/simple-set';
export type { ISimpleSet } from './lib/simple-set';
export { Base64 } from './lib/base64';
export { Cookie } from './lib/cookie';
export { LocalStorage } from './lib/local-storage';
export { I18n } from './lib/I18n';
/**
* 常量
*/
export { isWindows } from './lib/isWindows';
export { isMac } from './lib/isMac';
export { isLikelyNode } from './lib/isLikelyNode';
export { EMPTY_OBJECT } from './lib/EMPTY_OBJECT';
export { XMLEntities } from './lib/XMLEntities';
export { XMLParserErrorCode } from './lib/XMLParserErrorCode';
/**
* 函数
*/
export * from './lib/basics';
export * from './ui/error';
export { mustache } from './lib/mustache';
export { toHump } from './lib/to-hump';
export { camelToDash } from './lib/camelToDash';
export { clone } from './lib/clone';
export { colorFormat } from './lib/colorFormat';
export { dashToCamel } from './lib/dashToCamel';
export { dashToPascal } from './lib/dashToPascal';
export { deepClone } from './lib/deepClone';
export { deepCopy } from './lib/deepCopy';
export { deepMerge } from './lib/deepMerge';
export { getScroll } from './lib/getScroll';
export { pxToRem } from './lib/pxToRem';
export { isWhitespace } from './lib/isWhitespace';
export { isWhitespaceString } from './lib/isWhitespaceString';
export { encodeToXmlString } from './lib/encodeToXmlString';
export { Uint8ArrayToHexString } from './lib/Uint8ArrayToHexString';
export { formatFloat } from './lib/formatFloat';
export { createRotatableElement } from './lib/animation';
export { throttleByRaf } from './ui/throttleByRaf';
export { throttle } from './lib/throttle';
export { debounce } from './lib/debounce';
export { md5 } from './lib/md5';
export { anonymizeData } from './lib/anonymizeData';
export { fromPairs } from './lib/fromPairs';
export { isEqual } from './lib/isEqual';
export { pick } from './lib/pick';
export { genNumArr } from './lib/genNumArr';
/**
* 接口
*/
/**
* 集成库
*/
export * from './lib/env';
export * from './lib/browser';
export * from './lib/casing';
export * from './util';
export * from './ui/index';
export type * from './interface';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;GAEG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;GAEG;AAEH;;GAEG;AAGH,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,mBAAmB,aAAa,CAAC"}
// export * from './test-dts/utils';
/**
* 类
*/
export { Ratio } from './ratio';
export { SimpleSet } from './lib/simple-set';
export { Base64 } from './lib/base64';
export { Cookie } from './lib/cookie';
export { LocalStorage } from './lib/local-storage';
export { I18n } from './lib/I18n';
/**
* 常量
*/
export { isWindows } from './lib/isWindows';
export { isMac } from './lib/isMac';
export { isLikelyNode } from './lib/isLikelyNode';
export { EMPTY_OBJECT } from './lib/EMPTY_OBJECT';
export { XMLEntities } from './lib/XMLEntities';
export { XMLParserErrorCode } from './lib/XMLParserErrorCode';
/**
* 函数
*/
export * from './lib/basics';
export * from './ui/error';
export { mustache } from './lib/mustache';
export { toHump } from './lib/to-hump';
export { camelToDash } from './lib/camelToDash';
export { clone } from './lib/clone';
export { colorFormat } from './lib/colorFormat';
export { dashToCamel } from './lib/dashToCamel';
export { dashToPascal } from './lib/dashToPascal';
export { deepClone } from './lib/deepClone';
export { deepCopy } from './lib/deepCopy';
export { deepMerge } from './lib/deepMerge';
export { getScroll } from './lib/getScroll';
export { pxToRem } from './lib/pxToRem';
export { isWhitespace } from './lib/isWhitespace';
export { isWhitespaceString } from './lib/isWhitespaceString';
export { encodeToXmlString } from './lib/encodeToXmlString';
export { Uint8ArrayToHexString } from './lib/Uint8ArrayToHexString';
export { formatFloat } from './lib/formatFloat';
export { createRotatableElement } from './lib/animation';
export { throttleByRaf } from './ui/throttleByRaf';
export { throttle } from './lib/throttle';
export { debounce } from './lib/debounce';
export { md5 } from './lib/md5';
export { anonymizeData } from './lib/anonymizeData';
export { fromPairs } from './lib/fromPairs';
export { isEqual } from './lib/isEqual';
export { pick } from './lib/pick';
export { genNumArr } from './lib/genNumArr';
/**
* 接口
*/
/**
* 集成库
*/
// export * from './console';
// export * from './currency';
export * from './lib/env';
export * from './lib/browser';
export * from './lib/casing';
export * from './util';
export * from './ui/index';
export type IPrimitive = null | undefined | string | number | boolean | symbol | bigint;
export type IBrowserNativeObject = Date | FileList | File | Blob | RegExp;
/**
* Void function
*/
export type Fn = () => void;
/**
* Any function
*/
export type AnyFn = (...args: any[]) => any;
//# sourceMappingURL=interface.d.ts.map
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AACX,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,IAAI,CAAA;AAE3B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA"}
export {};
export declare function createRotatableElement(element: HTMLElement, initialRotation?: number, speed?: number): {
start: () => void;
stop: () => void;
setSpeed: (newSpeed: number) => void;
getSpeed: () => number;
};
//# sourceMappingURL=animation.d.ts.map
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/lib/animation.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,WAAW,EACpB,eAAe,SAAI,EACnB,KAAK,SAAI;;;yBAmDc,MAAM;;EAK9B"}
export function createRotatableElement(element, initialRotation = 0, speed = 4) {
let currentRotation = initialRotation;
let lastFrameTime;
let isRotating = false;
function animate(now) {
// ...(保持原有animate函数内容不变)
if (!lastFrameTime) {
lastFrameTime = now;
}
const deltaTime = now - lastFrameTime;
lastFrameTime = now;
if (isRotating) {
currentRotation += (speed * deltaTime) / 1000;
while (currentRotation >= 360) {
currentRotation -= 360;
}
while (currentRotation < 0) {
currentRotation += 360;
}
element.style.transform = `rotate(${currentRotation}deg)`;
}
if (isRotating) {
requestAnimationFrame(animate);
}
}
// function toggleRotation() {
// // ...(保持原有toggleRotation函数内容不变)
// isRotating = !isRotating;
// if (isRotating) {
// requestAnimationFrame(animate);
// }
// }
// 绑定点击事件以触发旋转
// element.addEventListener("click", toggleRotation);
return {
start: () => {
isRotating = true;
requestAnimationFrame(animate);
},
stop: () => {
isRotating = false;
},
setSpeed: (newSpeed) => {
speed = newSpeed;
},
getSpeed: () => speed,
};
}
// const element1 = document.createElement('div');
// const rotatingElementController = createRotatableElement(element1);
// // 启动旋转
// rotatingElementController.start();
// // 更改旋转速度
// rotatingElementController.setSpeed(2);
export declare function anonymizeData(data: Record<string, string>): {
name: string;
address: string;
phoneNumber: string;
faxNumber: string;
email: string;
socialId: string;
};
//# sourceMappingURL=anonymizeData.d.ts.map
{"version":3,"file":"anonymizeData.d.ts","sourceRoot":"","sources":["../../src/lib/anonymizeData.ts"],"names":[],"mappings":"AACA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;EASzD"}
export function anonymizeData(data) {
return {
name: anonymizeName(data.name),
address: anonymizeAddress(data.address),
phoneNumber: anonymizePhoneNumber(data.phoneNumber),
faxNumber: anonymizeFaxNumber(data.faxNumber),
email: anonymizeEmail(data.email),
socialId: anonymizeSocialId(data.socialId)
};
}
// 现在是中文名,需要根据实际场景修改。英文名等需要修改。
function anonymizeName(name) {
console.warn('name is ', name);
const parts = name.split(' ');
if (parts.length === 1) {
if (parts[0].length === 2) {
return parts[0].charAt(0) + '*';
}
else {
return parts[0].charAt(0) + '**';
}
}
else {
return parts[0] + '**';
}
}
/**
* 地址匿名化
* todo 针对Itas的地址格式,需要根据实际场景修改。
* @example 北京市海淀区上地小区信息路3号华为大厦6楼
* @param address
*/
function anonymizeAddress(address) {
console.log('anonymizeAddress . address is ', address);
// 定义正则表达式匹配地址的各个部分
const regex = /(.*市)(.*?[区|镇|县])(.*?)(.*?路)(\d+号)(.*)$/;
const match = address.match(regex);
// 确保地址格式正确
if (!match) {
throw new Error('地址格式不正确');
}
// 提取匹配的部分
const [_, city, district, subdistrict, road, number, rest] = match;
// 将路名部分替换为星号
const maskedRoad = '*'.repeat(road.length - 1);
// 获取并处理门牌号
const maskedNumber = '*'.repeat(number.length - 1);
// 将号后面的所有内容替换为星号
const maskedRest = '*'.repeat(rest.length);
// 拼接新的地址
return `${city}${district}${subdistrict}${maskedRoad}路${maskedNumber}号${maskedRest}`;
}
function anonymizePhoneNumber(phoneNumber) {
return phoneNumber.slice(0, 3) + '****' + phoneNumber.slice(-4);
}
function anonymizeFaxNumber(faxNumber) {
return faxNumber ? 'NA' : '';
}
function anonymizeEmail(email) {
const [local, domain] = email.split('@');
const localPart = local.charAt(0) + '***';
return localPart + '@' + domain;
}
function anonymizeSocialId(socialId) {
return socialId.slice(0, 6) + '************';
}
//
// // 示例用法
// const data = {
// name: '张小明',
// address: '北京市海淀区上地信息路3号华为大厦6楼',
// phoneNumber: '12345678911',
// faxNumber: '1234567890',
// email: 'tom123@aabbcc.com',
// socialId: '123456196010201234'
// };
//
// const anonymizedData = anonymizeData(data);
// console.log(anonymizedData);
export declare const arrayMethods: any;
//# sourceMappingURL=array.d.ts.map
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/lib/array.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,KAA4B,CAAC"}
/*
* not type checking this file because flow doesn't play well with
* dynamically accessing methods on Array prototype
*/
// import { TriggerOpTypes } from '../../v3'
// import { def } from '../util/index'
const arrayProto = Array.prototype;
export const arrayMethods = Object.create(arrayProto);
const methodsToPatch = [
'push',
'pop',
'shift',
'unshift',
'splice',
'sort',
'reverse'
];
/**
* Intercept mutating methods and emit events
*/
methodsToPatch.forEach(function (method) {
// cache original method
// const original = arrayProto[method];
// def(arrayMethods, method, function mutator(...args: any[]) {
// const result = original.apply(this, args)
// const ob = this.__ob__
// let inserted
// switch (method) {
// case 'push':
// case 'unshift':
// inserted = args
// break
// case 'splice':
// inserted = args.slice(2)
// break
// }
// if (inserted) ob.observeArray(inserted)
// // notify change
// if (__DEV__) {
// ob.dep.notify({
// type: TriggerOpTypes.ARRAY_MUTATION,
// target: this,
// key: method
// })
// } else {
// ob.dep.notify()
// }
// return result
// })
});
/**
* base64.ts
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*
* @author Dan Kogai (https://github.com/dankogai)
*/
export declare class Base64 {
static encode(input: string): string;
static decode(input: string): string;
}
//# sourceMappingURL=base64.d.ts.map
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/lib/base64.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,MAAM;IACjB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM;IAO3B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM;CAO5B"}
/**
* base64.ts
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*
* @author Dan Kogai (https://github.com/dankogai)
*/
export class Base64 {
static encode(input) {
// 对输入的字符串进行Base64编码
if (typeof btoa === 'undefined') {
return encode(input);
}
return btoa(unescape(encodeURIComponent(input)));
}
static decode(input) {
// 对输入的字符串进行Base64解码
if (typeof atob === 'undefined') {
return decode(input);
}
return decodeURIComponent(escape(atob(input)));
}
}
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* 将字符串进行 Base64 编码
* @param input 需要编码的字符串
* @returns 编码后的 Base64 字符串
*/
function encode(input) {
const str = String(input);
let output = '';
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
let i = 0;
while (i < str.length) {
chr1 = str.charCodeAt(i++);
chr2 = str.charCodeAt(i++);
chr3 = str.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
}
else if (isNaN(chr3)) {
enc4 = 64;
}
output += chars.charAt(enc1) + chars.charAt(enc2) + chars.charAt(enc3) + chars.charAt(enc4);
}
return output;
}
/**
* 将 Base64 编码的字符串进行解码
* @param input 需要解码的 Base64 字符串
* @returns 解码后的字符串
*/
function decode(input) {
const str = String(input).replace(/[^A-Za-z0-9+/=]/g, '');
let output = '';
let chr1, chr2, chr3;
let enc1, enc2, enc3, enc4;
let i = 0;
if (str.length % 4 !== 0) {
throw new Error('Invalid Base64 string length');
}
while (i < str.length) {
enc1 = chars.indexOf(str.charAt(i++));
enc2 = chars.indexOf(str.charAt(i++));
enc3 = chars.indexOf(str.charAt(i++));
enc4 = chars.indexOf(str.charAt(i++));
if (enc1 === -1 || enc2 === -1 || enc3 === -1 || enc4 === -1) {
throw new Error('Invalid Base64 character');
}
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output += String.fromCharCode(chr1);
if (enc3 !== 64) {
output += String.fromCharCode(chr2);
}
if (enc4 !== 64) {
output += String.fromCharCode(chr3);
}
}
return output;
}
//# sourceMappingURL=baseGetTag.d.ts.map
{"version":3,"file":"baseGetTag.d.ts","sourceRoot":"","sources":["../../src/lib/baseGetTag.ts"],"names":[],"mappings":""}
"use strict";
// import { nullTag, symToStringTag, undefinedTag } from './lodash';
//
// /**
// * The base implementation of `getTag` without fallbacks for buggy environments.
// *
// * @private
// * @param {*} value The value to query.
// * @returns {string} Returns the `toStringTag`.
// */
// function baseGetTag(value: unknown) {
// if (value == null) {
// return value === undefined ? undefinedTag : nullTag;
// }
// return (symToStringTag && symToStringTag in Object(value))
// ? getRawTag(value)
// : objectToString(value);
// }
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
//# sourceMappingURL=baseIsEqual.d.ts.map
{"version":3,"file":"baseIsEqual.d.ts","sourceRoot":"","sources":["../../src/lib/baseIsEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
"use strict";
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
// function baseIsEqual(value: unknown, other: unknown, bitmask: unknown, customizer: unknown, stack: unknown) {
// if (value === other) {
// return true;
// }
// if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
// return value !== value && other !== other;
// }
// return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
// }
//# sourceMappingURL=baseIsEqualDeep.d.ts.map
{"version":3,"file":"baseIsEqualDeep.d.ts","sourceRoot":"","sources":["../../src/lib/baseIsEqualDeep.ts"],"names":[],"mappings":""}
"use strict";
// /**
// * A specialized version of `baseIsEqual` for arrays and objects which performs
// * deep comparisons and tracks traversed objects enabling objects with circular
// * references to be compared.
// *
// * @private
// * @param {Object} object The object to compare.
// * @param {Object} other The other object to compare.
// * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
// * @param {Function} customizer The function to customize comparisons.
// * @param {Function} equalFunc The function to determine equivalents of values.
// * @param {Object} [stack] Tracks traversed `object` and `other` objects.
// * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
// */
// function baseIsEqualDeep(object: unknown, other: unknown, bitmask: unknown, customizer: unknown, equalFunc: unknown, stack: unknown) {
// var objIsArr = isArray(object),
// othIsArr = isArray(other),
// objTag = objIsArr ? arrayTag : getTag(object),
// othTag = othIsArr ? arrayTag : getTag(other);
//
// objTag = objTag == argsTag ? objectTag : objTag;
// othTag = othTag == argsTag ? objectTag : othTag;
//
// var objIsObj = objTag == objectTag,
// othIsObj = othTag == objectTag,
// isSameTag = objTag == othTag;
//
// if (isSameTag && isBuffer(object)) {
// if (!isBuffer(other)) {
// return false;
// }
// objIsArr = true;
// objIsObj = false;
// }
// if (isSameTag && !objIsObj) {
// stack || (stack = new Stack);
// return (objIsArr || isTypedArray(object))
// ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
// : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
// }
// if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
// var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
// othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
//
// if (objIsWrapped || othIsWrapped) {
// var objUnwrapped = objIsWrapped ? object.value() : object,
// othUnwrapped = othIsWrapped ? other.value() : other;
//
// stack || (stack = new Stack);
// return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
// }
// }
// if (!isSameTag) {
// return false;
// }
// stack || (stack = new Stack);
// return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
// }
/**
* 检查字符串是否为Mustache模板
* @param str 需要检查的字符串
* @returns {boolean} 如果字符串包含Mustache模板,则返回true;否则返回false。
*/
export declare function isMustache(str: string): boolean;
export declare function isTrue(v: unknown): v is true;
export declare function isFalse(v: unknown): boolean;
export declare const isString: (val: unknown) => val is string;
export declare const isDate: (val: unknown) => val is Date;
export declare const isNil: (val: unknown) => val is null | undefined;
/**
* Check if value is primitive.
*/
export declare function isPrimitive(value: any): boolean;
export declare const isArray: (arg: any) => arg is any[];
/**
* Quick object check - this is primarily used to tell
* objects from primitive values when we know the value
* is a JSON-compliant type.
*/
export declare const isObject: (val: unknown) => val is object;
export declare function isFunction(value: any): value is (...args: any[]) => any;
export declare const emptyObject: Record<string, any>;
export declare function toRawType(value: unknown): string;
/**
* Strict object type check. Only returns true
* for plain JavaScript objects.
*/
export declare function isPlainObject(obj: unknown): boolean;
export declare function isRegExp(v: unknown): v is RegExp;
/**
* Check if val is a valid array index.
*/
export declare function isValidArrayIndex(val: unknown): boolean;
export declare function isDef<T>(v: T): v is NonNullable<T>;
export declare function isPromise(val: any): val is Promise<unknown>;
/**
* Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
export declare function toNumber(val: string): number | string;
/**
* Convert a value to a string that is actually rendered.
*/
export declare function toString(val: unknown): string;
export declare function changeCssVar(key: string, newValue: string): void;
//# sourceMappingURL=basics.d.ts.map
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/lib/basics.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C;AAYD,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,IAAI,CAE5C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE3C;AAGD,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAiC,CAAC;AACjF,eAAO,MAAM,MAAM,QAAS,OAAO,gBAAwB,CAAC;AAM5D,eAAO,MAAM,KAAK,QAAS,OAAO,KAAG,GAAG,IAAI,IAAI,GAAG,SAElD,CAAC;AAaF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAY/C;AAED,eAAO,MAAM,OAAO,4BAAgB,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAsE,CAAC;AAMtH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAEvE;AAMD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAqB,CAAC;AAOlE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGvD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAElD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAM3D;AAUD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAM7C;AAgBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAGzD"}
// 第一个表达式较为宽松,匹配所有双大括号内的内容。
// const mustachePattern = /\{\{.*?\}\}/g; // 匹配Mustache模板语法的正则表达式
// /(^|\s){{([\w\s\.]+)}}($|\s)|^\{{2}([\w\s\.]+)\}{2}$/g;
// 第二个表达式较为严格,仅匹配由字母数字、空白字符或点号组成的内容,并且也是全局搜索。它更适合用于寻找符合某种特定格式的Mustache变量名或路径表达式。
// 定义用于匹配Mustache模板语法的正则表达式,重点匹配由字母数字、空白字符或点号组成的内容
// const pattern = /\{\{([\w\s\.]+)\}\}/g;
// 不能设置成全局变量,调用会有问题的。
// export const mustachePattern = /\{\{([\w\s\\.]+)\}\}/g;
/**
* 检查字符串是否为Mustache模板
* @param str 需要检查的字符串
* @returns {boolean} 如果字符串包含Mustache模板,则返回true;否则返回false。
*/
export function isMustache(str) {
const pattern = /\{\{([\w\s\\.]+)\}\}/g;
return pattern.test(str);
}
// // 使用示例
// let templateString = "Hello, {{name}}!";
// console.log(isMustacheTemplate(templateString)); // 输出:true
//
// let plainString = "Hello, World!";
// console.log(isMustacheTemplate(plainString)); // 输出:false
// export const isUndefined = (val: unknown): val is undefined => val === undefined;
// export const isBoolean = (val: unknown): val is boolean => 'boolean' === typeof val;
export function isTrue(v) {
return v === true;
}
export function isFalse(v) {
return v === false;
}
// export const isNumber = (val: unknown): val is number => typeof val === 'number';
export const isString = (val) => typeof val === 'string';
export const isDate = (val) => val instanceof Date;
// export const isElement = (e: unknown): e is Element => {
// if (typeof Element === 'undefined') return false;
// return e instanceof Element;
// };
export const isNil = (val) => {
return val === null || val === undefined;
};
// export const isPropAbsent = (prop: unknown): prop is null | undefined => {
// return isNil(prop);
// };
// export const isStringNumber = (val: unknown): val is string => {
// if (!isString(val)) {
// return false;
// }
// return !Number.isNaN(Number(val));
// };
/**
* Check if value is primitive.
*/
export function isPrimitive(value) {
return (value === null ||
value === undefined ||
typeof value === 'string' ||
typeof value === 'number' ||
typeof value === 'bigint' ||
// $flow-disable-line
(typeof Symbol !== 'undefined' && typeof value === 'symbol') ||
typeof value === 'boolean' ||
(typeof value !== 'object' && typeof value !== 'function') // add by me
);
}
export const isArray = Array.isArray;
/**
* Quick object check - this is primarily used to tell
* objects from primitive values when we know the value
* is a JSON-compliant type.
*/
export const isObject = (val) => val !== null && val !== undefined && typeof val === 'object';
// export const isEmpty = (val: unknown) =>
// (!val && val !== 0) ||
// (isArray(val) && val.length === 0) ||
// (isObject(val) && !Object.keys(val).length);
export function isFunction(value) {
return typeof value === 'function';
}
// export const isWindow = (val: unknown): val is Window => {
// return val === window;
// };
export const emptyObject = Object.freeze({});
/**
* Get the raw type string of a value, e.g., [object Object].
*/
const _toString = Object.prototype.toString;
export function toRawType(value) {
return _toString.call(value).slice(8, -1);
}
/**
* Strict object type check. Only returns true
* for plain JavaScript objects.
*/
export function isPlainObject(obj) {
return _toString.call(obj) === '[object Object]';
}
export function isRegExp(v) {
return _toString.call(v) === '[object RegExp]';
}
/**
* Check if val is a valid array index.
*/
export function isValidArrayIndex(val) {
const n = parseFloat(String(val));
return n >= 0 && Math.floor(n) === n && isFinite(val);
}
export function isDef(v) {
return v !== undefined && v !== null;
}
export function isPromise(val) {
return (isDef(val) &&
typeof val.then === 'function' &&
typeof val.catch === 'function');
}
function replacer(_key, val) {
// avoid circular deps from v3
if (val && val.__v_isRef) {
return val.value;
}
return val;
}
/**
* Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
export function toNumber(val) {
const n = parseFloat(val);
return isNaN(n) ? val : n;
}
/**
* Convert a value to a string that is actually rendered.
*/
export function toString(val) {
return val == null
? ''
: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
? JSON.stringify(val, replacer, 2)
: String(val);
}
// export function addUnit(value?: string | number, defaultUnit = 'px'): string {
// if (!value) {
// return '';
// }
// if (isNumber(value) || isStringNumber(value)) {
// return `${value}${defaultUnit}`;
// } else if (isString(value)) {
// return value;
// } else {
// throw Error('binding value must be a string or number');
// }
// }
// 定义一个函数来改变CSS变量的值
export function changeCssVar(key, newValue) {
const root = document.documentElement;
root.style.setProperty('--' + key, newValue);
}
// 调用函数,改变背景颜色
// changeBackgroundColor('salmon');
//
// export const keysOf = <T>(arr: T) => Object.keys(arr as object) as Array<keyof T>;
// export const entriesOf = <T>(arr: T) => Object.entries(arr as object); // as Entries<T>
export declare const inBrowser: boolean;
export declare const UA: string | false;
export declare const isClient: boolean;
export declare const isIE: boolean | "";
export declare const isIE9: boolean | "";
export declare const isEdge: boolean | "";
export declare const isAndroid: boolean | "";
export declare const isChrome: boolean | "";
export declare const isPhantomJS: boolean | "";
export declare const isFireFox: false | "" | RegExpMatchArray | null;
export declare const isFirefox: () => boolean;
export declare const isIOS: boolean | "";
export declare function isChromeBelow80(): boolean;
export declare function isChromeAbove80(): boolean;
export declare function supportsSameSite(): boolean;
//# sourceMappingURL=browser.d.ts.map
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/lib/browser.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,SAAgC,CAAC;AACvD,eAAO,MAAM,EAAE,gBAAwD,CAAC;AACxE,eAAO,MAAM,QAAQ,SAC6C,CAAC;AACnE,eAAO,MAAM,IAAI,cAAgC,CAAC;AAClD,eAAO,MAAM,KAAK,cAAmC,CAAC;AACtD,eAAO,MAAM,MAAM,cAAgC,CAAC;AACpD,eAAO,MAAM,SAAS,cAAkC,CAAC;AAEzD,eAAO,MAAM,QAAQ,cAA0C,CAAC;AAChE,eAAO,MAAM,WAAW,cAA6B,CAAC;AACtD,eAAO,MAAM,SAAS,sCAAmC,CAAC;AAE1D,eAAO,MAAM,SAAS,QAAO,OAC4B,CAAA;AAEzD,eAAO,MAAM,KAAK,cAA6B,CAAC;AAehD,wBAAgB,eAAe,YAe9B;AAGD,wBAAgB,eAAe,YAe9B;AAED,wBAAgB,gBAAgB,YA8C/B"}
// Browser environment sniffing
export const inBrowser = typeof window !== 'undefined';
export const UA = inBrowser && window.navigator.userAgent.toLowerCase();
export const isClient = typeof window !== 'undefined' && typeof document !== 'undefined';
export const isIE = UA && /msie|trident/.test(UA);
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
export const isEdge = UA && UA.indexOf('edge/') > 0;
export const isAndroid = UA && UA.indexOf('android') > 0;
// export const isIOS = UA && /iphone|ipad|ipod|ios/.test-dts(UA);
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
export const isPhantomJS = UA && /phantomjs/.test(UA);
export const isFireFox = UA && UA.match(/firefox\/(\d+)/);
export const isFirefox = () => isClient && /firefox/i.test(window.navigator.userAgent);
export const isIOS = /* #__PURE__ */ getIsIOS();
function getIsIOS() {
var _a, _b;
return (isClient &&
((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) &&
(/iP(?:ad|hone|od)/.test(window.navigator.userAgent) ||
// The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.
// https://github.com/vueuse/vueuse/issues/3577
(((_b = window === null || window === void 0 ? void 0 : window.navigator) === null || _b === void 0 ? void 0 : _b.maxTouchPoints) > 2 &&
/iPad|Macintosh/.test(window === null || window === void 0 ? void 0 : window.navigator.userAgent))));
}
// 判断 Chrome 浏览器版本是否 < 80 sameSite策略不同
export function isChromeBelow80() {
const ua = navigator.userAgent;
// 1. 识别 Chrome 且排除基于 Chromium 的 Edge/Opera 等浏览器
const isChrome = /Chrome/.test(ua) && !/(Edg|OPR)/.test(ua);
if (isChrome) {
// 2. 提取版本号(示例 UA: "Chrome/84.0.4147.89")
const versionMatch = ua.match(/Chrome\/(\d+)/);
if (versionMatch) {
const version = parseInt(versionMatch[1], 10);
return version < 80;
}
}
return false;
}
// 判断 Chrome 浏览器版本是否 > 80 sameSite策略不同
export function isChromeAbove80() {
const ua = navigator.userAgent;
// 识别 Chrome 且排除基于 Chromium 的 Edge/Opera 等浏览器
const isChrome = /Chrome/.test(ua) && !/(Edg|OPR)/.test(ua);
if (isChrome) {
// 提取版本号(示例 UA: "Chrome/84.0.4147.89")
const versionMatch = ua.match(/Chrome\/(\d+)/);
if (versionMatch) {
const version = parseInt(versionMatch[1], 10);
return version > 80; // 修改比较运算符为大于号
}
}
return false;
}
export function supportsSameSite() {
const ua = navigator.userAgent;
// 1. 检测 Chrome 及 Chromium 内核浏览器(Chrome >=51 支持 SameSite)
if (/Chrome\/(\d+)/.test(ua) && !/(Edg|OPR)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 51; // Chrome 51+ 支持 SameSite
}
// 2. 检测 Edge Chromium(Edge >=80 支持 SameSite)
if (/Edg\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 80; // Edge 80+ 基于 Chromium
}
// 3. 检测 Safari(Safari >=13.1 支持 SameSite)
if (/Version\/(\d+\.\d+).*Safari/.test(ua)) {
const majorVersion = parseFloat(RegExp.$1);
return majorVersion >= 13.1; // macOS Safari 13.1+ 或 iOS 13+
}
// 4. 检测 Firefox(Firefox >=60 支持 SameSite)
if (/Firefox\/(\d+)/.test(ua)) {
return parseInt(RegExp.$1, 10) >= 60;
}
// 5. 检测 Opera(Opera >=71 支持 SameSite)
if (/Opera\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 71;
}
// 6. 检测 Samsung Internet(Samsung Internet >=5 支持 SameSite)
if (/SamsungInternet\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 5;
}
// 7. 检测 UC Browser for Android(UC Browser >=12.1 支持 SameSite)
if (/UCBrowser\/(\d+)/.test(ua)) {
const version = parseInt(RegExp.$1, 10);
return version >= 12.1;
}
// 8. 其他浏览器保守返回 false
return false;
}
/**
* 将驼峰命名转换为短横线命名。
*
* 此函数主要用于将JavaScript或TypeScript中常用的驼峰命名法转换为短横线分隔的命名方式。
* 这种转换在某些场合下是必要的,比如将JavaScript类名转换为对应的CSS类名,或者将API接口的驼峰命名转换为URL参数的格式。
*
* @param camelString 驼峰命名的字符串。
* @returns 转换为短横线分隔的字符串。
*/
export declare function camelToDash(camelString: string): string;
//# sourceMappingURL=camelToDash.d.ts.map
{"version":3,"file":"camelToDash.d.ts","sourceRoot":"","sources":["../../src/lib/camelToDash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAevD"}
/**
* 将驼峰命名转换为短横线命名。
*
* 此函数主要用于将JavaScript或TypeScript中常用的驼峰命名法转换为短横线分隔的命名方式。
* 这种转换在某些场合下是必要的,比如将JavaScript类名转换为对应的CSS类名,或者将API接口的驼峰命名转换为URL参数的格式。
*
* @param camelString 驼峰命名的字符串。
* @returns 转换为短横线分隔的字符串。
*/
export function camelToDash(camelString) {
var _a, _b;
if (camelString === undefined) {
// console.error('camelString is undefined . ');
throw Error('camelString is undefined . ');
}
// 使用正则表达式匹配并替换字符串中的驼峰命名。
// 第一个正则表达式用于匹配单词之间的大写字母,例如"camelCase"中的"C"。
// 第二个正则表达式用于匹配单词末尾和大写字母之间的边界,例如"getHTTPRequest"中的"HTTP"。
// 替换规则是插入一个短横线,并将所有字母转换为小写。
// 使用正则表达式匹配大写字母,并在其前添加中划线,然后将整个字符串转换为小写
// 确保非首字母大写前添加中划线,并忽略原本就存在的中划线前的大写字母
return (_b = (_a = camelString === null || camelString === void 0 ? void 0 : camelString.replace(/(.)([A-Z][a-z]+)/g, '$1-$2')) === null || _a === void 0 ? void 0 : _a.replace(/([a-z0-9])([A-Z])/g, '$1-$2')) === null || _b === void 0 ? void 0 : _b.toLowerCase();
}
/**
* 将kebab-case格式的字符串转换为PascalCase格式。
* kebab-case格式的字符串是一种命名规范,也称为短线连接命名法、短横线命名法或中横线命名法。
* 在这种格式中,字符串中的每个单词以小写字母书写,并且单词之间用短横线(-)分隔。
* 这种命名风格常见于HTML的class属性、CSS的类名、以及某些编程语言或框架(如Vue.js的非字符串模板属性)中。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的PascalCase格式字符串
*/
export declare function toPascalCase(kebabCase: string): string;
/**
* 将给定的属性名转换为带有供应商前缀的格式。
* @param property 输入的属性名
* @returns 转换后的带有供应商前缀的属性名
*/
export declare function toVendorPrefixCase(property: string): string;
/**
* 将kebab-case格式的字符串转换为camelCase格式。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的camelCase格式字符串
*/
export declare function toCamelCase(kebabCase: string): string;
/**
* 替换函数,将匹配到的子字符串转换为大写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为大写的字符串
*/
export declare function toUpperReplacer(substring: string, ...args: string[]): string;
/**
* 替换函数,将匹配到的子字符串转换为小写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为小写的字符串
*/
export declare function toLowerReplacer(substring: string, ...args: string[]): string;
//# sourceMappingURL=casing.d.ts.map
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/lib/casing.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,UAM7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAKlD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,UAK5C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE5E"}
// 正则表达式,用于匹配字符串的首字母
const REGEX_LEADING_LETTER = /^(\w)/;
// 正则表达式,用于匹配kebab-case中的分隔符并捕获其后的字符
const REGEX_KEBAB_SEPARATOR = /-(\w)/g;
// 正则表达式,用于匹配带有供应商前缀的字符串
const REGEX_VENDOR_PREFIXED = /^-(\w)/;
// 正则表达式,专门用于匹配以"-ms-"为前缀的字符串
const REGEX_MS_PREFIXED = /^-ms-/;
/**
* 将kebab-case格式的字符串转换为PascalCase格式。
* kebab-case格式的字符串是一种命名规范,也称为短线连接命名法、短横线命名法或中横线命名法。
* 在这种格式中,字符串中的每个单词以小写字母书写,并且单词之间用短横线(-)分隔。
* 这种命名风格常见于HTML的class属性、CSS的类名、以及某些编程语言或框架(如Vue.js的非字符串模板属性)中。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的PascalCase格式字符串
*/
export function toPascalCase(kebabCase) {
// 替换供应商前缀、首字母和kebab-case中的连字符,将其转换为大写
return kebabCase
.replace(REGEX_VENDOR_PREFIXED, toUpperReplacer)
.replace(REGEX_LEADING_LETTER, toUpperReplacer)
.replace(REGEX_KEBAB_SEPARATOR, toUpperReplacer);
}
/**
* 将给定的属性名转换为带有供应商前缀的格式。
* @param property 输入的属性名
* @returns 转换后的带有供应商前缀的属性名
*/
export function toVendorPrefixCase(property) {
// 如果属性名以"-ms-"开头,将其转换为"ms"加上转换后的PascalCase格式字符串;否则直接转换为PascalCase格式
return REGEX_MS_PREFIXED.test(property)
? 'ms' + toPascalCase(property.slice(4))
: toPascalCase(property);
}
/**
* 将kebab-case格式的字符串转换为camelCase格式。
* @param kebabCase 输入的kebab-case格式字符串
* @returns 转换后的camelCase格式字符串
*/
export function toCamelCase(kebabCase) {
// 替换供应商前缀和kebab-case中的连字符,将其转换为合适的形式
return kebabCase
.replace(REGEX_VENDOR_PREFIXED, toLowerReplacer)
.replace(REGEX_KEBAB_SEPARATOR, toUpperReplacer);
}
/**
* 替换函数,将匹配到的子字符串转换为大写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为大写的字符串
*/
export function toUpperReplacer(substring, ...args) {
return args[0].toUpperCase();
}
/**
* 替换函数,将匹配到的子字符串转换为小写。
* @param substring 被正则表达式匹配到的子字符串
* @param args 正则表达式匹配到的组的数组
* @returns 转换为小写的字符串
*/
export function toLowerReplacer(substring, ...args) {
return args[0].toLowerCase();
}
/**
* Creates a shallow copy of the given obejct/value.
* @param {*} obj value to clone
* @returns {*} shallow clone of the given value
*/
export declare const clone: <T>(obj: T) => T;
//# sourceMappingURL=clone.d.ts.map
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/lib/clone.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,OAAO,CAAC,KAAG,CAwBjC,CAAA"}
import { isPrimitive } from './basics';
/**
* Creates a shallow copy of the given obejct/value.
* @param {*} obj value to clone
* @returns {*} shallow clone of the given value
*/
export const clone = (obj) => {
// Primitive values do not need cloning.
if (isPrimitive(obj)) {
return obj;
}
// Binding a function to an empty object creates a
// copy function.
if (typeof obj === 'function') {
return obj.bind({});
}
// Access the constructor and create a new object.
// This method can create an array as well.
const newObj = new obj.constructor();
// Assign the props.
Object.getOwnPropertyNames(obj).forEach(prop => {
// Bypass type checking since the primitive cases
// are already checked in the beginning
newObj[prop] = obj[prop];
});
return newObj;
};
/**
* 解析颜色值
*
* 此函数支持解析两种颜色格式:RGB/RGBA和十六进制颜色值
* 对于十六进制颜色值,支持3位、6位以及带附加位的格式
* 对于RGB/RGBA颜色值,支持透明度的解析,并将其转换为整数格式
*
* @param value 颜色值字符串,可以是RGB/RGBA或十六进制格式, white 这种单词颜色;
* @returns 返回一个字符串,表示解析后的颜色值,格式为 'R G B A', 如果是单词颜色,则返回原字符串;
*/
export declare function colorFormat(value: string): string;
//# sourceMappingURL=colorFormat.d.ts.map
{"version":3,"file":"colorFormat.d.ts","sourceRoot":"","sources":["../../src/lib/colorFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA2DjD"}
/**
* 解析颜色值
*
* 此函数支持解析两种颜色格式:RGB/RGBA和十六进制颜色值
* 对于十六进制颜色值,支持3位、6位以及带附加位的格式
* 对于RGB/RGBA颜色值,支持透明度的解析,并将其转换为整数格式
*
* @param value 颜色值字符串,可以是RGB/RGBA或十六进制格式, white 这种单词颜色;
* @returns 返回一个字符串,表示解析后的颜色值,格式为 'R G B A', 如果是单词颜色,则返回原字符串;
*/
export function colorFormat(value) {
// 检查是否为十六进制颜色值
if (/^#([a-f\d]{3}|[a-f\d]{6})[a-f\d]?$/i.test(value)) {
// #号开头的颜色值 3位或6位
if (value.length < 7) {
// 展开3位十六进制颜色值
return value
.replace(/([\w])/gi, (hex) => ` ${parseInt(`${hex}${hex}`, 16)}`)
.substr(2);
}
else if (value.length === 7) {
// 直接使用6位十六进制颜色值
return value
.replace(/([\w]{2})/gi, (hex) => ` ${parseInt(hex, 16)}`)
.substr(2);
}
else if (value.length === 9) {
// 8位带透明度的十六进制颜色值
const alpha = parseInt(value.substr(7), 16);
return `${value
.replace(/([\w]{2})/gi, (hex) => ` ${parseInt(hex, 16)}`)
.substr(2)} ${alpha}`;
}
}
else if (/^rgba?\(\s*((2(5[0-5]|[0-4]\d)|1?\d{1,2})\s*,?\s*){3}(,\s*(\d+)?(\.\d+)?)?\)$/.test(value)) {
// 检查是否为RGB或RGBA颜色值
// 提取颜色值并转换为数字
const color = value
.replace(/[a-z()\s]/g, '')
.split(',')
.map((item) => Number(item));
// 处理RGBA颜色值的透明度
if (color.length === 4) {
color[3] = Math.min(255, Math.round(color[3] * 255));
if (isNaN(color[3])) {
color[3] = 0;
}
}
// 返回解析后的颜色值
return color.join(' ');
}
else if (/^hsla?\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*(,\s*(\d+)?(\.\d+)?)?\)$/.test(value)) {
// 检查是否为HSL或HSLA颜色值
const hsl = value.match(/^hsla?\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})%\s*,\s*([0-9]{1,3})%\s*(,\s*(\d+)?(\.\d+)?)?\)$/);
if (hsl) {
const hue = parseInt(hsl[1], 10);
const saturation = parseInt(hsl[2], 10) / 100;
const lightness = parseInt(hsl[3], 10) / 100;
const alpha = hsl[5] ? parseFloat(hsl[5]) : 1;
const color = hslToRgb(hue, saturation, lightness);
return color.join(' ') + ' ' + alpha;
}
}
// 返回单词颜色值
return value;
}
// 转换HSL到RGB
function hslToRgb(h, s, l) {
const c = (1 - Math.abs(2 * l - 1)) * s;
const x = c * (1 - Math.abs((h / 60) % 2 - 1));
const m = l - c / 2;
let r, g, b;
if (h < 60) {
r = c, g = x, b = 0;
}
else if (h < 120) {
r = x, g = c, b = 0;
}
else if (h < 180) {
r = 0, g = c, b = x;
}
else if (h < 240) {
r = 0, g = x, b = c;
}
else if (h < 300) {
r = x, g = 0, b = c;
}
else {
r = c, g = 0, b = x;
}
r = Math.round((r + m) * 255);
g = Math.round((g + m) * 255);
b = Math.round((b + m) * 255);
return [r, g, b];
}
export declare class Cookie {
/**
* 设置 cookie
*
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @static
*/
static set(name: string, value: string): void;
/**
* 设置 cookie, 默认30天过期时间
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @param {String} expires 单位(秒)
* @static
*/
static setExpires(name: string, value: string, expires: number): void;
/**
* 获取 cookie
* @param {String} name Cookie名称
* @return {Object} Cookie值,没有返回null
* @static
*/
static get(name: string): string | null;
/**
* 删除 cookie
* @param {String} name Cookie名称
* @static
*/
static del(name: string): void;
/**
* 清理cookie
*/
static clear(): void;
}
//# sourceMappingURL=cookie.d.ts.map
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/lib/cookie.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAItC;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAW9D;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM;IASvB;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM;IAUvB;;OAEG;IACH,MAAM,CAAC,KAAK;CAcb"}
import { isEmpty } from 'lodash-es';
export class Cookie {
/**
* 设置 cookie
*
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @static
*/
static set(name, value) {
document.cookie = name + '=' + escape(value);
}
/**
* 设置 cookie, 默认30天过期时间
* @param {String} name Cookie名称
* @param {String} value Cookie值
* @param {String} expires 单位(秒)
* @static
*/
static setExpires(name, value, expires) {
const days = 30; //cookie 将被保存 30 天
const exp = new Date();
if (isEmpty(expires)) {
exp.setTime(exp.getTime() + days * 24 * 60 * 60);
}
else {
exp.setTime(exp.getTime() + expires);
}
document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
}
/**
* 获取 cookie
* @param {String} name Cookie名称
* @return {Object} Cookie值,没有返回null
* @static
*/
static get(name) {
const arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
if (arr !== null) {
return unescape(arr[2]);
}
return null;
}
/**
* 删除 cookie
* @param {String} name Cookie名称
* @static
*/
static del(name) {
const exp = new Date();
exp.setTime(exp.getTime() - 1);
const cookieVal = this.get(name);
if (cookieVal !== null) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT';
}
}
/**
* 清理cookie
*/
static clear() {
// debugger;
// 获取所有cookie
const cookies = document.cookie.split(';');
// 遍历所有cookie并删除它们
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i];
// 分割cookie名称和值
const eqPos = cookie.indexOf('=');
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
}
}
}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export declare function dashToCamel(dashStr: string): string;
//# sourceMappingURL=dashToCamel.d.ts.map
{"version":3,"file":"dashToCamel.d.ts","sourceRoot":"","sources":["../../src/lib/dashToCamel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,UAO1C"}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export function dashToCamel(dashStr) {
// 使用连字符分割字符串,并对每个部分进行处理
// 分割字符串,然后对除了第一个部分之外的每个部分首字母大写并拼接
return dashStr.split('-').map((word, index) =>
// 对第一个部分保持原样,对其他部分首字母大写
index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('');
}
// 示例
// console.log(dashToCamel('dash-to-camel')); // 输出: dashToCamel
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用,因为这两种情况下,连字符分隔的字符串常常需要转换为驼峰式。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export declare function dashToPascal(dashStr: string): string;
//# sourceMappingURL=dashToPascal.d.ts.map
{"version":3,"file":"dashToPascal.d.ts","sourceRoot":"","sources":["../../src/lib/dashToPascal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,UAM3C"}
/**
* 将连字符分隔的字符串转换为驼峰式字符串。
*
* 这个函数接受一个以连字符分隔的字符串,例如"hello-world",并将其转换为驼峰式字符串,例如"helloWorld"。
* 这种转换在处理CSS类名或JavaScript属性名时非常有用,因为这两种情况下,连字符分隔的字符串常常需要转换为驼峰式。
*
* @param dashStr 一个以连字符分隔的字符串。
* @returns 转换后的驼峰式字符串。
*/
export function dashToPascal(dashStr) {
// 使用split方法将字符串按连字符分割成单词数组。
return dashStr.split('-').map(word =>
// 对每个单词,将首字母转换为大写,然后将剩余的字母与之拼接,形成驼峰式字符串。
word.charAt(0).toUpperCase() + word.slice(1)).join('');
}
// 示例
// console.log(dashToPascal('dash-to-pascal')); // 输出: DashToPascal
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): T;
//# sourceMappingURL=debounce.d.ts.map
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/lib/debounce.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAWpF"}
export function debounce(func, wait) {
let timeoutId = null;
return ((...args) => {
if (timeoutId !== null) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
func(...args);
timeoutId = null;
}, wait);
});
}
// const handleInput = debounce((value: string) => {
// console.log('输入值:', value);
// // 这里可以放置处理逻辑,比如发起网络请求
// }, 300); // 300毫秒内没有新的输入才会执行
//
// const onInputChange = (event: Event) => {
// const target = event.target as HTMLInputElement;
// handleInput(target.value);
// };
/**
* 引用类型与非引用类型 深拷贝方法
* @param source
*/
export declare function deepClone<T>(source: T): T;
//# sourceMappingURL=deepClone.d.ts.map
{"version":3,"file":"deepClone.d.ts","sourceRoot":"","sources":["../../src/lib/deepClone.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA4BzC"}
import { isLikelyNode } from '../index';
/**
* 引用类型与非引用类型 深拷贝方法
* @param source
*/
export function deepClone(source) {
if (typeof source !== 'object' ||
typeof source === 'function' ||
source === null) {
return source;
}
else if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
return source;
}
let destination;
if (Array.isArray(source)) {
destination = [];
}
else {
destination = {};
}
for (const prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
if (prop === 'parent' || prop === 'parentNode') {
// 处理自定义的虚拟dom
destination[prop] = source[prop];
}
else {
destination[prop] = deepClone(source[prop]);
}
}
}
return destination;
}
// function deepClone1(obj: any, hash = new WeakMap()) {
// // 处理函数
// if (typeof obj === 'function') {
// return obj.bind({});
// }
//
// // 基本类型和特殊对象处理
// if (obj === null || typeof obj !== 'object') {
// return obj;
// }
//
// // 处理特殊对象类型
// if (obj instanceof Date) return new Date(obj);
// if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
// if (obj instanceof Symbol) return Symbol(obj.description);
//
// // 处理 Set
// if (obj instanceof Set) {
// const newSet = new Set();
// obj.forEach(val => {
// newSet.add(deepClone1(val, hash));
// });
// return newSet;
// }
//
// // 处理 Map
// if (obj instanceof Map) {
// const newMap = new Map();
// obj.forEach((val, key) => {
// newMap.set(key, deepClone1(val, hash));
// });
// return newMap;
// }
//
// // 避免重复处理
// if (hash.has(obj)) {
// return hash.get(obj);
// }
//
// // 使用 Object.getOwnPropertyDescriptors 获取所有属性,包括不可枚举属性
// const descriptors = Object.getOwnPropertyDescriptors(obj);
// const clonedObj = Object.create(Object.getPrototypeOf(obj));
//
// Object.keys(descriptors).forEach(key => {
// const descriptor = descriptors[key];
//
// // 特殊处理访问器属性
// if (descriptor.get || descriptor.set) {
// Object.defineProperty(clonedObj, key, {
// get: descriptor.get && deepClone1(descriptor.get),
// set: descriptor.set && deepClone1(descriptor.set),
// enumerable: descriptor.enumerable,
// configurable: descriptor.configurable
// });
// } else {
// descriptor.value = deepClone1(descriptor.value, hash);
// Object.defineProperty(clonedObj, key, descriptor);
// }
// });
//
// return clonedObj;
// }
// function deepClone2(obj, hash = new WeakMap()) {
// // 处理基本类型
// if (obj === null || typeof obj !== 'object') {
// return obj;
// }
//
// // // 处理特殊对象类型
// // if (obj instanceof Date) return new Date(obj);
// // if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
// // if (obj instanceof Symbol) return Symbol(obj.description);
// //
// // // 处理 Set
// // if (obj instanceof Set) {
// // const newSet = new Set();
// // obj.forEach(val => {
// // newSet.add(deepClone(val, hash));
// // });
// // return newSet;
// // }
// //
// // // 处理 Map
// // if (obj instanceof Map) {
// // const newMap = new Map();
// // obj.forEach((val, key) => {
// // newMap.set(key, deepClone(val, hash));
// // });
// // return newMap;
// // }
// //
// // // 避免重复处理
// // if (hash.has(obj)) {
// // return hash.get(obj);
// // }
//
// const result = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
// hash.set(obj, result);
//
// // 复制自有属性和原型属性
// const keys = [
// ...Object.getOwnPropertyNames(obj),
// ...Object.getOwnPropertySymbols(obj)
// ];
//
// for (const key of keys) {
// const descriptor = Object.getOwnPropertyDescriptor(obj, key);
// if (descriptor) {
// // 保留属性描述符
// Object.defineProperty(result, key, {
// ...descriptor,
// value: deepClone(descriptor.value, hash)
// });
// }
// }
//
// return result;
// }
export declare function deepCopy<T>(destination: T, source: T, deep?: boolean): T;
//# sourceMappingURL=deepCopy.d.ts.map
{"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/lib/deepCopy.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,CAAC,CAoCxE"}
import { isLikelyNode } from './isLikelyNode';
export function deepCopy(destination, source, deep) {
// JScript DontEnum bug is not taken care of
// the deep clone is for internal use, is not meant to avoid
// javascript traps or cloning html element or self referenced objects.
if (deep) {
if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
destination = source;
}
else if (source instanceof Array) {
destination = [];
for (let i = 0, len = source.length; i < len; i++) {
destination[i] = deepCopy({}, source[i], deep);
}
}
else if (source && typeof source === 'object') {
for (const property in source) {
if (property === 'canvas') {
destination[property] = deepCopy({}, source[property]);
}
else if (property === 'parent' || property === 'parentNode') {
// 直接赋值 处理XNode,XElement等虚拟dom的深拷贝
destination[property] = source[property];
}
else if (Object.prototype.hasOwnProperty.call(source, property)) {
destination[property] = deepCopy({}, source[property], deep);
}
}
}
else {
// this sounds odd for an extend but is ok for recursive use
destination = source;
}
}
else {
for (const property in source) {
if (property) {
destination[property] = source[property];
}
}
}
return destination;
}
export declare function deepMerge<T>(target: T, source: T): T;
//# sourceMappingURL=deepMerge.d.ts.map
{"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/lib/deepMerge.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KA6BhD"}
import { isLikelyNode } from './isLikelyNode';
// todo 可能有问题
export function deepMerge(target, source) {
console.warn('target is ', target, ' source is ', source);
if (!isLikelyNode && source instanceof Element) {
// avoid cloning deep images, canvases,
target = source;
}
else if (source instanceof Array) {
target = [];
for (let i = 0, len = source.length; i < len; i++) {
target[i] = deepMerge(target[i], source[i]);
}
}
else if (source && typeof source === 'object') {
for (const key in source) {
if (key === 'canvas') {
target[key] = deepMerge(target[key] || {}, source[key]);
}
else if (key === 'parent' || key === 'parentNode') {
// 直接赋值 处理XNode,XElement等虚拟dom的深拷贝
target[key] = source[key];
}
else if (Object.prototype.hasOwnProperty.call(source, key)) {
if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {
if (!target[key])
target[key] = {};
deepMerge(target[key], source[key]);
}
else {
target[key] = source[key];
}
}
}
}
return target;
}
// const target = { a: { b: 1 } };
// const source = { a: { c: 2 } };
//
// // 使用 deepMerge() 进行深合并
// const result = deepMerge(_.cloneDeep(target), source);
//
// console.log(result); // 输出: { a: { b: 1, c: 2 } }
/**
* Collect dependencies on array elements when the array is touched, since
* we cannot intercept array element access like property getters.
*/
export declare function dependArray(value: Array<any>): void;
//# sourceMappingURL=dependArray.d.ts.map
{"version":3,"file":"dependArray.d.ts","sourceRoot":"","sources":["../../src/lib/dependArray.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,QAU5C"}
import { isArray } from './isArray';
/**
* Collect dependencies on array elements when the array is touched, since
* we cannot intercept array element access like property getters.
*/
export function dependArray(value) {
for (let e, i = 0, l = value.length; i < l; i++) {
e = value[i];
if (e && e.__ob__) {
e.__ob__.dep.depend();
}
if (isArray(e)) {
dependArray(e);
}
}
}
export declare const EMPTY_OBJECT: {};
//# sourceMappingURL=EMPTY_OBJECT.d.ts.map
{"version":3,"file":"EMPTY_OBJECT.d.ts","sourceRoot":"","sources":["../../src/lib/EMPTY_OBJECT.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,IAAkB,CAAC"}
export const EMPTY_OBJECT = Object.seal({});
/**
* 转为xml字符串
* @param value
*/
export declare function encodeToXmlString(value?: string | number | boolean): string;
//# sourceMappingURL=encodeToXmlString.d.ts.map
{"version":3,"file":"encodeToXmlString.d.ts","sourceRoot":"","sources":["../../src/lib/encodeToXmlString.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,GAAE,MAAM,GAAG,MAAM,GAAG,OAAY,GACpC,MAAM,CAuCR"}
import { XMLEntities } from './XMLEntities';
/**
* 转为xml字符串
* @param value
*/
export function encodeToXmlString(value = '') {
const buffer = [];
let start = 0;
const str = String(value);
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.codePointAt(i);
if (char === undefined) {
throw Error('char is undefined . ');
}
if (0x20 <= char && char <= 0x7e) {
// ascii
const entity = XMLEntities[char];
if (entity) {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(entity);
start = i + 1;
}
}
else {
if (start < i) {
buffer.push(str.substring(start, i));
}
// todo 为什么转码 ??????
buffer.push(`&#x${char.toString(16).toUpperCase()};`);
if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
// char is represented by two u16
i++;
}
start = i + 1;
}
}
if (buffer.length === 0) {
return str;
}
if (start < str.length) {
buffer.push(str.substring(start, str.length));
}
return buffer.join('');
}
export declare const hasProto: boolean;
export declare const nativeWatch: any;
export declare let supportsPassive: boolean;
export declare function isNative(Ctor: any): boolean;
export declare const hasSymbol: boolean;
//# sourceMappingURL=env.d.ts.map
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/lib/env.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,SAAoB,CAAC;AAI1C,eAAO,MAAM,WAAW,KAAW,CAAC;AAEpC,eAAO,IAAI,eAAe,SAAQ,CAAC;AAiBnC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAE3C;AAED,eAAO,MAAM,SAAS,SAIK,CAAC"}
// can we use __proto__?
import { inBrowser } from './browser';
export const hasProto = '__proto__' in {};
// Firefox has a "watch" function on Object.prototype...
// @ts-expect-error firebox support
export const nativeWatch = {}.watch;
export let supportsPassive = false;
if (inBrowser) {
try {
const opts = {};
Object.defineProperty(opts, 'passive', {
get() {
/* istanbul ignore next */
supportsPassive = true;
},
}); // https://github.com/facebook/flow/issues/285
window.addEventListener('test-dts-passive', null, opts);
}
catch (e) {
// no support
}
}
/* istanbul ignore next */
export function isNative(Ctor) {
return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
}
export const hasSymbol = typeof Symbol !== 'undefined' &&
isNative(Symbol) &&
typeof Reflect !== 'undefined' &&
isNative(Reflect.ownKeys);
export declare function formatFloat(src: string | number, pos?: number): number;
//# sourceMappingURL=formatFloat.d.ts.map
{"version":3,"file":"formatFloat.d.ts","sourceRoot":"","sources":["../../src/lib/formatFloat.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAI,GAAG,MAAM,CAOjE"}
// 转为保留pos位的小数,默认为6位
// todo 带字符串怎么处理的
export function formatFloat(src, pos = 6) {
if (isNaN(parseFloat(String(src)))) {
console.error('src is ', src);
throw Error('src 不是数字');
}
// return Math.round(Number(src) * Math.pow(10, pos)) / Math.pow(10, pos);
return Number(parseFloat(src).toFixed(pos));
}
export declare function fromPairs<T extends any[]>(pairs: T[]): {
[K in T[0]]: T[1];
};
//# sourceMappingURL=fromPairs.d.ts.map
{"version":3,"file":"fromPairs.d.ts","sourceRoot":"","sources":["../../src/lib/fromPairs.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAa5E"}
// 将 pairs 数组转换为一个对象,并将其绑定到模板中显示。
export function fromPairs(pairs) {
let index = -1;
const length = pairs == null ? 0 : pairs.length;
const result = {};
while (++index < length) {
const pair = pairs[index];
if (Array.isArray(pair) && pair.length === 2) {
result[pair[0]] = pair[1];
}
}
return result;
}
export declare function genNumArr(len?: number): number[];
//# sourceMappingURL=genNumArr.d.ts.map
{"version":3,"file":"genNumArr.d.ts","sourceRoot":"","sources":["../../src/lib/genNumArr.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAGhD"}
export function genNumArr(len) {
if (!len)
return [];
return Array.from({ length: len }, (_, i) => i + 1);
}
export declare function getScroll(area?: Element): {
x: number;
y: number;
};
//# sourceMappingURL=getScroll.d.ts.map
{"version":3,"file":"getScroll.d.ts","sourceRoot":"","sources":["../../src/lib/getScroll.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAelE"}
export function getScroll(area) {
const body = {
top: document.body.scrollTop > 0
? document.body.scrollTop
: document.documentElement.scrollTop,
left: document.body.scrollLeft > 0
? document.body.scrollLeft
: document.documentElement.scrollLeft,
};
return {
y: area && area.scrollTop >= 0 ? area.scrollTop : body.top,
x: area && area.scrollLeft >= 0 ? area.scrollLeft : body.left,
};
}
interface IInfo {
keys: Record<string, string>;
bundles: Record<string, Record<string, string>>;
}
/**
* I18n helper.
*
* @since 1.0
*/
export declare class I18n {
/**
* @private
* @property {Object}
*/
static keys: Record<string, string>;
/**
* @private
* @property {Object}
*/
static bundles: Record<string, Record<string, string>>;
/**
* @public
* @param {Object} strings
*/
register(strings: IInfo): void;
/**
* Resolves a string from a key.
*
* If the key begins with '@' then the remainder is assumed to be a reference to another key and will be resolved.
*
* @public
* @param {String} key
* @param defaultText
*/
static get(key: string, defaultText?: string): string;
/**
* @public
* @param {String} key
* @returns {String}
*/
static format(key: string): string;
/**
* Render a bundle string.
*
* @param {Object/String} bundle
* @param {String} key
* @returns {String}
*/
static render(bundle: string, key: string): string | undefined;
}
export {};
//# sourceMappingURL=I18n.d.ts.map
{"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../../src/lib/I18n.ts"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AACD;;;;GAIG;AACH,qBAAa,IAAI;IACf;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkElC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAK;IAE3D;;;OAGG;IACH,QAAQ,CAAE,OAAO,EAAE,KAAK;IAKxB;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;IAuBrD;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAE,GAAG,EAAE,MAAM;IAa1B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CA0D/D"}
import { isObject } from './typed';
/**
* I18n helper.
*
* @since 1.0
*/
export class I18n {
/**
* @public
* @param {Object} strings
*/
register(strings) {
Object.assign(I18n.keys, strings.keys);
Object.assign(I18n.bundles, strings.bundles);
}
/**
* Resolves a string from a key.
*
* If the key begins with '@' then the remainder is assumed to be a reference to another key and will be resolved.
*
* @public
* @param {String} key
* @param defaultText
*/
static get(key, defaultText) {
// console.log('this.keys is ', this.keys);
// debugger;
const text = I18n.keys[key];
if (text === null || text === undefined) {
// 初始化表单验证 todo 如何加载所有的自定义的表单验证 无效 报错 ?????
// ITAS.form.Validator.init();
if (text === null || text === undefined || text === '') {
if (defaultText) {
return defaultText;
}
else {
return 'MISSING_I18N:' + key;
}
}
}
// resolve references
if (text.charAt(0) === '@') {
return I18n.get(text.substring(1, text.length));
}
else {
return text;
}
}
/**
* @public
* @param {String} key
* @returns {String}
*/
static format(key) {
let text = I18n.get(key);
if (text) {
const params = Array.prototype.slice.call(arguments);
// replace first element with text
params.shift();
params.unshift(text);
// text = Ext.String.format.apply(this, params);
text = strFormat(...params);
}
return text;
}
/**
* Render a bundle string.
*
* @param {Object/String} bundle
* @param {String} key
* @returns {String}
*/
static render(bundle, key) {
let resources, text, params;
// resolve bundle
if (isObject(bundle)) {
// bundle = Ext.getClassName(bundle);
}
//<if debug>
// this.logTrace('Resolving bundle:', bundle, 'key:', key);
//</if>
resources = I18n.bundles[bundle];
if (resources === undefined) {
console.warn('Missing I18n bundle:', bundle);
return 'MISSING_I18N:' + bundle + ':' + key;
}
// resolve text
text = resources[key];
if (text === undefined) {
// handle bundle extension
const extend = resources['$extend'];
if (extend !== undefined) {
params = Array.prototype.slice.call(arguments, 1);
params.unshift(extend);
// return this.render.apply(this, params);
return I18n.render(params[0], params[1]);
}
console.warn('Missing I18n bundle key:', bundle, ':', key);
return 'MISSING_I18N:' + bundle + ':' + key;
}
// resolve references
if (text.charAt(0) === '@') {
if (text.indexOf(':') !== -1) {
// bundle ref <bundle>:[key]
const items = text.substring(1, text.length).split(':', 2);
// default to given key if ref missing key
if (items[1] === '') {
items[1] = key;
}
params = Array.prototype.slice.call(arguments, 2);
params.unshift(items[1]);
params.unshift(items[0]);
// return this.render.apply(this, params);
return I18n.render(params[0], params[1]);
}
else {
// key ref <key>
text = I18n.get(text.substring(1, text.length));
}
}
// optionally format with parameters
if (arguments.length > 2) {
params = Array.prototype.slice.call(arguments, 2);
params.unshift(text);
// text = Ext.String.format.apply(this, params);
text = strFormat(...params);
}
return text;
}
}
/**
* @private
* @property {Object}
*/
I18n.keys = {
// dialogs tip title
// Dialogs
Dialogs_Info_Title: 'Information',
Dialogs_Error_Title: 'Error',
Dialogs_Error_Message: 'Operation failed',
Dialogs_Tip_Title: 'Friendly reminder',
Dialogs_Login_Expire_Message: 'Login information has expired. Please log in again.',
Dialog_Service_Error_Message: 'The system is not ready and unable to provide services. Please contact the administrator.',
// Message Operate
Message_Operate_Success: 'Successful',
Message_Operate_Failed: 'Failed',
Message_Selected_Data_Tip: 'Please select data',
// Action Title
Delete: 'Delete',
Are_You_Sure_Delete: 'Are you sure to delete it?',
Tree_Tools_Refresh_Tip: 'refresh',
Tree_Tools_ExpandAll_Text: 'Expand All',
Tree_Tools_CollapseAll_Text: 'Collapse All',
// Field validation messages
Util_Validator_Text: 'Only letters, digits, underscores(_), hyphens(-), and dots(.) are allowed and may not start with underscore or dot.',
Util_Validator_Hostname: 'Hostname must be valid',
Util_Validator_Trim: 'This field may not start or end with a space',
Util_Validator_Url: 'This field should be a URL in the format "http://www.example.com"',
Util_Validator_Subdomain_Text: 'Subdomain field must be a minimum of 1 and maximum of 63 characters (letters, numbers, and dashes) and must start with a letter and end with a letter or digit',
/**
* email验证错误提示语国际化设置。
* 国际化设置中Util_Validator_Email对应objId,
* 'email format is error'对应objName
* 其它需要国际化的错误提示语,按email的方式配置。
*/
Util_Validator_Email: 'This field should be email format . ',
Util_Validator_Blank: 'This field is required . ',
Util_Validator_ConfirmPwd: 'Inconsistent passwords before and after',
/**
* 纳税人识别号提示信息
*/
Util_Validator_TaxpayerIdentificationNumber: 'Please enter the correct taxpayer identification number',
/**
* 联系方式提示信息
*/
Util_Validator_Cellphone: 'Please enter the correct cellphone number',
Util_Validator_Telephone: 'Please enter the correct telephone number',
Util_Validator_Fax: 'Please enter the correct fax number',
/**
* 表格提示信息
*/
Grid_Record_Not_Exist: 'The record does not exist.',
Record_Not_Select: 'Please select the items you want to operate.',
Select_Only_One_Notification: 'Please select Only One record',
/**
* 附件提示
*/
Document_Download_Fail: 'Document download fail!',
Document_Download_Wait: 'Document is prepared for export. Please wait ...',
Document_Upload_Type_Not_Allow: 'Please upload a file in the required format',
Documnet_Size_Exceeds_Limit: 'Please select file of size smaller than',
/**
* 导出文件标题
*/
Data_Information: 'Data Information'
};
/**
* @private
* @property {Object}
*/
I18n.bundles = {};
const strFormat = function (...args) {
// const args = arguments;
return args[0].replace(/\{(\d+)\}/g, function (match, number) {
return typeof args[number + 1] !== 'undefined' ? args[number + 1] : match;
});
};
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
export declare const isArray: (arg: any) => arg is any[];
//# sourceMappingURL=isArray.d.ts.map
{"version":3,"file":"isArray.d.ts","sourceRoot":"","sources":["../../src/lib/isArray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,OAAO,4BAAgB,CAAC"}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
export const isArray = Array.isArray;
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
export declare const isEqual: <TType>(x: TType, y: TType) => boolean;
//# sourceMappingURL=isEqual.d.ts.map
{"version":3,"file":"isEqual.d.ts","sourceRoot":"","sources":["../../src/lib/isEqual.ts"],"names":[],"mappings":"AAqIA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,eAAO,MAAM,OAAO,GAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAG,OAwBnD,CAAA"}
// import { isObject } from './basics';
// function isDOMElement(obj: any): boolean {
// return obj instanceof HTMLElement || obj instanceof Element || obj instanceof DocumentFragment;
// }
//
// function removeDOMElements(obj: any): any {
// if (Array.isArray(obj)) {
// return obj.filter(item => !isDOMElement(item)).map(removeDOMElements);
// } else if (typeof obj === 'object' && obj !== null) {
// const newObj: { [key: string]: any } = {};
// for (const key in obj) {
// if (key === 'dom') {
// continue;
// }
// if (!isDOMElement(obj[key])) {
// newObj[key] = removeDOMElements(obj[key]);
// }
// }
// return newObj;
// }
// return obj;
// }
// function isEqualWithoutDOM(a: any, b: any): boolean {
// const aCleaned = removeDOMElements(a);
// const bCleaned = removeDOMElements(b);
// return JSON.stringify(aCleaned) === JSON.stringify(bCleaned);
// }
// // todo
// export function isEqual(value: any, other: any, ) {
// if (value === other) {
// return true;
// }
// if (isObject(value) && isObject(other)) { // todo 如果有dom,可能会报错
// try {
// return isEqualWithoutDOM(value, other);
// } catch (e) {
// console.error('isEqual error is ', e, ' value is ', value);
// return false;
// }
//
// }
// if (value == null || other == null || (!isObject(value) && !isObject(other))) {
// return value !== value && other !== other;
// }
// return false;
// }
//
// const Stack = require('./_Stack'),
// equalArrays = require('./_equalArrays'),
// equalByTag = require('./_equalByTag'),
// equalObjects = require('./_equalObjects'),
// getTag = require('./_getTag'),
// isArray = require('./isArray'),
// isBuffer = require('./isBuffer'),
// isTypedArray = require('./isTypedArray');
//
// /** Used to compose bitmasks for value comparisons. */
// const COMPARE_PARTIAL_FLAG = 1;
//
// /** `Object#toString` result references. */
// const argsTag = '[object Arguments]',
// arrayTag = '[object Array]',
// objectTag = '[object Object]';
//
// /** Used for built-in method references. */
// const objectProto = Object.prototype;
//
// /** Used to check objects for own properties. */
// const hasOwnProperty = objectProto.hasOwnProperty;
//
// /**
// * A specialized version of `baseIsEqual` for arrays and objects which performs
// * deep comparisons and tracks traversed objects enabling objects with circular
// * references to be compared.
// *
// * @private
// * @param {Object} object The object to compare.
// * @param {Object} other The other object to compare.
// * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
// * @param {Function} customizer The function to customize comparisons.
// * @param {Function} equalFunc The function to determine equivalents of values.
// * @param {Object} [stack] Tracks traversed `object` and `other` objects.
// * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
// */
// function baseIsEqualDeep(object: { value: () => any; }, other: {
// value: () => any;
// }, bitmask: number, customizer: any, equalFunc: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any) => any, stack: any) {
// let objIsArr = isArray(object),
// othIsArr = isArray(other),
// objTag = objIsArr ? arrayTag : getTag(object),
// othTag = othIsArr ? arrayTag : getTag(other);
//
// objTag = objTag == argsTag ? objectTag : objTag;
// othTag = othTag == argsTag ? objectTag : othTag;
//
// let objIsObj = objTag == objectTag,
// othIsObj = othTag == objectTag,
// isSameTag = objTag == othTag;
//
// if (isSameTag && isBuffer(object)) {
// if (!isBuffer(other)) {
// return false;
// }
// objIsArr = true;
// objIsObj = false;
// }
// if (isSameTag && !objIsObj) {
// stack || (stack = new Stack);
// return (objIsArr || isTypedArray(object))
// ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
// : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
// }
// if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
// const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
// othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
//
// if (objIsWrapped || othIsWrapped) {
// const objUnwrapped = objIsWrapped ? object.value() : object,
// othUnwrapped = othIsWrapped ? other.value() : other;
//
// stack || (stack = new Stack);
// return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
// }
// }
// if (!isSameTag) {
// return false;
// }
// stack || (stack = new Stack);
// return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
// }
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
// function isEqual(value: unknown, other: unknown) {
// return baseIsEqual(value, other);
// }
export const isEqual = (x, y) => {
if (Object.is(x, y))
return true;
if (x instanceof Date && y instanceof Date) {
return x.getTime() === y.getTime();
}
if (x instanceof RegExp && y instanceof RegExp) {
return x.toString() === y.toString();
}
if (typeof x !== 'object' ||
x === null ||
typeof y !== 'object' ||
y === null) {
return false;
}
const keysX = Reflect.ownKeys(x);
const keysY = Reflect.ownKeys(y);
if (keysX.length !== keysY.length)
return false;
for (let i = 0; i < keysX.length; i++) {
if (!Reflect.has(y, keysX[i]))
return false;
if (!isEqual(x[keysX[i]], y[keysX[i]]))
return false;
}
return true;
};
/**
* 判断当前环境是否为 Node 环境。
* 该函数通过检测 Buffer 是否定义以及 window 是否未定义来判断。
*
* @returns {boolean} 如果当前环境为 Node 环境,则返回 true;否则返回 false。
*/
export declare const isLikelyNode: boolean;
//# sourceMappingURL=isLikelyNode.d.ts.map
{"version":3,"file":"isLikelyNode.d.ts","sourceRoot":"","sources":["../../src/lib/isLikelyNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SACuC,CAAC"}
/**
* 判断当前环境是否为 Node 环境。
* 该函数通过检测 Buffer 是否定义以及 window 是否未定义来判断。
*
* @returns {boolean} 如果当前环境为 Node 环境,则返回 true;否则返回 false。
*/
export const isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined';
export declare const isMac: boolean;
//# sourceMappingURL=isMac.d.ts.map
{"version":3,"file":"isMac.d.ts","sourceRoot":"","sources":["../../src/lib/isMac.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,SAAsC,CAAC"}
export const isMac = /mac os/i.test(navigator.userAgent);
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
declare function isObjectLike(value: unknown): value is object;
//# sourceMappingURL=isObjectLike.d.ts.map
{"version":3,"file":"isObjectLike.d.ts","sourceRoot":"","sources":["../../src/lib/isObjectLike.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,mBAEnC"}
"use strict";
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/**
* 是否空格
* Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
* @param str
* @param index
*/
export declare function isWhitespace(str: string, index: number): boolean;
//# sourceMappingURL=isWhitespace.d.ts.map
{"version":3,"file":"isWhitespace.d.ts","sourceRoot":"","sources":["../../src/lib/isWhitespace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAIhE"}
/**
* 是否空格
* Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
* @param str
* @param index
*/
export function isWhitespace(str, index) {
const ch = str[index];
return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
// return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
}
/**
* 是否连续的空格符
* @param str
*/
export declare function isWhitespaceString(str: string): boolean;
//# sourceMappingURL=isWhitespaceString.d.ts.map
{"version":3,"file":"isWhitespaceString.d.ts","sourceRoot":"","sources":["../../src/lib/isWhitespaceString.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOvD"}
import { isWhitespace } from './isWhitespace';
/**
* 是否连续的空格符
* @param str
*/
export function isWhitespaceString(str) {
for (let i = 0, ii = str.length; i < ii; i++) {
if (!isWhitespace(str, i)) {
return false;
}
}
return true;
}
export declare const isWindows: boolean;
//# sourceMappingURL=isWindows.d.ts.map
{"version":3,"file":"isWindows.d.ts","sourceRoot":"","sources":["../../src/lib/isWindows.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAA+C,CAAC"}
export const isWindows = /win(dows|32|64)/i.test(navigator.userAgent);
interface IParams {
id: string;
}
export declare class LocalStorage {
private readonly id;
constructor(params: IParams);
getItem(key: string): string | null;
setItem(key: string, value: string): void;
removeItem(key: string): void;
}
export {};
//# sourceMappingURL=local-storage.d.ts.map
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/lib/local-storage.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;gBAChB,MAAM,EAAE,OAAO;IAI3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIlC,UAAU,CAAC,GAAG,EAAE,MAAM;CAGvB"}
export class LocalStorage {
constructor(params) {
this.id = params.id;
}
getItem(key) {
return localStorage.getItem(this.id + '-' + key);
}
setItem(key, value) {
localStorage.setItem(this.id + '-' + key, value);
}
removeItem(key) {
localStorage.removeItem(this.id + '-' + key);
}
}
export declare const undefinedTag = "[object Undefined]";
export declare const nullTag = "[object Null]";
export declare const symToStringTag: typeof Symbol.toStringTag | undefined;
//# sourceMappingURL=lodash.d.ts.map
{"version":3,"file":"lodash.d.ts","sourceRoot":"","sources":["../../src/lib/lodash.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,uBAAuB,CAAC;AACjD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAEvC,eAAO,MAAM,cAAc,uCAA0C,CAAC"}
export const undefinedTag = '[object Undefined]';
export const nullTag = '[object Null]';
export const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
export declare function md5(inStr: string): string;
//# sourceMappingURL=md5.d.ts.map
{"version":3,"file":"md5.d.ts","sourceRoot":"","sources":["../../src/lib/md5.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,UAkXhC"}
export function md5(inStr) {
let hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
// let b64pad = ''; /* base-64 pad character. "=" for strict RFC compliance */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s) {
return rstr2hex(rstr_md5(str2rstr_utf8(s)));
}
// function b64_md5(s: string) {
// return rstr2b64(rstr_md5(str2rstr_utf8(s)));
// }
// function any_md5(s: string, e: string) {
// return rstr2any(rstr_md5(str2rstr_utf8(s)), e);
// }
//
// function hex_hmac_md5(k: string, d: string) {
// return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
// }
// function b64_hmac_md5(k: string, d: string) {
// return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
// }
//
// function any_hmac_md5(k: string, d: string, e: string) {
// return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e);
// }
/*
* Perform a simple self-test-dts to see if the VM is working
*/
// function md5_vm_test() {
// return hex_md5('abc').toLowerCase() == '900150983cd24fb0d6963f7d28e17f72';
// }
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
// function rstr_hmac_md5(key: string, data: string) {
// let bkey = rstr2binl(key);
// if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
//
// const ipad = Array(16), opad = Array(16);
// for (let i = 0; i < 16; i++) {
// ipad[i] = bkey[i] ^ 0x36363636;
// opad[i] = bkey[i] ^ 0x5C5C5C5C;
// }
//
// const hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
// return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
// }
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
hexcase;
}
catch (e) {
hexcase = 0;
}
const hex_tab = hexcase ? '0123456789ABCDEF' : '0123456789abcdef';
let output = '';
let x;
for (let i = 0; i < input.length; i++) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F)
+ hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Convert a raw string to a base-64 string
*/
// function rstr2b64(input: string) {
// try {
// b64pad;
// } catch (e) {
// b64pad = '';
// }
// const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// let output = '';
// const len = input.length;
// for (let i = 0; i < len; i += 3) {
// const triplet = (input.charCodeAt(i) << 16)
// | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0)
// | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
// for (let j = 0; j < 4; j++) {
// if (i * 8 + j * 6 > input.length * 8) output += b64pad;
// else output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
// }
// }
// return output;
// }
/*
* Convert a raw string to an arbitrary string encoding
*/
// function rstr2any(input: string, encoding: string) {
// const divisor = encoding.length;
// let i, j, q, x, quotient;
//
// /* Convert to an array of 16-bit big-endian values, forming the dividend */
// let dividend = Array(Math.ceil(input.length / 2));
// for (i = 0; i < dividend.length; i++) {
// dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
// }
//
// /*
// * Repeatedly perform a long division. The binary array forms the dividend,
// * the length of the encoding is the divisor. Once computed, the quotient
// * forms the dividend for the next step. All remainders are stored for later
// * use.
// */
// const full_length = Math.ceil(input.length * 8 /
// (Math.log(encoding.length) / Math.log(2)));
// const remainders = Array(full_length);
// for (j = 0; j < full_length; j++) {
// quotient = [];
// x = 0;
// for (i = 0; i < dividend.length; i++) {
// x = (x << 16) + dividend[i];
// q = Math.floor(x / divisor);
// x -= q * divisor;
// if (quotient.length > 0 || q > 0)
// quotient[quotient.length] = q;
// }
// remainders[j] = x;
// dividend = quotient;
// }
//
// /* Convert the remainders to the output string */
// let output = '';
// for (i = remainders.length - 1; i >= 0; i--)
// output += encoding.charAt(remainders[i]);
//
// return output;
// }
/*
* Encode a string as utf-8.
* For efficiency, this assumes the input is valid utf-16.
*/
function str2rstr_utf8(input) {
let output = '';
let i = -1;
let x, y;
while (++i < input.length) {
/* Decode utf-16 surrogate pairs */
x = input.charCodeAt(i);
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i++;
}
/* Encode output as utf-8 */
if (x <= 0x7F)
output += String.fromCharCode(x);
else if (x <= 0x7FF)
output += String.fromCharCode(0xC0 | ((x >>> 6) & 0x1F), 0x80 | (x & 0x3F));
else if (x <= 0xFFFF)
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
else if (x <= 0x1FFFFF)
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
}
return output;
}
/*
* Encode a string as utf-16
*/
// function str2rstr_utf16le(input: string) {
// let output = '';
// for (let i = 0; i < input.length; i++)
// output += String.fromCharCode(input.charCodeAt(i) & 0xFF,
// (input.charCodeAt(i) >>> 8) & 0xFF);
// return output;
// }
//
// function str2rstr_utf16be(input: string) {
// let output = '';
// for (let i = 0; i < input.length; i++)
// output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
// input.charCodeAt(i) & 0xFF);
// return output;
// }
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
const output = Array(input.length >> 2);
for (let i = 0; i < output.length; i++) {
output[i] = 0;
}
for (let i = 0; i < input.length * 8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
let output = '';
for (let i = 0; i < input.length * 32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
let a = 1732584193;
let b = -271733879;
let c = -1732584194;
let d = 271733878;
for (let i = 0; i < x.length; i += 16) {
const olda = a;
const oldb = b;
const oldc = c;
const oldd = d;
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y) {
const lsw = (x & 0xFFFF) + (y & 0xFFFF);
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
return hex_md5(inStr);
}
/**
* 使用提供的数据渲染mustache模板。
* @param template 要渲染的mustache模板字符串。
* @param data 包含模板中要替换的键值对的数据对象。
* @returns 渲染后的字符串结果。
*/
export declare function mustache(template: string, data: Record<string, string>): string;
//# sourceMappingURL=mustache.d.ts.map
{"version":3,"file":"mustache.d.ts","sourceRoot":"","sources":["../../src/lib/mustache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAmBtE"}
/**
* 使用提供的数据渲染mustache模板。
* @param template 要渲染的mustache模板字符串。
* @param data 包含模板中要替换的键值对的数据对象。
* @returns 渲染后的字符串结果。
*/
export function mustache(template, data) {
const pattern = /\{\{([\w\s\\.]+)\}\}/g;
let result = template;
let match;
while ((match = pattern.exec(template))) {
const keys = match[1].trim().split('.');
let value = data[keys[0]];
for (let i = 1; i < keys.length; i++) {
value = value[keys[i]];
}
if (value !== undefined) {
if (value.value) {
result = result.replace(match[0], value.value);
}
else {
result = result.replace(match[0], value);
}
}
}
return result;
}
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
};
export declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
export {};
//# sourceMappingURL=pick.d.ts.map
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/lib/pick.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI;KAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACf,CAAC;AAEF,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAOxE"}
export function pick(obj, keys) {
return keys.reduce((acc, key) => {
if (obj && Object.prototype.hasOwnProperty.call(obj, key)) {
acc[key] = obj[key];
}
return acc;
}, {});
}
// 示例用法
// interface Item {
// id: number;
// label: string;
// value: string;
// }
// const item: Item = { id: 1, label: 'Option 1', value: 'A' };
// const pickedItem = pick(item, ['id', 'value']);
//
// console.log(pickedItem); // 输出: { id: 1, value: 'A' }
export declare function pxToRem(str: string): string;
//# sourceMappingURL=pxToRem.d.ts.map
{"version":3,"file":"pxToRem.d.ts","sourceRoot":"","sources":["../../src/lib/pxToRem.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3C"}
export function pxToRem(str) {
// 匹配:20px或: 20px不区分大小写
const reg = /(\:|: )+(\d)+(px)/gi;
return str.replace(reg, function (char) {
const x = char.replace(/(\:|: )/, '').replace(/px/i, '');
return ':' + parseFloat(x) / 100 + 'rem';
});
}
declare function setProperty(target: any, propertyKey: string, value: any, receiver?: any): boolean;
declare const obj: any;
//# sourceMappingURL=setProperty.d.ts.map
{"version":3,"file":"setProperty.d.ts","sourceRoot":"","sources":["../../src/lib/setProperty.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAClB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,GAAG,EACV,QAAQ,MAAS,WA4BlB;AAED,QAAA,MAAM,GAAG,EAAE,GAST,CAAC"}
"use strict";
function setProperty(target, propertyKey, value, receiver = target) {
if (typeof target !== 'object' && typeof target !== 'function') {
throw new TypeError('target must be an object');
}
const descriptor = Object.getOwnPropertyDescriptor(target, propertyKey);
if (descriptor &&
(descriptor.writable === false || !descriptor.configurable)) {
return false;
}
try {
// 检查是否存在访问器属性,并尝试调用set访问器
if (descriptor && typeof descriptor.set === 'function') {
descriptor.set.call(receiver, value);
return true;
}
// 如果是常规属性或没有set访问器,则直接设置值
target[propertyKey] = value;
return true;
}
catch (error) {
return false;
}
}
const obj = Object.defineProperty({}, 'name', {
configurable: true,
enumerable: true,
get: function () {
return this._name;
},
set: function (value) {
this._name = value;
},
});
setProperty(obj, 'name', 'John Doe');
console.log(obj.name); // 输出: John Doe
/**
* 简单集合类,实现了ISimpleSet接口。
*/
export declare class SimpleSet implements ISimpleSet {
set: Record<string, boolean>;
/**
* 检查集合中是否存在指定元素。
* @param key 要检查的元素,可以是字符串或数字。
* @returns {boolean} 如果元素存在,则返回true;否则返回false。
*/
has(key: string | number): boolean;
/**
* 向集合中添加元素。
* @param key 要添加的元素,可以是字符串或数字。
*/
add(key: string | number): void;
/**
* 清空集合,移除所有元素。
*/
clear(): void;
}
export interface ISimpleSet {
has(key: string | number): boolean;
add(key: string | number): any;
clear(): void;
}
//# sourceMappingURL=simple-set.d.ts.map
{"version":3,"file":"simple-set.d.ts","sourceRoot":"","sources":["../../src/lib/simple-set.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,YAAW,UAAU;IAE1C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAuB;IAEnD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIxB;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIxB;;OAEG;IACH,KAAK;CAGN;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAEnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE/B,KAAK,IAAI,IAAI,CAAC;CACf"}
/**
* 简单集合类,实现了ISimpleSet接口。
*/
export class SimpleSet {
constructor() {
// 使用记录类型存储集合中的元素,键为元素值,值为布尔类型标记存在与否
this.set = Object.create(null);
}
/**
* 检查集合中是否存在指定元素。
* @param key 要检查的元素,可以是字符串或数字。
* @returns {boolean} 如果元素存在,则返回true;否则返回false。
*/
has(key) {
return this.set[key] === true;
}
/**
* 向集合中添加元素。
* @param key 要添加的元素,可以是字符串或数字。
*/
add(key) {
this.set[key] = true;
}
/**
* 清空集合,移除所有元素。
*/
clear() {
this.set = Object.create(null);
}
}
export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): T;
//# sourceMappingURL=throttle.d.ts.map
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/lib/throttle.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAoBrF"}
export function throttle(func, limit) {
console.log('throttle . ');
let inThrottle = false;
let lastArgs = null;
return ((...args) => {
if (!inThrottle) {
func(...args);
inThrottle = true;
setTimeout(() => {
inThrottle = false;
if (lastArgs) {
const tempArgs = lastArgs;
lastArgs = null;
throttle(func, limit)(...tempArgs);
}
}, limit);
}
else {
lastArgs = args; // 如果在限制时间内再次调用,则记录下这次调用的参数
}
});
}
/**
* hello-world- to HelloWorldMinus
* @param str 字符串
* @param separator 分割符(默认"-")
* @param topIsCapital 开头是否大写(默认是)
*/
export declare function toHump(str: string, separator?: string, topIsCapital?: boolean): string;
//# sourceMappingURL=to-hump.d.ts.map
{"version":3,"file":"to-hump.d.ts","sourceRoot":"","sources":["../../src/lib/to-hump.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAM,EAAE,YAAY,UAAO,UAiBvE"}
/**
* hello-world- to HelloWorldMinus
* @param str 字符串
* @param separator 分割符(默认"-")
* @param topIsCapital 开头是否大写(默认是)
*/
export function toHump(str, separator = '-', topIsCapital = true) {
if (str.endsWith(separator)) {
// 最后是减号的处理
str = str + 'minus';
}
const strArray = str.split(separator);
return strArray
.map((item, index) => {
if (!topIsCapital && index === 0)
return item;
if (item.match(/^./)) {
return item.replace(/^./, function (match) {
return match.toUpperCase();
});
}
return item;
})
.join('');
}
export declare const isSymbol: (value: any) => value is symbol;
export declare const isObject: (value: any) => value is object;
/**
* Checks if the given value is primitive.
*
* Primitive Types: number , string , boolean , symbol, bigint, undefined, null
*
* @param {*} value value to check
* @returns {boolean} result
*/
export declare const isPrimitive: (value: any) => boolean;
export declare const isFunction: (value: any) => value is Function;
export declare const isString: (value: any) => value is string;
export declare const isInt: (value: any) => value is number;
export declare const isFloat: (value: any) => value is number;
export declare const isNumber: (value: any) => value is number;
export declare const isDate: (value: any) => value is Date;
/**
* This is really a _best guess_ promise checking. You
* should probably use Promise.resolve(value) to be 100%
* sure you're handling it correctly.
*/
export declare const isPromise: (value: any) => value is Promise<any>;
export declare const isEmpty: (value: any) => boolean;
export declare const isEqual: <TType>(x: TType, y: TType) => boolean;
//# sourceMappingURL=typed.d.ts.map
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/lib/typed.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,GAAG,KAAG,OAMxC,CAAA;AAGD,eAAO,MAAM,UAAU,UAAW,GAAG,KAAG,KAAK,IAAI,QAEhD,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED,eAAO,MAAM,KAAK,UAAW,GAAG,KAAG,KAAK,IAAI,MAE3C,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,GAAG,KAAG,KAAK,IAAI,MAE7C,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAG,KAAK,IAAI,MAM9C,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,GAAG,KAAG,KAAK,IAAI,IAE5C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,GAAG,KAAG,KAAK,IAAI,OAAO,CAAC,GAAG,CAK1D,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,GAAG,YAajC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAG,OAwBnD,CAAA"}
// from radash
export const isSymbol = (value) => {
return !!value && value.constructor === Symbol;
};
export const isObject = (value) => {
return !!value && value.constructor === Object;
};
/**
* Checks if the given value is primitive.
*
* Primitive Types: number , string , boolean , symbol, bigint, undefined, null
*
* @param {*} value value to check
* @returns {boolean} result
*/
export const isPrimitive = (value) => {
return (value === undefined ||
value === null ||
(typeof value !== 'object' && typeof value !== 'function'));
};
// eslint-disable-next-line @typescript-eslint/ban-types
export const isFunction = (value) => {
return !!(value && value.constructor && value.call && value.apply);
};
export const isString = (value) => {
return typeof value === 'string' || value instanceof String;
};
export const isInt = (value) => {
return isNumber(value) && value % 1 === 0;
};
export const isFloat = (value) => {
return isNumber(value) && value % 1 !== 0;
};
export const isNumber = (value) => {
try {
return Number(value) === value;
}
catch (_a) {
return false;
}
};
export const isDate = (value) => {
return Object.prototype.toString.call(value) === '[object Date]';
};
/**
* This is really a _best guess_ promise checking. You
* should probably use Promise.resolve(value) to be 100%
* sure you're handling it correctly.
*/
export const isPromise = (value) => {
if (!value)
return false;
if (!value.then)
return false;
if (!isFunction(value.then))
return false;
return true;
};
export const isEmpty = (value) => {
if (value === true || value === false)
return true;
if (value === null || value === undefined)
return true;
if (isNumber(value))
return value === 0;
if (isDate(value))
return isNaN(value.getTime());
if (isFunction(value))
return false;
if (isSymbol(value))
return false;
const length = value.length;
if (isNumber(length))
return length === 0;
const size = value.size;
if (isNumber(size))
return size === 0;
const keys = Object.keys(value).length;
return keys === 0;
};
export const isEqual = (x, y) => {
if (Object.is(x, y))
return true;
if (x instanceof Date && y instanceof Date) {
return x.getTime() === y.getTime();
}
if (x instanceof RegExp && y instanceof RegExp) {
return x.toString() === y.toString();
}
if (typeof x !== 'object' ||
x === null ||
typeof y !== 'object' ||
y === null) {
return false;
}
const keysX = Reflect.ownKeys(x);
const keysY = Reflect.ownKeys(y);
if (keysX.length !== keysY.length)
return false;
for (let i = 0; i < keysX.length; i++) {
if (!Reflect.has(y, keysX[i]))
return false;
if (!isEqual(x[keysX[i]], y[keysX[i]]))
return false;
}
return true;
};
export declare function Uint8ArrayToHexString(arr: Uint8Array): string;
//# sourceMappingURL=Uint8ArrayToHexString.d.ts.map
{"version":3,"file":"Uint8ArrayToHexString.d.ts","sourceRoot":"","sources":["../../src/lib/Uint8ArrayToHexString.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAe7D"}
export function Uint8ArrayToHexString(arr) {
const words = [];
let j = 0;
for (let i = 0; i < arr.length * 2; i += 2) {
words[i >>> 3] |= parseInt(String(arr[j]), 10) << (24 - (i % 8) * 4);
j++;
}
// 转换到16进制
const hexChars = [];
for (let i = 0; i < arr.length; i++) {
const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
}
export declare const XMLEntities: {
60: string;
62: string;
38: string;
34: string;
39: string;
};
//# sourceMappingURL=XMLEntities.d.ts.map
{"version":3,"file":"XMLEntities.d.ts","sourceRoot":"","sources":["../../src/lib/XMLEntities.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAC"}
export const XMLEntities = {
/* < */ 0x3c: '&lt;',
/* > */ 0x3e: '&gt;',
/* & */ 0x26: '&amp;',
/* " */ 0x22: '&quot;',
/* ' */ 0x27: '&apos;',
};
export declare const XMLParserErrorCode: {
NoError: number;
EndOfDocument: number;
UnterminatedCdat: number;
UnterminatedXmlDeclaration: number;
UnterminatedDoctypeDeclaration: number;
UnterminatedComment: number;
MalformedElement: number;
OutOfMemory: number;
UnterminatedAttributeValue: number;
UnterminatedElement: number;
ElementNeverBegun: number;
};
//# sourceMappingURL=XMLParserErrorCode.d.ts.map
{"version":3,"file":"XMLParserErrorCode.d.ts","sourceRoot":"","sources":["../../src/lib/XMLParserErrorCode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAY9B,CAAC"}
export const XMLParserErrorCode = {
NoError: 0,
EndOfDocument: -1,
UnterminatedCdat: -2,
UnterminatedXmlDeclaration: -3,
UnterminatedDoctypeDeclaration: -4,
UnterminatedComment: -5,
MalformedElement: -6,
OutOfMemory: -7,
UnterminatedAttributeValue: -8,
UnterminatedElement: -9,
ElementNeverBegun: -10,
};
/**
* 单位换算率
* 一英寸等于25.4mm
* dpi (dot per inch)输出分辨率
* twip (twentieth of a point)
*/
export declare class Ratio {
static _dpi?: number;
static get dpi(): number;
static getDPI(): number[];
static inch2twip: number;
static inch2cm: number;
static inch2mm: number;
static inch2pt: number;
static mm2twip: number;
static mm2pt: number;
static get mm2px(): number;
static get pt2twip(): number;
static get pt2pxRatio(): number;
static px2pt: number;
static px2twip: number;
}
//# sourceMappingURL=ratio.d.ts.map
{"version":3,"file":"ratio.d.ts","sourceRoot":"","sources":["../src/ratio.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qBAAa,KAAK;IAChB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,KAAK,GAAG,WAQb;IAGD,MAAM,CAAC,MAAM;IAwBb,MAAM,CAAC,SAAS,SAAQ;IACxB,MAAM,CAAC,OAAO,SAAQ;IACtB,MAAM,CAAC,OAAO,SAAqB;IAEnC,MAAM,CAAC,OAAO,SAAM;IACpB,MAAM,CAAC,OAAO,SAA2D;IAEzE,MAAM,CAAC,KAAK,SAAyD;IAGrE,MAAM,KAAK,KAAK,WAGf;IAED,MAAM,KAAK,OAAO,WAEjB;IAED,MAAM,KAAK,UAAU,WAEpB;IAED,MAAM,CAAC,KAAK,SAA2B;IAEvC,MAAM,CAAC,OAAO,SAA6B;CAG5C"}
var _a;
import { formatFloat } from './lib/formatFloat';
/**
* 单位换算率
* 一英寸等于25.4mm
* dpi (dot per inch)输出分辨率
* twip (twentieth of a point)
*/
export class Ratio {
static get dpi() {
if (this._dpi === undefined) {
const dpiArr = _a.getDPI();
this._dpi = dpiArr[0]; // window.devicePixelRatio * 96;
}
// console.log('dpi is ', this._dpi);
// console.log('dpr is ', window.devicePixelRatio);
return this._dpi;
}
// windows默认dpi 96
static getDPI() {
var _b;
const arrDPI = [];
const screen = window.screen;
if (screen.deviceXDPI !== undefined) {
// ie 9
arrDPI[0] = screen.deviceXDPI;
arrDPI[1] = screen.deviceYDPI;
}
else {
// chrome firefox
const tmpNode = document.createElement('div');
tmpNode.style.cssText =
'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
document.body.appendChild(tmpNode);
arrDPI[0] = tmpNode.offsetWidth;
arrDPI[1] = tmpNode.offsetHeight;
(_b = tmpNode.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(tmpNode);
}
return arrDPI;
}
// console.log('mm2ptRatio is ', mm2ptRatio);
// window.devicePixelRatio dpr是设备像素比,dpi是每英寸的点数,不一样的
static get mm2px() {
// console.log('mm2px is ', formatFloat(Ratio.dpi / this.inch2mm));
return formatFloat(_a.dpi / this.inch2mm, 2);
} // 3.78
// console.log('mm2pxRatio is ', mm2pxRatio);
static get pt2twip() {
return this.inch2twip / this.inch2pt; // 20
}
static get pt2pxRatio() {
return Math.round((this.dpi / this.inch2pt) * 10000) / 10000;
} // 1.3333
}
_a = Ratio;
// Twip - twentieths of a point
Ratio.inch2twip = 1440;
Ratio.inch2cm = 2.54;
Ratio.inch2mm = _a.inch2cm * 10; // 25.4
// console.log('inch2mmRatio is ', inch2mmRatio);
Ratio.inch2pt = 72;
Ratio.mm2twip = Math.round((_a.inch2twip / _a.inch2mm) * 100) / 100; // 56.69
// console.log('mm2twipRation is ', mm2twipRatio);
Ratio.mm2pt = Math.round((_a.inch2pt / _a.inch2mm) * 100) / 100; // 2.83
// console.log('pt2pxRatio is ', pt2pxRatio);
Ratio.px2pt = _a.inch2pt / _a.dpi; // 0.75 72/96
// console.log('px2ptRatio is ', px2ptRatio);
Ratio.px2twip = _a.pt2twip * _a.px2pt; // 20 * 0.75 = 15

Sorry, the diff of this file is not supported yet

export declare const unique: <T>(arr: T[]) => T[];
type Many<T> = T | ReadonlyArray<T>;
/** like `_.castArray`, except falsy value returns empty array. */
export declare const castArray: <T>(arr: Many<T> | T) => T[];
export declare const ensureArray: <T>(arr: Many<T> | T) => T[];
export {};
//# sourceMappingURL=arrays.d.ts.map
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/ui/arrays.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,GAAI,CAAC,OAAO,CAAC,EAAE,QAAsB,CAAA;AAExD,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAEnC,kEAAkE;AAClE,eAAO,MAAM,SAAS,GAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,CAAC,EAGhD,CAAA;AACD,eAAO,MAAM,WAAW,GAJE,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,CAAC,EAIb,CAAC"}
// import { isArray } from './types'
import { isArray } from '../lib/isArray';
export const unique = (arr) => [...new Set(arr)];
// TODO: rename to `ensureArray`
/** like `_.castArray`, except falsy value returns empty array. */
export const castArray = (arr) => {
if (!arr && arr !== 0)
return [];
return isArray(arr) ? arr : [arr];
};
export const ensureArray = castArray;
// TODO: remove import alias
// avoid naming conflicts
// export { castArray as ensureArray } from 'lodash-unified'
/**
* Determine if the testing element is visible on screen no matter if its on the viewport or not
*/
export declare const isVisible: (element: HTMLElement) => boolean;
export declare const obtainAllFocusableElements: (element: HTMLElement) => HTMLElement[];
/**
* @desc Determine if target element is focusable
* @param element {HTMLElement}
* @returns {Boolean} true if it is focusable
*/
export declare const isFocusable: (element: HTMLElement) => boolean;
/**
* @desc Set Attempt to set focus on the current node.
* @param element
* The node to attempt to focus on.
* @returns
* true if element is focused.
*/
export declare const attemptFocus: (element: HTMLElement) => boolean;
/**
* Trigger an event
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
* @param {HTMLElement} elm
* @param {String} name
* @param {*} opts
*/
export declare const triggerEvent: (elm: HTMLElement, name: string, ...opts: Array<boolean>) => HTMLElement;
export declare const isLeaf: (el: HTMLElement) => boolean;
export declare const getSibling: (el: HTMLElement, distance: number, elClass: string) => Element | null;
export declare const focusNode: (el: HTMLElement) => void;
//# sourceMappingURL=aria.d.ts.map
{"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/aria.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,YAAa,WAAW,YAM7C,CAAA;AAED,eAAO,MAAM,0BAA0B,YAC5B,WAAW,KACnB,WAAW,EAIb,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAa,WAAW,KAAG,OAsClD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,YAAa,WAAW,KAAG,OAOnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAClB,WAAW,QACV,MAAM,WACH,KAAK,CAAC,OAAO,CAAC,KACtB,WAeF,CAAA;AAED,eAAO,MAAM,MAAM,OAAQ,WAAW,YAAkC,CAAA;AAExE,eAAO,MAAM,UAAU,OACjB,WAAW,YACL,MAAM,WACP,MAAM,mBAOhB,CAAA;AAED,eAAO,MAAM,SAAS,OAAQ,WAAW,SAIxC,CAAA"}
const FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex="-1"]),input:not([disabled]),input:not([type="hidden"]),select:not([disabled]),textarea:not([disabled])`;
/**
* Determine if the testing element is visible on screen no matter if its on the viewport or not
*/
export const isVisible = (element) => {
if (process.env.NODE_ENV === 'test')
return true;
const computed = getComputedStyle(element);
// element.offsetParent won't work on fix positioned
// WARNING: potential issue here, going to need some expert advices on this issue
return computed.position === 'fixed' ? false : element.offsetParent !== null;
};
export const obtainAllFocusableElements = (element) => {
return Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter((item) => isFocusable(item) && isVisible(item));
};
/**
* @desc Determine if target element is focusable
* @param element {HTMLElement}
* @returns {Boolean} true if it is focusable
*/
export const isFocusable = (element) => {
if (element.tabIndex > 0 ||
(element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)) {
return true;
}
if (element.tabIndex < 0 ||
element.hasAttribute('disabled') ||
element.getAttribute('aria-disabled') === 'true') {
return false;
}
switch (element.nodeName) {
case 'A': {
// casting current element to Specific HTMLElement in order to be more type precise
return (!!element.href &&
element.rel !== 'ignore');
}
case 'INPUT': {
return !(element.type === 'hidden' ||
element.type === 'file');
}
case 'BUTTON':
case 'SELECT':
case 'TEXTAREA': {
return true;
}
default: {
return false;
}
}
};
/**
* @desc Set Attempt to set focus on the current node.
* @param element
* The node to attempt to focus on.
* @returns
* true if element is focused.
*/
export const attemptFocus = (element) => {
var _a;
if (!isFocusable(element)) {
return false;
}
// Remove the old try catch block since there will be no error to be thrown
(_a = element.focus) === null || _a === void 0 ? void 0 : _a.call(element);
return document.activeElement === element;
};
/**
* Trigger an event
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
* @param {HTMLElement} elm
* @param {String} name
* @param {*} opts
*/
export const triggerEvent = function (elm, name, ...opts) {
let eventName;
if (name.includes('mouse') || name.includes('click')) {
eventName = 'MouseEvents';
}
else if (name.includes('key')) {
eventName = 'KeyboardEvent';
}
else {
eventName = 'HTMLEvents';
}
const evt = document.createEvent(eventName);
evt.initEvent(name, ...opts);
elm.dispatchEvent(evt);
return elm;
};
export const isLeaf = (el) => !el.getAttribute('aria-owns');
export const getSibling = (el, distance, elClass) => {
const { parentNode } = el;
if (!parentNode)
return null;
const siblings = parentNode.querySelectorAll(elClass);
const index = Array.prototype.indexOf.call(siblings, el);
return siblings[index + distance] || null;
};
export const focusNode = (el) => {
if (!el)
return;
el.focus();
!isLeaf(el) && el.click();
};
type GetElement = <T extends string | HTMLElement | Window | null | undefined>(target: T) => T extends string ? HTMLElement | null : T;
export declare const getElement: GetElement;
export {};
//# sourceMappingURL=element.d.ts.map
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/element.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3E,MAAM,EAAE,CAAC,KACN,CAAC,SAAS,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,CAAC,CAAA;AAE9C,eAAO,MAAM,UAAU,EAYjB,UAAU,CAAA"}
// import { isString } from '../types'
// import { isClient } from '../browser'
import { isClient, isString } from '../../index';
export const getElement = ((target) => {
if (!isClient || target === '')
return null;
if (isString(target)) {
try {
return document.querySelector(target);
}
catch (_a) {
return null;
}
}
return target;
});
export declare const composeEventHandlers: <E>(theirsHandler?: (event?: E) => boolean | void, oursHandler?: (event?: E) => void, { checkForDefaultPrevented }?: {
checkForDefaultPrevented?: boolean | undefined;
}) => (event?: E) => void;
type WhenMouseHandler = (e: PointerEvent) => any;
export declare const whenMouse: (handler: WhenMouseHandler) => WhenMouseHandler;
export {};
//# sourceMappingURL=event.d.ts.map
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/event.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,CAAC,kBACpB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,gBAC/B,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI;;eAIJ,CAAC,SAU/B,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,CAAC,EAAE,YAAY,KAAK,GAAG,CAAA;AAChD,eAAO,MAAM,SAAS,YAAa,gBAAgB,KAAG,gBAGrD,CAAC"}
export const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
// console.log('composeEventHandlers, theirsHandler is ', theirsHandler);
const handleEvent = (event) => {
// console.log('composeEventHandlers, event is ', event);
const shouldPrevent = theirsHandler === null || theirsHandler === void 0 ? void 0 : theirsHandler(event);
if (checkForDefaultPrevented === false ||
!shouldPrevent) {
return oursHandler === null || oursHandler === void 0 ? void 0 : oursHandler(event);
}
};
return handleEvent;
};
export const whenMouse = (handler) => {
return (e) => e.pointerType === 'mouse' ? handler(e) : undefined;
};
export * from './aria';
export * from './event';
export * from './position';
export * from './scroll';
export * from './style';
export * from './element';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
export * from './aria';
export * from './event';
export * from './position';
export * from './scroll';
export * from './style';
export * from './element';
export declare const isInContainer: (el?: Element, container?: Element | Window) => boolean;
export declare const getOffsetTop: (el: HTMLElement) => number;
export declare const getOffsetTopDistance: (el: HTMLElement, containerEl: HTMLElement) => number;
export declare const getClientXY: (event: MouseEvent | TouchEvent) => {
clientX: number;
clientY: number;
};
//# sourceMappingURL=position.d.ts.map
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/position.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QACnB,OAAO,cACA,OAAO,GAAG,MAAM,KAC3B,OAsBF,CAAA;AAED,eAAO,MAAM,YAAY,OAAQ,WAAW,WAU3C,CAAA;AAED,eAAO,MAAM,oBAAoB,OAC3B,WAAW,eACF,WAAW,WAGzB,CAAA;AAED,eAAO,MAAM,WAAW,UAAW,UAAU,GAAG,UAAU;;;CAiBzD,CAAA"}
// import { isClient } from '../browser'
import { isClient } from '../../index';
export const isInContainer = (el, container) => {
if (!isClient || !el || !container)
return false;
const elRect = el.getBoundingClientRect();
let containerRect;
if (container instanceof Element) {
containerRect = container.getBoundingClientRect();
}
else {
containerRect = {
top: 0,
right: window.innerWidth,
bottom: window.innerHeight,
left: 0,
};
}
return (elRect.top < containerRect.bottom &&
elRect.bottom > containerRect.top &&
elRect.right > containerRect.left &&
elRect.left < containerRect.right);
};
export const getOffsetTop = (el) => {
let offset = 0;
let parent = el;
while (parent) {
offset += parent.offsetTop;
parent = parent.offsetParent;
}
return offset;
};
export const getOffsetTopDistance = (el, containerEl) => {
return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl));
};
export const getClientXY = (event) => {
let clientX;
let clientY;
if (event.type === 'touchend') {
clientY = event.changedTouches[0].clientY;
clientX = event.changedTouches[0].clientX;
}
else if (event.type.startsWith('touch')) {
clientY = event.touches[0].clientY;
clientX = event.touches[0].clientX;
}
else {
clientY = event.clientY;
clientX = event.clientX;
}
return {
clientX,
clientY,
};
};
export declare const isScroll: (el: HTMLElement, isVertical?: boolean) => boolean;
export declare const getScrollContainer: (el: HTMLElement, isVertical?: boolean) => Window | HTMLElement | undefined;
export declare const getScrollBarWidth: (namespace: string) => number;
/**
* Scroll with in the container element, positioning the **selected** element at the top
* of the container
*/
export declare function scrollIntoView(container: HTMLElement, selected: HTMLElement): void;
export declare function animateScrollTo(container: HTMLElement | Window, from: number, to: number, duration: number, callback?: unknown): () => void;
export declare const getScrollElement: (target: HTMLElement, container: HTMLElement | Window) => HTMLElement;
export declare const getScrollTop: (container: HTMLElement | Window) => number;
//# sourceMappingURL=scroll.d.ts.map
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/scroll.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,OAAQ,WAAW,eAAe,OAAO,KAAG,OAYhE,CAAA;AAED,eAAO,MAAM,kBAAkB,OACzB,WAAW,eACF,OAAO,KACnB,MAAM,GAAG,WAAW,GAAG,SAkBzB,CAAA;AAGD,eAAO,MAAM,iBAAiB,cAAe,MAAM,KAAG,MAwBrD,CAAA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,WAAW,GACpB,IAAI,CA8BN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,GAAG,MAAM,EAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,OAAO,cAgCnB;AAED,eAAO,MAAM,gBAAgB,WACnB,WAAW,aACR,WAAW,GAAG,MAAM,gBAMhC,CAAA;AAED,eAAO,MAAM,YAAY,cAAe,WAAW,GAAG,MAAM,WAK3D,CAAA"}
// import { isClient } from '../browser'
import { isFunction } from '../../lib/basics';
import { isClient } from '../../lib/browser';
import { easeInOutCubic } from '../easings';
import { isWindow } from '../types';
import { cAF, rAF } from '../raf';
import { getStyle } from './style';
export const isScroll = (el, isVertical) => {
if (!isClient)
return false;
const key = {
undefined: 'overflow',
true: 'overflow-y',
false: 'overflow-x',
}[String(isVertical)];
const overflow = getStyle(el, key);
return ['scroll', 'auto', 'overlay'].some((s) => overflow.includes(s));
};
export const getScrollContainer = (el, isVertical) => {
// console.warn('getScrollContainer el is ', el);
if (!isClient)
return;
let parent = el;
while (parent) {
if ([window, document, document.documentElement].includes(parent)) {
return window;
}
if (isScroll(parent, isVertical)) {
return parent;
}
parent = parent.parentNode;
}
return parent;
};
let scrollBarWidth;
export const getScrollBarWidth = (namespace) => {
var _a;
if (!isClient)
return 0;
if (scrollBarWidth !== undefined)
return scrollBarWidth;
const outer = document.createElement('div');
outer.className = `${namespace}-scrollbar__wrap`;
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.position = 'absolute';
outer.style.top = '-9999px';
document.body.appendChild(outer);
const widthNoScroll = outer.offsetWidth;
outer.style.overflow = 'scroll';
const inner = document.createElement('div');
inner.style.width = '100%';
outer.appendChild(inner);
const widthWithScroll = inner.offsetWidth;
(_a = outer.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(outer);
scrollBarWidth = widthNoScroll - widthWithScroll;
return scrollBarWidth;
};
/**
* Scroll with in the container element, positioning the **selected** element at the top
* of the container
*/
export function scrollIntoView(container, selected) {
if (!isClient)
return;
if (!selected) {
container.scrollTop = 0;
return;
}
const offsetParents = [];
let pointer = selected.offsetParent;
while (pointer !== null &&
container !== pointer &&
container.contains(pointer)) {
offsetParents.push(pointer);
pointer = pointer.offsetParent;
}
const top = selected.offsetTop +
offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
const bottom = top + selected.offsetHeight;
const viewRectTop = container.scrollTop;
const viewRectBottom = viewRectTop + container.clientHeight;
if (top < viewRectTop) {
container.scrollTop = top;
}
else if (bottom > viewRectBottom) {
container.scrollTop = bottom - container.clientHeight;
}
}
export function animateScrollTo(container, from, to, duration, callback) {
const startTime = Date.now();
let handle;
const scroll = () => {
const timestamp = Date.now();
const time = timestamp - startTime;
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, from, to, duration);
if (isWindow(container)) {
container.scrollTo(window.pageXOffset, nextScrollTop);
}
else {
container.scrollTop = nextScrollTop;
}
if (time < duration) {
handle = rAF(scroll);
}
else if (isFunction(callback)) {
callback();
}
};
scroll();
return () => {
handle && cAF(handle);
};
}
export const getScrollElement = (target, container) => {
if (isWindow(container)) {
return target.ownerDocument.documentElement;
}
return container;
};
export const getScrollTop = (container) => {
if (isWindow(container)) {
return window.scrollY;
}
return container.scrollTop;
};
import { IStyle } from '@type-dom/css-type';
export declare const classNameToArray: (cls?: string) => string[];
export declare const hasClass: (el: Element, cls: string) => boolean;
export declare const addClass: (el?: Element, cls?: string | string[]) => void;
export declare const removeClass: (el: Element, cls: string) => void;
export declare const getStyle: (element: HTMLElement | SVGElement, styleName: keyof IStyle) => string;
export type StyleValue = string | undefined | IStyle | Array<StyleValue | undefined>;
export declare const setStyle: (element: HTMLElement | SVGElement, styleName: StyleValue, value?: string | number) => void;
export declare const removeStyle: (element: HTMLElement | SVGElement, style: IStyle | keyof IStyle) => void;
export declare function addUnit(value?: string | number, defaultUnit?: string): string;
//# sourceMappingURL=style.d.ts.map
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/ui/dom/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAY5C,eAAO,MAAM,gBAAgB,4BACmB,CAAC;AAEjD,eAAO,MAAM,QAAQ,OAAQ,OAAO,OAAO,MAAM,KAAG,OAInD,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAS,OAAO,QAAQ,MAAM,GAAG,MAAM,EAAE,SA2B7D,CAAC;AAEF,eAAO,MAAM,WAAW,OAAQ,OAAO,OAAO,MAAM,SAGnD,CAAC;AAEF,eAAO,MAAM,QAAQ,YACV,WAAW,GAAG,UAAU,aACtB,MAAM,MAAM,KACtB,MAaF,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;AACpF,eAAO,MAAM,QAAQ,YACV,WAAW,GAAG,UAAU,aACtB,UAAU,UACb,MAAM,GAAG,MAAM,SA0CxB,CAAC;AAEF,eAAO,MAAM,WAAW,YACb,WAAW,GAAG,UAAU,SAC1B,MAAM,GAAG,MAAM,MAAM,SAS7B,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAAW,SAAO,GAAG,MAAM,CAS3E"}
// import { isClient } from '../browser'
import { camelize, camelToDash, debugWarn, isClient, isObject, isString } from '../../index';
import { isArray } from '../../lib/isArray';
import { keysOf } from '../objects';
import { isNumber, isStringNumber } from '../types';
// import { debugWarn } from '../error'
// import type { CSSProperties } from 'vue'
const SCOPE = 'utils/dom/style';
export const classNameToArray = (cls = '') => cls.split(' ').filter((item) => !!item.trim());
export const hasClass = (el, cls) => {
if (!el || !cls)
return false;
if (cls.includes(' '))
throw new Error('className should not contain space.');
return el.classList.contains(cls);
};
export const addClass = (el, cls) => {
// if (typeof cls !== 'string') {
// console.warn('cls is not string');
// return;
// }
// console.warn('addClass . cls is ', cls);
if (!el)
return; // todo || !cls?.trim()
// el.className = ''; // 不兼容 SVGElement
// 清空现有类名
el.classList.remove(...Array.from(el.classList));
if (isString(cls)) {
el.classList.add(...classNameToArray(cls.trim()));
}
else if (isArray(cls)) {
const hasSpace = cls.some(item => /\s/.test(item));
// 使用 \s 正则表达式可匹配空格、制表符等空白字符
if (hasSpace) {
// console.warn('cls hasSpace . ');
cls = cls.flatMap(className => className.trim().split(/\s+/) // 拆分子项并展平
);
// console.log('cls is ', cls);
}
el.classList.add(...cls);
}
else {
console.error('cls is undefined ');
}
};
export const removeClass = (el, cls) => {
if (!el || !isString(cls) || !cls.trim())
return;
el.classList.remove(...classNameToArray(cls));
};
export const getStyle = (element, styleName) => {
var _a;
if (!isClient || !element || !styleName)
return '';
let key = camelize(styleName);
if (key === 'float')
key = 'cssFloat';
try {
const style = element.style[key];
if (style)
return style;
const computed = (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(element, '');
return computed ? computed[key] : '';
}
catch (_b) {
return element.style[key];
}
};
export const setStyle = (element, styleName, value) => {
var _a;
if (!element || !styleName)
return;
if (isArray(styleName)) {
// console.warn('styleName is array . ', styleName);
for (const s of styleName) {
if (isObject(s)) {
setStyle(element, s);
}
else {
console.error('styleName is ', styleName);
}
}
}
else if (isObject(styleName)) { // todo Record<string, IStyle> ??????
// entriesOf(styleName).forEach(([prop, value]) =>
// setStyle(element, prop as IStyle | keyof IStyle, value)
// );
for (const s in styleName) {
if (isString(styleName[s])) {
setStyle(element, s, styleName[s]);
}
else {
console.error('styleName is ', styleName);
}
}
}
else if (isString(styleName)) {
// --td-image-size: 50px -webkit-inline-box value is 2, need not addUnit px
if (styleName.startsWith('-')) {
// 自定义样式
// element.style[styleName as keyof CSSStyleDeclaration] = value;
element.style.setProperty(styleName, (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '');
}
else {
const key = camelize(styleName);
// (element.style as any)[key] = value;
// element.style.setProperty:使用短横线分隔的字符串作为属性名称。
// element.style 对象:使用驼峰命名法作为属性名称。
if (value === undefined)
return;
// addUnit(value) only key is with, height as ....
element.style.setProperty(camelToDash(key), value === null || value === void 0 ? void 0 : value.toString());
}
}
else {
console.error('error styleName is ', styleName);
}
};
export const removeStyle = (element, style) => {
if (!element || !style)
return;
if (isObject(style)) {
keysOf(style).forEach((prop) => removeStyle(element, prop));
}
else {
setStyle(element, style, '');
}
};
export function addUnit(value, defaultUnit = 'px') {
if (!value)
return '';
if (isNumber(value) || isStringNumber(value)) {
return `${value}${defaultUnit}`;
}
else if (isString(value)) {
return value;
}
debugWarn(SCOPE, 'binding value must be a string or number');
return '';
}
export declare function easeInOutCubic(t: number, b: number, c: number, d: number): number;
//# sourceMappingURL=easings.d.ts.map
{"version":3,"file":"easings.d.ts","sourceRoot":"","sources":["../../src/ui/easings.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAOxE"}
export function easeInOutCubic(t, b, c, d) {
const cc = c - b;
t /= d / 2;
if (t < 1) {
return (cc / 2) * t * t * t + b;
}
return (cc / 2) * ((t -= 2) * t * t + 2) + b;
}
export declare function throwError(scope: string, m: string): never;
export declare function debugWarn(err: Error): void;
export declare function debugWarn(scope: string, message: string): void;
//# sourceMappingURL=error.d.ts.map
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/ui/error.ts"],"names":[],"mappings":"AASA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAE1D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;AAC3C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA"}
import { isString } from '../lib/basics';
class ElementPlusError extends Error {
constructor(m) {
super(m);
this.name = 'ElementPlusError';
}
}
export function throwError(scope, m) {
throw new ElementPlusError(`[${scope}] ${m}`);
}
export function debugWarn(scope, message) {
if (process.env.NODE_ENV !== 'production') {
const error = isString(scope)
? new ElementPlusError(`[${scope}] ${message}`)
: scope;
// eslint-disable-next-line no-console
console.warn(error);
}
}
export declare const isKorean: (text: string) => boolean;
//# sourceMappingURL=i18n.d.ts.map
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/ui/i18n.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAU,MAAM,YACW,CAAA"}
export const isKorean = (text) => /([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(text);
export * from './dom';
export * from './arrays';
export * from './error';
export * from './i18n';
export * from './objects';
export * from './raf';
export * from './rand';
export * from './strings';
export * from './types';
export * from './typescript';
export * from './throttleByRaf';
export * from './easings';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AACA,cAAc,OAAO,CAAA;AAErB,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AAEvB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA"}
// Internal code, don't use in your app!
export * from './dom';
// export * from './vue'
export * from './arrays';
// export * from './browser'
export * from './error';
// export * from './functions'
export * from './i18n';
export * from './objects';
export * from './raf';
export * from './rand';
export * from './strings';
export * from './types';
export * from './typescript';
export * from './throttleByRaf';
export * from './easings';
import { Arrayable } from './typescript';
export declare const keysOf: <T extends object>(arr: T) => Array<keyof T>;
export declare const entriesOf: <T extends object>(arr: T) => [string, any][];
export declare const getProp: <T = any>(obj: Record<string, any>, path: Arrayable<string>, defaultValue?: any) => {
value: T;
};
//# sourceMappingURL=objects.d.ts.map
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/ui/objects.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,OAAO,CAAC,KACzB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AACpC,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,OAAO,CAAC,oBAC7B,CAAA;AAErB,eAAO,MAAM,OAAO,GAAI,CAAC,aAClB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAClB,SAAS,CAAC,MAAM,CAAC,iBACR,GAAG,KACjB;IAAE,KAAK,EAAE,CAAC,CAAA;CASZ,CAAA"}
// import { get, set } from 'lodash-unified'
// import type { Entries } from 'type-fest'
// import type { Arrayable } from '.'
// export { hasOwn } from '@vue/shared'
import { get, set } from 'lodash';
export const keysOf = (arr) => Object.keys(arr);
export const entriesOf = (arr) => Object.entries(arr);
export const getProp = (obj, path, defaultValue) => {
return {
get value() {
return get(obj, path, defaultValue);
},
set value(val) {
set(obj, path, val);
},
};
};
export declare const rAF: (fn: () => void) => number;
export declare const cAF: (handle: number) => void;
//# sourceMappingURL=raf.d.ts.map
{"version":3,"file":"raf.d.ts","sourceRoot":"","sources":["../../src/ui/raf.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,OAAQ,MAAM,IAAI,WAGa,CAAC;AAEhD,eAAO,MAAM,GAAG,WAAY,MAAM,SACqC,CAAC"}
import { isClient } from '../lib/browser';
export const rAF = (fn) => isClient
? window.requestAnimationFrame(fn)
: setTimeout(fn, 16);
export const cAF = (handle) => isClient ? window.cancelAnimationFrame(handle) : clearTimeout(handle);
/**
* @deprecated Use `useId` `useIdInjection` instead
* Generate random number in range [0, 1000]
* Maybe replace with [uuid](https://www.npmjs.com/package/uuid)
*/
export declare const generateId: () => number;
/**
* @deprecated
* Generating a random int in range (0, max - 1)
* @param max {number}
*/
export declare const getRandomInt: (max: number) => number;
//# sourceMappingURL=rand.d.ts.map
{"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../../src/ui/rand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAA2C,CAAA;AAEzE;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,WACK,CAAA"}
/**
* @deprecated Use `useId` `useIdInjection` instead
* Generate random number in range [0, 1000]
* Maybe replace with [uuid](https://www.npmjs.com/package/uuid)
*/
export const generateId = () => Math.floor(Math.random() * 10000);
/**
* @deprecated
* Generating a random int in range (0, max - 1)
* @param max {number}
*/
export const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export declare const escapeStringRegexp: (string?: string) => string;
/**
* Splits a string of space separated words into an array, trimming as needed. If the
* words are already an array, it is returned.
*
* @param {String/Array} words
*/
export declare function splitWords(words?: string | string[]): string[];
/**
* Creates a map (object) keyed by the elements of the given array. The values in
* the map are the index+1 of the array element. For example:
*
* var map = Ext.Array.toMap(['a','b','c']);
*
* // map = { a: 1, b: 2, c: 3 };
*
* Or a key property can be specified:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], 'name');
*
* // map = { a: 1, b: 2, c: 3 };
*
* Lastly, a key extractor can be provided:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], function(obj) { return obj.name.toUpperCase(); });
*
* // map = { A: 1, B: 2, C: 3 };
*
* @param {String/String[]} strings The strings from which to create the map.
* @param {String/Function} [getKey] Name of the object property to use
* as a key or a function to extract the key.
* @param {Object} [scope] Value of `this` inside callback specified for `getKey`.
* @return {Object} The resulting map.
*/
export declare function toMap<T extends Record<string, string>>(strings?: string | (string | T)[], getKey?: string | ((obj: T) => string), scope?: any): Record<string, number> | null;
//# sourceMappingURL=strings.d.ts.map
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/ui/strings.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,kBAAkB,6BACuC,CAAA;AAQtE;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,YAMnD;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,iCA6B7I"}
// import { capitalize as toCapitalize } from '@vue/shared'
// export {
// camelize,
// hyphenate,
// hyphenate as kebabCase, // alias
// } from '@vue/shared'
// import { capitalize as toCapitalize } from '@type-dom/utils';
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export const escapeStringRegexp = (string = '') => string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
// NOTE: improve capitalize types. Restore previous code after the [PR](https://github.com/vuejs/core/pull/6212) merge
// export const capitalize = <T extends string>(str: T) =>
// toCapitalize(str) as Capitalize<T>
const basicTrimRe = /^\s+|\s+$/g;
const whitespaceRe = /\s+/;
/**
* Splits a string of space separated words into an array, trimming as needed. If the
* words are already an array, it is returned.
*
* @param {String/Array} words
*/
export function splitWords(words) {
if (!words)
return [];
if (words && typeof words === 'string') {
return words.replace(basicTrimRe, '').split(whitespaceRe);
}
return words || [];
}
/**
* Creates a map (object) keyed by the elements of the given array. The values in
* the map are the index+1 of the array element. For example:
*
* var map = Ext.Array.toMap(['a','b','c']);
*
* // map = { a: 1, b: 2, c: 3 };
*
* Or a key property can be specified:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], 'name');
*
* // map = { a: 1, b: 2, c: 3 };
*
* Lastly, a key extractor can be provided:
*
* var map = Ext.Array.toMap([
* { name: 'a' },
* { name: 'b' },
* { name: 'c' }
* ], function(obj) { return obj.name.toUpperCase(); });
*
* // map = { A: 1, B: 2, C: 3 };
*
* @param {String/String[]} strings The strings from which to create the map.
* @param {String/Function} [getKey] Name of the object property to use
* as a key or a function to extract the key.
* @param {Object} [scope] Value of `this` inside callback specified for `getKey`.
* @return {Object} The resulting map.
*/
export function toMap(strings, getKey, scope) {
const map = {};
if (!strings) {
return null;
}
let i = strings.length;
if (typeof strings === 'string') {
map[strings] = 1;
}
else if (!getKey) { // getKey不存在时,strings为数组,是string[];
while (i--) {
map[strings[i]] = i + 1;
}
}
else if (typeof getKey === 'string') {
while (i--) {
map[strings[i][getKey]] = i + 1;
}
}
else {
while (i--) {
map[getKey.call(scope, strings[i])] = i + 1;
}
}
return map;
}
export declare function throttleByRaf(cb: (...args: any[]) => void): {
(...args: any[]): void;
cancel(): void;
};
//# sourceMappingURL=throttleByRaf.d.ts.map
{"version":3,"file":"throttleByRaf.d.ts","sourceRoot":"","sources":["../../src/ui/throttleByRaf.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;cAG7B,GAAG,EAAE,GAAG,IAAI;;EAgBxC"}
import { cAF, rAF } from './raf';
export function throttleByRaf(cb) {
let timer = 0;
const throttle = (...args) => {
if (timer) {
cAF(timer);
}
timer = rAF(() => {
cb(...args);
timer = 0;
});
};
throttle.cancel = () => {
cAF(timer);
timer = 0;
};
return throttle;
}
export declare const isUndefined: (val: any) => val is undefined;
export declare const isBoolean: (val: any) => val is boolean;
export declare const isNumber: (val: any) => val is number;
export declare const isEmpty: (val: unknown) => boolean;
export declare const isElement: (e: unknown) => e is Element;
export declare const isPropAbsent: (prop: unknown) => prop is null | undefined;
export declare const isStringNumber: (val: string) => boolean;
export declare const isWindow: (val: unknown) => val is Window;
//# sourceMappingURL=types.d.ts.map
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAAS,GAAG,KAAG,GAAG,IAAI,SAA8B,CAAA;AAC5E,eAAO,MAAM,SAAS,QAAS,GAAG,KAAG,GAAG,IAAI,OAAmC,CAAA;AAC/E,eAAO,MAAM,QAAQ,QAAS,GAAG,KAAG,GAAG,IAAI,MAAiC,CAAA;AAE5E,eAAO,MAAM,OAAO,QAAS,OAAO,YAGS,CAAA;AAE7C,eAAO,MAAM,SAAS,MAAO,OAAO,KAAG,CAAC,IAAI,OAG3C,CAAA;AAED,eAAO,MAAM,YAAY,SAAU,OAAO,KAAG,IAAI,IAAI,IAAI,GAAG,SAE3D,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,OAK5C,CAAA;AAED,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAE9C,CAAA"}
import { isNil } from '../lib/basics';
import { isArray } from '../lib/isArray';
import { isObject, isString } from '../lib/typed';
export const isUndefined = (val) => val === undefined;
export const isBoolean = (val) => typeof val === 'boolean';
export const isNumber = (val) => typeof val === 'number';
export const isEmpty = (val) => (!val && val !== 0) ||
(isArray(val) && val.length === 0) ||
(isObject(val) && !Object.keys(val).length);
export const isElement = (e) => {
if (typeof Element === 'undefined')
return false;
return e instanceof Element;
};
export const isPropAbsent = (prop) => {
return isNil(prop);
};
export const isStringNumber = (val) => {
if (!isString(val)) {
return false;
}
return !Number.isNaN(Number(val));
};
export const isWindow = (val) => {
return val === window;
};
export declare const mutable: <T extends readonly any[] | Record<string, unknown>>(val: T) => Mutable<typeof val>;
export type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
export type HTMLElementCustomized<T> = HTMLElement & T;
/**
* @deprecated stop to use null
* @see {@link https://github.com/sindresorhus/meta/discussions/7}
*/
export type Nullable<T> = T | null;
export type Arrayable<T> = T | T[];
export type Awaitable<T> = Promise<T> | T;
//# sourceMappingURL=typescript.d.ts.map
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/ui/typescript.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACnE,CAAC,KACI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAA;AAC/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAE3D,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,WAAW,GAAG,CAAC,CAAA;AAEtD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAElC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAClC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
export const mutable = (val) => val;
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => true | undefined;
/**
* Check if a tag is a built-in tag.
*/
export declare const isBuiltInTag: (key: string) => true | undefined;
/**
* Check if an attribute is a reserved attribute.
*/
export declare const isReservedAttribute: (key: string) => true | undefined;
/**
* Remove an item from an array.
*/
export declare function remove(arr: Array<any>, item: any): Array<any> | void;
export declare function hasOwn(obj: object | Array<any>, key: string): boolean;
/**
* Create a cached version of a pure function.
*/
export declare function cached<R>(fn: (str: string) => R): (sr: string) => R;
export declare const camelize: (sr: string) => string;
/**
* Capitalize a string.
*/
export declare const capitalize: (sr: string) => string;
export declare const hyphenate: (sr: string) => string;
/**
* Simple bind polyfill for environments that do not support it,
* e.g., PhantomJS 1.x. Technically, we don't need this anymore
* since native bind is now performant enough in most browsers.
* But removing it would mean breaking code that was able to run in
* PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/**
* Convert an Array-like object to a real Array.
*/
/**
* Mix properties into target object.
*/
export declare function extend(to: Record<PropertyKey, any>, _from?: Record<PropertyKey, any>): Record<PropertyKey, any>;
/**
* Merge an Array of Objects into a single Object.
*/
export declare function toObject(arr: Array<any>): object;
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
export declare function noop(a?: any, b?: any, c?: any): void;
export declare const NOOP: () => void;
/**
* Always return false.
*/
export declare const no: (a?: any, b?: any, c?: any) => boolean;
/**
* Return the same value.
*/
export declare const identity: (_: any) => any;
/**
* Generate a string containing static keys from compiler modules.
*/
export declare function genStaticKeys(modules: Array<{
staticKeys?: string[];
}>): string;
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export declare function looseEqual(a: any, b: any): boolean;
/**
* Return the first index at which a loosely equal value can be
* found in the array (if value is a plain object, the array must
* contain an object of the same shape), or -1 if it is not present.
*/
export declare function looseIndexOf(arr: Array<unknown>, val: unknown): number;
/**
* Ensure a function is called only once.
*/
export declare function once<T extends (...args: any[]) => any>(fn: T): T;
export declare function hasChanged(x: unknown, y: unknown): boolean;
//# sourceMappingURL=util.d.ts.map
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,gBAAgB,CAAC,EAAE,OAAO,GACzB,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAOnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,QAZhB,MAAM,KAAK,IAAI,GAAG,SAYgC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAjBvB,MAAM,KAAK,IAAI,GAAG,SAiB6C,CAAC;AAEzE;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAapE;AAOD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAErE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,CAAC,CAMnE;AAMD,eAAO,MAAM,QAAQ,OAZmC,MAAM,WAc5D,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,OAnBiC,MAAM,WAqB5D,CAAC;AAMH,eAAO,MAAM,SAAS,OA3BkC,MAAM,WA6B5D,CAAC;AAEH;;;;;;GAMG;AAuBH;;GAEG;AAWH;;GAEG;AACH,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,GAC/B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAK1B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAQhD;AAID;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,QAE7C;AAED,eAAO,MAAM,IAAI,QAAO,IAAU,CAAA;AAClC;;GAEG;AACH,eAAO,MAAM,EAAE,OAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,YAAU,CAAC;AAIvD;;GAEG;AACH,eAAO,MAAM,QAAQ,MAAO,GAAG,QAAM,CAAC;AAEtC;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,KAAK,CAAC;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAqB,GAC5D,MAAM,CAIR;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAwClD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAKtE;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAUhE;AAGD,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAM1D"}
import { isObject } from './lib/typed';
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
export function makeMap(str, expectsLowerCase) {
const map = Object.create({});
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => map[val.toLowerCase()] : (val) => map[val];
}
/**
* Check if a tag is a built-in tag.
*/
export const isBuiltInTag = makeMap('slot,component', true);
/**
* Check if an attribute is a reserved attribute.
*/
export const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
* Remove an item from an array.
*/
export function remove(arr, item) {
const len = arr.length;
if (len) {
// fast path for the only / last item
if (item === arr[len - 1]) {
arr.length = len - 1;
return;
}
const index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1);
}
}
}
/**
* Check whether an object has the property.
*/
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
}
/**
* Create a cached version of a pure function.
*/
export function cached(fn) {
const cache = Object.create({});
return function cachedFn(str) {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
}
/**
* Camelize a hyphen-delimited string.
*/
const camelizeRE = /-(\w)/g;
export const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
});
/**
* Capitalize a string.
*/
export const capitalize = cached((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
/**
* Hyphenate a camelCase string.
*/
const hyphenateRE = /\B([A-Z])/g;
export const hyphenate = cached((str) => {
return str.replace(hyphenateRE, '-$1').toLowerCase();
});
/**
* Simple bind polyfill for environments that do not support it,
* e.g., PhantomJS 1.x. Technically, we don't need this anymore
* since native bind is now performant enough in most browsers.
* But removing it would mean breaking code that was able to run in
* PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
// function polyfillBind(fn: Function, ctx: Object): Function {
// function boundFn(a: any) {
// const l = arguments.length
// return l
// ? l > 1
// ? fn.apply(ctx, arguments)
// : fn.call(ctx, a)
// : fn.call(ctx)
// }
//
// boundFn._length = fn.length
// return boundFn
// }
// function nativeBind(fn: Function, ctx: Object): Function {
// return fn.bind(ctx)
// }
// export const bind = Function.prototype.bind ? nativeBind : polyfillBind
/**
* Convert an Array-like object to a real Array.
*/
// export function toArray(list: any, start?: number): Array<any> {
// start = start || 0;
// let i = list.length - start;
// const ret: Array<any> = new Array(i);
// while (i--) {
// ret[i] = list[i + start];
// }
// return ret;
// }
/**
* Mix properties into target object.
*/
export function extend(to, _from) {
for (const key in _from) {
to[key] = _from === null || _from === void 0 ? void 0 : _from[key];
}
return to;
}
/**
* Merge an Array of Objects into a single Object.
*/
export function toObject(arr) {
const res = {};
for (let i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res;
}
/* eslint-disable no-unused-vars */
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
export function noop(a, b, c) {
/* empty */
}
export const NOOP = () => { };
/**
* Always return false.
*/
export const no = (a, b, c) => false;
/* eslint-enable no-unused-vars */
/**
* Return the same value.
*/
export const identity = (_) => _;
/**
* Generate a string containing static keys from compiler modules.
*/
export function genStaticKeys(modules) {
return modules
.reduce((keys, m) => keys.concat(m.staticKeys || []), [])
.join(',');
}
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export function looseEqual(a, b) {
if (a === b)
return true;
const isObjectA = isObject(a);
const isObjectB = isObject(b);
if (isObjectA && isObjectB) {
try {
const isArrayA = Array.isArray(a);
const isArrayB = Array.isArray(b);
if (isArrayA && isArrayB) {
return (a.length === b.length &&
a.every((e, i) => {
return looseEqual(e, b[i]);
}));
}
else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime();
}
else if (!isArrayA && !isArrayB) {
const keysA = Object.keys(a);
const keysB = Object.keys(b);
return (keysA.length === keysB.length &&
keysA.every((key) => {
// @ts-ignore
return looseEqual(a[key], b[key]);
}));
}
else {
/* istanbul ignore next */
return false;
}
}
catch (e) {
/* istanbul ignore next */
return false;
}
}
else if (!isObjectA && !isObjectB) {
return String(a) === String(b);
}
else {
return false;
}
}
/**
* Return the first index at which a loosely equal value can be
* found in the array (if value is a plain object, the array must
* contain an object of the same shape), or -1 if it is not present.
*/
export function looseIndexOf(arr, val) {
for (let i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val))
return i;
}
return -1;
}
/**
* Ensure a function is called only once.
*/
export function once(fn) {
let called = false;
return function () {
if (!called) {
called = true;
// @ts-ignore
fn.apply(this, arguments);
}
};
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
export function hasChanged(x, y) {
if (x === y) {
return x === 0 && 1 / x !== 1 / y;
}
else {
return x === x || y === y;
}
}