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/lib/perf.d.ts DELETED
@@ -1,213 +0,0 @@
1
- import type { WebPerformance } from "./typing";
2
- /**
3
- * @hidden
4
- */
5
- export declare function isSupportedEntryType(name: string): boolean;
6
- /**
7
- * Gets the first contentful paint (FCP) time of a web page using the Performance API.
8
- * The FCP time is the time it takes for the first piece of content to be painted on the screen.
9
- *
10
- * Usage:
11
- *
12
- * ```javascript
13
- * import { getFCP } from "mazey";
14
- *
15
- * getFCP().then(
16
- * res => {
17
- * console.log(`FCP: ${res}`);
18
- * }
19
- * );
20
- * ```
21
- *
22
- * Output:
23
- *
24
- * ```text
25
- * FCP: 123
26
- * ```
27
- *
28
- * @returns A promise that resolves with the FCP time in milliseconds, or 0 if the "paint" entry type is not supported.
29
- * @category Perf
30
- */
31
- export declare function getFCP(): Promise<number>;
32
- /**
33
- * Gets the first paint (FP) time of a web page using the Performance API.
34
- * The FP time is the time it takes for the first pixel to be painted on the screen.
35
- *
36
- * Usage:
37
- *
38
- * ```javascript
39
- * import { getFP } from "mazey";
40
- *
41
- * getFP().then(
42
- * res => {
43
- * console.log(`FP: ${res}`);
44
- * }
45
- * );
46
- * ```
47
- *
48
- * Output:
49
- *
50
- * ```text
51
- * FP: 123
52
- * ```
53
- *
54
- * @returns A promise that resolves with the FP time in milliseconds, or 0 if the "paint" entry type is not supported.
55
- * @category Perf
56
- */
57
- export declare function getFP(): Promise<number>;
58
- /**
59
- * Gets the largest contentful paint (LCP) time of a web page using the Performance API.
60
- * The LCP time is the time it takes for the largest piece of content to be painted on the screen.
61
- *
62
- * Usage:
63
- *
64
- * ```javascript
65
- * import { getLCP } from "mazey";
66
- *
67
- * getLCP().then(
68
- * res => {
69
- * console.log(`LCP: ${res}`);
70
- * }
71
- * );
72
- * ```
73
- *
74
- * Output:
75
- *
76
- * ```text
77
- * LCP: 123
78
- * ```
79
- *
80
- * @returns A promise that resolves with the LCP time in milliseconds, or 0 if the "largest-contentful-paint" entry type is not supported.
81
- * @category Perf
82
- */
83
- export declare function getLCP(): Promise<number>;
84
- /**
85
- * Gets the first input delay (FID) of a web page using the Performance API.
86
- * The FID is the time it takes for the first user input to be processed by the browser.
87
- *
88
- * Usage:
89
- *
90
- * ```javascript
91
- * import { getFID } from "mazey";
92
- *
93
- * getFID().then(
94
- * res => {
95
- * console.log(`FID: ${res}`);
96
- * }
97
- * );
98
- * ```
99
- *
100
- * Output:
101
- *
102
- * ```text
103
- * FID: 123
104
- * ```
105
- *
106
- * @returns A promise that resolves with the FID in milliseconds, or 0 if the "first-input" entry type is not supported.
107
- * @category Perf
108
- */
109
- export declare function getFID(): Promise<number>;
110
- /**
111
- * Gets the Cumulative Layout Shift (CLS) score of a web page using the Performance API.
112
- * The CLS score is a measure of how much the page layout shifts during loading.
113
- *
114
- * Usage:
115
- *
116
- * ```javascript
117
- * import { getCLS } from "mazey";
118
- *
119
- * getCLS().then(
120
- * res => {
121
- * console.log(`CLS: ${res}`);
122
- * }
123
- * );
124
- * ```
125
- *
126
- * Output:
127
- *
128
- * ```text
129
- * CLS: 123
130
- * ```
131
- *
132
- * @returns A promise that resolves with the CLS score, or 0 if the "layout-shift" entry type is not supported.
133
- * @category Perf
134
- */
135
- export declare function getCLS(): Promise<number>;
136
- /**
137
- * Gets the time to first byte (TTFB) of a web page using the Performance API.
138
- * The TTFB is the time it takes for the first byte of the response to be received by the browser.
139
- *
140
- * Usage:
141
- *
142
- * ```javascript
143
- * import { getTTFB } from "mazey";
144
- *
145
- * getTTFB().then(
146
- * res => {
147
- * console.log(`TTFB: ${res}`);
148
- * }
149
- * );
150
- * ```
151
- *
152
- * Output:
153
- *
154
- * ```text
155
- * TTFB: 123
156
- * ```
157
- *
158
- * @returns The TTFB in milliseconds, or 0 if the navigation timing information is not available.
159
- * @category Perf
160
- */
161
- export declare function getTTFB(): Promise<number>;
162
- /**
163
- * EN: Get page load time(`PerformanceNavigationTiming`).
164
- *
165
- * ZH: 获取页面加载相关的各项数据。
166
- *
167
- * @remarks
168
- * This function uses the [`PerformanceNavigationTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming) API to get page load time data.
169
- * The `PerformanceNavigationTiming` API provides more accurate and detailed information about page load time than the deprecated [`PerformanceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming) API.
170
- * If you are using an older browser that does not support `PerformanceNavigationTiming`, you can still use the `PerformanceTiming` API by using the previous version of this library ([`v3.9.7`](https://github.com/chengchuu/mazey/releases/tag/v3.9.7)).
171
- *
172
- * Usage:
173
- *
174
- * ```javascript
175
- * import { getPerformance } from "mazey";
176
- *
177
- * // `camelCase:false` (Default) Return underline(`a_b`) data.
178
- * // `camelCase:true` Return hump(`aB`) data.
179
- * getPerformance()
180
- * .then(res => {
181
- * console.log(JSON.stringify(res));
182
- * })
183
- * .catch(console.error);
184
- * ```
185
- *
186
- * Output:
187
- *
188
- * ```text
189
- * {"source":"PerformanceNavigationTiming","os":"others","os_version":"","device_type":"pc","network":"4g","screen_direction":"","unload_time":0,"redirect_time":0,"dns_time":0,"tcp_time":0,"ssl_time":0,"response_time":2,"download_time":2,"first_paint_time":288,"first_contentful_paint_time":288,"dom_ready_time":0,"onload_time":0,"white_time":0,"render_time":0,"decoded_body_size":718,"encoded_body_size":718}
190
- * ```
191
- *
192
- * Results:
193
- *
194
- * | Attribute | Description | Type | Values |
195
- * | :------------ | :------------ | :------------ | :------------ |
196
- * | dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
197
- * | tcp_time | Connection Negotiation | number | connectEnd - connectStart |
198
- * | response_time | Requests and Responses | number | responseStart - requestStart |
199
- * | white_time | White Screen | number | responseStart - navigationStart |
200
- * | dom_ready_time | Dom Ready | number | domContentLoadedEventStart - navigationStart |
201
- * | onload_time | Onload | number | loadEventStart - navigationStart |
202
- * | render_time | EventEnd | number | loadEventEnd -navigationStart |
203
- * | unload_time | Unload | number | (Optional) unloadEventEnd - unloadEventStart |
204
- * | redirect_time | Redirect | number | (Optional) redirectEnd - redirectStart |
205
- * | ssl_time | SSL | number | (Optional) connectEnd - secureConnectionStart |
206
- * | download_time | Download | number | (Optional) responseEnd - responseStart |
207
- *
208
- * @param {boolean} camelCase -- false(默认) 以下划线形式返回数据 true 以驼峰形式返回数据
209
- * @returns {Promise<object>} 加载数据
210
- * @category Perf
211
- */
212
- export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
213
- //# sourceMappingURL=perf.d.ts.map
package/lib/perf.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"perf.d.ts","sourceRoot":"","sources":["../src/perf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,WAUhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAe9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAe7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAe9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAoB9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAmB9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAc/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAsB,cAAc,CAAC,SAAS,UAAQ,GAAG,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CA8QvF"}
package/lib/store.d.ts DELETED
@@ -1,230 +0,0 @@
1
- /**
2
- * EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
3
- *
4
- * ZH: 存储/获取数据到 sessionStorage/localStorage。
5
- *
6
- * Usage:
7
- *
8
- * ```javascript
9
- * import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";
10
- *
11
- * setSessionStorage("test", "123");
12
- * const ret1 = getSessionStorage("test");
13
- * setLocalStorage("test", "123");
14
- * const ret2 = getLocalStorage("test");
15
- * console.log(ret1, ret2);
16
- *
17
- * // or package in usage
18
- * const projectName = "mazey";
19
- * function mSetLocalStorage (key, value) {
20
- * return setLocalStorage(`${projectName}_${key}`, value);
21
- * }
22
- *
23
- * function mGetLocalStorage (key) {
24
- * return getLocalStorage(`${projectName}_${key}`);
25
- * }
26
- * ```
27
- *
28
- * Output:
29
- *
30
- * ```text
31
- * 123 123
32
- * ```
33
- *
34
- * @param {string} key 键
35
- * @returns {void} 返回值
36
- * @category Store
37
- */
38
- export declare function setSessionStorage<T>(key: string, value?: T | null): void;
39
- /**
40
- * EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
41
- *
42
- * ZH: 存储/获取数据到 sessionStorage/localStorage。
43
- *
44
- * Usage:
45
- *
46
- * ```javascript
47
- * import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";
48
- *
49
- * setSessionStorage("test", "123");
50
- * const ret1 = getSessionStorage("test");
51
- * setLocalStorage("test", "123");
52
- * const ret2 = getLocalStorage("test");
53
- * console.log(ret1, ret2);
54
- *
55
- * // or package in usage
56
- * const projectName = "mazey";
57
- * function mSetLocalStorage (key, value) {
58
- * return setLocalStorage(`${projectName}_${key}`, value);
59
- * }
60
- *
61
- * function mGetLocalStorage (key) {
62
- * return getLocalStorage(`${projectName}_${key}`);
63
- * }
64
- * ```
65
- *
66
- * Output:
67
- *
68
- * ```text
69
- * 123 123
70
- * ```
71
- *
72
- * @param {string} key 键
73
- * @returns {any} 返回值
74
- * @category Store
75
- */
76
- export declare function getSessionStorage<T>(key: string): T | null;
77
- /**
78
- * EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
79
- *
80
- * ZH: 存储/获取数据到 sessionStorage/localStorage。
81
- *
82
- * Usage:
83
- *
84
- * ```javascript
85
- * import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";
86
- *
87
- * setSessionStorage("test", "123");
88
- * const ret1 = getSessionStorage("test");
89
- * setLocalStorage("test", "123");
90
- * const ret2 = getLocalStorage("test");
91
- * console.log(ret1, ret2);
92
- *
93
- * // or package in usage
94
- * const projectName = "mazey";
95
- * function mSetLocalStorage (key, value) {
96
- * return setLocalStorage(`${projectName}_${key}`, value);
97
- * }
98
- *
99
- * function mGetLocalStorage (key) {
100
- * return getLocalStorage(`${projectName}_${key}`);
101
- * }
102
- * ```
103
- *
104
- * Output:
105
- *
106
- * ```text
107
- * 123 123
108
- * ```
109
- *
110
- * @param {string} key 键
111
- * @returns {void} 返回值
112
- * @category Store
113
- */
114
- export declare function setLocalStorage<T>(key: string, value?: T | null): void;
115
- /**
116
- * EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
117
- *
118
- * ZH: 存储/获取数据到 sessionStorage/localStorage。
119
- *
120
- * Usage:
121
- *
122
- * ```javascript
123
- * import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";
124
- *
125
- * setSessionStorage("test", "123");
126
- * const ret1 = getSessionStorage("test");
127
- * setLocalStorage("test", "123");
128
- * const ret2 = getLocalStorage("test");
129
- * console.log(ret1, ret2);
130
- *
131
- * // or package in usage
132
- * const projectName = "mazey";
133
- * function mSetLocalStorage (key, value) {
134
- * return setLocalStorage(`${projectName}_${key}`, value);
135
- * }
136
- *
137
- * function mGetLocalStorage (key) {
138
- * return getLocalStorage(`${projectName}_${key}`);
139
- * }
140
- * ```
141
- *
142
- * Output:
143
- *
144
- * ```text
145
- * 123 123
146
- * ```
147
- *
148
- * @param {string} key 键
149
- * @returns {void} 返回值
150
- * @category Store
151
- */
152
- export declare function getLocalStorage<T>(key: string): T | null;
153
- /**
154
- * EN: Handle Cookie.
155
- *
156
- * ZH: 设置/获取 Cookie。
157
- *
158
- * Usage:
159
- *
160
- * ```javascript
161
- * import { setCookie, getCookie } from "mazey";
162
- *
163
- * setCookie("test", "123", 30, "example.com"); // key value day domain
164
- * const ret = getCookie("test");
165
- * console.log(ret);
166
- * ```
167
- *
168
- * Output:
169
- *
170
- * ```text
171
- * 123
172
- * ```
173
- *
174
- * @category Store
175
- */
176
- export declare function getCookie(name: string): string;
177
- /**
178
- * EN: Handle Cookie.
179
- *
180
- * ZH: 设置/获取 Cookie。
181
- *
182
- * Usage:
183
- *
184
- * ```javascript
185
- * import { setCookie, getCookie } from "mazey";
186
- *
187
- * setCookie("test", "123", 30, "example.com"); // key value day domain
188
- * const ret = getCookie("test");
189
- * console.log(ret);
190
- * ```
191
- *
192
- * Output:
193
- *
194
- * ```text
195
- * 123
196
- * ```
197
- *
198
- * @category Store
199
- */
200
- export declare function setCookie(name: string, value: string, days?: number, domain?: string): void;
201
- /**
202
- * Delete a cookie by name.
203
- *
204
- * Usage:
205
- *
206
- * ```javascript
207
- * import { removeCookie } from "mazey";
208
- *
209
- * const ret = removeCookie("test");
210
- * console.log(ret);
211
- * ```
212
- *
213
- * Output:
214
- *
215
- * ```text
216
- * true
217
- * ```
218
- *
219
- * @param name - The name of the cookie to delete.
220
- * @returns `true` if the cookie was deleted successfully, `false` otherwise.
221
- * @category Store
222
- */
223
- export declare function removeCookie(name: string): boolean;
224
- /**
225
- * Alias of `removeCookie`.
226
- *
227
- * @hidden
228
- */
229
- export declare function delCookie(name: string): void;
230
- //# sourceMappingURL=store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,GAAG,IAAW,GAAG,IAAI,CAI9E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,GAAG,IAAW,GAAG,IAAI,CAI5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CASxD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAmC3F;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAclD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C"}