mazey 4.10.0 → 4.10.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.
- package/.dockerignore +35 -0
- package/.gitattributes +5 -0
- package/AGENTS.md +111 -0
- package/Dockerfile +30 -0
- package/README.md +139 -60
- package/lib/index.cjs.js +2 -2
- package/lib/index.esm.js +2 -2
- package/lib/mazey.min.js +2 -2
- package/package.json +3 -2
- package/scripts/change-package-name.js +6 -4
- package/scripts/git-helper.js +13 -12
- package/scripts/release.js +1 -1
- package/scripts/rollup.config.mjs +5 -1
- package/lib/browser.d.ts +0 -124
- package/lib/browser.d.ts.map +0 -1
- package/lib/calc.d.ts +0 -117
- package/lib/calc.d.ts.map +0 -1
- package/lib/debug.d.ts +0 -74
- package/lib/debug.d.ts.map +0 -1
- package/lib/dom.d.ts +0 -232
- package/lib/dom.d.ts.map +0 -1
- package/lib/event.d.ts +0 -101
- package/lib/event.d.ts.map +0 -1
- package/lib/index.d.ts +0 -14
- package/lib/index.d.ts.map +0 -1
- package/lib/load.d.ts +0 -186
- package/lib/load.d.ts.map +0 -1
- package/lib/perf.d.ts +0 -213
- package/lib/perf.d.ts.map +0 -1
- package/lib/store.d.ts +0 -230
- package/lib/store.d.ts.map +0 -1
- package/lib/url.d.ts +0 -394
- package/lib/url.d.ts.map +0 -1
- package/lib/util.d.ts +0 -1174
- package/lib/util.d.ts.map +0 -1
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
|
package/lib/debug.d.ts.map
DELETED
|
@@ -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
|
package/lib/event.d.ts.map
DELETED
|
@@ -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
|
package/lib/index.d.ts.map
DELETED
|
@@ -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"}
|
package/lib/load.d.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { MazeyFnParams, MazeyFnReturn, LoadScriptReturns } from "./typing";
|
|
2
|
-
/**
|
|
3
|
-
* EN: Load a CSS file from the server.
|
|
4
|
-
*
|
|
5
|
-
* ZH: 动态加载 CSS 文件。
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* ```javascript
|
|
10
|
-
* import { loadCSS } from "mazey";
|
|
11
|
-
*
|
|
12
|
-
* loadCSS(
|
|
13
|
-
* "http://example.com/path/example.css",
|
|
14
|
-
* {
|
|
15
|
-
* id: "iamid", // Optional, link ID, default none
|
|
16
|
-
* }
|
|
17
|
-
* )
|
|
18
|
-
* .then(
|
|
19
|
-
* res => {
|
|
20
|
-
* console.log(`Load CSS Success: ${res}`);
|
|
21
|
-
* }
|
|
22
|
-
* )
|
|
23
|
-
* .catch(
|
|
24
|
-
* err => {
|
|
25
|
-
* console.error(`Load CSS Fail: ${err.message}`)
|
|
26
|
-
* }
|
|
27
|
-
* );
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* Output:
|
|
31
|
-
*
|
|
32
|
-
* ```text
|
|
33
|
-
* Load CSS Success: loaded
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param {string} url -- css资源路径
|
|
37
|
-
* @param {string} options.id -- link标签id
|
|
38
|
-
* @returns {Promise<string>} true -- 加载成功
|
|
39
|
-
* @category Load
|
|
40
|
-
*/
|
|
41
|
-
export declare function loadCSS(url: string, options?: {
|
|
42
|
-
id?: string;
|
|
43
|
-
}): Promise<unknown>;
|
|
44
|
-
/**
|
|
45
|
-
* EN: Load a JavaScript file from the server and execute it.
|
|
46
|
-
*
|
|
47
|
-
* ZH: 动态加载 JavaScript 文件。
|
|
48
|
-
*
|
|
49
|
-
* Usage:
|
|
50
|
-
*
|
|
51
|
-
* ```javascript
|
|
52
|
-
* import { loadScript } from "mazey";
|
|
53
|
-
*
|
|
54
|
-
* loadScript(
|
|
55
|
-
* "http://example.com/static/js/plugin-2.1.1.min.js",
|
|
56
|
-
* {
|
|
57
|
-
* id: "iamid", // (Optional) script ID, default none
|
|
58
|
-
* timeout: 5000, // (Optional) timeout, default `5000`
|
|
59
|
-
* }
|
|
60
|
-
* )
|
|
61
|
-
* .then(
|
|
62
|
-
* res => {
|
|
63
|
-
* console.log(`Load JavaScript script: ${res}`);
|
|
64
|
-
* }
|
|
65
|
-
* )
|
|
66
|
-
* .catch(
|
|
67
|
-
* err => {
|
|
68
|
-
* console.error(`Load JavaScript script: ${err.message}`);
|
|
69
|
-
* }
|
|
70
|
-
* );
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* Output:
|
|
74
|
-
*
|
|
75
|
-
* ```text
|
|
76
|
-
* Load JavaScript script: loaded
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @param {string} url -- JavaScript 资源路径
|
|
80
|
-
* @param {string} options.id -- DOM ID
|
|
81
|
-
* @param {function} options.callback -- 加载后回调函数
|
|
82
|
-
* @param {number} options.timeout -- 超时时长
|
|
83
|
-
* @param {boolean} options.isDefer -- 是否添加 defer 标签
|
|
84
|
-
* @param {boolean} options.isAsync -- 是否添加 async 标签
|
|
85
|
-
* @param {boolean} options.isCrossOrigin -- 是否跨域
|
|
86
|
-
* @param {object} options.attributes -- 其他属性
|
|
87
|
-
* @param {string} options.cssUrl -- CSS 资源路径
|
|
88
|
-
* @returns {Promise<string>} -- true 成功
|
|
89
|
-
* @category Load
|
|
90
|
-
*/
|
|
91
|
-
export declare function loadScript(url: string, options?: {
|
|
92
|
-
id?: string;
|
|
93
|
-
callback?: (...params: MazeyFnParams) => MazeyFnReturn;
|
|
94
|
-
timeout?: number;
|
|
95
|
-
isDefer?: boolean;
|
|
96
|
-
isAsync?: boolean;
|
|
97
|
-
isCrossOrigin?: boolean;
|
|
98
|
-
attributes?: Record<string, string> | null;
|
|
99
|
-
cssUrl?: string;
|
|
100
|
-
}): LoadScriptReturns;
|
|
101
|
-
/**
|
|
102
|
-
* EN: Check whether the page is loaded successfully (Keep the compatibility if the browser's `load` event has been triggered).
|
|
103
|
-
*
|
|
104
|
-
* ZH: 页面加载完成。
|
|
105
|
-
*
|
|
106
|
-
* Usage:
|
|
107
|
-
*
|
|
108
|
-
* ```javascript
|
|
109
|
-
* import { windowLoaded } from "mazey";
|
|
110
|
-
*
|
|
111
|
-
* windowLoaded()
|
|
112
|
-
* .then(res => {
|
|
113
|
-
* console.log(`Load Success: ${res}`);
|
|
114
|
-
* })
|
|
115
|
-
* .catch(err => {
|
|
116
|
-
* console.log(`Load Timeout or Fail: ${err.message}`);
|
|
117
|
-
* });
|
|
118
|
-
* ```
|
|
119
|
-
*
|
|
120
|
-
* Output:
|
|
121
|
-
*
|
|
122
|
-
* ```text
|
|
123
|
-
* Load Success: load
|
|
124
|
-
* ```
|
|
125
|
-
*
|
|
126
|
-
* @param {number} timeout 超时时间 / 单位:毫秒,默认:30000(30 秒)
|
|
127
|
-
* @returns {Promise<string>} document is loaded? "complete" "load" / "timeout"
|
|
128
|
-
* @category Load
|
|
129
|
-
*/
|
|
130
|
-
export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
131
|
-
/**
|
|
132
|
-
* Load an image from the given URL.
|
|
133
|
-
*
|
|
134
|
-
* The target image will be loaded in the background, and the Promise status will change after the image is loaded. If the image fails to load, the Promise status will change to `reject` with the error object. If the image is loaded successfully, the Promise status will change to `resolve` with the image object. This method can be used to preload images and cache them in the browser. It can also be used to implement lazy loading of images.
|
|
135
|
-
*
|
|
136
|
-
* Note that this method will not add the image to the DOM.
|
|
137
|
-
*
|
|
138
|
-
* Usage:
|
|
139
|
-
*
|
|
140
|
-
* ```javascript
|
|
141
|
-
* import { loadImage } from "mazey";
|
|
142
|
-
*
|
|
143
|
-
* loadImage("https://example.com/example.png")
|
|
144
|
-
* .then((img) => {
|
|
145
|
-
* console.log(img);
|
|
146
|
-
* })
|
|
147
|
-
* .catch((err) => {
|
|
148
|
-
* console.log(err);
|
|
149
|
-
* });
|
|
150
|
-
* ```
|
|
151
|
-
*
|
|
152
|
-
* @param {string} url - The URL of the image to load.
|
|
153
|
-
* @returns {Promise} A Promise that resolves with the loaded image or rejects with an error.
|
|
154
|
-
* @category Load
|
|
155
|
-
*/
|
|
156
|
-
export declare function loadImage(url: string): Promise<HTMLImageElement>;
|
|
157
|
-
/**
|
|
158
|
-
* Load a script from the given URL if it (`window["attribute"]`) has not already been loaded.
|
|
159
|
-
*
|
|
160
|
-
* Usage:
|
|
161
|
-
*
|
|
162
|
-
* ```javascript
|
|
163
|
-
* import { loadScriptIfUndefined } from "mazey";
|
|
164
|
-
*
|
|
165
|
-
* loadScriptIfUndefined("xyz", "https://example.com/lib/xyz.min.js")
|
|
166
|
-
* .then(() => {
|
|
167
|
-
* console.log("xyz is loaded.");
|
|
168
|
-
* })
|
|
169
|
-
* .catch(err => {
|
|
170
|
-
* console.log("Failed to load xyz.", err);
|
|
171
|
-
* });
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* Output:
|
|
175
|
-
*
|
|
176
|
-
* ```text
|
|
177
|
-
* xyz is loaded.
|
|
178
|
-
* ```
|
|
179
|
-
*
|
|
180
|
-
* @param {string} windowAttribute - The name of the window attribute to check (e.g. `jQuery`, `axios`, etc.).
|
|
181
|
-
* @param {string} url - The URL of the script to load.
|
|
182
|
-
* @returns {Promise} A Promise that resolves when the script has been loaded.
|
|
183
|
-
* @category Load
|
|
184
|
-
*/
|
|
185
|
-
export declare function loadScriptIfUndefined(windowAttribute: string, url: string): LoadScriptReturns;
|
|
186
|
-
//# sourceMappingURL=load.d.ts.map
|
package/lib/load.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAChD,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAyG5F;AAiCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,aAAa,KAAK,aAAa,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CAGjB,GACA,iBAAiB,CAgEnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAerE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAK7F"}
|