@yeepay/client-utils 4.0.0 → 4.0.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { AxiosError, AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from "axios";
|
|
3
|
+
export * from "@imyangyong/utils";
|
|
3
4
|
|
|
4
5
|
//#region src/debug.d.ts
|
|
5
6
|
declare const logger: Record<string, debug.Debugger> & debug.Debugger;
|
|
@@ -14,7 +15,7 @@ declare global {
|
|
|
14
15
|
}
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/is.d.ts
|
|
17
|
-
declare function
|
|
18
|
+
declare function isMobileDevice(): boolean;
|
|
18
19
|
declare const BREAKPOINTS: {
|
|
19
20
|
MOBILE_MAX: number;
|
|
20
21
|
TABLET_MIN: number;
|
|
@@ -109,4 +110,4 @@ declare function removeToken(): void;
|
|
|
109
110
|
//#region src/utils.d.ts
|
|
110
111
|
declare function getQueryObject(url?: string): Record<string, string>;
|
|
111
112
|
//#endregion
|
|
112
|
-
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile,
|
|
113
|
+
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile, isMobileDevice, isTablet, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ import AxiosMockAdapter from "axios-mock-adapter";
|
|
|
6
6
|
import picomatch from "picomatch/posix";
|
|
7
7
|
import Cookie from "js-cookie";
|
|
8
8
|
|
|
9
|
+
export * from "@imyangyong/utils"
|
|
10
|
+
|
|
9
11
|
//#region src/debug.ts
|
|
10
12
|
function createLogger(namespace) {
|
|
11
13
|
return debug(namespace);
|
|
@@ -56,10 +58,8 @@ try {
|
|
|
56
58
|
|
|
57
59
|
//#endregion
|
|
58
60
|
//#region src/is.ts
|
|
59
|
-
function
|
|
61
|
+
function isMobileDevice() {
|
|
60
62
|
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
63
|
const ua = navigator.userAgent || "";
|
|
64
64
|
return /android|iphone|ipad|ipod|windows phone|blackberry|mobile/i.test(ua);
|
|
65
65
|
}
|
|
@@ -75,12 +75,12 @@ const MEDIA_QUERIES = {
|
|
|
75
75
|
DESKTOP: `(min-width: ${BREAKPOINTS.DESKTOP_MIN}px)`
|
|
76
76
|
};
|
|
77
77
|
function isMobile() {
|
|
78
|
-
if (!
|
|
78
|
+
if (!isMobileDevice()) return false;
|
|
79
79
|
if (typeof window.matchMedia === "function") return window.matchMedia(MEDIA_QUERIES.MOBILE).matches;
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
82
82
|
function isTablet() {
|
|
83
|
-
if (!
|
|
83
|
+
if (!isMobileDevice()) return false;
|
|
84
84
|
if (typeof window.matchMedia === "function") return window.matchMedia(MEDIA_QUERIES.TABLET).matches;
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
@@ -158,10 +158,9 @@ async function setupMockAdapter(axiosInstance, mock) {
|
|
|
158
158
|
return response;
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
interopDefault(modules[path]).then((mod) => {
|
|
162
|
+
registerMock(mod);
|
|
163
163
|
});
|
|
164
|
-
else registerMock(modules[path]);
|
|
165
164
|
});
|
|
166
165
|
}
|
|
167
166
|
|
|
@@ -299,4 +298,4 @@ function serviceFactory(options, callbacks) {
|
|
|
299
298
|
}
|
|
300
299
|
|
|
301
300
|
//#endregion
|
|
302
|
-
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile,
|
|
301
|
+
export { BREAKPOINTS, MEDIA_QUERIES, logger as debug, getQueryObject, getToken, isDesktop, isMobile, isMobileDevice, isTablet, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeepay/client-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"description": "shared utilities for yeepay client packages",
|
|
6
6
|
"author": "Yong Yang",
|
|
7
7
|
"homepage": "http://gitlab.yeepay.com/ued/client-utils#readme",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@imyangyong/utils": "^
|
|
23
|
+
"@imyangyong/utils": "^9.4.0",
|
|
24
24
|
"@yeepay/client-utils": "link:",
|
|
25
25
|
"ansis": "^4.1.0",
|
|
26
26
|
"axios": "^1.13.2",
|