@xfe-repo/web-utils 1.0.2 → 1.0.4

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.
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+
38
+ export {
39
+ __spreadValues,
40
+ __async
41
+ };
@@ -0,0 +1,52 @@
1
+ // src/valid.ts
2
+ var regPhone = /^1[3-9]\d{9}$/;
3
+ var isValidPhone = (value) => Boolean(regPhone.test(value == null ? void 0 : value.replace(/\s/g, "")));
4
+ var regCaptchaSms = /^\d{4}$/;
5
+ var isValidCaptchaSms = (value) => Boolean(regCaptchaSms.test(value.replace(/\s/g, "")));
6
+ var regValidSms = /^\d{4}$/;
7
+ var isValidSms = (value) => Boolean(regValidSms.test(value.replace(/\s/g, "")));
8
+ var regNumber = /^\d+$/;
9
+ var isValidNumber = (value) => Boolean(regNumber.test(value.replace(/\s/g, "")));
10
+ var regEmail = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
11
+ var isValidEmail = (value) => Boolean(regEmail.test(value.replace(/\s/g, "")));
12
+ var regImgBase64 = /^data:image\/.*;base64,/i;
13
+ var isImgBase64 = (value) => Boolean(regImgBase64.test(value.replace(/\s/g, "")));
14
+ var regBlob = /^blob:/i;
15
+ var isBlob = (value) => Boolean(regBlob.test(value.replace(/\s/g, "")));
16
+ var regTmp = /^(wxfile|http):\/\/tmp/i;
17
+ var isTmp = (value) => Boolean(regTmp.test(value.replace(/\s/g, "")));
18
+ var regImgHeic = /\.(heic)(\?.+)?$/i;
19
+ var isImgHeic = (value) => Boolean(regImgHeic.test(value.replace(/\s/g, "")));
20
+ var regImgSvg = /\.(svg)(\?.+)?$/i;
21
+ var isImgSvg = (value) => Boolean(regImgSvg.test(value.replace(/\s/g, "")));
22
+ var regImgWeChat = /^https:\/\/(thirdwx|wx)\.qlogo\.cn/i;
23
+ var isImgWeChat = (value) => Boolean(regImgWeChat.test(value.replace(/\s/g, "")));
24
+ var regAssets = /^(\/(assets|static))/i;
25
+ var isAssets = (value) => Boolean(regAssets.test(value.replace(/\s/g, "")));
26
+
27
+ export {
28
+ regPhone,
29
+ isValidPhone,
30
+ regCaptchaSms,
31
+ isValidCaptchaSms,
32
+ regValidSms,
33
+ isValidSms,
34
+ regNumber,
35
+ isValidNumber,
36
+ regEmail,
37
+ isValidEmail,
38
+ regImgBase64,
39
+ isImgBase64,
40
+ regBlob,
41
+ isBlob,
42
+ regTmp,
43
+ isTmp,
44
+ regImgHeic,
45
+ isImgHeic,
46
+ regImgSvg,
47
+ isImgSvg,
48
+ regImgWeChat,
49
+ isImgWeChat,
50
+ regAssets,
51
+ isAssets
52
+ };
package/dist/env.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-WDFZ2WQK.mjs";
1
+ import "./chunk-6BSPRPK2.mjs";
2
2
 
3
3
  // src/env.ts
4
4
  var isServer = typeof window === "undefined";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "./chunk-WDFZ2WQK.mjs";
3
+ } from "./chunk-6BSPRPK2.mjs";
4
4
 
5
5
  // src/loadScript.ts
