@xfe-repo/web-utils 1.0.10 → 1.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/dist/env.d.mts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/env.mjs +3 -3
- package/dist/loadScript.js +2 -4
- package/dist/loadScript.mjs +3 -5
- package/dist/storage.js +2 -2
- package/dist/storage.mjs +3 -3
- package/dist/tools.d.mts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +8 -16
- package/dist/tools.mjs +9 -17
- package/dist/valid.mjs +1 -1
- package/package.json +5 -7
- /package/dist/{chunk-6BSPRPK2.mjs → chunk-3K5GXOTC.mjs} +0 -0
package/dist/env.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ declare const business: Business;
|
|
|
14
14
|
declare const assetsHost = "https://imgs.xianghuanji.com/";
|
|
15
15
|
declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
16
16
|
declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
17
|
-
declare const isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is
|
|
17
|
+
declare const isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is TestEnv;
|
|
18
18
|
declare const getEnvApi: (envApis: Record<ApiEnv, string>, _apiEnv?: ApiEnv) => string;
|
|
19
19
|
declare const getBffApi: (_apiEnv?: ApiEnv) => string;
|
|
20
20
|
declare function getEnvDomain(hostname: string): string;
|
package/dist/env.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const business: Business;
|
|
|
14
14
|
declare const assetsHost = "https://imgs.xianghuanji.com/";
|
|
15
15
|
declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
16
16
|
declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
17
|
-
declare const isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is
|
|
17
|
+
declare const isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is TestEnv;
|
|
18
18
|
declare const getEnvApi: (envApis: Record<ApiEnv, string>, _apiEnv?: ApiEnv) => string;
|
|
19
19
|
declare const getBffApi: (_apiEnv?: ApiEnv) => string;
|
|
20
20
|
declare function getEnvDomain(hostname: string): string;
|
package/dist/env.js
CHANGED
|
@@ -97,9 +97,9 @@ var isTestEnv = (_apiEnv) => {
|
|
|
97
97
|
};
|
|
98
98
|
var getEnvApi = (envApis, _apiEnv = apiEnv) => {
|
|
99
99
|
if (isTestEnv(_apiEnv)) {
|
|
100
|
-
return
|
|
100
|
+
return envApis["test"].replace("test", _apiEnv);
|
|
101
101
|
} else {
|
|
102
|
-
return
|
|
102
|
+
return envApis[_apiEnv];
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
var getBffApi = (_apiEnv = apiEnv) => {
|
package/dist/env.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-3K5GXOTC.mjs";
|
|
2
2
|
|
|
3
3
|
// src/env.ts
|
|
4
4
|
var isServer = typeof window === "undefined";
|
|
@@ -58,9 +58,9 @@ var isTestEnv = (_apiEnv) => {
|
|
|
58
58
|
};
|
|
59
59
|
var getEnvApi = (envApis, _apiEnv = apiEnv) => {
|
|
60
60
|
if (isTestEnv(_apiEnv)) {
|
|
61
|
-
return
|
|
61
|
+
return envApis["test"].replace("test", _apiEnv);
|
|
62
62
|
} else {
|
|
63
|
-
return
|
|
63
|
+
return envApis[_apiEnv];
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
var getBffApi = (_apiEnv = apiEnv) => {
|
package/dist/loadScript.js
CHANGED
|
@@ -52,8 +52,7 @@ var LoadScript = class _LoadScript {
|
|
|
52
52
|
this.isLoaded = false;
|
|
53
53
|
this.url = url;
|
|
54
54
|
this.name = name;
|
|
55
|
-
if (!window)
|
|
56
|
-
throw new Error("must init in client");
|
|
55
|
+
if (!window) throw new Error("must init in client");
|
|
57
56
|
if (window[name]) {
|
|
58
57
|
this.isLoaded = true;
|
|
59
58
|
return;
|
|
@@ -63,8 +62,7 @@ var LoadScript = class _LoadScript {
|
|
|
63
62
|
_LoadScript.script.src = url;
|
|
64
63
|
_LoadScript.script.async = true;
|
|
65
64
|
const el = document.getElementsByTagName("script")[0];
|
|
66
|
-
if (!el)
|
|
67
|
-
throw new Error("script tag not found");
|
|
65
|
+
if (!el) throw new Error("script tag not found");
|
|
68
66
|
el.parentNode.insertBefore(_LoadScript.script, el);
|
|
69
67
|
}
|
|
70
68
|
load() {
|
package/dist/loadScript.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__async
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3K5GXOTC.mjs";
|
|
4
4
|
|
|
5
5
|
// src/loadScript.ts
|
|
6
6
|
var LoadScript = class _LoadScript {
|
|
@@ -10,8 +10,7 @@ var LoadScript = class _LoadScript {
|
|
|
10
10
|
this.isLoaded = false;
|
|
11
11
|
this.url = url;
|
|
12
12
|
this.name = name;
|
|
13
|
-
if (!window)
|
|
14
|
-
throw new Error("must init in client");
|
|
13
|
+
if (!window) throw new Error("must init in client");
|
|
15
14
|
if (window[name]) {
|
|
16
15
|
this.isLoaded = true;
|
|
17
16
|
return;
|
|
@@ -21,8 +20,7 @@ var LoadScript = class _LoadScript {
|
|
|
21
20
|
_LoadScript.script.src = url;
|
|
22
21
|
_LoadScript.script.async = true;
|
|
23
22
|
const el = document.getElementsByTagName("script")[0];
|
|
24
|
-
if (!el)
|
|
25
|
-
throw new Error("script tag not found");
|
|
23
|
+
if (!el) throw new Error("script tag not found");
|
|
26
24
|
el.parentNode.insertBefore(_LoadScript.script, el);
|
|
27
25
|
}
|
|
28
26
|
load() {
|
package/dist/storage.js
CHANGED
|
@@ -58,9 +58,9 @@ function getUrlQuery(key) {
|
|
|
58
58
|
return queryJson[key];
|
|
59
59
|
}
|
|
60
60
|
function setUrlQuery(queryJson) {
|
|
61
|
-
let { hash
|
|
61
|
+
let { hash } = window.location;
|
|
62
62
|
const search = import_query_string.default.stringify(queryJson, { skipNull: true, skipEmptyString: true });
|
|
63
|
-
const url =
|
|
63
|
+
const url = `?${search}${hash.split("?")[0]}`;
|
|
64
64
|
window.history.replaceState({}, "", url);
|
|
65
65
|
}
|
|
66
66
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/storage.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-3K5GXOTC.mjs";
|
|
2
2
|
|
|
3
3
|
// src/storage.ts
|
|
4
4
|
import cookie from "js-cookie";
|
|
@@ -23,9 +23,9 @@ function getUrlQuery(key) {
|
|
|
23
23
|
return queryJson[key];
|
|
24
24
|
}
|
|
25
25
|
function setUrlQuery(queryJson) {
|
|
26
|
-
let { hash
|
|
26
|
+
let { hash } = window.location;
|
|
27
27
|
const search = queryString.stringify(queryJson, { skipNull: true, skipEmptyString: true });
|
|
28
|
-
const url =
|
|
28
|
+
const url = `?${search}${hash.split("?")[0]}`;
|
|
29
29
|
window.history.replaceState({}, "", url);
|
|
30
30
|
}
|
|
31
31
|
export {
|
package/dist/tools.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** mock 骨架屏数据 */
|
|
2
|
-
declare const mockSkeletons: <T>(length: number, fn?: (
|
|
2
|
+
declare const mockSkeletons: <T>(length: number, fn?: (id: number) => Partial<T>) => T[];
|
|
3
3
|
declare const delayHandle: (tick: number) => Promise<void>;
|
|
4
4
|
declare function getBase64(file: File | Blob): Promise<any>;
|
|
5
5
|
declare function getObjectURL(file: File | Blob): string;
|
|
@@ -36,7 +36,7 @@ type OptionsRecordType<Keys extends string | number | symbol = any> = {
|
|
|
36
36
|
type OptionsMapType<Keys extends string | number | symbol = any> = {
|
|
37
37
|
[key in Keys]?: Record<string, string>;
|
|
38
38
|
};
|
|
39
|
-
declare const combobox2Options: <CB extends Record<string, (ComboBox
|
|
39
|
+
declare const combobox2Options: <CB extends Record<string, (ComboBox | ComboBox<string>)[]>>(comboBox: CB) => {
|
|
40
40
|
options: OptionsRecordType<keyof CB>;
|
|
41
41
|
optionsMap: OptionsMapType<keyof CB>;
|
|
42
42
|
};
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** mock 骨架屏数据 */
|
|
2
|
-
declare const mockSkeletons: <T>(length: number, fn?: (
|
|
2
|
+
declare const mockSkeletons: <T>(length: number, fn?: (id: number) => Partial<T>) => T[];
|
|
3
3
|
declare const delayHandle: (tick: number) => Promise<void>;
|
|
4
4
|
declare function getBase64(file: File | Blob): Promise<any>;
|
|
5
5
|
declare function getObjectURL(file: File | Blob): string;
|
|
@@ -36,7 +36,7 @@ type OptionsRecordType<Keys extends string | number | symbol = any> = {
|
|
|
36
36
|
type OptionsMapType<Keys extends string | number | symbol = any> = {
|
|
37
37
|
[key in Keys]?: Record<string, string>;
|
|
38
38
|
};
|
|
39
|
-
declare const combobox2Options: <CB extends Record<string, (ComboBox
|
|
39
|
+
declare const combobox2Options: <CB extends Record<string, (ComboBox | ComboBox<string>)[]>>(comboBox: CB) => {
|
|
40
40
|
options: OptionsRecordType<keyof CB>;
|
|
41
41
|
optionsMap: OptionsMapType<keyof CB>;
|
|
42
42
|
};
|
package/dist/tools.js
CHANGED
|
@@ -156,8 +156,7 @@ var widthThrottle = (delay) => {
|
|
|
156
156
|
var debounce = (delay, callback) => {
|
|
157
157
|
let timeoutID;
|
|
158
158
|
function wrapper(...args) {
|
|
159
|
-
if (timeoutID)
|
|
160
|
-
clearTimeout(timeoutID);
|
|
159
|
+
if (timeoutID) clearTimeout(timeoutID);
|
|
161
160
|
const exec = () => {
|
|
162
161
|
callback(...args);
|
|
163
162
|
};
|
|
@@ -177,8 +176,7 @@ function uuid() {
|
|
|
177
176
|
return s.join("");
|
|
178
177
|
}
|
|
179
178
|
var imgRelative2Absolute = (imgUrl = "") => {
|
|
180
|
-
if (!imgUrl)
|
|
181
|
-
return imgUrl;
|
|
179
|
+
if (!imgUrl) return imgUrl;
|
|
182
180
|
const isAbsoluteUrl = imgUrl.startsWith("https");
|
|
183
181
|
if (!isAbsoluteUrl) {
|
|
184
182
|
imgUrl = `https://imgs.xianghuanji.com/${imgUrl.replace(/^\//, "")}`;
|
|
@@ -186,8 +184,7 @@ var imgRelative2Absolute = (imgUrl = "") => {
|
|
|
186
184
|
return imgUrl;
|
|
187
185
|
};
|
|
188
186
|
var resizeAliYun = (imgUrl = "", width, quality) => {
|
|
189
|
-
if (!imgUrl)
|
|
190
|
-
return imgUrl;
|
|
187
|
+
if (!imgUrl) return imgUrl;
|
|
191
188
|
if (isTmp(imgUrl) || isBlob(imgUrl) || isImgWeChat(imgUrl)) {
|
|
192
189
|
return imgUrl;
|
|
193
190
|
}
|
|
@@ -201,12 +198,9 @@ var resizeAliYun = (imgUrl = "", width, quality) => {
|
|
|
201
198
|
imgUrl = imgUrl.replace(/[?#].*/g, "");
|
|
202
199
|
const isHeic = isImgHeic(imgUrl);
|
|
203
200
|
let params = "x-oss-process=image";
|
|
204
|
-
if (width)
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
params = `${params}/quality,Q_${quality}`;
|
|
208
|
-
if (isHeic)
|
|
209
|
-
params = `${params}/format,jpg`;
|
|
201
|
+
if (width) params = `${params}/resize,w_${width}`;
|
|
202
|
+
if (quality) params = `${params}/quality,Q_${quality}`;
|
|
203
|
+
if (isHeic) params = `${params}/format,jpg`;
|
|
210
204
|
return `${imgUrl}?${params}`;
|
|
211
205
|
};
|
|
212
206
|
var fieldsArrayToString = (fields) => {
|
|
@@ -214,8 +208,7 @@ var fieldsArrayToString = (fields) => {
|
|
|
214
208
|
Object.keys(fieldsCopy).forEach((key) => {
|
|
215
209
|
const typeKey = key;
|
|
216
210
|
const value = fieldsCopy[typeKey];
|
|
217
|
-
if (Array.isArray(value))
|
|
218
|
-
fieldsCopy[typeKey] = value.join(",");
|
|
211
|
+
if (Array.isArray(value)) fieldsCopy[typeKey] = value.join(",");
|
|
219
212
|
});
|
|
220
213
|
return fieldsCopy;
|
|
221
214
|
};
|
|
@@ -234,8 +227,7 @@ var combobox2Options = (comboBox) => {
|
|
|
234
227
|
const optionsKey = key;
|
|
235
228
|
const optionsList = comboBox[optionsKey];
|
|
236
229
|
options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
|
|
237
|
-
if (!optionsMap[optionsKey])
|
|
238
|
-
optionsMap[optionsKey] = {};
|
|
230
|
+
if (!optionsMap[optionsKey]) optionsMap[optionsKey] = {};
|
|
239
231
|
optionsMap[optionsKey][id] = name;
|
|
240
232
|
return { label: name, value: id };
|
|
241
233
|
})) || [];
|
package/dist/tools.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-BVYCWBGX.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__spreadValues
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3K5GXOTC.mjs";
|
|
13
13
|
|
|
14
14
|
// src/tools.ts
|
|
15
15
|
var mockSkeletons = (length, fn) => {
|
|
@@ -99,8 +99,7 @@ var widthThrottle = (delay) => {
|
|
|
99
99
|
var debounce = (delay, callback) => {
|
|
100
100
|
let timeoutID;
|
|
101
101
|
function wrapper(...args) {
|
|
102
|
-
if (timeoutID)
|
|
103
|
-
clearTimeout(timeoutID);
|
|
102
|
+
if (timeoutID) clearTimeout(timeoutID);
|
|
104
103
|
const exec = () => {
|
|
105
104
|
callback(...args);
|
|
106
105
|
};
|
|
@@ -120,8 +119,7 @@ function uuid() {
|
|
|
120
119
|
return s.join("");
|
|
121
120
|
}
|
|
122
121
|
var imgRelative2Absolute = (imgUrl = "") => {
|
|
123
|
-
if (!imgUrl)
|
|
124
|
-
return imgUrl;
|
|
122
|
+
if (!imgUrl) return imgUrl;
|
|
125
123
|
const isAbsoluteUrl = imgUrl.startsWith("https");
|
|
126
124
|
if (!isAbsoluteUrl) {
|
|
127
125
|
imgUrl = `https://imgs.xianghuanji.com/${imgUrl.replace(/^\//, "")}`;
|
|
@@ -129,8 +127,7 @@ var imgRelative2Absolute = (imgUrl = "") => {
|
|
|
129
127
|
return imgUrl;
|
|
130
128
|
};
|
|
131
129
|
var resizeAliYun = (imgUrl = "", width, quality) => {
|
|
132
|
-
if (!imgUrl)
|
|
133
|
-
return imgUrl;
|
|
130
|
+
if (!imgUrl) return imgUrl;
|
|
134
131
|
if (isTmp(imgUrl) || isBlob(imgUrl) || isImgWeChat(imgUrl)) {
|
|
135
132
|
return imgUrl;
|
|
136
133
|
}
|
|
@@ -144,12 +141,9 @@ var resizeAliYun = (imgUrl = "", width, quality) => {
|
|
|
144
141
|
imgUrl = imgUrl.replace(/[?#].*/g, "");
|
|
145
142
|
const isHeic = isImgHeic(imgUrl);
|
|
146
143
|
let params = "x-oss-process=image";
|
|
147
|
-
if (width)
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
params = `${params}/quality,Q_${quality}`;
|
|
151
|
-
if (isHeic)
|
|
152
|
-
params = `${params}/format,jpg`;
|
|
144
|
+
if (width) params = `${params}/resize,w_${width}`;
|
|
145
|
+
if (quality) params = `${params}/quality,Q_${quality}`;
|
|
146
|
+
if (isHeic) params = `${params}/format,jpg`;
|
|
153
147
|
return `${imgUrl}?${params}`;
|
|
154
148
|
};
|
|
155
149
|
var fieldsArrayToString = (fields) => {
|
|
@@ -157,8 +151,7 @@ var fieldsArrayToString = (fields) => {
|
|
|
157
151
|
Object.keys(fieldsCopy).forEach((key) => {
|
|
158
152
|
const typeKey = key;
|
|
159
153
|
const value = fieldsCopy[typeKey];
|
|
160
|
-
if (Array.isArray(value))
|
|
161
|
-
fieldsCopy[typeKey] = value.join(",");
|
|
154
|
+
if (Array.isArray(value)) fieldsCopy[typeKey] = value.join(",");
|
|
162
155
|
});
|
|
163
156
|
return fieldsCopy;
|
|
164
157
|
};
|
|
@@ -177,8 +170,7 @@ var combobox2Options = (comboBox) => {
|
|
|
177
170
|
const optionsKey = key;
|
|
178
171
|
const optionsList = comboBox[optionsKey];
|
|
179
172
|
options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
|
|
180
|
-
if (!optionsMap[optionsKey])
|
|
181
|
-
optionsMap[optionsKey] = {};
|
|
173
|
+
if (!optionsMap[optionsKey]) optionsMap[optionsKey] = {};
|
|
182
174
|
optionsMap[optionsKey][id] = name;
|
|
183
175
|
return { label: name, value: id };
|
|
184
176
|
})) || [];
|
package/dist/valid.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-utils",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
+
"module": "dist/*.js",
|
|
6
|
+
"types": "types/*.d.ts",
|
|
5
7
|
"exports": {
|
|
6
8
|
"./*": {
|
|
7
9
|
"import": {
|
|
@@ -11,10 +13,6 @@
|
|
|
11
13
|
"require": {
|
|
12
14
|
"types": "./dist/*.d.ts",
|
|
13
15
|
"default": "./dist/*.js"
|
|
14
|
-
},
|
|
15
|
-
"default": {
|
|
16
|
-
"types": "./dist/*.d.ts",
|
|
17
|
-
"default": "./dist/*.js"
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
},
|
|
@@ -28,8 +26,8 @@
|
|
|
28
26
|
"devDependencies": {
|
|
29
27
|
"@types/js-cookie": "^3.0.5",
|
|
30
28
|
"@types/node": "^20.10.3",
|
|
31
|
-
"@xfe-repo/
|
|
32
|
-
"@xfe-repo/
|
|
29
|
+
"@xfe-repo/typescript-config": "0.0.3",
|
|
30
|
+
"@xfe-repo/eslint-config": "0.0.2"
|
|
33
31
|
},
|
|
34
32
|
"scripts": {
|
|
35
33
|
"build": "tsup",
|
|
File without changes
|