@yeepay/client-utils 4.0.0 → 4.0.1
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/dist/index.d.ts +2 -2
- package/dist/index.js +6 -9
- package/package.json +14 -11
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare global {
|
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/is.d.ts
|
|
17
|
-
declare function
|
|
17
|
+
declare function isMobileDevice(): boolean;
|
|
18
18
|
declare const BREAKPOINTS: {
|
|
19
19
|
MOBILE_MAX: number;
|
|
20
20
|
TABLET_MIN: number;
|
|
@@ -109,4 +109,4 @@ declare function removeToken(): void;
|
|
|
109
109
|
//#region src/utils.d.ts
|
|
110
110
|
declare function getQueryObject(url?: string): Record<string, string>;
|
|
111
111
|
//#endregion
|
|
112
|
-
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile,
|
|
112
|
+
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile, isMobileDevice, isTablet, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/dist/index.js
CHANGED
|
@@ -56,10 +56,8 @@ try {
|
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/is.ts
|
|
59
|
-
function
|
|
59
|
+
function isMobileDevice() {
|
|
60
60
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
61
|
-
if ("maxTouchPoints" in navigator) return navigator.maxTouchPoints > 0;
|
|
62
|
-
if (typeof window.matchMedia === "function") return window.matchMedia("(pointer: coarse)").matches;
|
|
63
61
|
const ua = navigator.userAgent || "";
|
|
64
62
|
return /android|iphone|ipad|ipod|windows phone|blackberry|mobile/i.test(ua);
|
|
65
63
|
}
|
|
@@ -75,12 +73,12 @@ const MEDIA_QUERIES = {
|
|
|
75
73
|
DESKTOP: `(min-width: ${BREAKPOINTS.DESKTOP_MIN}px)`
|
|
76
74
|
};
|
|
77
75
|
function isMobile() {
|
|
78
|
-
if (!
|
|
76
|
+
if (!isMobileDevice()) return false;
|
|
79
77
|
if (typeof window.matchMedia === "function") return window.matchMedia(MEDIA_QUERIES.MOBILE).matches;
|
|
80
78
|
return false;
|
|
81
79
|
}
|
|
82
80
|
function isTablet() {
|
|
83
|
-
if (!
|
|
81
|
+
if (!isMobileDevice()) return false;
|
|
84
82
|
if (typeof window.matchMedia === "function") return window.matchMedia(MEDIA_QUERIES.TABLET).matches;
|
|
85
83
|
return false;
|
|
86
84
|
}
|
|
@@ -158,10 +156,9 @@ async function setupMockAdapter(axiosInstance, mock) {
|
|
|
158
156
|
return response;
|
|
159
157
|
});
|
|
160
158
|
};
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
interopDefault(modules[path]).then((mod) => {
|
|
160
|
+
registerMock(mod);
|
|
163
161
|
});
|
|
164
|
-
else registerMock(modules[path]);
|
|
165
162
|
});
|
|
166
163
|
}
|
|
167
164
|
|
|
@@ -299,4 +296,4 @@ function serviceFactory(options, callbacks) {
|
|
|
299
296
|
}
|
|
300
297
|
|
|
301
298
|
//#endregion
|
|
302
|
-
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile,
|
|
299
|
+
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile, isMobileDevice, isTablet, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeepay/client-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.1",
|
|
5
|
+
"packageManager": "pnpm@10.17.1",
|
|
5
6
|
"description": "shared utilities for yeepay client packages",
|
|
6
7
|
"author": "Yong Yang",
|
|
7
8
|
"homepage": "http://gitlab.yeepay.com/ued/client-utils#readme",
|
|
@@ -19,6 +20,17 @@
|
|
|
19
20
|
"files": [
|
|
20
21
|
"dist"
|
|
21
22
|
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsdown",
|
|
25
|
+
"dev": "tsdown --watch",
|
|
26
|
+
"watch": "tsdown --watch",
|
|
27
|
+
"lint": "eslint .",
|
|
28
|
+
"prepack": "nr build",
|
|
29
|
+
"release": "bumpp && pnpm publish",
|
|
30
|
+
"test": "vitest",
|
|
31
|
+
"prepare": "simple-git-hooks",
|
|
32
|
+
"play": "npm -C playground run dev"
|
|
33
|
+
},
|
|
22
34
|
"dependencies": {
|
|
23
35
|
"@imyangyong/utils": "^0.8.0",
|
|
24
36
|
"@yeepay/client-utils": "link:",
|
|
@@ -50,14 +62,5 @@
|
|
|
50
62
|
},
|
|
51
63
|
"lint-staged": {
|
|
52
64
|
"*": "eslint --fix"
|
|
53
|
-
},
|
|
54
|
-
"scripts": {
|
|
55
|
-
"build": "tsdown",
|
|
56
|
-
"dev": "tsdown --watch",
|
|
57
|
-
"watch": "tsdown --watch",
|
|
58
|
-
"lint": "eslint .",
|
|
59
|
-
"release": "bumpp && pnpm publish",
|
|
60
|
-
"test": "vitest",
|
|
61
|
-
"play": "npm -C playground run dev"
|
|
62
65
|
}
|
|
63
|
-
}
|
|
66
|
+
}
|