zcw-shared 1.22.0 → 1.23.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/functions/algorithm/visualizeGarbageCollection.d.ts +44 -0
- package/dist/functions/algorithm/visualizeGarbageCollection.js +263 -0
- package/dist/functions/algorithm/visualizeGarbageCollection.js.map +1 -0
- package/dist/functions/dom/createThrottledEventListener.d.ts +11 -0
- package/dist/functions/dom/createThrottledEventListener.js +51 -0
- package/dist/functions/dom/createThrottledEventListener.js.map +1 -0
- package/dist/functions/string/testRegex.d.ts +20 -0
- package/dist/functions/string/testRegex.js +300 -0
- package/dist/functions/string/testRegex.js.map +1 -0
- package/dist/functions/string/visualizeRegexSteps.d.ts +39 -0
- package/dist/functions/string/visualizeRegexSteps.js +446 -0
- package/dist/functions/string/visualizeRegexSteps.js.map +1 -0
- package/dist/functions/tencent-cloud/upload.cos.js +44 -36
- package/dist/functions/tencent-cloud/upload.cos.js.map +1 -1
- package/dist/reactive/useReactiveSSE.d.ts +46 -0
- package/dist/reactive/useReactiveSSE.js +212 -0
- package/dist/reactive/useReactiveSSE.js.map +1 -0
- package/dist/reactive/useReactiveWebsocket.d.ts +50 -0
- package/dist/reactive/useReactiveWebsocket.js +250 -0
- package/dist/reactive/useReactiveWebsocket.js.map +1 -0
- package/package.json +11 -3
- package/references/browser.d.ts +4 -0
- package/references/eventsource.d.ts +121 -0
- package/references/websocket.d.ts +121 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// EventSource (Server-Sent Events) 类型声明
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EventSource 连接状态
|
|
5
|
+
*/
|
|
6
|
+
export enum EventSourceReadyState {
|
|
7
|
+
CONNECTING = 0,
|
|
8
|
+
OPEN = 1,
|
|
9
|
+
CLOSED = 2
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* EventSource 事件接口
|
|
14
|
+
*/
|
|
15
|
+
export interface EventSourceEventMap {
|
|
16
|
+
open: Event
|
|
17
|
+
message: MessageEvent
|
|
18
|
+
error: Event
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* EventSource 消息事件
|
|
23
|
+
*/
|
|
24
|
+
export interface MessageEvent extends Event {
|
|
25
|
+
readonly data: string
|
|
26
|
+
readonly lastEventId: string
|
|
27
|
+
readonly origin: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* EventSource 配置选项
|
|
32
|
+
*/
|
|
33
|
+
export interface EventSourceInit {
|
|
34
|
+
withCredentials?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* EventSource 构造函数类型
|
|
39
|
+
*/
|
|
40
|
+
export interface EventSourceConstructor {
|
|
41
|
+
new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource
|
|
42
|
+
readonly CONNECTING: 0
|
|
43
|
+
readonly OPEN: 1
|
|
44
|
+
readonly CLOSED: 2
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* EventSource 实例接口
|
|
49
|
+
*/
|
|
50
|
+
export interface EventSource {
|
|
51
|
+
readonly url: string
|
|
52
|
+
readonly readyState: number
|
|
53
|
+
readonly withCredentials: boolean
|
|
54
|
+
|
|
55
|
+
// 事件监听器
|
|
56
|
+
onopen: ((this: EventSource, ev: Event) => any) | null
|
|
57
|
+
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null
|
|
58
|
+
onerror: ((this: EventSource, ev: Event) => any) | null
|
|
59
|
+
|
|
60
|
+
// 方法
|
|
61
|
+
close(): void
|
|
62
|
+
addEventListener<K extends keyof EventSourceEventMap>(
|
|
63
|
+
type: K,
|
|
64
|
+
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
|
|
65
|
+
options?: boolean | AddEventListenerOptions
|
|
66
|
+
): void
|
|
67
|
+
addEventListener(
|
|
68
|
+
type: string,
|
|
69
|
+
listener: (this: EventSource, ev: MessageEvent) => any,
|
|
70
|
+
options?: boolean | AddEventListenerOptions
|
|
71
|
+
): void
|
|
72
|
+
removeEventListener<K extends keyof EventSourceEventMap>(
|
|
73
|
+
type: K,
|
|
74
|
+
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
|
|
75
|
+
options?: boolean | EventListenerOptions
|
|
76
|
+
): void
|
|
77
|
+
removeEventListener(
|
|
78
|
+
type: string,
|
|
79
|
+
listener: (this: EventSource, ev: MessageEvent) => any,
|
|
80
|
+
options?: boolean | EventListenerOptions
|
|
81
|
+
): void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 事件监听器选项
|
|
86
|
+
*/
|
|
87
|
+
export interface AddEventListenerOptions {
|
|
88
|
+
capture?: boolean
|
|
89
|
+
once?: boolean
|
|
90
|
+
passive?: boolean
|
|
91
|
+
signal?: AbortSignal
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface EventListenerOptions {
|
|
95
|
+
capture?: boolean
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 中止信号
|
|
100
|
+
*/
|
|
101
|
+
export interface AbortSignal {
|
|
102
|
+
readonly aborted: boolean
|
|
103
|
+
onabort: ((this: AbortSignal, ev: Event) => any) | null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 事件基础接口
|
|
108
|
+
*/
|
|
109
|
+
export interface Event {
|
|
110
|
+
readonly type: string
|
|
111
|
+
readonly target: any
|
|
112
|
+
readonly currentTarget: any
|
|
113
|
+
readonly bubbles: boolean
|
|
114
|
+
readonly cancelable: boolean
|
|
115
|
+
readonly defaultPrevented: boolean
|
|
116
|
+
readonly timeStamp: number
|
|
117
|
+
preventDefault(): void
|
|
118
|
+
stopPropagation(): void
|
|
119
|
+
stopImmediatePropagation(): void
|
|
120
|
+
}
|
|
121
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// WebSocket 类型声明
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WebSocket 连接状态
|
|
5
|
+
*/
|
|
6
|
+
export enum WebSocketReadyState {
|
|
7
|
+
CONNECTING = 0,
|
|
8
|
+
OPEN = 1,
|
|
9
|
+
CLOSING = 2,
|
|
10
|
+
CLOSED = 3
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WebSocket 事件接口
|
|
15
|
+
*/
|
|
16
|
+
export interface WebSocketEventMap {
|
|
17
|
+
close: CloseEvent
|
|
18
|
+
error: Event
|
|
19
|
+
message: MessageEvent
|
|
20
|
+
open: Event
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* WebSocket 关闭事件
|
|
25
|
+
*/
|
|
26
|
+
export interface CloseEvent extends Event {
|
|
27
|
+
readonly code: number
|
|
28
|
+
readonly reason: string
|
|
29
|
+
readonly wasClean: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* WebSocket 消息事件
|
|
34
|
+
*/
|
|
35
|
+
export interface MessageEvent extends Event {
|
|
36
|
+
readonly data: any
|
|
37
|
+
readonly origin: string
|
|
38
|
+
readonly lastEventId: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* WebSocket 构造函数类型
|
|
43
|
+
*/
|
|
44
|
+
export interface WebSocketConstructor {
|
|
45
|
+
new (url: string | URL, protocols?: string | string[]): WebSocket
|
|
46
|
+
readonly CONNECTING: 0
|
|
47
|
+
readonly OPEN: 1
|
|
48
|
+
readonly CLOSING: 2
|
|
49
|
+
readonly CLOSED: 3
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* WebSocket 实例接口
|
|
54
|
+
*/
|
|
55
|
+
export interface WebSocket {
|
|
56
|
+
readonly url: string
|
|
57
|
+
readonly readyState: number
|
|
58
|
+
readonly bufferedAmount: number
|
|
59
|
+
readonly extensions: string
|
|
60
|
+
readonly protocol: string
|
|
61
|
+
binaryType: 'blob' | 'arraybuffer'
|
|
62
|
+
|
|
63
|
+
// 事件监听器
|
|
64
|
+
onopen: ((this: WebSocket, ev: Event) => any) | null
|
|
65
|
+
onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null
|
|
66
|
+
onerror: ((this: WebSocket, ev: Event) => any) | null
|
|
67
|
+
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null
|
|
68
|
+
|
|
69
|
+
// 方法
|
|
70
|
+
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
|
|
71
|
+
close(code?: number, reason?: string): void
|
|
72
|
+
addEventListener<K extends keyof WebSocketEventMap>(
|
|
73
|
+
type: K,
|
|
74
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
75
|
+
options?: boolean | AddEventListenerOptions
|
|
76
|
+
): void
|
|
77
|
+
removeEventListener<K extends keyof WebSocketEventMap>(
|
|
78
|
+
type: K,
|
|
79
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
80
|
+
options?: boolean | EventListenerOptions
|
|
81
|
+
): void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 事件监听器选项
|
|
86
|
+
*/
|
|
87
|
+
export interface AddEventListenerOptions {
|
|
88
|
+
capture?: boolean
|
|
89
|
+
once?: boolean
|
|
90
|
+
passive?: boolean
|
|
91
|
+
signal?: AbortSignal
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface EventListenerOptions {
|
|
95
|
+
capture?: boolean
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 中止信号
|
|
100
|
+
*/
|
|
101
|
+
export interface AbortSignal {
|
|
102
|
+
readonly aborted: boolean
|
|
103
|
+
onabort: ((this: AbortSignal, ev: Event) => any) | null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 事件基础接口
|
|
108
|
+
*/
|
|
109
|
+
export interface Event {
|
|
110
|
+
readonly type: string
|
|
111
|
+
readonly target: any
|
|
112
|
+
readonly currentTarget: any
|
|
113
|
+
readonly bubbles: boolean
|
|
114
|
+
readonly cancelable: boolean
|
|
115
|
+
readonly defaultPrevented: boolean
|
|
116
|
+
readonly timeStamp: number
|
|
117
|
+
preventDefault(): void
|
|
118
|
+
stopPropagation(): void
|
|
119
|
+
stopImmediatePropagation(): void
|
|
120
|
+
}
|
|
121
|
+
|