vdrag-topo-utils 1.0.3 → 1.2.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.
Files changed (55) hide show
  1. package/dist/es/index.d.ts +11 -2
  2. package/dist/es/index.js +69 -4
  3. package/dist/es/src/browser.d.ts +127 -0
  4. package/dist/es/src/browser.js +147 -0
  5. package/dist/es/src/dom.d.ts +8 -0
  6. package/dist/es/src/dom.js +25 -0
  7. package/dist/es/src/http.d.ts +5 -0
  8. package/dist/es/src/http.js +37 -0
  9. package/dist/es/src/image.d.ts +12 -0
  10. package/dist/es/src/image.js +18 -0
  11. package/dist/es/src/number.d.ts +14 -0
  12. package/dist/es/src/number.js +14 -0
  13. package/dist/es/src/object.d.ts +9 -0
  14. package/dist/es/src/object.js +9 -0
  15. package/dist/es/src/string.d.ts +68 -0
  16. package/dist/es/src/string.js +49 -0
  17. package/dist/es/src/time.d.ts +37 -0
  18. package/dist/es/src/time.js +38 -0
  19. package/dist/es/src/type.d.ts +17 -0
  20. package/dist/es/src/type.js +25 -0
  21. package/dist/es/src/withinstall.js +7 -0
  22. package/dist/es/types/index.d.ts +41 -0
  23. package/dist/es/types/index.js +4 -0
  24. package/dist/lib/index.d.ts +11 -2
  25. package/dist/lib/index.js +1 -1
  26. package/dist/lib/src/browser.d.ts +127 -0
  27. package/dist/lib/src/browser.js +1 -0
  28. package/dist/lib/src/dom.d.ts +8 -0
  29. package/dist/lib/src/dom.js +1 -0
  30. package/dist/lib/src/http.d.ts +5 -0
  31. package/dist/lib/src/http.js +1 -0
  32. package/dist/lib/src/image.d.ts +12 -0
  33. package/dist/lib/src/image.js +1 -0
  34. package/dist/lib/src/number.d.ts +14 -0
  35. package/dist/lib/src/number.js +1 -0
  36. package/dist/lib/src/object.d.ts +9 -0
  37. package/dist/lib/src/object.js +1 -0
  38. package/dist/lib/src/string.d.ts +68 -0
  39. package/dist/lib/src/string.js +1 -0
  40. package/dist/lib/src/time.d.ts +37 -0
  41. package/dist/lib/src/time.js +1 -0
  42. package/dist/lib/src/type.d.ts +17 -0
  43. package/dist/lib/src/type.js +1 -0
  44. package/dist/lib/src/withinstall.js +1 -0
  45. package/dist/lib/types/index.d.ts +41 -0
  46. package/dist/lib/types/index.js +1 -0
  47. package/package.json +7 -6
  48. package/dist/es/withinstall/index.js +0 -7
  49. package/dist/lib/withinstall/index.js +0 -1
  50. /package/dist/es/{bus/index.d.ts → src/bus.d.ts} +0 -0
  51. /package/dist/es/{bus/index.js → src/bus.js} +0 -0
  52. /package/dist/es/{withinstall/index.d.ts → src/withinstall.d.ts} +0 -0
  53. /package/dist/lib/{bus/index.d.ts → src/bus.d.ts} +0 -0
  54. /package/dist/lib/{bus/index.js → src/bus.js} +0 -0
  55. /package/dist/lib/{withinstall/index.d.ts → src/withinstall.d.ts} +0 -0
