@ka-libs/utils 1.0.3 → 1.0.4

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 @@
1
+ import*as e from"../lib/core/helper.js";import*as r from"../lib/core/dom-helper.js";export{r as DomHelper};export{BindKey}from"../lib/bindkey.js";export{EventManager}from"../lib/eventManager.js";function o(){}const a="";var s={Helper2:e,asd:123};export{e as Helper,e as Helper2,a as aaa,o as asd,e as asdf,s as default};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import*as e from"./exports.js";export{aaa,asd}from"./exports.js";export{BindKey}from"./lib/bindkey.js";import*as r from"./lib/core/dom-helper.js";export{r as DomHelper};export{EventManager}from"./lib/eventManager.js";import*as o from"./lib/core/helper.js";export{o as Helper};export{o as Helper2};export{o as asdf};export{e as default};
1
+ import*as e from"./exports/index.js";export{aaa,asd}from"./exports/index.js";export{BindKey}from"./lib/bindkey.js";import*as r from"./lib/core/dom-helper.js";export{r as DomHelper};export{EventManager}from"./lib/eventManager.js";import*as o from"./lib/core/helper.js";export{o as Helper};export{o as Helper2};export{o as asdf};export{e as default};
package/dist/index.d.ts CHANGED
@@ -1,122 +1,3 @@
1
- interface BindKeyCallBack {
2
- (...args: any[]): any;
3
- }
4
- interface BindKeyOpt {
5
- shortcut: string;
6
- repeat?: boolean;
7
- callback: BindKeyCallBack;
8
- }
9
- interface BindKeyEvent extends BindKeyOpt {
10
- name: string;
11
- disabled: boolean;
12
- repeat: boolean;
13
- before?: () => boolean;
14
- }
15
- declare class BindKey {
16
- event: Map<string, BindKeyEvent>;
17
- watch: Map<any, any>;
18
- stop: boolean;
19
- active: boolean;
20
- keyEvent: BindKeyEvent;
21
- constructor(ManualBind?: boolean);
22
- init(): void;
23
- getCode(_key: string): number;
24
- has(_name: string): boolean;
25
- /**
26
- * 注册事件
27
- * @param {string} name 事件名,必须,用于映射事件的回调函数。
28
- * @param {callback} opt 事件对象或回调函数,为对象时应包含参数 shortcut 和 callback。
29
- */
30
- register(name: string, opt: BindKeyOpt): void;
31
- register(name: string, callback: BindKeyCallBack): void;
32
- /**
33
- * 删除事件
34
- * @param {string} name 事件名。
35
- */
36
- remove(name: string): void;
37
- /**
38
- * 执行事件
39
- * @param {string} name 事件名。
40
- */
41
- on(name: string): void;
42
- dispatcher(event: KeyboardEvent): boolean;
43
- }
44
-
45
- /**
46
- * FrequencyEvent 类 - 用于实现节流和防抖功能的工具类
47
- * 可以对函数执行频率进行控制,支持节流(throttle)和防抖(debounce)两种模式
48
- */
49
- declare class FrequencyEvent {
50
- /**
51
- * 原始回调函数
52
- */
53
- callback: Function;
54
- /**
55
- * 包装后的监听器函数,将根据节流或防抖配置执行原始回调
56
- */
57
- listener: (...args: any[]) => void;
58
- /**
59
- * 节流时间限制,单位为毫秒
60
- * 0表示不进行节流限制
61
- */
62
- private limit;
63
- /**
64
- * 防抖延迟时间,单位为毫秒
65
- * 0表示不进行防抖处理
66
- */
67
- private delay;
68
- /**
69
- * 构造函数 - 创建 FrequencyEvent 实例
70
- * @param callback - 需要执行频率控制的原始回调函数
71
- */
72
- constructor(callback: Function);
73
- /**
74
- * 构造函数 - 创建 FrequencyEvent 实例并设置节流
75
- * @param callback - 需要执行频率控制的原始回调函数
76
- * @param throttleLimit - 节流时间限制,单位为毫秒
77
- */
78
- constructor(callback: Function, throttleLimit: number);
79
- constructor(callback: Function, throttleLimit: number, debounceDelay: number);
80
- throttle(limit: number): this;
81
- /**
82
- * 防抖函数设置方法
83
- * @param delay - 防抖延迟时间,单位为毫秒
84
- * 设置防抖的延迟时间并重新初始化,支持链式调用
85
- */
86
- debounce(delay: number): this;
87
- /**
88
- * 初始化函数,用于设置事件监听器
89
- * 根据limit和delay的值决定如何处理回调函数的执行
90
- */
91
- private init;
92
- }
93
-
94
- type EventElement = HTMLElement | Document;
95
- declare global {
96
- interface Window {
97
- __CirnoGlobalEventMap__?: {
98
- [key: string]: Function[];
99
- };
100
- }
101
- }
102
- interface EventConfig {
103
- throttle?: number;
104
- debounce?: number;
105
- }
106
- declare class EventManager {
107
- static name: string;
108
- static eventMap: WeakMap<EventElement, {
109
- [key: string]: Array<FrequencyEvent | Function>;
110
- }>;
111
- static globalEventMap: {
112
- [key: string]: Array<FrequencyEvent | Function>;
113
- };
114
- static Global: {};
115
- static Document: {};
116
- static addEvent(_elem: EventElement, type: keyof HTMLElementEventMap, listener: Function, _config?: EventConfig): void;
117
- static delEvent(_elem: EventElement, type: keyof HTMLElementEventMap, eventListener?: Function): void;
118
- }
119
-
120
1
  declare function rgbToNum(rgbStr: string): number[];
121
2
  declare function toHex(num: number): string;
