mazey 4.10.0 → 4.11.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/lib/calc.d.ts DELETED
@@ -1,117 +0,0 @@
1
- /**
2
- * EN: Computes the longest common substring of two strings.
3
- *
4
- * ZH: 计算两个字符串的最长公共子串。
5
- *
6
- * Usage:
7
- *
8
- * ```javascript
9
- * import { longestComSubstring } from "mazey";
10
- *
11
- * const ret = longestComSubstring("fish", "finish");
12
- * console.log(ret);
13
- * ```
14
- *
15
- * Output:
16
- *
17
- * ```text
18
- * 3
19
- * ```
20
- *
21
- * @param {string} aStr String
22
- * @param {string} bStr String
23
- * @returns {number} Length
24
- * @category Calculate and Formula
25
- */
26
- export declare function longestComSubstring(aStr: string, bStr: string): number;
27
- /**
28
- * Alias of `longestComSubstring`.
29
- *
30
- * @hidden
31
- */
32
- export declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
33
- /**
34
- * EN: Computes the longest common subsequence of two strings.
35
- *
36
- * ZH: 计算两个字符串的最长公共子序列。
37
- *
38
- * Usage:
39
- *
40
- * ```javascript
41
- * import { longestComSubsequence } from "mazey";
42
- *
43
- * const ret = longestComSubsequence("fish", "finish");
44
- * console.log(ret);
45
- * ```
46
- *
47
- * Output:
48
- *
49
- * ```text
50
- * 4
51
- * ```
52
- *
53
- * @param {string} aStr 字符串
54
- * @param {string} bStr 字符串
55
- * @returns {number} 长度
56
- * @category Calculate and Formula
57
- */
58
- export declare function longestComSubsequence(aStr: string, bStr: string): number;
59
- /**
60
- * Alias of `longestComSubsequence`.
61
- *
62
- * @hidden
63
- */
64
- export declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
65
- /**
66
- * EN: Hit probability (1% ~ 100%).
67
- *
68
- * ZH: 百分位概率。
69
- *
70
- * Usage:
71
- *
72
- * ```javascript
73
- * import { isHit } from "mazey";
74
- *
75
- * const ret = isHit(0.5); // 0.01 ~ 1 true/false
76
- * console.log(ret);
77
- * ```
78
- *
79
- * Output:
80
- *
81
- * ```text
82
- * true
83
- * ```
84
- *
85
- * Example: Test the precision.
86
- *
87
- * ```javascript
88
- * let trueCount = 0;
89
- * let falseCount = 0;
90
- * new Array(1000000).fill(0).forEach(() => {
91
- * if (isHit(0.5)) {
92
- * trueCount++;
93
- * } else {
94
- * falseCount++;
95
- * }
96
- * });
97
- * console.log(trueCount, falseCount);
98
- * ```
99
- *
100
- * Output:
101
- *
102
- * ```text
103
- * 499994 500006
104
- * ```
105
- *
106
- * @param {number} rate 0.1 ~ 1 => 1% ~ 100%
107
- * @returns {boolean} true 命中
108
- * @category Calculate and Formula
109
- */
110
- export declare function isHit(rate: number): boolean;
111
- /**
112
- * Alias of `isHit`.
113
- *
114
- * @hidden
115
- */
116
- export declare function inRate(rate: number): boolean;
117
- //# sourceMappingURL=calc.d.ts.map
package/lib/calc.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"calc.d.ts","sourceRoot":"","sources":["../src/calc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBtE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA8BxE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK3C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C"}
package/lib/debug.d.ts DELETED
@@ -1,74 +0,0 @@
1
- /**
2
- * EN: Custom console printing (`console`).
3
- *
4
- * ZH: 生成自定义控制台打印。
5
- *
6
- * Usage:
7
- *
8
- * ```javascript
9
- * import { genCustomConsole } from "mazey";
10
- *
11
- * const cusConsole = genCustomConsole("[MazeyLog]");
12
- * cusConsole.log("I am string.");
13
- * cusConsole.info("I am boolean.", true);
14
- * cusConsole.info("I am number.", 123, 456);
15
- * cusConsole.info("I am object.", { a: 123, b: 456});
16
- * ```
17
- *
18
- * Output:
19
- *
20
- * ```text
21
- * [MazeyLog] I am string.
22
- * [MazeyLog] I am boolean. true
23
- * [MazeyLog] I am number. 123 456
24
- * [MazeyLog] I am object. {a: 123, b: 456}
25
- * ```
26
- *
27
- * @param {string} prefix The prefix string.
28
- * @param {object} options The options object.
29
- * @param {boolean} options.enabled Whether logging is enabled.
30
- * @param {boolean} options.isClosed Deprecated, Use "enabled" instead.
31
- * @param {boolean} options.showWrap Whether to show the wrap.
32
- * @param {boolean} options.showDate Whether to show the date.
33
- * @param {string} options.locales A locale string.
34
- * @param {boolean} options.isStringifyObject Whether to stringify the object.
35
- * @param {function} options.logFn The function with Log.
36
- * @param {function} options.errorFn The function with Error.
37
- * @returns {object} The custom console object.
38
- * @category Debug
39
- */
40
- export declare function genCustomConsole(prefix?: string, options?: {
41
- enabled?: boolean;
42
- isClosed?: boolean;
43
- showWrap?: boolean;
44
- showDate?: boolean;
45
- locales?: string;
46
- isStringifyObject?: boolean;
47
- logFn?: () => void;
48
- errorFn?: () => void;
49
- }): Console;
50
- /**
51
- * @hidden
52
- */
53
- export declare const mazeyCon: Console;
54
- /**
55
- * EN: Print logs with Time.
56
- *
57
- * ZH: 打印带有时间的日志。
58
- *
59
- * Usage:
60
- *
61
- * ```javascript
62
- * timeCon("I am string.");
63
- * ```
64
- *
65
- * Output:
66
- *
67
- * ```text
68
- * 2024年11月2日周六 09:24:40 I am string.
69
- * ```
70
- *
71
- * @hidden
72
- */
73
- export declare const timeCon: Console;
74
- //# sourceMappingURL=debug.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAK,EACX,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAGtB,GACA,OAAO,CAoFT;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,SAA8B,CAAC;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,SAAsF,CAAC"}
package/lib/dom.d.ts DELETED
@@ -1,232 +0,0 @@
1
- import type { MazeyElement } from "./typing";
2
- /**
3
- * Modify `class`: determine `class`.
4
- *
5
- * Usage:
6
- *
7
- * ```javascript
8
- * import { hasClass, addClass, removeClass } from "mazey";
9
- *
10
- * const dom = document.querySelector("#box");
11
- * // Determine `class`
12
- * hasClass(dom, "test");
13
- * // Add `class`
14
- * addClass(dom, "test");
15
- * // Remove `class`
16
- * removeClass(dom, "test");
17
- * ```
18
- *
19
- * @category DOM
20
- */
21
- export declare function hasClass(obj: MazeyElement, cls: string): boolean;
22
- /**
23
- * Add `class` to the element. The second parameter can be a single class name or an array of class names.
24
- *
25
- * Basic Usage:
26
- *
27
- * ```javascript
28
- * import { addClass } from "mazey";
29
- *
30
- * const ele = document.querySelector("#box");
31
- * addClass(ele, "test");
32
- * ```
33
- *
34
- * Output:
35
- *
36
- * ```html
37
- * <div id="box" class="test"></div>
38
- * ```
39
- *
40
- * Advanced Usage:
41
- *
42
- * ```javascript
43
- * import { addClass, genBrowserAttrs } from "mazey";
44
- *
45
- * const ele = document.querySelector("html");
46
- * addClass(ele, genBrowserAttrs());
47
- * ```
48
- *
49
- * Output:
50
- *
51
- * ```html
52
- * <html class="windows desktop webkit chrome"></html>
53
- * ```
54
- *
55
- * @category DOM
56
- */
57
- export declare function addClass(ele: MazeyElement, cls: string | string[]): void;
58
- /**
59
- * Alias of `addClass`.
60
- *
61
- * @hidden
62
- */
63
- export declare function setClass(ele: HTMLElement, cls: string): void;
64
- /**
65
- * Modify `class`: remove `class`.
66
- *
67
- * Usage:
68
- *
69
- * ```javascript
70
- * import { hasClass, addClass, removeClass } from "mazey";
71
- *
72
- * const dom = document.querySelector("#box");
73
- * // Determine `class`
74
- * hasClass(dom, "test");
75
- * // Add `class`
76
- * addClass(dom, "test");
77
- * // Remove `class`
78
- * removeClass(dom, "test");
79
- * ```
80
- *
81
- * @category DOM
82
- */
83
- export declare function removeClass(obj: MazeyElement, cls: string): void;
84
- /**
85
- * EN: Add `<style>` in `<head>`.
86
- *
87
- * ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败。
88
- *
89
- * Usage:
90
- *
91
- * Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
92
- *
93
- * ```javascript
94
- * import { addStyle } from "mazey";
95
- *
96
- * addStyle(
97
- * `
98
- * body {
99
- * background-color: #333;
100
- * }
101
- * `,
102
- * {
103
- * id: "test",
104
- * }
105
- * );
106
- * ```
107
- *
108
- * Output:
109
- *
110
- * ```html
111
- * <style id="test">
112
- * body {
113
- * background-color: #333;
114
- * }
115
- * </style>
116
- * ```
117
- *
118
- * Example 2: Add the `<style>` without `id`, and repeated invoking will add a new one.
119
- *
120
- * ```javascript
121
- * import { addStyle } from "mazey";
122
- *
123
- * addStyle(
124
- * `
125
- * body {
126
- * background-color: #444;
127
- * }
128
- * `
129
- * );
130
- * ```
131
- *
132
- * Output:
133
- *
134
- * ```html
135
- * <style>
136
- * body {
137
- * background-color: #444;
138
- * }
139
- * </style>
140
- * ```
141
- *
142
- * @category DOM
143
- */
144
- export declare function addStyle(style: string, options?: {
145
- id?: string;
146
- }): boolean;
147
- /**
148
- * Sets the width and height of all images on the page based on their `src` attribute.
149
- * The `src` attribute should contain `width` and/or `height` values in the format "width=100" or "height=100".
150
- * If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.
151
- *
152
- * Usage:
153
- *
154
- * ```html
155
- * <img src="image.jpg?width=100px&height=200px">
156
- * ```
157
- *
158
- * ```javascript
159
- * import { setImgSizeBySrc } from "mazey";
160
- *
161
- * setImgSizeBySrc();
162
- * ```
163
- *
164
- * Output:
165
- *
166
- * ```html
167
- * <img src="image.jpg?width=100px&height=200px" width="100px" height="200px">
168
- * ```
169
- *
170
- * @returns {boolean} - Returns `true` if images were found and their dimensions were set, otherwise `false`.
171
- * @category DOM
172
- */
173
- export declare function setImgSizeBySrc(): boolean;
174
- /**
175
- * Alias of `setImgSizeBySrc`.
176
- *
177
- * @hidden
178
- */
179
- export declare function setImgWidHeiBySrc(): boolean;
180
- /**
181
- * Generate the inline style string from the given parameters. The first parameter is the query selector, and the second parameter is the style array.
182
- *
183
- * Usage:
184
- *
185
- * ```javascript
186
- * const ret1 = genStyleString(".a", [ "color:red" ]);
187
- * const ret2 = genStyleString("#b", [ "color:red", "font-size:12px" ]);
188
- * console.log(ret1);
189
- * console.log(ret2);
190
- * ```
191
- *
192
- * Output:
193
- *
194
- * ```text
195
- * .a{color:red;}
196
- * #b{color:red;font-size:12px;}
197
- * ```
198
- *
199
- * @param {string} selector
200
- * @param {array} styleArray
201
- * @returns {string} The inline style string.
202
- * @category DOM
203
- */
204
- export declare function genStyleString(selector: string, styleArray: Array<string>): string;
205
- /**
206
- * Get the value of the meta tag by the given name.
207
- *
208
- * Usage:
209
- *
210
- * ```html
211
- * <meta name="keywords" content="mazey,web,frontend">
212
- * ```
213
- *
214
- * ```javascript
215
- * import { getPageMeta } from "mazey";
216
- *
217
- * const keywords = getPageMeta("keywords");
218
- * console.log(keywords);
219
- * ```
220
- *
221
- * Output:
222
- *
223
- * ```text
224
- * mazey,web,frontend
225
- * ```
226
- *
227
- * @param {string} name - The name of the meta tag.
228
- * @returns {string} The content of the meta tag.
229
- * @category DOM
230
- */
231
- export declare function getPageMeta(name: string): string;
232
- //# sourceMappingURL=dom.d.ts.map
package/lib/dom.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAahE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA2BxE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAYhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAe,GAAG,OAAO,CA+BtF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,IAAI,OAAO,CA6CzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAMlF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD"}
package/lib/event.d.ts DELETED
@@ -1,101 +0,0 @@
1
- import type { DefineListeners, MazeyFn, MazeyObject } from "./typing";
2
- /**
3
- * Prevent bubbling.
4
- *
5
- * Usage:
6
- *
7
- * ```javascript
8
- * import { cancelBubble } from "mazey";
9
- *
10
- * const ret1 = cancelBubble(e);
11
- * ```
12
- *
13
- * @category Event
14
- */
15
- export declare function cancelBubble(e: Event): void;
16
- /**
17
- * Get the defined listeners.
18
- *
19
- * Usage:
20
- *
21
- * ```javascript
22
- * import { getDefineListeners } from "mazey";
23
- *
24
- * const ret = getDefineListeners();
25
- * console.log(ret);
26
- * ```
27
- *
28
- * Output:
29
- *
30
- * ```text
31
- * {}
32
- * ```
33
- *
34
- * @category Event
35
- * @hidden
36
- */
37
- export declare function getDefineListeners(): DefineListeners;
38
- /**
39
- * Add event.
40
- *
41
- * Usage:
42
- *
43
- * ```javascript
44
- * import { addEvent } from "mazey";
45
- *
46
- * addEvent("test", (e) => {
47
- * console.log("test event:", e);
48
- * });
49
- * fireEvent("test");
50
- * ```
51
- *
52
- * Output:
53
- *
54
- * ```javascript
55
- * test event: { type: "test" }
56
- * ```
57
- *
58
- * @param type
59
- * @param fn
60
- * @category Event
61
- */
62
- export declare function addEvent(type: string, fn: MazeyFn): void;
63
- /**
64
- * Fire/Invoke event.
65
- *
66
- * Usage:
67
- *
68
- * ```javascript
69
- * import { fireEvent } from "mazey";
70
- *
71
- * fireEvent("test");
72
- * ```
73
- *
74
- * @param type The event type.
75
- * @param params The event parameters.
76
- * @category Event
77
- */
78
- export declare function fireEvent(type: string, params?: MazeyObject): void;
79
- /**
80
- * Alias of `fireEvent`.
81
- *
82
- * @hidden
83
- */
84
- export declare function invokeEvent(type: string): void;
85
- /**
86
- * Remove event.
87
- *
88
- * Usage:
89
- *
90
- * ```javascript
91
- * import { removeEvent } from "mazey";
92
- *
93
- * removeEvent("test");
94
- * ```
95
- *
96
- * @param type
97
- * @param fn
98
- * @category Event
99
- */
100
- export declare function removeEvent(type: string, fn: MazeyFn): void;
101
- //# sourceMappingURL=event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAS3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAOpD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAQxD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAUlE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAe3D"}
package/lib/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * @author Cheng
3
- */
4
- export * from "./calc";
5
- export * from "./util";
6
- export * from "./url";
7
- export * from "./dom";
8
- export * from "./event";
9
- export * from "./store";
10
- export * from "./load";
11
- export * from "./perf";
12
- export * from "./browser";
13
- export * from "./debug";
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}