6
6
  var LoadScript = class _LoadScript {
package/dist/token.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-WDFZ2WQK.mjs";
1
+ import "./chunk-6BSPRPK2.mjs";
2
2
 
3
3
  // src/token.ts
4
4
  import cookie from "js-cookie";
package/dist/tools.d.mts CHANGED
@@ -11,6 +11,33 @@ declare const throttle: (delay: number, callback: any) => {
11
11
  };
12
12
  declare const widthThrottle: (delay: number) => (target: any, _name: string, descriptor: PropertyDescriptor) => void;
13
13
  declare const debounce: <T extends (...args: any) => any>(delay: number, callback: T) => T;
14
- declare const resizeAliYun: (imgUrl?: string, width?: number) => string;
14
+ declare const imgRelative2Absolute: (imgUrl?: string) => string;
15
+ declare const resizeAliYun: (imgUrl?: string, width?: number | null, quality?: number) => string;
16
+ type FieldsWithoutArray<FS extends Record<string, any>> = {
17
+ [K in keyof FS]: FS[K] extends any[] | undefined ? string | undefined : FS[K];
18
+ };
19
+ declare const fieldsArrayToString: <FS extends Record<string, any>>(fields: FS) => FieldsWithoutArray<FS>;
20
+ type FieldsWithUndefined<FS extends Record<string, any>> = {
21
+ [K in keyof FS]: undefined;
22
+ };
23
+ declare const fieldsReset: <FS extends Record<string, any>>(fields: FS) => FieldsWithUndefined<FS>;
24
+ type ComboBox<Value = number> = {
25
+ name?: string;
26
+ id?: Value;
27
+ };
28
+ type OptionsType = {
29
+ label: string;
30
+ value: string | number;
31
+ }[];
32
+ type OptionsRecordType<Keys extends string | number | symbol = any> = {
33
+ [key in Keys]?: OptionsType;
34
+ };
35
+ type OptionsMapType<Keys extends string | number | symbol = any> = {
36
+ [key in Keys]?: Record<string, string>;
37
+ };
38
+ declare const combobox2Options: <CB extends Record<string, (ComboBox<number> | ComboBox<string>)[]>>(comboBox: CB) => {
39
+ options: OptionsRecordType<keyof CB>;
40
+ optionsMap: OptionsMapType<keyof CB>;
41
+ };
15
42
 
16
- export { debounce, delayHandle, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
43
+ export { type ComboBox, type OptionsMapType, type OptionsRecordType, type OptionsType, combobox2Options, debounce, delayHandle, fieldsArrayToString, fieldsReset, formatterPrice, formatterTax, getBase64, getObjectURL, imgRelative2Absolute, mockSkeletons, resizeAliYun, throttle, widthThrottle };
package/dist/tools.d.ts CHANGED
@@ -11,6 +11,33 @@ declare const throttle: (delay: number, callback: any) => {
11
11
  };
12
12
  declare const widthThrottle: (delay: number) => (target: any, _name: string, descriptor: PropertyDescriptor) => void;
13
13
  declare const debounce: <T extends (...args: any) => any>(delay: number, callback: T) => T;
14
- declare const resizeAliYun: (imgUrl?: string, width?: number) => string;
14
+ declare const imgRelative2Absolute: (imgUrl?: string) => string;
15
+ declare const resizeAliYun: (imgUrl?: string, width?: number | null, quality?: number) => string;
16
+ type FieldsWithoutArray<FS extends Record<string, any>> = {
17
+ [K in keyof FS]: FS[K] extends any[] | undefined ? string | undefined : FS[K];
18
+ };
19
+ declare const fieldsArrayToString: <FS extends Record<string, any>>(fields: FS) => FieldsWithoutArray<FS>;
20
+ type FieldsWithUndefined<FS extends Record<string, any>> = {
21
+ [K in keyof FS]: undefined;
22
+ };
23
+ declare const fieldsReset: <FS extends Record<string, any>>(fields: FS) => FieldsWithUndefined<FS>;
24
+ type ComboBox<Value = number> = {
25
+ name?: string;
26
+ id?: Value;
27
+ };
28
+ type OptionsType = {
29
+ label: string;
30
+ value: string | number;
31
+ }[];
32
+ type OptionsRecordType<Keys extends string | number | symbol = any> = {
33
+ [key in Keys]?: OptionsType;
34
+ };
35
+ type OptionsMapType<Keys extends string | number | symbol = any> = {
36
+ [key in Keys]?: Record<string, string>;
37
+ };
38
+ declare const combobox2Options: <CB extends Record<string, (ComboBox<number> | ComboBox<string>)[]>>(comboBox: CB) => {
39
+ options: OptionsRecordType<keyof CB>;
40
+ optionsMap: OptionsMapType<keyof CB>;
41
+ };
15
42
 
16
- export { debounce, delayHandle, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
43
+ export { type ComboBox, type OptionsMapType, type OptionsRecordType, type OptionsType, combobox2Options, debounce, delayHandle, fieldsArrayToString, fieldsReset, formatterPrice, formatterTax, getBase64, getObjectURL, imgRelative2Absolute, mockSkeletons, resizeAliYun, throttle, widthThrottle };
package/dist/tools.js CHANGED
@@ -2,7 +2,21 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
6
20
  var __export = (target, all) => {
7
21
  for (var name in all)
8
22
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -20,18 +34,40 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
34
  // src/tools.ts
21
35
  var tools_exports = {};
22
36
  __export(tools_exports, {
37
+ combobox2Options: () => combobox2Options,
23
38
  debounce: () => debounce,
24
39
  delayHandle: () => delayHandle,
40
+ fieldsArrayToString: () => fieldsArrayToString,
41
+ fieldsReset: () => fieldsReset,
25
42
  formatterPrice: () => formatterPrice,
26
43
  formatterTax: () => formatterTax,
27
44
  getBase64: () => getBase64,
28
45
  getObjectURL: () => getObjectURL,
46
+ imgRelative2Absolute: () => imgRelative2Absolute,
29
47
  mockSkeletons: () => mockSkeletons,
30
48
  resizeAliYun: () => resizeAliYun,
31
49
  throttle: () => throttle,
32
50
  widthThrottle: () => widthThrottle
33
51
  });
34
52
  module.exports = __toCommonJS(tools_exports);
53
+
54
+ // src/valid.ts
55
+ var regImgBase64 = /^data:image\/.*;base64,/i;
56
+ var isImgBase64 = (value) => Boolean(regImgBase64.test(value.replace(/\s/g, "")));
57
+ var regBlob = /^blob:/i;
58
+ var isBlob = (value) => Boolean(regBlob.test(value.replace(/\s/g, "")));
59
+ var regTmp = /^(wxfile|http):\/\/tmp/i;
60
+ var isTmp = (value) => Boolean(regTmp.test(value.replace(/\s/g, "")));
61
+ var regImgHeic = /\.(heic)(\?.+)?$/i;
62
+ var isImgHeic = (value) => Boolean(regImgHeic.test(value.replace(/\s/g, "")));
63
+ var regImgSvg = /\.(svg)(\?.+)?$/i;
64
+ var isImgSvg = (value) => Boolean(regImgSvg.test(value.replace(/\s/g, "")));
65
+ var regImgWeChat = /^https:\/\/(thirdwx|wx)\.qlogo\.cn/i;
66
+ var isImgWeChat = (value) => Boolean(regImgWeChat.test(value.replace(/\s/g, "")));
67
+ var regAssets = /^(\/(assets|static))/i;
68
+ var isAssets = (value) => Boolean(regAssets.test(value.replace(/\s/g, "")));
69
+
70
+ // src/tools.ts
35
71
  var mockSkeletons = (length, fn) => {
36
72
  const mockList = [];
37
73
  fn = fn || ((id) => ({ id }));
@@ -128,20 +164,84 @@ var debounce = (delay, callback) => {
128
164
  }
129
165
  return wrapper;
130
166
  };
131
- var resizeAliYun = (imgUrl = "", width = 300) => {
132
- if (!imgUrl || !imgUrl.startsWith("http"))
167
+ var imgRelative2Absolute = (imgUrl = "") => {
168
+ if (!imgUrl)
169
+ return imgUrl;
170
+ const isAbsoluteUrl = imgUrl.startsWith("https");
171
+ if (!isAbsoluteUrl) {
172
+ imgUrl = `https://imgs.xianghuanji.com/${imgUrl.replace(/^\//, "")}`;
173
+ }
174
+ return imgUrl;
175
+ };
176
+ var resizeAliYun = (imgUrl = "", width, quality) => {
177
+ if (!imgUrl)
178
+ return imgUrl;
179
+ if (isTmp(imgUrl) || isBlob(imgUrl) || isImgWeChat(imgUrl)) {
180
+ return imgUrl;
181
+ }
182
+ if (isImgBase64(imgUrl) || isAssets(imgUrl)) {
183
+ return imgUrl;
184
+ }
185
+ imgUrl = imgRelative2Absolute(imgUrl);
186
+ if (isImgSvg(imgUrl)) {
133
187
  return imgUrl;
188
+ }
134
189
  imgUrl = imgUrl.replace(/[?#].*/g, "");
135
- return `${imgUrl}?x-oss-process=image/resize,w_${width}`;
190
+ const isHeic = isImgHeic(imgUrl);
191
+ let params = "x-oss-process=image";
192
+ if (width)
193
+ params = `${params}/resize,w_${width}`;
194
+ if (quality)
195
+ params = `${params}/quality,Q_${quality}`;
196
+ if (isHeic)
197
+ params = `${params}/format,jpg`;
198
+ return `${imgUrl}?${params}`;
199
+ };
200
+ var fieldsArrayToString = (fields) => {
201
+ const fieldsCopy = __spreadValues({}, fields);
202
+ Object.keys(fieldsCopy).forEach((key) => {
203
+ const typeKey = key;
204
+ const value = fieldsCopy[typeKey];
205
+ if (Array.isArray(value))
206
+ fieldsCopy[typeKey] = value.join(",");
207
+ });
208
+ return fieldsCopy;
209
+ };
210
+ var fieldsReset = (fields) => {
211
+ const fieldsCopy = __spreadValues({}, fields);
212
+ Object.keys(fieldsCopy).forEach((key) => {
213
+ const typeKey = key;
214
+ fieldsCopy[typeKey] = void 0;
215
+ });
216
+ return fieldsCopy;
217
+ };
218
+ var combobox2Options = (comboBox) => {
219
+ const options = {};
220
+ const optionsMap = {};
221
+ Object.keys(comboBox).forEach((key) => {
222
+ const optionsKey = key;
223
+ const optionsList = comboBox[optionsKey];
224
+ options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
225
+ if (!optionsMap[optionsKey])
226
+ optionsMap[optionsKey] = {};
227
+ optionsMap[optionsKey][id] = name;
228
+ return { label: name, value: id };
229
+ })) || [];
230
+ });
231
+ return { options, optionsMap };
136
232
  };
137
233
  // Annotate the CommonJS export names for ESM import in node:
138
234
  0 && (module.exports = {
235
+ combobox2Options,
139
236
  debounce,
140
237
  delayHandle,
238
+ fieldsArrayToString,
239
+ fieldsReset,
141
240
  formatterPrice,
142
241
  formatterTax,
143
242
  getBase64,
144
243
  getObjectURL,
244
+ imgRelative2Absolute,
145
245
  mockSkeletons,
146
246
  resizeAliYun,
147
247
  throttle,
package/dist/tools.mjs CHANGED
@@ -1,4 +1,15 @@
1
- import "./chunk-WDFZ2WQK.mjs";
1
+ import {
2
+ isAssets,
3
+ isBlob,
4
+ isImgBase64,
5
+ isImgHeic,
6
+ isImgSvg,
7
+ isImgWeChat,
8
+ isTmp
9
+ } from "./chunk-BVYCWBGX.mjs";
10
+ import {
11
+ __spreadValues
12
+ } from "./chunk-6BSPRPK2.mjs";
2
13
 
3
14
  // src/tools.ts
4
15
  var mockSkeletons = (length, fn) => {
@@ -97,19 +108,83 @@ var debounce = (delay, callback) => {
97
108
  }
98
109
  return wrapper;
99
110
  };
100
- var resizeAliYun = (imgUrl = "", width = 300) => {
101
- if (!imgUrl || !imgUrl.startsWith("http"))
111
+ var imgRelative2Absolute = (imgUrl = "") => {
112
+ if (!imgUrl)
102
113
  return imgUrl;
114
+ const isAbsoluteUrl = imgUrl.startsWith("https");
115
+ if (!isAbsoluteUrl) {
116
+ imgUrl = `https://imgs.xianghuanji.com/${imgUrl.replace(/^\//, "")}`;
117
+ }
118
+ return imgUrl;
119
+ };
120
+ var resizeAliYun = (imgUrl = "", width, quality) => {
121
+ if (!imgUrl)
122
+ return imgUrl;
123
+ if (isTmp(imgUrl) || isBlob(imgUrl) || isImgWeChat(imgUrl)) {
124
+ return imgUrl;
125
+ }
126
+ if (isImgBase64(imgUrl) || isAssets(imgUrl)) {
127
+ return imgUrl;
128
+ }
129
+ imgUrl = imgRelative2Absolute(imgUrl);
130
+ if (isImgSvg(imgUrl)) {
131
+ return imgUrl;
132
+ }
103
133
  imgUrl = imgUrl.replace(/[?#].*/g, "");
104
- return `${imgUrl}?x-oss-process=image/resize,w_${width}`;
134
+ const isHeic = isImgHeic(imgUrl);
135
+ let params = "x-oss-process=image";
136
+ if (width)
137
+ params = `${params}/resize,w_${width}`;
138
+ if (quality)
139
+ params = `${params}/quality,Q_${quality}`;
140
+ if (isHeic)
141
+ params = `${params}/format,jpg`;
142
+ return `${imgUrl}?${params}`;
143
+ };
144
+ var fieldsArrayToString = (fields) => {
145
+ const fieldsCopy = __spreadValues({}, fields);
146
+ Object.keys(fieldsCopy).forEach((key) => {
147
+ const typeKey = key;
148
+ const value = fieldsCopy[typeKey];
149
+ if (Array.isArray(value))
150
+ fieldsCopy[typeKey] = value.join(",");
151
+ });
152
+ return fieldsCopy;
153
+ };
154
+ var fieldsReset = (fields) => {
155
+ const fieldsCopy = __spreadValues({}, fields);
156
+ Object.keys(fieldsCopy).forEach((key) => {
157
+ const typeKey = key;
158
+ fieldsCopy[typeKey] = void 0;
159
+ });
160
+ return fieldsCopy;
161
+ };
162
+ var combobox2Options = (comboBox) => {
163
+ const options = {};
164
+ const optionsMap = {};
165
+ Object.keys(comboBox).forEach((key) => {
166
+ const optionsKey = key;
167
+ const optionsList = comboBox[optionsKey];
168
+ options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
169
+ if (!optionsMap[optionsKey])
170
+ optionsMap[optionsKey] = {};
171
+ optionsMap[optionsKey][id] = name;
172
+ return { label: name, value: id };
173
+ })) || [];
174
+ });
175
+ return { options, optionsMap };
105
176
  };
106
177
  export {
178
+ combobox2Options,
107
179
  debounce,
108
180
  delayHandle,
181
+ fieldsArrayToString,
182
+ fieldsReset,
109
183
  formatterPrice,
110
184
  formatterTax,
111
185
  getBase64,
112
186
  getObjectURL,
187
+ imgRelative2Absolute,
113
188
  mockSkeletons,
114
189
  resizeAliYun,
115
190
  throttle,
package/dist/valid.d.mts CHANGED
@@ -2,7 +2,25 @@ declare const regPhone: RegExp;
2
2
  declare const isValidPhone: (value: string) => boolean;
3
3
  declare const regCaptchaSms: RegExp;
4
4
  declare const isValidCaptchaSms: (value: string) => boolean;
5
+ declare const regValidSms: RegExp;
6
+ declare const isValidSms: (value: string) => boolean;
5
7
  declare const regNumber: RegExp;
6
8
  declare const isValidNumber: (value: string) => boolean;
9
+ declare const regEmail: RegExp;
10
+ declare const isValidEmail: (value: string) => boolean;
11
+ declare const regImgBase64: RegExp;
12
+ declare const isImgBase64: (value: string) => boolean;
13
+ declare const regBlob: RegExp;
14
+ declare const isBlob: (value: string) => boolean;
15
+ declare const regTmp: RegExp;
16
+ declare const isTmp: (value: string) => boolean;
17
+ declare const regImgHeic: RegExp;
18
+ declare const isImgHeic: (value: string) => boolean;
19
+ declare const regImgSvg: RegExp;
20
+ declare const isImgSvg: (value: string) => boolean;
21
+ declare const regImgWeChat: RegExp;
22
+ declare const isImgWeChat: (value: string) => boolean;
23
+ declare const regAssets: RegExp;
24
+ declare const isAssets: (value: string) => boolean;
7
25
 
8
- export { isValidCaptchaSms, isValidNumber, isValidPhone, regCaptchaSms, regNumber, regPhone };
26
+ export { isAssets, isBlob, isImgBase64, isImgHeic, isImgSvg, isImgWeChat, isTmp, isValidCaptchaSms, isValidEmail, isValidNumber, isValidPhone, isValidSms, regAssets, regBlob, regCaptchaSms, regEmail, regImgBase64, regImgHeic, regImgSvg, regImgWeChat, regNumber, regPhone, regTmp, regValidSms };
package/dist/valid.d.ts CHANGED
@@ -2,7 +2,25 @@ declare const regPhone: RegExp;
2
2
  declare const isValidPhone: (value: string) => boolean;
3
3
  declare const regCaptchaSms: RegExp;
4
4
  declare const isValidCaptchaSms: (value: string) => boolean;
5
+ declare const regValidSms: RegExp;
6
+ declare const isValidSms: (value: string) => boolean;
5
7
  declare const regNumber: RegExp;
6
8
  declare const isValidNumber: (value: string) => boolean;
9
+ declare const regEmail: RegExp;
10
+ declare const isValidEmail: (value: string) => boolean;
11
+ declare const regImgBase64: RegExp;
12
+ declare const isImgBase64: (value: string) => boolean;
13
+ declare const regBlob: RegExp;
14
+ declare const isBlob: (value: string) => boolean;
15
+ declare const regTmp: RegExp;
16
+ declare const isTmp: (value: string) => boolean;
17
+ declare const regImgHeic: RegExp;
18
+ declare const isImgHeic: (value: string) => boolean;
19
+ declare const regImgSvg: RegExp;
20
+ declare const isImgSvg: (value: string) => boolean;
21
+ declare const regImgWeChat: RegExp;
22
+ declare const isImgWeChat: (value: string) => boolean;
23
+ declare const regAssets: RegExp;
24
+ declare const isAssets: (value: string) => boolean;
7
25
 
8
- export { isValidCaptchaSms, isValidNumber, isValidPhone, regCaptchaSms, regNumber, regPhone };
26
+ export { isAssets, isBlob, isImgBase64, isImgHeic, isImgSvg, isImgWeChat, isTmp, isValidCaptchaSms, isValidEmail, isValidNumber, isValidPhone, isValidSms, regAssets, regBlob, regCaptchaSms, regEmail, regImgBase64, regImgHeic, regImgSvg, regImgWeChat, regNumber, regPhone, regTmp, regValidSms };
package/dist/valid.js CHANGED
@@ -20,26 +20,80 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/valid.ts
21
21
  var valid_exports = {};
22
22
  __export(valid_exports, {
23
+ isAssets: () => isAssets,
24
+ isBlob: () => isBlob,
25
+ isImgBase64: () => isImgBase64,
26
+ isImgHeic: () => isImgHeic,
27
+ isImgSvg: () => isImgSvg,
28
+ isImgWeChat: () => isImgWeChat,
29
+ isTmp: () => isTmp,
23
30
  isValidCaptchaSms: () => isValidCaptchaSms,
31
+ isValidEmail: () => isValidEmail,
24
32
  isValidNumber: () => isValidNumber,
25
33
  isValidPhone: () => isValidPhone,
34
+ isValidSms: () => isValidSms,
35
+ regAssets: () => regAssets,
36
+ regBlob: () => regBlob,
26
37
  regCaptchaSms: () => regCaptchaSms,
38
+ regEmail: () => regEmail,
39
+ regImgBase64: () => regImgBase64,
40
+ regImgHeic: () => regImgHeic,
41
+ regImgSvg: () => regImgSvg,
42
+ regImgWeChat: () => regImgWeChat,
27
43
  regNumber: () => regNumber,
28
- regPhone: () => regPhone
44
+ regPhone: () => regPhone,
45
+ regTmp: () => regTmp,
46
+ regValidSms: () => regValidSms
29
47
  });
30
48
  module.exports = __toCommonJS(valid_exports);
31
49
  var regPhone = /^1[3-9]\d{9}$/;
32
- var isValidPhone = (value) => Boolean(regPhone.test(value.replace(/\s/g, "")));
50
+ var isValidPhone = (value) => Boolean(regPhone.test(value == null ? void 0 : value.replace(/\s/g, "")));
33
51
  var regCaptchaSms = /^\d{4}$/;
34
52
  var isValidCaptchaSms = (value) => Boolean(regCaptchaSms.test(value.replace(/\s/g, "")));
53
+ var regValidSms = /^\d{4}$/;
54
+ var isValidSms = (value) => Boolean(regValidSms.test(value.replace(/\s/g, "")));
35
55
  var regNumber = /^\d+$/;
36
56
  var isValidNumber = (value) => Boolean(regNumber.test(value.replace(/\s/g, "")));
57
+ var regEmail = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
58
+ var isValidEmail = (value) => Boolean(regEmail.test(value.replace(/\s/g, "")));
59
+ var regImgBase64 = /^data:image\/.*;base64,/i;
60
+ var isImgBase64 = (value) => Boolean(regImgBase64.test(value.replace(/\s/g, "")));
61
+ var regBlob = /^blob:/i;
62
+ var isBlob = (value) => Boolean(regBlob.test(value.replace(/\s/g, "")));
63
+ var regTmp = /^(wxfile|http):\/\/tmp/i;
64
+ var isTmp = (value) => Boolean(regTmp.test(value.replace(/\s/g, "")));
65
+ var regImgHeic = /\.(heic)(\?.+)?$/i;
66
+ var isImgHeic = (value) => Boolean(regImgHeic.test(value.replace(/\s/g, "")));
67
+ var regImgSvg = /\.(svg)(\?.+)?$/i;
68
+ var isImgSvg = (value) => Boolean(regImgSvg.test(value.replace(/\s/g, "")));
69
+ var regImgWeChat = /^https:\/\/(thirdwx|wx)\.qlogo\.cn/i;
70
+ var isImgWeChat = (value) => Boolean(regImgWeChat.test(value.replace(/\s/g, "")));
71
+ var regAssets = /^(\/(assets|static))/i;
72
+ var isAssets = (value) => Boolean(regAssets.test(value.replace(/\s/g, "")));
37
73
  // Annotate the CommonJS export names for ESM import in node:
38
74
  0 && (module.exports = {
75
+ isAssets,
76
+ isBlob,
77
+ isImgBase64,
78
+ isImgHeic,
79
+ isImgSvg,
80
+ isImgWeChat,
81
+ isTmp,
39
82
  isValidCaptchaSms,
83
+ isValidEmail,
40
84
  isValidNumber,
41
85
  isValidPhone,
86
+ isValidSms,
87
+ regAssets,
88
+ regBlob,
42
89
  regCaptchaSms,
90
+ regEmail,
91
+ regImgBase64,
92
+ regImgHeic,
93
+ regImgSvg,
94
+ regImgWeChat,
43
95
  regNumber,
44
- regPhone
96
+ regPhone,
97
+ regTmp,
98
+ regValidSms
45
99
  });
package/dist/valid.mjs CHANGED
@@ -1,17 +1,53 @@
1
- import "./chunk-WDFZ2WQK.mjs";
2
-
3
- // src/valid.ts
4
- var regPhone = /^1[3-9]\d{9}$/;
5
- var isValidPhone = (value) => Boolean(regPhone.test(value.replace(/\s/g, "")));
6
- var regCaptchaSms = /^\d{4}$/;
7
- var isValidCaptchaSms = (value) => Boolean(regCaptchaSms.test(value.replace(/\s/g, "")));
8
- var regNumber = /^\d+$/;
9
- var isValidNumber = (value) => Boolean(regNumber.test(value.replace(/\s/g, "")));
1
+ import {
2
+ isAssets,
3
+ isBlob,
4
+ isImgBase64,
5
+ isImgHeic,
6
+ isImgSvg,
7
+ isImgWeChat,
8
+ isTmp,
9
+ isValidCaptchaSms,
10
+ isValidEmail,
11
+ isValidNumber,
12
+ isValidPhone,
13
+ isValidSms,
14
+ regAssets,
15
+ regBlob,
16
+ regCaptchaSms,
17
+ regEmail,
18
+ regImgBase64,
19
+ regImgHeic,
20
+ regImgSvg,
21
+ regImgWeChat,
22
+ regNumber,
23
+ regPhone,
24
+ regTmp,
25
+ regValidSms
26
+ } from "./chunk-BVYCWBGX.mjs";
27
+ import "./chunk-6BSPRPK2.mjs";
10
28
  export {
29
+ isAssets,
30
+ isBlob,
31
+ isImgBase64,
32
+ isImgHeic,
33
+ isImgSvg,
34
+ isImgWeChat,
35
+ isTmp,
11
36
  isValidCaptchaSms,
37
+ isValidEmail,
12
38
  isValidNumber,
13
39
  isValidPhone,
40
+ isValidSms,
41
+ regAssets,
42
+ regBlob,
14
43
  regCaptchaSms,
44
+ regEmail,
45
+ regImgBase64,
46
+ regImgHeic,
47
+ regImgSvg,
48
+ regImgWeChat,
15
49
  regNumber,
16
- regPhone
50
+ regPhone,
51
+ regTmp,
52
+ regValidSms
17
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./*": {
@@ -18,9 +18,6 @@
18
18
  "devDependencies": {
19
19
  "@types/js-cookie": "^3.0.5",
20
20
  "@types/node": "^20.10.3",
21
- "eslint": "^8.53.0",
22
- "tsup": "^8.0.1",
23
- "typescript": "^5.2.2",
24
21
  "@xfe-repo/eslint-config": "0.0.1",
25
22
  "@xfe-repo/typescript-config": "0.0.2"
26
23
  },