@@ -0,0 +1,38 @@
1
+ function c() {
2
+ return Date.now();
3
+ }
4
+ const D = (e = Date.now(), a = "Y-M-D h:m:s") => {
5
+ const n = new Date(e || Date.now()), t = {
6
+ Y: `${n.getFullYear()}`,
7
+ M: `${n.getMonth() + 1}`,
8
+ D: `${n.getDate()}`,
9
+ h: n.getHours(),
10
+ m: n.getMinutes(),
11
+ s: n.getSeconds()
12
+ }, o = (r) => r > 10 ? r : "0" + r;
13
+ return (a || "Y-M-D h:m:s").replace("Y", t.Y).replace("M", t.M).replace("D", t.D).replace("h", o(t.h)).replace("m", o(t.m)).replace("s", o(t.s));
14
+ }, s = (e) => Number(e) >= 10 ? e : "0" + e;
15
+ function u() {
16
+ let e = (/* @__PURE__ */ new Date()).getTime();
17
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
18
+ /[xy]/g,
19
+ function(n) {
20
+ const t = (e + Math.random() * 16) % 16 | 0;
21
+ return e = Math.floor(e / 16), (n == "x" ? t : t & 3 | 8).toString(16);
22
+ }
23
+ );
24
+ }
25
+ function m(e) {
26
+ const a = /* @__PURE__ */ new Date();
27
+ let t = new Date(e).getTime() - a.getTime();
28
+ return t <= 0 && (t = 0), Math.ceil(t / (60 * 60 * 24 * 1e3));
29
+ }
30
+ const i = (e, a) => (a - e) / (1e3 * 3600 * 24);
31
+ export {
32
+ D as formatDate,
33
+ s as formatDate_02,
34
+ u as generateUUID,
35
+ i as getDaysDiffBetweenDates,
36
+ m as getDaysDiffFromNow,
37
+ c as getTimestamp
38
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 判断变量的类型
3
+ */
4
+ export declare const variableTypeDetection: {
5
+ isNumber: (value: any) => boolean;
6
+ isString: (value: any) => boolean;
7
+ isBoolean: (value: any) => boolean;
8
+ isNull: (value: any) => boolean;
9
+ isUndefined: (value: any) => boolean;
10
+ isSymbol: (value: any) => boolean;
11
+ isFunction: (value: any) => boolean;
12
+ isObject: (value: any) => boolean;
13
+ isArray: (value: any) => boolean;
14
+ isProcess: (value: any) => boolean;
15
+ isWindow: (value: any) => boolean;
16
+ };
17
+ export declare function isExistProperty(obj: any, key: any): boolean;
@@ -0,0 +1,25 @@
1
+ const n = {
2
+ isNumber: e("Number"),
3
+ isString: e("String"),
4
+ isBoolean: e("Boolean"),
5
+ isNull: e("Null"),
6
+ isUndefined: e("Undefined"),
7
+ isSymbol: e("Symbol"),
8
+ isFunction: e("Function"),
9
+ isObject: e("Object"),
10
+ isArray: e("Array"),
11
+ isProcess: e("process"),
12
+ isWindow: e("Window")
13
+ };
14
+ function e(i) {
15
+ return function(t) {
16
+ return Object.prototype.toString.call(t) === `[object ${i}]`;
17
+ };
18
+ }
19
+ function o(i, t) {
20
+ return Object.prototype.hasOwnProperty.call(i, t);
21
+ }
22
+ export {
23
+ o as isExistProperty,
24
+ n as variableTypeDetection
25
+ };
@@ -0,0 +1,7 @@
1
+ const e = (n) => (n.install = (t) => {
2
+ const a = n.name || n.__name;
3
+ t.component(a, n);
4
+ }, n);
5
+ export {
6
+ e as default
7
+ };
@@ -0,0 +1,41 @@
1
+ export interface Callback {
2
+ (...args: any[]): any;
3
+ }
4
+ export interface IAnyObject {
5
+ [key: string]: any;
6
+ }
7
+ export interface Window {
8
+ chrome: {
9
+ app: {
10
+ [key: string]: any;
11
+ };
12
+ };
13
+ history: any;
14
+ addEventListener: any;
15
+ innerWidth: any;
16
+ innerHeight: any;
17
+ onpopstate: any;
18
+ performance: any;
19
+ __vdrag_topo_error__: {
20
+ [key: string]: any;
21
+ };
22
+ }
23
+ export declare enum SpanStatus {
24
+ Ok = "ok",
25
+ DeadlineExceeded = "deadline_exceeded",
26
+ Unauthenticated = "unauthenticated",
27
+ PermissionDenied = "permission_denied",
28
+ NotFound = "not_found",
29
+ ResourceExhausted = "resource_exhausted",
30
+ InvalidArgument = "invalid_argument",
31
+ Unimplemented = "unimplemented",
32
+ Unavailable = "unavailable",
33
+ InternalError = "internal_error",
34
+ UnknownError = "unknown_error",
35
+ Cancelled = "cancelled",
36
+ AlreadyExists = "already_exists",
37
+ FailedPrecondition = "failed_precondition",
38
+ Aborted = "aborted",
39
+ OutOfRange = "out_of_range",
40
+ DataLoss = "data_loss"
41
+ }
@@ -0,0 +1,4 @@
1
+ var r = /* @__PURE__ */ ((e) => (e.Ok = "ok", e.DeadlineExceeded = "deadline_exceeded", e.Unauthenticated = "unauthenticated", e.PermissionDenied = "permission_denied", e.NotFound = "not_found", e.ResourceExhausted = "resource_exhausted", e.InvalidArgument = "invalid_argument", e.Unimplemented = "unimplemented", e.Unavailable = "unavailable", e.InternalError = "internal_error", e.UnknownError = "unknown_error", e.Cancelled = "cancelled", e.AlreadyExists = "already_exists", e.FailedPrecondition = "failed_precondition", e.Aborted = "aborted", e.OutOfRange = "out_of_range", e.DataLoss = "data_loss", e))(r || {});
2
+ export {
3
+ r as SpanStatus
4
+ };
@@ -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/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./withinstall/index.js"),t=require("./bus/index.js");exports.withInstall=e;exports.bus=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./src/withinstall.js"),n=require("./src/bus.js"),e=require("./src/browser.js"),t=require("./src/string.js"),r=require("./src/time.js"),a=require("./src/type.js"),g=require("./src/object.js"),c=require("./src/http.js"),i=require("./src/dom.js"),o=require("./src/number.js"),l=require("./src/image.js");exports.withInstall=s;exports.bus=n;exports.UA=e.UA;exports._global=e._global;exports._support=e._support;exports.customizeSetInterval=e.customizeSetInterval;exports.debounce=e.debounce;exports.getClientHeight=e.getClientHeight;exports.getGlobal=e.getGlobal;exports.getGlobalSupport=e.getGlobalSupport;exports.getLocationHref=e.getLocationHref;exports.getScrollHeight=e.getScrollHeight;exports.getScrollTop=e.getScrollTop;exports.getUrlParam=e.getUrlParam;exports.htmlElementAsString=e.htmlElementAsString;exports.inBrowser=e.inBrowser;exports.is360zhushou=e.is360zhushou;exports.isAndroid=e.isAndroid;exports.isChrome=e.isChrome;exports.isEdge=e.isEdge;exports.isIE=e.isIE;exports.isIE9=e.isIE9;exports.isIOS=e.isIOS;exports.isMobile=e.isMobile;exports.isWeiXin=e.isWeiXin;exports.matchUrlFileName=e.matchUrlFileName;exports.nativeTryCatch=e.nativeTryCatch;exports.parseUrlToObj=e.parseUrlToObj;exports.supportsHistory=e.supportsHistory;exports.throttle=e.throttle;exports.throttle_02=e.throttle_02;exports.addBigBraceToStr=t.addBigBraceToStr;exports.addMiddleBraceToStr=t.addMiddleBraceToStr;exports.extractStrFromCurlyBrace=t.extractStrFromCurlyBrace;exports.extractStrFromMiddleBrace=t.extractStrFromMiddleBrace;exports.interceptStr=t.interceptStr;exports.unknownToString=t.unknownToString;exports.validateEmail=t.validateEmail;exports.validateFixedPhone=t.validateFixedPhone;exports.validatePhone=t.validatePhone;exports.validateSpecialString_01=t.validateSpecialString_01;exports.formatDate=r.formatDate;exports.formatDate_02=r.formatDate_02;exports.generateUUID=r.generateUUID;exports.getDaysDiffBetweenDates=r.getDaysDiffBetweenDates;exports.getDaysDiffFromNow=r.getDaysDiffFromNow;exports.getTimestamp=r.getTimestamp;exports.isExistProperty=a.isExistProperty;exports.variableTypeDetection=a.variableTypeDetection;exports.replaceAop=g.replaceAop;exports.fromHttpStatus=c.fromHttpStatus;exports.addEventListener=i.addEventListener;exports.removeEventListener=i.removeEventListener;exports.triggerDragEvent=i.triggerDragEvent;exports.formatDecimal=o.formatDecimal;exports.random=o.random;exports.imgError=l.imgError;exports.preloadImage=l.preloadImage;
@@ -0,0 +1,127 @@
1
+ import { 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
+ * @returns window
20
+ */
21
+ export declare function getGlobal(): Window;
22
+ export declare function getGlobalSupport(): {
23
+ [key: string]: any;
24
+ };
25
+ export declare const _global: Window;
26
+ export declare const _support: {
27
+ [key: string]: any;
28
+ };
29
+ /**
30
+ * 原生try函数
31
+ * ../param fn try中执行的函数体
32
+ * ../param errorFn 报错时执行的函数体,将err传入
33
+ * @param fn
34
+ * @param errorFn
35
+ */
36
+ export declare function nativeTryCatch(fn: any, errorFn?: any): void;
37
+ /**
38
+ * 获取当前页面的URL
39
+ * @returns
40
+ */
41
+ export declare function getLocationHref(): string;
42
+ /**
43
+ * 匹配url中文件的名称
44
+ * http://127.0.0.1:8080/index/index-53807b53.js => index-53807b53.js
45
+ * @param str
46
+ * @param ext
47
+ * @returns
48
+ */
49
+ export declare function matchUrlFileName(str: string, ext?: string): string | undefined;
50
+ /**
51
+ * 从URL上获取指定key的值
52
+ * @param keyValue
53
+ * @returns value
54
+ */
55
+ export declare function getUrlParam(keyValue: string, parseUrl?: string): string | null;
56
+ /**
57
+ * 解析URL为Obj
58
+ * @param url
59
+ * @returns
60
+ */
61
+ export declare function parseUrlToObj(url: string): {
62
+ host?: undefined;
63
+ path?: undefined;
64
+ protocol?: undefined;
65
+ relative?: undefined;
66
+ } | {
67
+ host: string;
68
+ path: string;
69
+ protocol: string;
70
+ relative: string;
71
+ };
72
+ /**
73
+ * html标签转string
74
+ * @param target
75
+ * @returns
76
+ */
77
+ export declare function htmlElementAsString(target: HTMLElement): string;
78
+ /**
79
+ * 截流函数
80
+ * @param fn
81
+ * @param delay
82
+ * @returns
83
+ */
84
+ export declare const throttle: (fn: any, delay: number) => (this: any, ...args: any[]) => void;
85
+ /**
86
+ * 防抖函数
87
+ * @param func
88
+ * @param wait
89
+ * @param immediate
90
+ * @returns
91
+ */
92
+ export declare const debounce: (func: () => void, wait: number, immediate: boolean) => (this: any) => any;
93
+ /**
94
+ *
95
+ * @param func 截流函数
96
+ * @param wait
97
+ * @param options
98
+ * @returns
99
+ */
100
+ export declare const throttle_02: (func: () => void, wait: number, options: any) => (this: any) => any;
101
+ /**
102
+ * 判断浏览器是否支持History
103
+ * @returns
104
+ */
105
+ export declare function supportsHistory(): boolean;
106
+ /**
107
+ * 获取滚动条位置
108
+ * @return {Number} 滚动条位置
109
+ */
110
+ export declare const getScrollTop: () => number;
111
+ /**
112
+ * 获取可视范围高度
113
+ * @return {Number} 可视范围高度
114
+ */
115
+ export declare const getClientHeight: () => number;
116
+ /**
117
+ * 获取文档完整的高度
118
+ * @returns
119
+ */
120
+ export declare const getScrollHeight: () => number;
121
+ /**
122
+ * 自定义定时器
123
+ * @param callback
124
+ * @param interval
125
+ * @returns
126
+ */
127
+ export declare function customizeSetInterval(callback: () => void, interval: number): number;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=typeof window<"u",r=f&&window.navigator.userAgent.toLowerCase(),y=r&&/msie|trident/.test(r),b=r&&r.indexOf("msie 9.0")>0,h=r&&r.indexOf("edge/")>0,w=r&&r.indexOf("android")>0,T=r&&/iphone|ipad|ipod|ios/.test(r),S=r&&/chrome\/\d+/.test(r)&&!h,H=r&&/micromessenger/.test(r),E=r&&/360appstore/.test(r),_=()=>r.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);function p(){return window}function g(){return m.__vdrag_topo_error__||{}}const m=p(),A=g();function v(t,e){try{t()}catch(n){e&&e(n)}}function I(){return typeof document>"u"||document.location==null?"":document.location.href}function O(t,e=".js"){if(t.endsWith(e))return t.substring(t.lastIndexOf("/")+1)}function x(t,e=window.location.href){const n=decodeURI(e),o={},i=n.split("?").length>1?n.split("?")[1]:null;return i?(i.split("&").forEach(function(s){const[c,a]=s.split("=");o[c]=a}),o[t]):null}function C(t){if(!t)return{};const e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};const n=e[6]||"",o=e[8]||"";return{host:e[4],path:e[5],protocol:e[2],relative:e[5]+n+o}}function U(t){const e=t.tagName.toLowerCase();if(e==="body")return"";let n=t.classList.value;n=n!==""?` class='${n}'`:"";const o=t.id?` id="${t.id}"`:"",i=t.innerText;return`<${e}${o}${n!==""?n:""}>${i}</${e}>`}const M=(t,e)=>{let n=!0;return function(...o){n&&(t.apply(this,o),n=!1,setTimeout(()=>{n=!0},e))}},P=function(t,e,n){let o,i,l,s,c;const a=function(){const u=new Date().getTime()-s;u<e&&u>=0?o=setTimeout(a,e-u):(o=null,n||(c=t.apply(l,i),o||(l=i=null)))};return function(){l=this,i=arguments,s=new Date().getTime();const u=n&&!o;return o||(o=setTimeout(a,e)),u&&(c=t.apply(l,i),l=i=null),c}},$=function(t,e,n){let o,i,l,s=null,c=0;n||(n={});const a=function(){c=n.leading===!1?0:new Date().getTime(),s=null,l=t.apply(o,i),s||(o=i=null)};return function(){const u=new Date().getTime();!c&&n.leading===!1&&(c=u);const d=e-(u-c);return o=this,i=arguments,d<=0||d>e?(s&&(clearTimeout(s),s=null),c=u,l=t.apply(o,i),s||(o=i=null)):!s&&n.trailing!==!1&&(s=setTimeout(a,d)),l}};function B(){const t=m.chrome,e=t&&t.app&&t.app.runtime,n="history"in m&&!!m.history.pushState&&!!m.history.replaceState;return!e&&n}const D=()=>{let t=0;return document.documentElement&&document.documentElement.scrollTop?t=document.documentElement.scrollTop:document.body&&(t=document.body.scrollTop),t},N=()=>{let t=0;return document.body.clientHeight&&document.documentElement.clientHeight?t=Math.min(document.body.clientHeight,document.documentElement.clientHeight):t=Math.max(document.body.clientHeight,document.documentElement.clientHeight),t},G=()=>Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);function L(t,e){let n=Date.now(),o=0;const i=()=>{let l=Date.now();l-n>=e&&(n=l=Date.now(),t()),cancelAnimationFrame(o),o=window.requestAnimationFrame(i)};return i(),o}exports.UA=r;exports._global=m;exports._support=A;exports.customizeSetInterval=L;exports.debounce=P;exports.getClientHeight=N;exports.getGlobal=p;exports.getGlobalSupport=g;exports.getLocationHref=I;exports.getScrollHeight=G;exports.getScrollTop=D;exports.getUrlParam=x;exports.htmlElementAsString=U;exports.inBrowser=f;exports.is360zhushou=E;exports.isAndroid=w;exports.isChrome=S;exports.isEdge=h;exports.isIE=y;exports.isIE9=b;exports.isIOS=T;exports.isMobile=_;exports.isWeiXin=H;exports.matchUrlFileName=O;exports.nativeTryCatch=v;exports.parseUrlToObj=C;exports.supportsHistory=B;exports.throttle=M;exports.throttle_02=$;
@@ -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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(u,e){let t=!1;const n=function(a){var r;(r=e.drag)==null||r.call(e,a)},m=a=>{var r;c(document,"mousemove",n),c(document,"mouseup",m),document.onselectstart=null,document.ondragstart=null,t=!1,(r=e.end)==null||r.call(e,a)};d(u,"mousedown",a=>{var r;t||(document.onselectstart=()=>!1,document.ondragstart=()=>!1,d(document,"mousemove",n),d(document,"mouseup",m),t=!0,(r=e.start)==null||r.call(e,a))})}function c(u,e,t,n=!1){u&&e&&t&&u.removeEventListener(e,t,n)}function d(u,e,t,n=!1){u&&e&&t&&u.addEventListener(e,t,n)}exports.addEventListener=d;exports.removeEventListener=c;exports.triggerDragEvent=s;
@@ -0,0 +1,5 @@
1
+ import { SpanStatus } from "../types/index";
2
+ /**
3
+ * http请求的状态码进行转换
4
+ */
5
+ 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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../types/index.js");function a(n){if(n<400)return e.SpanStatus.Ok;if(n>=400&&n<500)switch(n){case 401:return e.SpanStatus.Unauthenticated;case 403:return e.SpanStatus.PermissionDenied;case 404:return e.SpanStatus.NotFound;case 409:return e.SpanStatus.AlreadyExists;case 413:return e.SpanStatus.FailedPrecondition;case 429:return e.SpanStatus.ResourceExhausted;default:return e.SpanStatus.InvalidArgument}if(n>=500&&n<600)switch(n){case 501:return e.SpanStatus.Unimplemented;case 503:return e.SpanStatus.Unavailable;case 504:return e.SpanStatus.DeadlineExceeded;default:return e.SpanStatus.InternalError}return e.SpanStatus.UnknownError}exports.fromHttpStatus=a;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * img获取404时,设置默认的图片
3
+ * @param event
4
+ * @param defaultImage
5
+ */
6
+ export declare function imgError(event: any, defaultImage: string): void;
7
+ /**
8
+ * 图片预加载
9
+ * @param {string} url
10
+ * @param {fun} callback
11
+ */
12
+ export declare const preloadImage: (url: string, callback: () => void) => void;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(o,e){const r=o.target;r.src=e,r.onerror=null}const n=(o,e)=>{const r=new Image;if(r.src=o,r.complete){e&&e.call(r);return}r.onload=function(){e&&e.call(r)}};exports.imgError=t;exports.preloadImage=n;
@@ -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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,e){if(!t)return t;let r=t.toString();const o=r.indexOf(".");return o!==-1?r=r.substring(0,e+o+1):r=r.substring(0),parseFloat(r)}function a(t,e){return Math.floor(Math.random()*(e-t))+t}exports.formatDecimal=n;exports.random=a;
@@ -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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(i,t,o,n=!1){if(i!==void 0&&(t in i||n)){const f=i[t],e=o(f);typeof e=="function"&&(i[t]=e)}}exports.replaceAop=p;
@@ -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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./type.js");function o(e){return t.variableTypeDetection.isString(e)?e:t.variableTypeDetection.isUndefined(e)?"undefined":JSON.stringify(e)}function c(e,r){return t.variableTypeDetection.isString(e)?e.slice(0,r)+(e.length>r?`:截取前${r}个字符`:""):""}function d(e){if(!e)return{str1:"",str2:""};const n=/\$?\{?([\w\[\]\"\'\-]+)\}?/.exec(e)||[],i=e.indexOf("}"),a=i<0?"":e.slice(i+1);return{str1:n[1],str2:a}}function u(e){const r=new RegExp("(?<=\\[)(.+?)(?=\\])","g");return e.match(r)||[]}function s(e){return e===void 0?e:`["${e}"]`}function l(e){return e===void 0?e:`\${${e}}`}function f(e){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(e)}function S(e){return/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(e)}function v(e){return/\d{2,5}-\d{7,8}/.test(e)}function g(e){return/^[a-zA-Z][a-zA-Z0-9_]{1,20}$/.test(e)}exports.addBigBraceToStr=l;exports.addMiddleBraceToStr=s;exports.extractStrFromCurlyBrace=d;exports.extractStrFromMiddleBrace=u;exports.interceptStr=c;exports.unknownToString=o;exports.validateEmail=f;exports.validateFixedPhone=v;exports.validatePhone=S;exports.validateSpecialString_01=g;
@@ -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: (timestamp?: number, format?: string) => string;
13
+ /**
14
+ * 数值格式化为两位数
15
+ * @author beth
16
+ * @DateTime 5 => 05
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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function D(){return Date.now()}const x=(e=Date.now(),a="Y-M-D h:m:s")=>{const n=new Date(e||Date.now()),t={Y:`${n.getFullYear()}`,M:`${n.getMonth()+1}`,D:`${n.getDate()}`,h:n.getHours(),m:n.getMinutes(),s:n.getSeconds()},o=r=>r>10?r:"0"+r;return(a||"Y-M-D h:m:s").replace("Y",t.Y).replace("M",t.M).replace("D",t.D).replace("h",o(t.h)).replace("m",o(t.m)).replace("s",o(t.s))},s=e=>Number(e)>=10?e:"0"+e;function c(){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const t=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(n=="x"?t:t&3|8).toString(16)})}function m(e){const a=new Date;let t=new Date(e).getTime()-a.getTime();return t<=0&&(t=0),Math.ceil(t/(60*60*24*1e3))}const u=(e,a)=>(a-e)/(1e3*3600*24);exports.formatDate=x;exports.formatDate_02=s;exports.generateUUID=c;exports.getDaysDiffBetweenDates=u;exports.getDaysDiffFromNow=m;exports.getTimestamp=D;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 判断变量的类型
3
+ */
4
+ export declare const variableTypeDetection: {
5
+ isNumber: (value: any) => boolean;
6
+ isString: (value: any) => boolean;
7
+ isBoolean: (value: any) => boolean;
8
+ isNull: (value: any) => boolean;
9
+ isUndefined: (value: any) => boolean;
10
+ isSymbol: (value: any) => boolean;
11
+ isFunction: (value: any) => boolean;
12
+ isObject: (value: any) => boolean;
13
+ isArray: (value: any) => boolean;
14
+ isProcess: (value: any) => boolean;
15
+ isWindow: (value: any) => boolean;
16
+ };
17
+ export declare function isExistProperty(obj: any, key: any): boolean;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o={isNumber:e("Number"),isString:e("String"),isBoolean:e("Boolean"),isNull:e("Null"),isUndefined:e("Undefined"),isSymbol:e("Symbol"),isFunction:e("Function"),isObject:e("Object"),isArray:e("Array"),isProcess:e("process"),isWindow:e("Window")};function e(t){return function(i){return Object.prototype.toString.call(i)===`[object ${t}]`}}function r(t,i){return Object.prototype.hasOwnProperty.call(t,i)}exports.isExistProperty=r;exports.variableTypeDetection=o;
@@ -0,0 +1 @@
1
+ "use strict";const s=n=>(n.install=t=>{const e=n.name||n.__name;t.component(e,n)},n);module.exports=s;
@@ -0,0 +1,41 @@
1
+ export interface Callback {
2
+ (...args: any[]): any;
3
+ }
4
+ export interface IAnyObject {
5
+ [key: string]: any;
6
+ }
7
+ export interface Window {
8
+ chrome: {
9
+ app: {
10
+ [key: string]: any;
11
+ };
12
+ };
13
+ history: any;
14
+ addEventListener: any;
15
+ innerWidth: any;
16
+ innerHeight: any;
17
+ onpopstate: any;
18
+ performance: any;
19
+ __vdrag_topo_error__: {
20
+ [key: string]: any;
21
+ };
22
+ }
23
+ export declare enum SpanStatus {
24
+ Ok = "ok",
25
+ DeadlineExceeded = "deadline_exceeded",
26
+ Unauthenticated = "unauthenticated",
27
+ PermissionDenied = "permission_denied",
28
+ NotFound = "not_found",
29
+ ResourceExhausted = "resource_exhausted",
30
+ InvalidArgument = "invalid_argument",
31
+ Unimplemented = "unimplemented",
32
+ Unavailable = "unavailable",
33
+ InternalError = "internal_error",
34
+ UnknownError = "unknown_error",
35
+ Cancelled = "cancelled",
36
+ AlreadyExists = "already_exists",
37
+ FailedPrecondition = "failed_precondition",
38
+ Aborted = "aborted",
39
+ OutOfRange = "out_of_range",
40
+ DataLoss = "data_loss"
41
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=(e=>(e.Ok="ok",e.DeadlineExceeded="deadline_exceeded",e.Unauthenticated="unauthenticated",e.PermissionDenied="permission_denied",e.NotFound="not_found",e.ResourceExhausted="resource_exhausted",e.InvalidArgument="invalid_argument",e.Unimplemented="unimplemented",e.Unavailable="unavailable",e.InternalError="internal_error",e.UnknownError="unknown_error",e.Cancelled="cancelled",e.AlreadyExists="already_exists",e.FailedPrecondition="failed_precondition",e.Aborted="aborted",e.OutOfRange="out_of_range",e.DataLoss="data_loss",e))(r||{});exports.SpanStatus=r;
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "vdrag-topo-utils",
3
- "version": "1.0.3",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "dist/lib/index.js",
6
6
  "module": "dist/es/index.js",
7
+ "scripts": {
8
+ "build": "vite build",
9
+ "release": "release-it --npm.skipCheck"
10
+ },
7
11
  "files": [
8
12
  "dist"
9
13
  ],
10
14
  "keywords": [],
11
15
  "author": "",
12
- "license": "MIT",
13
- "scripts": {
14
- "build": "vite build"
15
- }
16
- }
16
+ "license": "MIT"
17
+ }
@@ -1,7 +0,0 @@
1
- const a = (n) => (n.install = (e) => {
2
- const t = n.name || n.__name;
3
- e.component(t, n);
4
- }, n);
5
- export {
6
- a as default
7
- };
@@ -1 +0,0 @@
1
- "use strict";const s=n=>(n.install=e=>{const t=n.name||n.__name;e.component(t,n)},n);module.exports=s;
File without changes
File without changes
File without changes
File without changes