mazey 4.0.6 → 4.1.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/LICENSE +21 -21
- package/README.md +990 -990
- package/coverage/clover.xml +1238 -0
- package/coverage/coverage-final.json +2 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.esm.js.html +12646 -0
- package/coverage/lcov-report/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +2548 -0
- package/lib/browser.d.ts +90 -0
- package/lib/browser.d.ts.map +1 -0
- package/lib/calc.d.ts +106 -0
- package/lib/calc.d.ts.map +1 -0
- package/lib/debug.d.ts +40 -0
- package/lib/debug.d.ts.map +1 -0
- package/lib/dom.d.ts +164 -0
- package/lib/dom.d.ts.map +1 -0
- package/lib/event.d.ts +76 -0
- package/lib/event.d.ts.map +1 -0
- package/lib/global.d.ts +87 -0
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +10 -2040
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +2 -2
- package/lib/load.d.ts +169 -0
- package/lib/load.d.ts.map +1 -0
- package/lib/mazey.min.js +2 -2
- package/lib/perf.d.ts +199 -0
- package/lib/perf.d.ts.map +1 -0
- package/lib/store.d.ts +216 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/typing.d.ts +88 -74
- package/lib/url.d.ts +246 -0
- package/lib/url.d.ts.map +1 -0
- package/lib/util.d.ts +841 -0
- package/lib/util.d.ts.map +1 -0
- package/package.json +124 -122
- package/scripts/README.md +0 -38
- package/scripts/build-helper.js +0 -76
- package/scripts/dev.js +0 -23
- package/scripts/env-win.sh +0 -2
- package/scripts/git-helper.js +0 -155
- package/scripts/mac-build.sh +0 -8
- package/scripts/release.js +0 -9
- package/scripts/rollup.config.mjs +0 -152
package/lib/browser.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { BrowserInfo } from "./typing";
|
|
2
|
+
/**
|
|
3
|
+
* EN: Detect the margin of Safety. Determine if it is a secure PWA environment that it can run.
|
|
4
|
+
*
|
|
5
|
+
* ZH: 判断是否是安全的 PWA 环境
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
*
|
|
9
|
+
* ```javascript
|
|
10
|
+
* const ret = isSafePWAEnv();
|
|
11
|
+
* console.log(ret);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Output:
|
|
15
|
+
*
|
|
16
|
+
* ```text
|
|
17
|
+
* true
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @returns {boolean} true 是
|
|
21
|
+
* @category Browser Information
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSafePWAEnv(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* EN: Browser Information
|
|
26
|
+
*
|
|
27
|
+
* ZH: 返回浏览器信息
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
*
|
|
31
|
+
* ```javascript
|
|
32
|
+
* const ret = getBrowserInfo();
|
|
33
|
+
* console.log(ret);
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Output:
|
|
37
|
+
*
|
|
38
|
+
* ```text
|
|
39
|
+
* {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Results:
|
|
43
|
+
*
|
|
44
|
+
* | Attribute | Description | Type | Values |
|
|
45
|
+
* | :------------ | :------------ | :------------ | :------------ |
|
|
46
|
+
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
47
|
+
* | systemVs | System version | string | Windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 macOS: ... |
|
|
48
|
+
* | platform | Platform | string | desktop, mobile |
|
|
49
|
+
* | engine | Engine | string | webkit, gecko, presto, trident |
|
|
50
|
+
* | engineVs | Engine version | string | - |
|
|
51
|
+
* | supporter | Supporter | string | edge, opera, chrome, safari, firefox, iexplore |
|
|
52
|
+
* | supporterVs | Supporter version | string | - |
|
|
53
|
+
* | shell | Shell | string | (Optional) wechat, qq_browser, qq_app, uc, 360, 2345, sougou, liebao, maxthon, bilibili |
|
|
54
|
+
* | shellVs | Shell version | string | (Optional) 20/... |
|
|
55
|
+
* | appleType | Apple device type | string | (Optional) ipad, iphone, ipod, iwatch |
|
|
56
|
+
*
|
|
57
|
+
* Example: Determine the environment of the mobile QQ.
|
|
58
|
+
*
|
|
59
|
+
* ```javascript
|
|
60
|
+
* const { system, shell } = getBrowserInfo();
|
|
61
|
+
* const isMobileQQ = ['android', 'ios'].includes(system) && ['qq_browser', 'qq_app'].includes(shell);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @returns 浏览器信息
|
|
65
|
+
* @category Browser Information
|
|
66
|
+
*/
|
|
67
|
+
export declare function getBrowserInfo(): BrowserInfo;
|
|
68
|
+
/**
|
|
69
|
+
* Detect webp support.
|
|
70
|
+
*
|
|
71
|
+
* Usage:
|
|
72
|
+
*
|
|
73
|
+
* ```javascript
|
|
74
|
+
* isSupportWebp().then(res => {
|
|
75
|
+
* console.log('isSupportWebp:', res);
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* Output:
|
|
80
|
+
*
|
|
81
|
+
* ```text
|
|
82
|
+
* isSupportWebp: true
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* Reference: [Detect WEBP Support with JavaScript](https://davidwalsh.name/detect-webp)
|
|
86
|
+
*
|
|
87
|
+
* @category Browser Information
|
|
88
|
+
*/
|
|
89
|
+
export declare function isSupportWebp(): Promise<boolean>;
|
|
90
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,UAAU,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA4BtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,cAAc,IAAI,WAAW,CA+M5C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAYhD"}
|
package/lib/calc.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EN: Computes the longest common substring of two strings.
|
|
3
|
+
*
|
|
4
|
+
* ZH: 计算两个字符串的最长公共子串
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* ```javascript
|
|
9
|
+
* const ret = longestComSubstring('fish', 'finish');
|
|
10
|
+
* console.log(ret);
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Output:
|
|
14
|
+
*
|
|
15
|
+
* ```text
|
|
16
|
+
* 3
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {string} aStr String
|
|
20
|
+
* @param {string} bStr String
|
|
21
|
+
* @returns {number} Length
|
|
22
|
+
* @category Calculate and Formula
|
|
23
|
+
*/
|
|
24
|
+
export declare function longestComSubstring(aStr: string, bStr: string): number;
|
|
25
|
+
/**
|
|
26
|
+
* Alias of `longestComSubstring`.
|
|
27
|
+
*
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
export declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* EN: Computes the longest common subsequence of two strings.
|
|
33
|
+
*
|
|
34
|
+
* ZH: 计算两个字符串的最长公共子序列
|
|
35
|
+
*
|
|
36
|
+
* Usage:
|
|
37
|
+
*
|
|
38
|
+
* ```javascript
|
|
39
|
+
* const ret = longestComSubsequence('fish', 'finish');
|
|
40
|
+
* console.log(ret);
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Output:
|
|
44
|
+
*
|
|
45
|
+
* ```text
|
|
46
|
+
* 4
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param {string} aStr 字符串
|
|
50
|
+
* @param {string} bStr 字符串
|
|
51
|
+
* @returns {number} 长度
|
|
52
|
+
* @category Calculate and Formula
|
|
53
|
+
*/
|
|
54
|
+
export declare function longestComSubsequence(aStr: string, bStr: string): number;
|
|
55
|
+
/**
|
|
56
|
+
* Alias of `longestComSubsequence`.
|
|
57
|
+
*
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
60
|
+
export declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
|
|
61
|
+
/**
|
|
62
|
+
* EN: Hit probability (1% ~ 100%).
|
|
63
|
+
*
|
|
64
|
+
* ZH: 百分位概率
|
|
65
|
+
*
|
|
66
|
+
* Usage:
|
|
67
|
+
*
|
|
68
|
+
* ```javascript
|
|
69
|
+
* const ret = isHit(0.5); // 0.01 ~ 1 true/false
|
|
70
|
+
* console.log(ret);
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Output:
|
|
74
|
+
*
|
|
75
|
+
* ```text
|
|
76
|
+
* true
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* Example: Test the precision.
|
|
80
|
+
*
|
|
81
|
+
* ```javascript
|
|
82
|
+
* // Test
|
|
83
|
+
* let trueCount = 0;
|
|
84
|
+
* let falseCount = 0;
|
|
85
|
+
* new Array(1000000).fill(0).forEach(() => {
|
|
86
|
+
* if (isHit(0.5)) {
|
|
87
|
+
* trueCount++;
|
|
88
|
+
* } else {
|
|
89
|
+
* falseCount++;
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
* console.log(trueCount, falseCount); // 499994 500006
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
|
|
96
|
+
* @returns {boolean} true 命中
|
|
97
|
+
* @category Calculate and Formula
|
|
98
|
+
*/
|
|
99
|
+
export declare function isHit(rate: number): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Alias of `isHit`.
|
|
102
|
+
*
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
105
|
+
export declare function inRate(rate: number): boolean;
|
|
106
|
+
//# sourceMappingURL=calc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc.d.ts","sourceRoot":"","sources":["../src/calc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;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;;;;;;;;;;;;;;;;;;;;;;GAsBG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EN: Custom console printing (`console`).
|
|
3
|
+
*
|
|
4
|
+
* ZH: 生成自定义控制台打印
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* ```javascript
|
|
9
|
+
* const myConsole = genCustomConsole('MazeyLog:');
|
|
10
|
+
* myConsole.log('I am string.');
|
|
11
|
+
* myConsole.info('I am boolean.', true);
|
|
12
|
+
* myConsole.info('I am number.', 123, 456);
|
|
13
|
+
* myConsole.info('I am object.', { a: 123, b: 456});
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Output:
|
|
17
|
+
*
|
|
18
|
+
* ```text
|
|
19
|
+
* MazeyLog: I am string.
|
|
20
|
+
* MazeyLog: I am boolean. true
|
|
21
|
+
* MazeyLog: I am number. 123 456
|
|
22
|
+
* MazeyLog: I am object. {a: 123, b: 456}
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param {string} prefix 前缀
|
|
26
|
+
* @param {string} locales A locale string.
|
|
27
|
+
* @param {function} logFn The function with Log.
|
|
28
|
+
* @param {function} errorFn The function with Error.
|
|
29
|
+
* @returns {object} 新实例
|
|
30
|
+
* @category Debug
|
|
31
|
+
*/
|
|
32
|
+
export declare function genCustomConsole(prefix?: string, options?: {
|
|
33
|
+
isClosed?: boolean;
|
|
34
|
+
showWrap?: boolean;
|
|
35
|
+
showDate?: boolean;
|
|
36
|
+
locales?: string;
|
|
37
|
+
logFn?: () => void;
|
|
38
|
+
errorFn?: () => void;
|
|
39
|
+
}): Console;
|
|
40
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAK,EACX,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAQtB,GACA,OAAO,CA0ET"}
|
package/lib/dom.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modify `class`: determine `class`.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
*
|
|
6
|
+
* ```javascript
|
|
7
|
+
* const dom = document.querySelector('#box');
|
|
8
|
+
*
|
|
9
|
+
* // Determine `class`
|
|
10
|
+
* hasClass(dom, 'test');
|
|
11
|
+
* // Add `class`
|
|
12
|
+
* addClass(dom, 'test');
|
|
13
|
+
* // Remove `class`
|
|
14
|
+
* removeClass(dom, 'test');
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @category DOM
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasClass(obj: HTMLElement, cls: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Modify `class`: add `class`.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
*
|
|
25
|
+
* ```javascript
|
|
26
|
+
* const dom = document.querySelector('#box');
|
|
27
|
+
*
|
|
28
|
+
* // Determine `class`
|
|
29
|
+
* hasClass(dom, 'test');
|
|
30
|
+
* // Add `class`
|
|
31
|
+
* addClass(dom, 'test');
|
|
32
|
+
* // Remove `class`
|
|
33
|
+
* removeClass(dom, 'test');
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @category DOM
|
|
37
|
+
*/
|
|
38
|
+
export declare function addClass(obj: HTMLElement, cls: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Alias of `addClass`.
|
|
41
|
+
*
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
44
|
+
export declare function setClass(obj: HTMLElement, cls: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Modify `class`: remove `class`.
|
|
47
|
+
*
|
|
48
|
+
* Usage:
|
|
49
|
+
*
|
|
50
|
+
* ```javascript
|
|
51
|
+
* const dom = document.querySelector('#box');
|
|
52
|
+
*
|
|
53
|
+
* // Determine `class`
|
|
54
|
+
* hasClass(dom, 'test');
|
|
55
|
+
* // Add `class`
|
|
56
|
+
* addClass(dom, 'test');
|
|
57
|
+
* // Remove `class`
|
|
58
|
+
* removeClass(dom, 'test');
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @category DOM
|
|
62
|
+
*/
|
|
63
|
+
export declare function removeClass(obj: HTMLElement, cls: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* EN: Add `<style>` in `<head>`.
|
|
66
|
+
*
|
|
67
|
+
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败
|
|
68
|
+
*
|
|
69
|
+
* Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
|
|
70
|
+
*
|
|
71
|
+
* ```javascript
|
|
72
|
+
* addStyle(
|
|
73
|
+
* `
|
|
74
|
+
* body {
|
|
75
|
+
* background-color: #333;
|
|
76
|
+
* }
|
|
77
|
+
* `,
|
|
78
|
+
* {
|
|
79
|
+
* id: 'test',
|
|
80
|
+
* }
|
|
81
|
+
* );
|
|
82
|
+
* // <style id="test">
|
|
83
|
+
* // body {
|
|
84
|
+
* // background-color: #333;
|
|
85
|
+
* // }
|
|
86
|
+
* // </style>
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* Example 2: Add the `<style>` without `id`, and repeated invoking will add a new one.
|
|
90
|
+
*
|
|
91
|
+
* ```javascript
|
|
92
|
+
* addStyle(
|
|
93
|
+
* `
|
|
94
|
+
* body {
|
|
95
|
+
* background-color: #444;
|
|
96
|
+
* }
|
|
97
|
+
* `
|
|
98
|
+
* );
|
|
99
|
+
* // <style>
|
|
100
|
+
* // body {
|
|
101
|
+
* // background-color: #444;
|
|
102
|
+
* // }
|
|
103
|
+
* // </style>
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @category DOM
|
|
107
|
+
*/
|
|
108
|
+
export declare function addStyle(style: string, options?: {
|
|
109
|
+
id?: string;
|
|
110
|
+
}): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the width and height of all images on the page based on their `src` attribute.
|
|
113
|
+
* The `src` attribute should contain `width` and/or `height` values in the format "width=100" or "height=100".
|
|
114
|
+
* If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.
|
|
115
|
+
*
|
|
116
|
+
* Usage:
|
|
117
|
+
*
|
|
118
|
+
* ```javascript
|
|
119
|
+
* // Example images with `src` attributes containing `width` and/or `height` values
|
|
120
|
+
* const img1 = document.createElement('img');
|
|
121
|
+
* img1.setAttribute('src', 'https://example.com/example.png?width=2233&height=111');
|
|
122
|
+
* document.body.appendChild(img1);
|
|
123
|
+
*
|
|
124
|
+
* const img2 = document.createElement('img');
|
|
125
|
+
* img2.setAttribute('src', 'https://example.com/example.png?width=100%&height=auto');
|
|
126
|
+
* document.body.appendChild(img2);
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @returns {boolean} - Returns `true` if images were found and their dimensions were set, otherwise `false`.
|
|
130
|
+
* @category DOM
|
|
131
|
+
*/
|
|
132
|
+
export declare function setImgSizeBySrc(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Alias of `setImgSizeBySrc`.
|
|
135
|
+
*
|
|
136
|
+
* @hidden
|
|
137
|
+
*/
|
|
138
|
+
export declare function setImgWidHeiBySrc(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Generate the inline style string from the given parameters. The first parameter is the query selector, and the second parameter is the style array.
|
|
141
|
+
*
|
|
142
|
+
* Usage:
|
|
143
|
+
*
|
|
144
|
+
* ```javascript
|
|
145
|
+
* const ret1 = genStyleString('.a', [ 'color:red' ]);
|
|
146
|
+
* const ret2 = genStyleString('#b', [ 'color:red', 'font-size:12px' ]);
|
|
147
|
+
* console.log(ret1);
|
|
148
|
+
* console.log(ret2);
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* Output:
|
|
152
|
+
*
|
|
153
|
+
* ```text
|
|
154
|
+
* .a{color:red;}
|
|
155
|
+
* #b{color:red;font-size:12px;}
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @param {string} selector
|
|
159
|
+
* @param {array} styleArray
|
|
160
|
+
* @returns {string} The inline style string.
|
|
161
|
+
* @category DOM
|
|
162
|
+
*/
|
|
163
|
+
export declare function genStyleString(selector: string, styleArray: Array<string>): string;
|
|
164
|
+
//# sourceMappingURL=dom.d.ts.map
|
package/lib/dom.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAS/D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAiB5D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAe,GAAG,OAAO,CAiCtF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;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"}
|
package/lib/event.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DefineListeners, MazeyFn } from "./typing";
|
|
2
|
+
/**
|
|
3
|
+
* Prevent bubbling.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
*
|
|
7
|
+
* ```javascript
|
|
8
|
+
* const ret1 = cancelBubble(e);
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @category Event
|
|
12
|
+
*/
|
|
13
|
+
export declare function cancelBubble(e: Event): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get event container.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
*
|
|
19
|
+
* ```javascript
|
|
20
|
+
* const ret = getEventContainer();
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @category Event
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export declare function getDefineListeners(): DefineListeners;
|
|
27
|
+
/**
|
|
28
|
+
* Add event.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
*
|
|
32
|
+
* ```javascript
|
|
33
|
+
* addEvent('test', (e) => {
|
|
34
|
+
* console.log('test event:', e);
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param type
|
|
39
|
+
* @param fn
|
|
40
|
+
* @category Event
|
|
41
|
+
*/
|
|
42
|
+
export declare function addEvent(type: string, fn: MazeyFn): void;
|
|
43
|
+
/**
|
|
44
|
+
* Invoke event.
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
*
|
|
48
|
+
* ```javascript
|
|
49
|
+
* fireEvent('test');
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param type
|
|
53
|
+
* @category Event
|
|
54
|
+
*/
|
|
55
|
+
export declare function fireEvent(type: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Alias of `fireEvent`.
|
|
58
|
+
*
|
|
59
|
+
* @hidden
|
|
60
|
+
*/
|
|
61
|
+
export declare function invokeEvent(type: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Remove event.
|
|
64
|
+
*
|
|
65
|
+
* Usage:
|
|
66
|
+
*
|
|
67
|
+
* ```javascript
|
|
68
|
+
* removeEvent('test');
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @param type
|
|
72
|
+
* @param fn
|
|
73
|
+
* @category Event
|
|
74
|
+
*/
|
|
75
|
+
export declare function removeEvent(type: string, fn: MazeyFn): void;
|
|
76
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAS3C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAOpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAQxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAY5C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAe3D"}
|
package/lib/global.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author Cheng
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface BrowserInfo {
|
|
8
|
+
engine: string; // webkit gecko presto trident
|
|
9
|
+
engineVs: string;
|
|
10
|
+
platform: string; // desktop mobile
|
|
11
|
+
supporter: string; // chrome safari firefox opera iexplore edge
|
|
12
|
+
supporterVs: string;
|
|
13
|
+
system: string; // windows macos linux android ios
|
|
14
|
+
systemVs: string;
|
|
15
|
+
shell?: string; // wechat qq uc 360 2345 sougou liebao maxthon
|
|
16
|
+
shellVs?: string;
|
|
17
|
+
appleType?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface DefineListeners {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @author Cheng
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
declare global {
|
|
30
|
+
interface PerformanceEntry {
|
|
31
|
+
readonly processingStart?: DOMHighResTimeStamp;
|
|
32
|
+
readonly processingEnd?: DOMHighResTimeStamp;
|
|
33
|
+
readonly value?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface NetworkInformation {
|
|
37
|
+
readonly rtt?: number;
|
|
38
|
+
readonly downlink?: number;
|
|
39
|
+
readonly effectiveType?: string;
|
|
40
|
+
readonly saveData?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface Navigator {
|
|
44
|
+
readonly connection?: NetworkInformation;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface HTMLLinkElement {
|
|
48
|
+
onreadystatechange: any;
|
|
49
|
+
readyState: any;
|
|
50
|
+
sheet: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface HTMLScriptElement {
|
|
54
|
+
readyState: any;
|
|
55
|
+
onreadystatechange: any;
|
|
56
|
+
parentNode: any;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface Console {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ErrorEvent {
|
|
64
|
+
type?: string;
|
|
65
|
+
time?: number;
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly filename: string; // Deprecated, but still supported.
|
|
68
|
+
fileName?: string;
|
|
69
|
+
readonly lineno: number; // Deprecated, but still supported.
|
|
70
|
+
line?: number;
|
|
71
|
+
readonly colno: number; // Deprecated, but still supported.
|
|
72
|
+
column?: number;
|
|
73
|
+
stack?: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface Window {
|
|
78
|
+
// VAR
|
|
79
|
+
MAZEY_DEFINE_LISTENERS: {
|
|
80
|
+
[key: string]: DefineListeners;
|
|
81
|
+
};
|
|
82
|
+
MAZEY_BROWSER_INFO: BrowserInfo;
|
|
83
|
+
// LIB
|
|
84
|
+
$: typeof $;
|
|
85
|
+
jQuery: typeof $;
|
|
86
|
+
}
|
|
87
|
+
}
|