122
3
  declare function rgbFadeOut(rgbStr: string, steps: number): string;
@@ -249,6 +130,125 @@ declare namespace Helper2 {
249
130
  };
250
131
  }
251
132
 
133
+ interface BindKeyCallBack {
134
+ (...args: any[]): any;
135
+ }
136
+ interface BindKeyOpt {
137
+ shortcut: string;
138
+ repeat?: boolean;
139
+ callback: BindKeyCallBack;
140
+ }
141
+ interface BindKeyEvent extends BindKeyOpt {
142
+ name: string;
143
+ disabled: boolean;
144
+ repeat: boolean;
145
+ before?: () => boolean;
146
+ }
147
+ declare class BindKey {
148
+ event: Map<string, BindKeyEvent>;
149
+ watch: Map<any, any>;
150
+ stop: boolean;
151
+ active: boolean;
152
+ keyEvent: BindKeyEvent;
153
+ constructor(ManualBind?: boolean);
154
+ init(): void;
155
+ getCode(_key: string): number;
156
+ has(_name: string): boolean;
157
+ /**
158
+ * 注册事件
159
+ * @param {string} name 事件名,必须,用于映射事件的回调函数。
160
+ * @param {callback} opt 事件对象或回调函数,为对象时应包含参数 shortcut 和 callback。
161
+ */
162
+ register(name: string, opt: BindKeyOpt): void;
163
+ register(name: string, callback: BindKeyCallBack): void;
164
+ /**
165
+ * 删除事件
166
+ * @param {string} name 事件名。
167
+ */
168
+ remove(name: string): void;
169
+ /**
170
+ * 执行事件
171
+ * @param {string} name 事件名。
172
+ */
173
+ on(name: string): void;
174
+ dispatcher(event: KeyboardEvent): boolean;
175
+ }
176
+
177
+ /**
178
+ * FrequencyEvent 类 - 用于实现节流和防抖功能的工具类
179
+ * 可以对函数执行频率进行控制,支持节流(throttle)和防抖(debounce)两种模式
180
+ */
181
+ declare class FrequencyEvent {
182
+ /**
183
+ * 原始回调函数
184
+ */
185
+ callback: Function;
186
+ /**
187
+ * 包装后的监听器函数,将根据节流或防抖配置执行原始回调
188
+ */
189
+ listener: (...args: any[]) => void;
190
+ /**
191
+ * 节流时间限制,单位为毫秒
192
+ * 0表示不进行节流限制
193
+ */
194
+ private limit;
195
+ /**
196
+ * 防抖延迟时间,单位为毫秒
197
+ * 0表示不进行防抖处理
198
+ */
199
+ private delay;
200
+ /**
201
+ * 构造函数 - 创建 FrequencyEvent 实例
202
+ * @param callback - 需要执行频率控制的原始回调函数
203
+ */
204
+ constructor(callback: Function);
205
+ /**
206
+ * 构造函数 - 创建 FrequencyEvent 实例并设置节流
207
+ * @param callback - 需要执行频率控制的原始回调函数
208
+ * @param throttleLimit - 节流时间限制,单位为毫秒
209
+ */
210
+ constructor(callback: Function, throttleLimit: number);
211
+ constructor(callback: Function, throttleLimit: number, debounceDelay: number);
212
+ throttle(limit: number): this;
213
+ /**
214
+ * 防抖函数设置方法
215
+ * @param delay - 防抖延迟时间,单位为毫秒
216
+ * 设置防抖的延迟时间并重新初始化,支持链式调用
217
+ */
218
+ debounce(delay: number): this;
219
+ /**
220
+ * 初始化函数,用于设置事件监听器
221
+ * 根据limit和delay的值决定如何处理回调函数的执行
222
+ */
223
+ private init;
224
+ }
225
+
226
+ type EventElement = HTMLElement | Document;
227
+ declare global {
228
+ interface Window {
229
+ __CirnoGlobalEventMap__?: {
230
+ [key: string]: Function[];
231
+ };
232
+ }
233
+ }
234
+ interface EventConfig {
235
+ throttle?: number;
236
+ debounce?: number;
237
+ }
238
+ declare class EventManager {
239
+ static name: string;
240
+ static eventMap: WeakMap<EventElement, {
241
+ [key: string]: Array<FrequencyEvent | Function>;
242
+ }>;
243
+ static globalEventMap: {
244
+ [key: string]: Array<FrequencyEvent | Function>;
245
+ };
246
+ static Global: {};
247
+ static Document: {};
248
+ static addEvent(_elem: EventElement, type: keyof HTMLElementEventMap, listener: Function, _config?: EventConfig): void;
249
+ static delEvent(_elem: EventElement, type: keyof HTMLElementEventMap, eventListener?: Function): void;
250
+ }
251
+
252
252
  declare function initCanvas(): {
253
253
  canvas: HTMLCanvasElement;
254
254
  ctx: CanvasRenderingContext2D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ka-libs/utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",
@@ -12,9 +12,9 @@
12
12
  "import": "./dist/esm/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
- "./helper": {
15
+ "./*": {
16
16
  "types": "./dist/index.d.ts",
17
- "import": "./dist/esm/core/helper.js"
17
+ "import": "./dist/esm/exports/*.js"
18
18
  }
19
19
  },
20
20
  "files": [
@@ -1 +0,0 @@
1
- import*as e from"./lib/core/helper.js";import*as r from"./lib/core/dom-helper.js";export{r as DomHelper};export{BindKey}from"./lib/bindkey.js";export{EventManager}from"./lib/eventManager.js";function o(){}const a="";var s={Helper2:e,asd:123};export{e as Helper,e as Helper2,a as aaa,o as asd,e as asdf,s as default};