vdrag-topo-utils 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.d.ts +11 -2
- package/dist/es/index.js +70 -4
- package/dist/es/src/browser.d.ts +135 -0
- package/dist/es/src/browser.js +151 -0
- package/dist/es/src/dom.d.ts +8 -0
- package/dist/es/src/dom.js +25 -0
- package/dist/es/src/http.d.ts +2 -0
- package/dist/es/src/http.js +37 -0
- package/dist/es/src/image.d.ts +10 -0
- package/dist/es/src/image.js +18 -0
- package/dist/es/src/number.d.ts +14 -0
- package/dist/es/src/number.js +14 -0
- package/dist/es/src/object.d.ts +9 -0
- package/dist/es/src/object.js +9 -0
- package/dist/es/src/string.d.ts +68 -0
- package/dist/es/src/string.js +49 -0
- package/dist/es/src/time.d.ts +37 -0
- package/dist/es/src/time.js +38 -0
- package/dist/es/src/type.d.ts +14 -0
- package/dist/es/src/type.js +25 -0
- package/dist/es/src/withinstall.js +7 -0
- package/dist/es/types/index.d.ts +41 -0
- package/dist/es/types/index.js +4 -0
- package/dist/lib/index.d.ts +11 -2
- package/dist/lib/index.js +1 -1
- package/dist/lib/src/browser.d.ts +135 -0
- package/dist/lib/src/browser.js +1 -0
- package/dist/lib/src/dom.d.ts +8 -0
- package/dist/lib/src/dom.js +1 -0
- package/dist/lib/src/http.d.ts +2 -0
- package/dist/lib/src/http.js +1 -0
- package/dist/lib/src/image.d.ts +10 -0
- package/dist/lib/src/image.js +1 -0
- package/dist/lib/src/number.d.ts +14 -0
- package/dist/lib/src/number.js +1 -0
- package/dist/lib/src/object.d.ts +9 -0
- package/dist/lib/src/object.js +1 -0
- package/dist/lib/src/string.d.ts +68 -0
- package/dist/lib/src/string.js +1 -0
- package/dist/lib/src/time.d.ts +37 -0
- package/dist/lib/src/time.js +1 -0
- package/dist/lib/src/type.d.ts +14 -0
- package/dist/lib/src/type.js +1 -0
- package/dist/lib/src/withinstall.js +1 -0
- package/dist/lib/types/index.d.ts +41 -0
- package/dist/lib/types/index.js +1 -0
- package/package.json +7 -6
- package/dist/es/withinstall/index.js +0 -7
- package/dist/lib/withinstall/index.js +0 -1
- /package/dist/es/{bus/index.d.ts → src/bus.d.ts} +0 -0
- /package/dist/es/{bus/index.js → src/bus.js} +0 -0
- /package/dist/es/{withinstall/index.d.ts → src/withinstall.d.ts} +0 -0
- /package/dist/lib/{bus/index.d.ts → src/bus.d.ts} +0 -0
- /package/dist/lib/{bus/index.js → src/bus.js} +0 -0
- /package/dist/lib/{withinstall/index.d.ts → src/withinstall.d.ts} +0 -0
package/dist/es/index.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export { default as withInstall } from "./withinstall";
|
|
2
|
-
export { default as bus } from "./bus";
|
|
1
|
+
export { default as withInstall } from "./src/withinstall";
|
|
2
|
+
export { default as bus } from "./src/bus";
|
|
3
|
+
export * from "./src/browser";
|
|
4
|
+
export * from "./src/string";
|
|
5
|
+
export * from "./src/time";
|
|
6
|
+
export * from "./src/type";
|
|
7
|
+
export * from "./src/object";
|
|
8
|
+
export * from "./src/http";
|
|
9
|
+
export * from "./src/dom";
|
|
10
|
+
export * from "./src/number";
|
|
11
|
+
export * from "./src/image";
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
1
|
+
import { default as r } from "./src/withinstall.js";
|
|
2
|
+
import { default as a } from "./src/bus.js";
|
|
3
|
+
import { UA as l, _global as m, _support as s, addEventListenter as n, customizeSetInterval as p, debounce as d, getClientHeight as g, getGlobal as f, getGlobalSupport as c, getLocationHref as x, getScrollHeight as S, getScrollTop as h, getUrlParam as u, htmlElementAsString as v, inBrowser as D, is360zhushou as E, isAndroid as b, isChrome as T, isEdge as y, isIE as B, isIE9 as I, isIOS as U, isMobile as w, isWeiXin as F, matchUrlFileName as H, nativeTryCatch as _, parseUrlToObj as A, supportsHistory as C, throttle as L, throttle_02 as P } from "./src/browser.js";
|
|
4
|
+
import { addBigBraceToStr as z, addMiddleBraceToStr as G, extractStrFromCurlyBrace as N, extractStrFromMiddleBrace as O, interceptStr as j, unknownToString as k, validateEmail as W, validateFixedPhone as X, validatePhone as q, validateSpecialString_01 as J } from "./src/string.js";
|
|
5
|
+
import { formatDate as Q, formatDate_02 as R, generateUUID as V, getDaysDiffBetweenDates as Y, getDaysDiffFromNow as Z, getTimestamp as $ } from "./src/time.js";
|
|
6
|
+
import { isExistProperty as te, variableTypeDetection as re } from "./src/type.js";
|
|
7
|
+
import { replaceAop as ae } from "./src/object.js";
|
|
8
|
+
import { fromHttpStatus as le } from "./src/http.js";
|
|
9
|
+
import { addEventListener as se, removeEventListener as ne, triggerDragEvent as pe } from "./src/dom.js";
|
|
10
|
+
import { formatDecimal as ge, random as fe } from "./src/number.js";
|
|
11
|
+
import { imgError as xe, preloadImage as Se } from "./src/image.js";
|
|
3
12
|
export {
|
|
4
|
-
l as
|
|
5
|
-
|
|
13
|
+
l as UA,
|
|
14
|
+
m as _global,
|
|
15
|
+
s as _support,
|
|
16
|
+
z as addBigBraceToStr,
|
|
17
|
+
se as addEventListener,
|
|
18
|
+
n as addEventListenter,
|
|
19
|
+
G as addMiddleBraceToStr,
|
|
20
|
+
a as bus,
|
|
21
|
+
p as customizeSetInterval,
|
|
22
|
+
d as debounce,
|
|
23
|
+
N as extractStrFromCurlyBrace,
|
|
24
|
+
O as extractStrFromMiddleBrace,
|
|
25
|
+
Q as formatDate,
|
|
26
|
+
R as formatDate_02,
|
|
27
|
+
ge as formatDecimal,
|
|
28
|
+
le as fromHttpStatus,
|
|
29
|
+
V as generateUUID,
|
|
30
|
+
g as getClientHeight,
|
|
31
|
+
Y as getDaysDiffBetweenDates,
|
|
32
|
+
Z as getDaysDiffFromNow,
|
|
33
|
+
f as getGlobal,
|
|
34
|
+
c as getGlobalSupport,
|
|
35
|
+
x as getLocationHref,
|
|
36
|
+
S as getScrollHeight,
|
|
37
|
+
h as getScrollTop,
|
|
38
|
+
$ as getTimestamp,
|
|
39
|
+
u as getUrlParam,
|
|
40
|
+
v as htmlElementAsString,
|
|
41
|
+
xe as imgError,
|
|
42
|
+
D as inBrowser,
|
|
43
|
+
j as interceptStr,
|
|
44
|
+
E as is360zhushou,
|
|
45
|
+
b as isAndroid,
|
|
46
|
+
T as isChrome,
|
|
47
|
+
y as isEdge,
|
|
48
|
+
te as isExistProperty,
|
|
49
|
+
B as isIE,
|
|
50
|
+
I as isIE9,
|
|
51
|
+
U as isIOS,
|
|
52
|
+
w as isMobile,
|
|
53
|
+
F as isWeiXin,
|
|
54
|
+
H as matchUrlFileName,
|
|
55
|
+
_ as nativeTryCatch,
|
|
56
|
+
A as parseUrlToObj,
|
|
57
|
+
Se as preloadImage,
|
|
58
|
+
fe as random,
|
|
59
|
+
ne as removeEventListener,
|
|
60
|
+
ae as replaceAop,
|
|
61
|
+
C as supportsHistory,
|
|
62
|
+
L as throttle,
|
|
63
|
+
P as throttle_02,
|
|
64
|
+
pe as triggerDragEvent,
|
|
65
|
+
k as unknownToString,
|
|
66
|
+
W as validateEmail,
|
|
67
|
+
X as validateFixedPhone,
|
|
68
|
+
q as validatePhone,
|
|
69
|
+
J as validateSpecialString_01,
|
|
70
|
+
re as variableTypeDetection,
|
|
71
|
+
r as withInstall
|
|
6
72
|
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Callback, Window } from "../types";
|
|
2
|
+
export declare const inBrowser: boolean;
|
|
3
|
+
export declare const UA: any;
|
|
4
|
+
export declare const isIE: any;
|
|
5
|
+
export declare const isIE9: any;
|
|
6
|
+
export declare const isEdge: any;
|
|
7
|
+
export declare const isAndroid: any;
|
|
8
|
+
export declare const isIOS: any;
|
|
9
|
+
export declare const isChrome: any;
|
|
10
|
+
export declare const isWeiXin: any;
|
|
11
|
+
export declare const is360zhushou: any;
|
|
12
|
+
/**
|
|
13
|
+
* 判断是否是移动端
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const isMobile: () => any;
|
|
17
|
+
/**
|
|
18
|
+
* 给节点添加监听事件
|
|
19
|
+
* @param target
|
|
20
|
+
* @param eventName
|
|
21
|
+
* @param handler
|
|
22
|
+
* @param options
|
|
23
|
+
*/
|
|
24
|
+
export declare function addEventListenter(target: any, eventName: string, handler: Callback, options?: boolean): void;
|
|
25
|
+
/**
|
|
26
|
+
* 获取全局事件
|
|
27
|
+
* @returns window
|
|
28
|
+
*/
|
|
29
|
+
export declare function getGlobal(): Window;
|
|
30
|
+
export declare function getGlobalSupport(): {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
export declare const _global: Window;
|
|
34
|
+
export declare const _support: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 原生try函数
|
|
39
|
+
* ../param fn try中执行的函数体
|
|
40
|
+
* ../param errorFn 报错时执行的函数体,将err传入
|
|
41
|
+
* @param fn
|
|
42
|
+
* @param errorFn
|
|
43
|
+
*/
|
|
44
|
+
export declare function nativeTryCatch(fn: any, errorFn?: any): void;
|
|
45
|
+
/**
|
|
46
|
+
* 获取当前页面的URL
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function getLocationHref(): string;
|
|
50
|
+
/**
|
|
51
|
+
* 匹配url中文件的名称
|
|
52
|
+
* http://127.0.0.1:8080/index/index-53807b53.js => index-53807b53.js
|
|
53
|
+
* @param str
|
|
54
|
+
* @param ext
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
export declare function matchUrlFileName(str: string, ext?: string): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* 从URL上获取指定key的值
|
|
60
|
+
* @param keyValue
|
|
61
|
+
* @returns value
|
|
62
|
+
*/
|
|
63
|
+
export declare function getUrlParam(keyValue: string, parseUrl?: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* 解析URL为Obj
|
|
66
|
+
* @param url
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseUrlToObj(url: string): {
|
|
70
|
+
host?: undefined;
|
|
71
|
+
path?: undefined;
|
|
72
|
+
protocol?: undefined;
|
|
73
|
+
relative?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
host: string;
|
|
76
|
+
path: string;
|
|
77
|
+
protocol: string;
|
|
78
|
+
relative: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* html标签转string
|
|
82
|
+
* @param target
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
export declare function htmlElementAsString(target: HTMLElement): string;
|
|
86
|
+
/**
|
|
87
|
+
* 截流函数
|
|
88
|
+
* @param fn
|
|
89
|
+
* @param delay
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
export declare const throttle: (fn: any, delay: number) => (this: any, ...args: any[]) => void;
|
|
93
|
+
/**
|
|
94
|
+
* 防抖函数
|
|
95
|
+
* @param func
|
|
96
|
+
* @param wait
|
|
97
|
+
* @param immediate
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
export declare const debounce: (func: () => void, wait: number, immediate: boolean) => (this: any) => any;
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param func 截流函数
|
|
104
|
+
* @param wait
|
|
105
|
+
* @param options
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
export declare const throttle_02: (func: () => void, wait: number, options: any) => (this: any) => any;
|
|
109
|
+
/**
|
|
110
|
+
* 判断浏览器是否支持History
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
export declare function supportsHistory(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* 获取滚动条位置
|
|
116
|
+
* @return {Number} 滚动条位置
|
|
117
|
+
*/
|
|
118
|
+
export declare const getScrollTop: () => number;
|
|
119
|
+
/**
|
|
120
|
+
* 获取可视范围高度
|
|
121
|
+
* @return {Number} 可视范围高度
|
|
122
|
+
*/
|
|
123
|
+
export declare const getClientHeight: () => number;
|
|
124
|
+
/**
|
|
125
|
+
* 获取文档完整的高度
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
export declare const getScrollHeight: () => number;
|
|
129
|
+
/**
|
|
130
|
+
* 自定义定时器
|
|
131
|
+
* @param callback
|
|
132
|
+
* @param interval
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
export declare function customizeSetInterval(callback: () => void, interval: number): number;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const f = typeof window < "u", r = f && window.navigator.userAgent.toLowerCase(), y = r && /msie|trident/.test(r), w = r && r.indexOf("msie 9.0") > 0, p = r && r.indexOf("edge/") > 0, T = r && r.indexOf("android") > 0, b = r && /iphone|ipad|ipod|ios/.test(r), E = r && /chrome\/\d+/.test(r) && !p, H = r && /micromessenger/.test(r), _ = r && /360appstore/.test(r), x = () => r.match(
|
|
2
|
+
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
3
|
+
);
|
|
4
|
+
function S(t, e, n, o = !1) {
|
|
5
|
+
t.addEventListener(e, n, o);
|
|
6
|
+
}
|
|
7
|
+
function h() {
|
|
8
|
+
return window;
|
|
9
|
+
}
|
|
10
|
+
function g() {
|
|
11
|
+
return m.__vdrag_topo_error__ || {};
|
|
12
|
+
}
|
|
13
|
+
const m = h(), v = g();
|
|
14
|
+
function A(t, e) {
|
|
15
|
+
try {
|
|
16
|
+
t();
|
|
17
|
+
} catch (n) {
|
|
18
|
+
e && e(n);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function O() {
|
|
22
|
+
return typeof document > "u" || document.location == null ? "" : document.location.href;
|
|
23
|
+
}
|
|
24
|
+
function $(t, e = ".js") {
|
|
25
|
+
if (t.endsWith(e))
|
|
26
|
+
return t.substring(t.lastIndexOf("/") + 1);
|
|
27
|
+
}
|
|
28
|
+
function C(t, e = window.location.href) {
|
|
29
|
+
const n = decodeURI(e), o = {}, i = n.split("?").length > 1 ? n.split("?")[1] : null;
|
|
30
|
+
return i ? (i.split("&").forEach(function(c) {
|
|
31
|
+
const [l, a] = c.split("=");
|
|
32
|
+
o[l] = a;
|
|
33
|
+
}), o[t]) : null;
|
|
34
|
+
}
|
|
35
|
+
function D(t) {
|
|
36
|
+
if (!t)
|
|
37
|
+
return {};
|
|
38
|
+
const e = t.match(
|
|
39
|
+
// eslint-disable-next-line no-useless-escape
|
|
40
|
+
/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/
|
|
41
|
+
);
|
|
42
|
+
if (!e)
|
|
43
|
+
return {};
|
|
44
|
+
const n = e[6] || "", o = e[8] || "";
|
|
45
|
+
return {
|
|
46
|
+
host: e[4],
|
|
47
|
+
path: e[5],
|
|
48
|
+
protocol: e[2],
|
|
49
|
+
relative: e[5] + n + o
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function I(t) {
|
|
53
|
+
const e = t.tagName.toLowerCase();
|
|
54
|
+
if (e === "body")
|
|
55
|
+
return "";
|
|
56
|
+
let n = t.classList.value;
|
|
57
|
+
n = n !== "" ? ` class='${n}'` : "";
|
|
58
|
+
const o = t.id ? ` id="${t.id}"` : "", i = t.innerText;
|
|
59
|
+
return `<${e}${o}${n !== "" ? n : ""}>${i}</${e}>`;
|
|
60
|
+
}
|
|
61
|
+
const M = (t, e) => {
|
|
62
|
+
let n = !0;
|
|
63
|
+
return function(...o) {
|
|
64
|
+
n && (t.apply(this, o), n = !1, setTimeout(() => {
|
|
65
|
+
n = !0;
|
|
66
|
+
}, e));
|
|
67
|
+
};
|
|
68
|
+
}, B = function(t, e, n) {
|
|
69
|
+
let o, i, s, c, l;
|
|
70
|
+
const a = function() {
|
|
71
|
+
const u = (/* @__PURE__ */ new Date()).getTime() - c;
|
|
72
|
+
u < e && u >= 0 ? o = setTimeout(a, e - u) : (o = null, n || (l = t.apply(s, i), o || (s = i = null)));
|
|
73
|
+
};
|
|
74
|
+
return function() {
|
|
75
|
+
s = this, i = arguments, c = (/* @__PURE__ */ new Date()).getTime();
|
|
76
|
+
const u = n && !o;
|
|
77
|
+
return o || (o = setTimeout(a, e)), u && (l = t.apply(s, i), s = i = null), l;
|
|
78
|
+
};
|
|
79
|
+
}, L = function(t, e, n) {
|
|
80
|
+
let o, i, s, c = null, l = 0;
|
|
81
|
+
n || (n = {});
|
|
82
|
+
const a = function() {
|
|
83
|
+
l = n.leading === !1 ? 0 : (/* @__PURE__ */ new Date()).getTime(), c = null, s = t.apply(o, i), c || (o = i = null);
|
|
84
|
+
};
|
|
85
|
+
return function() {
|
|
86
|
+
const u = (/* @__PURE__ */ new Date()).getTime();
|
|
87
|
+
!l && n.leading === !1 && (l = u);
|
|
88
|
+
const d = e - (u - l);
|
|
89
|
+
return o = this, i = arguments, d <= 0 || d > e ? (c && (clearTimeout(c), c = null), l = u, s = t.apply(o, i), c || (o = i = null)) : !c && n.trailing !== !1 && (c = setTimeout(a, d)), s;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
function N() {
|
|
93
|
+
const t = m.chrome, e = t && t.app && t.app.runtime, n = "history" in m && !!m.history.pushState && !!m.history.replaceState;
|
|
94
|
+
return !e && n;
|
|
95
|
+
}
|
|
96
|
+
const P = () => {
|
|
97
|
+
let t = 0;
|
|
98
|
+
return document.documentElement && document.documentElement.scrollTop ? t = document.documentElement.scrollTop : document.body && (t = document.body.scrollTop), t;
|
|
99
|
+
}, U = () => {
|
|
100
|
+
let t = 0;
|
|
101
|
+
return document.body.clientHeight && document.documentElement.clientHeight ? t = Math.min(
|
|
102
|
+
document.body.clientHeight,
|
|
103
|
+
document.documentElement.clientHeight
|
|
104
|
+
) : t = Math.max(
|
|
105
|
+
document.body.clientHeight,
|
|
106
|
+
document.documentElement.clientHeight
|
|
107
|
+
), t;
|
|
108
|
+
}, W = () => Math.max(
|
|
109
|
+
document.body.scrollHeight,
|
|
110
|
+
document.documentElement.scrollHeight
|
|
111
|
+
);
|
|
112
|
+
function k(t, e) {
|
|
113
|
+
let n = Date.now(), o = 0;
|
|
114
|
+
const i = () => {
|
|
115
|
+
let s = Date.now();
|
|
116
|
+
s - n >= e && (n = s = Date.now(), t()), cancelAnimationFrame(o), o = window.requestAnimationFrame(i);
|
|
117
|
+
};
|
|
118
|
+
return i(), o;
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
r as UA,
|
|
122
|
+
m as _global,
|
|
123
|
+
v as _support,
|
|
124
|
+
S as addEventListenter,
|
|
125
|
+
k as customizeSetInterval,
|
|
126
|
+
B as debounce,
|
|
127
|
+
U as getClientHeight,
|
|
128
|
+
h as getGlobal,
|
|
129
|
+
g as getGlobalSupport,
|
|
130
|
+
O as getLocationHref,
|
|
131
|
+
W as getScrollHeight,
|
|
132
|
+
P as getScrollTop,
|
|
133
|
+
C as getUrlParam,
|
|
134
|
+
I as htmlElementAsString,
|
|
135
|
+
f as inBrowser,
|
|
136
|
+
_ as is360zhushou,
|
|
137
|
+
T as isAndroid,
|
|
138
|
+
E as isChrome,
|
|
139
|
+
p as isEdge,
|
|
140
|
+
y as isIE,
|
|
141
|
+
w as isIE9,
|
|
142
|
+
b as isIOS,
|
|
143
|
+
x as isMobile,
|
|
144
|
+
H as isWeiXin,
|
|
145
|
+
$ as matchUrlFileName,
|
|
146
|
+
A as nativeTryCatch,
|
|
147
|
+
D as parseUrlToObj,
|
|
148
|
+
N as supportsHistory,
|
|
149
|
+
M as throttle,
|
|
150
|
+
L as throttle_02
|
|
151
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface DragEventOptions {
|
|
2
|
+
drag?: (event: Event) => void;
|
|
3
|
+
start?: (event: Event) => void;
|
|
4
|
+
end?: (event: Event) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function triggerDragEvent(element: HTMLElement, options: DragEventOptions): void;
|
|
7
|
+
export declare function removeEventListener(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
8
|
+
export declare function addEventListener(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function f(r, e) {
|
|
2
|
+
let u = !1;
|
|
3
|
+
const n = function(a) {
|
|
4
|
+
var t;
|
|
5
|
+
(t = e.drag) == null || t.call(e, a);
|
|
6
|
+
}, m = (a) => {
|
|
7
|
+
var t;
|
|
8
|
+
d(document, "mousemove", n), d(document, "mouseup", m), document.onselectstart = null, document.ondragstart = null, u = !1, (t = e.end) == null || t.call(e, a);
|
|
9
|
+
};
|
|
10
|
+
c(r, "mousedown", (a) => {
|
|
11
|
+
var t;
|
|
12
|
+
u || (document.onselectstart = () => !1, document.ondragstart = () => !1, c(document, "mousemove", n), c(document, "mouseup", m), u = !0, (t = e.start) == null || t.call(e, a));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function d(r, e, u, n = !1) {
|
|
16
|
+
r && e && u && r.removeEventListener(e, u, n);
|
|
17
|
+
}
|
|
18
|
+
function c(r, e, u, n = !1) {
|
|
19
|
+
r && e && u && r.addEventListener(e, u, n);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
c as addEventListener,
|
|
23
|
+
d as removeEventListener,
|
|
24
|
+
f as triggerDragEvent
|
|
25
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { SpanStatus } from "../types/index";
|
|
2
|
+
export declare function fromHttpStatus(httpStatus: any): SpanStatus.Ok | SpanStatus.DeadlineExceeded | SpanStatus.Unauthenticated | SpanStatus.PermissionDenied | SpanStatus.NotFound | SpanStatus.ResourceExhausted | SpanStatus.InvalidArgument | SpanStatus.Unimplemented | SpanStatus.Unavailable | SpanStatus.InternalError | SpanStatus.UnknownError | SpanStatus.AlreadyExists | SpanStatus.FailedPrecondition;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SpanStatus as e } from "../types/index.js";
|
|
2
|
+
function a(r) {
|
|
3
|
+
if (r < 400)
|
|
4
|
+
return e.Ok;
|
|
5
|
+
if (r >= 400 && r < 500)
|
|
6
|
+
switch (r) {
|
|
7
|
+
case 401:
|
|
8
|
+
return e.Unauthenticated;
|
|
9
|
+
case 403:
|
|
10
|
+
return e.PermissionDenied;
|
|
11
|
+
case 404:
|
|
12
|
+
return e.NotFound;
|
|
13
|
+
case 409:
|
|
14
|
+
return e.AlreadyExists;
|
|
15
|
+
case 413:
|
|
16
|
+
return e.FailedPrecondition;
|
|
17
|
+
case 429:
|
|
18
|
+
return e.ResourceExhausted;
|
|
19
|
+
default:
|
|
20
|
+
return e.InvalidArgument;
|
|
21
|
+
}
|
|
22
|
+
if (r >= 500 && r < 600)
|
|
23
|
+
switch (r) {
|
|
24
|
+
case 501:
|
|
25
|
+
return e.Unimplemented;
|
|
26
|
+
case 503:
|
|
27
|
+
return e.Unavailable;
|
|
28
|
+
case 504:
|
|
29
|
+
return e.DeadlineExceeded;
|
|
30
|
+
default:
|
|
31
|
+
return e.InternalError;
|
|
32
|
+
}
|
|
33
|
+
return e.UnknownError;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
a as fromHttpStatus
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function e(n, r) {
|
|
2
|
+
const o = n.target;
|
|
3
|
+
o.src = r, o.onerror = null;
|
|
4
|
+
}
|
|
5
|
+
const t = (n, r) => {
|
|
6
|
+
const o = new Image();
|
|
7
|
+
if (o.src = n, o.complete) {
|
|
8
|
+
r && r.call(o);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
o.onload = function() {
|
|
12
|
+
r && r.call(o);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
e as imgError,
|
|
17
|
+
t as preloadImage
|
|
18
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 保留指定位数的小数
|
|
3
|
+
* @param num 原数据
|
|
4
|
+
* @param decimal 小数位数
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatDecimal(num: number, decimal: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* 生成指定范围(包含min, 不包含max)的随机整数
|
|
10
|
+
* @param min
|
|
11
|
+
* @param max
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function random(min: number, max: number): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function o(t, n) {
|
|
2
|
+
if (!t)
|
|
3
|
+
return t;
|
|
4
|
+
let r = t.toString();
|
|
5
|
+
const e = r.indexOf(".");
|
|
6
|
+
return e !== -1 ? r = r.substring(0, n + e + 1) : r = r.substring(0), parseFloat(r);
|
|
7
|
+
}
|
|
8
|
+
function i(t, n) {
|
|
9
|
+
return Math.floor(Math.random() * (n - t)) + t;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
o as formatDecimal,
|
|
13
|
+
i as random
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAnyObject, Callback } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 重写对象上的某个方法
|
|
4
|
+
* @param source 需要重写的对象
|
|
5
|
+
* @param name 被重写对象的属性名
|
|
6
|
+
* @param replacementFactory 以原有的函数作为参数,执行并重写原有函数
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function replaceAop(source: IAnyObject, name: string, replacementFactory: Callback, isForced?: boolean): void;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unknown转成自负出啊
|
|
3
|
+
* @param target
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export declare function unknownToString(target: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* 截取字符串
|
|
9
|
+
* @param str
|
|
10
|
+
* @param interceptLength
|
|
11
|
+
* @returns string
|
|
12
|
+
*/
|
|
13
|
+
export declare function interceptStr(str: string, interceptLength: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* 从${}中提取内部的字符串以及外部的字符串
|
|
16
|
+
* ${test[0]}˚C=> {str1: 'test[0]', str2: '˚C'};
|
|
17
|
+
* @param str
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractStrFromCurlyBrace(str: string): {
|
|
21
|
+
str1: string;
|
|
22
|
+
str2: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 提取[]内的字符串,不包含[]
|
|
26
|
+
* ${test["000"]["111"]} => ["000", "111"]
|
|
27
|
+
* @param str
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractStrFromMiddleBrace(str: string): RegExpMatchArray | [];
|
|
31
|
+
/**
|
|
32
|
+
* 给字符串添加中括号
|
|
33
|
+
* "test" => ["test"]
|
|
34
|
+
* @param str
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function addMiddleBraceToStr(str: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 给字符串添加大括号
|
|
40
|
+
* @param str
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function addBigBraceToStr(str: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* 邮箱校验
|
|
46
|
+
* @param str
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateEmail(str: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 验证固定电话
|
|
52
|
+
* @param num
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function validatePhone(str: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 验证固定电话
|
|
58
|
+
* @param str
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
export declare function validateFixedPhone(str: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 校验特殊的字符串
|
|
64
|
+
* 字符串以字母、数字、下划线组成,且以数字和字母开头、且不超过20个字
|
|
65
|
+
* @param str
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateSpecialString_01(str: string): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { variableTypeDetection as e } from "./type.js";
|
|
2
|
+
function u(r) {
|
|
3
|
+
return e.isString(r) ? r : e.isUndefined(r) ? "undefined" : JSON.stringify(r);
|
|
4
|
+
}
|
|
5
|
+
function s(r, n) {
|
|
6
|
+
return e.isString(r) ? r.slice(0, n) + (r.length > n ? `:截取前${n}个字符` : "") : "";
|
|
7
|
+
}
|
|
8
|
+
function d(r) {
|
|
9
|
+
if (!r)
|
|
10
|
+
return { str1: "", str2: "" };
|
|
11
|
+
const t = /\$?\{?([\w\[\]\"\'\-]+)\}?/.exec(r) || [], i = r.indexOf("}"), o = i < 0 ? "" : r.slice(i + 1);
|
|
12
|
+
return { str1: t[1], str2: o };
|
|
13
|
+
}
|
|
14
|
+
function a(r) {
|
|
15
|
+
const n = new RegExp("(?<=\\[)(.+?)(?=\\])", "g");
|
|
16
|
+
return r.match(n) || [];
|
|
17
|
+
}
|
|
18
|
+
function f(r) {
|
|
19
|
+
return r === void 0 ? r : `["${r}"]`;
|
|
20
|
+
}
|
|
21
|
+
function l(r) {
|
|
22
|
+
return r === void 0 ? r : `\${${r}}`;
|
|
23
|
+
}
|
|
24
|
+
function S(r) {
|
|
25
|
+
return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
|
|
26
|
+
r
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function $(r) {
|
|
30
|
+
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(r);
|
|
31
|
+
}
|
|
32
|
+
function v(r) {
|
|
33
|
+
return /\d{2,5}-\d{7,8}/.test(r);
|
|
34
|
+
}
|
|
35
|
+
function x(r) {
|
|
36
|
+
return /^[a-zA-Z][a-zA-Z0-9_]{1,20}$/.test(r);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
l as addBigBraceToStr,
|
|
40
|
+
f as addMiddleBraceToStr,
|
|
41
|
+
d as extractStrFromCurlyBrace,
|
|
42
|
+
a as extractStrFromMiddleBrace,
|
|
43
|
+
s as interceptStr,
|
|
44
|
+
u as unknownToString,
|
|
45
|
+
S as validateEmail,
|
|
46
|
+
v as validateFixedPhone,
|
|
47
|
+
$ as validatePhone,
|
|
48
|
+
x as validateSpecialString_01
|
|
49
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 返回当前时间的时间戳
|
|
3
|
+
* @returns timeStamp
|
|
4
|
+
*/
|
|
5
|
+
export declare function getTimestamp(): number;
|
|
6
|
+
/**
|
|
7
|
+
* 格式化日期时间为指定的格式
|
|
8
|
+
* @param {string} format
|
|
9
|
+
* @param {number} timestamp - 时间戳
|
|
10
|
+
* @return {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare const formatDate: (format?: string, timestamp?: number) => string;
|
|
13
|
+
/**
|
|
14
|
+
* 时间格式化为两位数
|
|
15
|
+
* @author beth
|
|
16
|
+
* @DateTime 2020-05-22
|
|
17
|
+
* @return {Number} s
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatDate_02: (str: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* 生成UUID
|
|
22
|
+
* @return {string} {string}
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateUUID(): string;
|
|
25
|
+
/**
|
|
26
|
+
* 计算传入的日期距离当前时间剩余的天数
|
|
27
|
+
* @param date
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function getDaysDiffFromNow(date: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* 计算传入的两个日期间差的天数
|
|
33
|
+
* @param dateInitial
|
|
34
|
+
* @param dateFinal
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare const getDaysDiffBetweenDates: (dateInitial: number, dateFinal: number) => number;
|