cool-common-utils 0.0.1-beta.2

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.
@@ -0,0 +1,13 @@
1
+ import { ManagerOptions, SocketOptions } from 'socket.io-client';
2
+ export declare class SocketIO {
3
+ private socket;
4
+ private isConnected;
5
+ private registerMessageHandlerMap;
6
+ private messageQueueList;
7
+ private readonly options;
8
+ constructor(url: string, options?: Partial<ManagerOptions & SocketOptions>);
9
+ private createSocketIO;
10
+ disconnect(): void;
11
+ send(event: string, data: any): void;
12
+ registerMessageHandler(event: string, callback: any): void;
13
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * eventId枚举,actionId枚举
3
+ */
4
+ export declare enum EventId {
5
+ HEARTBEAT = 1000
6
+ }
7
+ /**
8
+ * 请求参数
9
+ */
10
+ export interface WebSocketRequestMessage {
11
+ msgType?: number;
12
+ fromUserId?: number;
13
+ toUserId?: number;
14
+ formOrigin?: number;
15
+ actionId: number;
16
+ eventId?: number;
17
+ toOrigin?: number;
18
+ data?: any;
19
+ }
20
+ /**
21
+ * 接收参数
22
+ */
23
+ export interface WebSocketResponseMessage {
24
+ msgType: number;
25
+ actionId: number;
26
+ code: number;
27
+ msg: string;
28
+ data: any;
29
+ }
30
+ export declare class Websocket {
31
+ private websocket;
32
+ private connectState;
33
+ private reconnectCount;
34
+ private maxReconnectCount;
35
+ private reconnectTimestamp;
36
+ private heartBeatTimer;
37
+ private heartBeatTimeout;
38
+ private heartBeatData;
39
+ private registerTipMap;
40
+ private registerMessageHandlerMap;
41
+ private messageQueueList;
42
+ private readonly url;
43
+ constructor(url: string);
44
+ private initWebsocket;
45
+ private websocketOpen;
46
+ private websocketOnError;
47
+ private websocketOnClose;
48
+ private websocketOnMessage;
49
+ private disconnectAndReconnect;
50
+ private startHeartBeat;
51
+ private resetHeartBeat;
52
+ private clearHeartBeat;
53
+ private allRegisterWebsocket;
54
+ private allRegisterMessageHandler;
55
+ registerWebsocket(data: WebSocketRequestMessage): void;
56
+ unregisterWebsocket(data: WebSocketRequestMessage): void;
57
+ send(data: WebSocketRequestMessage): void;
58
+ message(actionId: string, callback: any): void;
59
+ close(): void;
60
+ private addStatus;
61
+ private removeStatus;
62
+ private changeStatusColor;
63
+ }
@@ -0,0 +1 @@
1
+ export { SweetSuccess, SweetError, SweetAlert, SweetWarning, SweetConfirm } from './message';
@@ -0,0 +1,5 @@
1
+ export declare const SweetSuccess: (message?: string, timer?: number) => Promise<any>;
2
+ export declare const SweetError: (message?: string, timer?: number) => Promise<any>;
3
+ export declare const SweetWarning: (message?: string, title?: string, timer?: number) => Promise<any>;
4
+ export declare const SweetConfirm: (message?: string, title?: string, cancel?: string, confirm?: string) => Promise<any>;
5
+ export declare const SweetAlert: (message?: string) => Promise<any>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * 判断是否为Json
3
+ * @param data
4
+ */
5
+ export declare const isJson: (data: any) => boolean;
6
+ /**
7
+ * 格式化查询对象数据
8
+ * @param item
9
+ */
10
+ export declare const formatSearchFiled: (item: Record<string, unknown>) => Record<string, unknown>;
11
+ /**
12
+ * 树形数据递归为一维数组
13
+ * @param data
14
+ */
15
+ export declare const flattenDeepArray: (data: Record<string, any>[]) => Record<string, any>[];
16
+ /**
17
+ * 检查给定数据是否为数字类型
18
+ *
19
+ * @param data 待检查的数据,可以是任意类型
20
+ * @returns 如果数据是数字类型,则返回true;否则返回false
21
+ */
22
+ export declare const isNumber: (data: any) => data is number;
23
+ export declare class TransformConvertor {
24
+ private readonly M_PI;
25
+ private readonly A;
26
+ private readonly EE;
27
+ private readonly X_PI;
28
+ constructor();
29
+ private outOfChine;
30
+ private WGS2GCJLat;
31
+ private WGS2GCJLng;
32
+ private transformLat;
33
+ private transformLon;
34
+ private delta;
35
+ WGS2GCJ(poi: Record<string, any>): Record<string, any> | undefined;
36
+ GCJ2BD09(poi: Record<string, any>): Record<string, any>;
37
+ WGS2BD09(poi: Record<string, any>): Record<string, any>;
38
+ transformGCJ2WGS(gcjLat: number, gcjLon: number): {
39
+ lat: number;
40
+ lon: number;
41
+ };
42
+ }
43
+ export declare const UUID: (len: number, radix: number) => string;
44
+ export declare const getTreeName: (data: any[], val: any, props: any, type?: string) => string | any[];
45
+ export declare const getSelectName: (data: any[], val: any, props: any, type?: string) => string | any[];
46
+ export declare const platformListGenerate: (list: any[], num: number) => any[][];
@@ -0,0 +1,12 @@
1
+ export declare class CanvasWater {
2
+ watermark: any;
3
+ canvas: any;
4
+ constructor(watermark: any);
5
+ render(): any;
6
+ }
7
+ export declare const addWater: {
8
+ div: HTMLDivElement;
9
+ init(text: string, x?: number, y?: number, width?: string, height?: string): void;
10
+ show(): void;
11
+ hide(): void;
12
+ };
@@ -0,0 +1 @@
1
+ export { CanvasWater, addWater } from './canvas-water';
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "cool-common-utils",
3
+ "version": "0.0.1-beta.2",
4
+ "description": "cool工具函数库",
5
+ "main": "./dist/index.cjs.min.js",
6
+ "module": "./dist/index.esm.min.js",
7
+ "unpkg": "./dist/index.umd.min.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "serve": "rollup -w -c",
14
+ "build:types": "tsc -b ./tsconfig.json",
15
+ "build": "esno ./scripts/build.ts",
16
+ "push": "esno ./scripts/push.ts",
17
+ "publish": "esno ./scripts/publish.ts",
18
+ "test": "jest --no-cache",
19
+ "clean": "npx rimraf dist"
20
+ },
21
+ "author": "cool-boy",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "axios": "^1.13.2",
25
+ "crypto-js": "^4.2.0",
26
+ "mqtt": "^5.14.1",
27
+ "qs": "^6.14.0",
28
+ "socket.io-client": "^4.8.1",
29
+ "sweetalert": "^2.1.2",
30
+ "xlsx-js-style": "^1.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "@babel/plugin-transform-runtime": "^7.28.5",
34
+ "@babel/preset-env": "^7.28.5",
35
+ "@rollup/plugin-babel": "^6.1.0",
36
+ "@rollup/plugin-commonjs": "^29.0.0",
37
+ "@rollup/plugin-image": "^3.0.3",
38
+ "@rollup/plugin-json": "^6.1.0",
39
+ "@rollup/plugin-node-resolve": "^16.0.3",
40
+ "@rollup/plugin-terser": "^0.4.4",
41
+ "@rollup/plugin-typescript": "^12.3.0",
42
+ "@types/crypto-js": "^4.2.2",
43
+ "@types/jest": "^30.0.0",
44
+ "@types/node": "^24.10.0",
45
+ "@types/qs": "^6.14.0",
46
+ "bumpp": "^10.3.1",
47
+ "child_process": "^1.0.2",
48
+ "consola": "^3.4.2",
49
+ "esm": "^3.2.25",
50
+ "esno": "^4.8.0",
51
+ "fs-extra": "^11.3.2",
52
+ "jest": "^30.2.0",
53
+ "moment": "^2.30.1",
54
+ "rimraf": "^6.1.0",
55
+ "rollup": "^4.53.2",
56
+ "rollup-plugin-polyfill-node": "^0.13.0",
57
+ "ts-jest": "^29.4.5",
58
+ "ts-node": "^10.9.2",
59
+ "tslib": "^2.8.1",
60
+ "typescript": "^5.9.3"
61
+ }
62
+ }