@snack-kit/lib 0.7.0 → 0.8.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/README.md +5 -0
- package/dist/cjs/{chunk-U6KYHCBL.cjs → chunk-MNKOKLT2.cjs} +124 -2
- package/dist/cjs/chunk-MNKOKLT2.cjs.map +1 -0
- package/dist/cjs/index.cjs +44 -36
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils.cjs +43 -35
- package/dist/es/chunk-C4CPPDML.js +349 -0
- package/dist/es/chunk-C4CPPDML.js.map +1 -0
- package/dist/es/index.js +2 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/utils.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils.d.ts +119 -1
- package/dist/umd/index.global.js +123 -1
- package/dist/umd/index.global.js.map +1 -1
- package/dist/umd/utils.global.js +122 -0
- package/dist/umd/utils.global.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/chunk-U6KYHCBL.cjs.map +0 -1
- package/dist/es/chunk-WJX5Q3WL.js +0 -229
- package/dist/es/chunk-WJX5Q3WL.js.map +0 -1
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../package.json"],"names":[],"mappings":";;;;;;AAEE,IAAA,OAAA,GAAW","file":"index.js","sourcesContent":["{\n \"name\": \"@snack-kit/lib\",\n \"version\": \"0.
|
|
1
|
+
{"version":3,"sources":["../../package.json"],"names":[],"mappings":";;;;;;AAEE,IAAA,OAAA,GAAW","file":"index.js","sourcesContent":["{\n \"name\": \"@snack-kit/lib\",\n \"version\": \"0.8.0\",\n \"description\": \"Enterprise-grade utility library\",\n \"keywords\": [],\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"import\": \"./dist/es/index.js\",\n \"require\": \"./dist/cjs/index.cjs\"\n },\n \"./http\": {\n \"types\": \"./dist/types/http.d.ts\",\n \"import\": \"./dist/es/http.js\",\n \"require\": \"./dist/cjs/http.cjs\"\n },\n \"./debugger\": {\n \"types\": \"./dist/types/debugger.d.ts\",\n \"import\": \"./dist/es/debugger.js\",\n \"require\": \"./dist/cjs/debugger.cjs\"\n },\n \"./utils\": {\n \"types\": \"./dist/types/utils.d.ts\",\n \"import\": \"./dist/es/utils.js\",\n \"require\": \"./dist/cjs/utils.cjs\"\n }\n },\n \"main\": \"./dist/cjs/index.cjs\",\n \"module\": \"./dist/es/index.js\",\n \"types\": \"./dist/types/index.d.ts\",\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:watch\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"docs\": \"typedoc && cp -r docs/demo docs/api/demo\",\n \"docs:watch\": \"typedoc --watch\",\n \"lint\": \"tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\",\n \"release\": \"npm run build && npm publish --access public\"\n },\n \"devDependencies\": {\n \"@vitest/coverage-v8\": \"^2.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typedoc\": \"^0.26.0\",\n \"typescript\": \"^5.5.3\",\n \"vitest\": \"^2.0.0\"\n },\n \"dependencies\": {\n \"axios\": \"^1.13.6\"\n }\n}\n"]}
|
package/dist/es/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CleanObject, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, Throttle, UUID, Unique, UniqueByKey } from './chunk-
|
|
1
|
+
export { CleanObject, CopyToClipboard, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, REGEXPRULES, Throttle, UUID, Unique, UniqueByKey } from './chunk-C4CPPDML.js';
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
3
3
|
//# sourceMappingURL=utils.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { C as Context, a as ContextInfo, b as Ctx, D as DEBUGGER_ACTIVE_KEY, H a
|
|
|
2
2
|
export { Cancel, CancelAll, Del, Get, Patch, Post, Put, Request } from './http.js';
|
|
3
3
|
export { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, default as axios } from 'axios';
|
|
4
4
|
export { Debugger, DebuggerOptions } from './debugger.js';
|
|
5
|
-
export { CleanObject, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, Throttle, UUID, Unique, UniqueByKey } from './utils.js';
|
|
5
|
+
export { CleanObject, CopyToClipboard, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, REGEXPRULES, Throttle, UUID, Unique, UniqueByKey } from './utils.js';
|
|
6
6
|
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.8.0";
|
|
8
8
|
|
|
9
9
|
export { version as VERSION };
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -164,6 +164,103 @@ declare const IsInteger: (val: string) => boolean;
|
|
|
164
164
|
* 浏览器兼容性:Chrome 5+ · Firefox 3+ · Safari 4+ · Node.js 0.10+
|
|
165
165
|
*/
|
|
166
166
|
declare const IsPositiveInteger: (val: string) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* 完整正则规则集,来源参考 any-rule(https://github.com/any86/any-rule)。
|
|
169
|
+
*
|
|
170
|
+
* 包含数字/英文/中文、身份证、邮箱、电话、URL、IP、时间、颜色等常用规则。
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* REGEXPRULES.phone.test('13812345678') // true
|
|
175
|
+
* REGEXPRULES.email.test('user@example.com') // true
|
|
176
|
+
* ```
|
|
177
|
+
* @remarks
|
|
178
|
+
* 浏览器兼容性:Chrome 5+ · Firefox 3+ · Safari 4+ · Node.js 0.10+
|
|
179
|
+
*/
|
|
180
|
+
declare const REGEXPRULES: {
|
|
181
|
+
/** 只能是数字和字母 */
|
|
182
|
+
readonly numberEnglish: RegExp;
|
|
183
|
+
/** 只能是非数字和字母 */
|
|
184
|
+
readonly unnumberEnglish: RegExp;
|
|
185
|
+
/** 只能是数字 */
|
|
186
|
+
readonly number: RegExp;
|
|
187
|
+
/** 只能是非数字 */
|
|
188
|
+
readonly unnumber: RegExp;
|
|
189
|
+
/** 只能是英文 */
|
|
190
|
+
readonly english: RegExp;
|
|
191
|
+
/** 只能是中文 */
|
|
192
|
+
readonly chinese: RegExp;
|
|
193
|
+
/** 不能包含中文 */
|
|
194
|
+
readonly unchinese: RegExp;
|
|
195
|
+
/** 整数(含负数和零) */
|
|
196
|
+
readonly integer: RegExp;
|
|
197
|
+
/** 中文、字母、数字 */
|
|
198
|
+
readonly chineseEnglishNumber: RegExp;
|
|
199
|
+
/** 浮点数 */
|
|
200
|
+
readonly floatNumber: RegExp;
|
|
201
|
+
/** 严格浮点数 */
|
|
202
|
+
readonly strictFloatNumber: RegExp;
|
|
203
|
+
/** 二代身份证 */
|
|
204
|
+
readonly idcard: RegExp;
|
|
205
|
+
/** 香港身份证 */
|
|
206
|
+
readonly hkIdcard: RegExp;
|
|
207
|
+
/** 澳门身份证 */
|
|
208
|
+
readonly amIdcard: RegExp;
|
|
209
|
+
/** 台湾身份证 */
|
|
210
|
+
readonly twIdcard: RegExp;
|
|
211
|
+
/** 邮箱(符合 RFC 标准) */
|
|
212
|
+
readonly email: RegExp;
|
|
213
|
+
/** 中文邮箱 */
|
|
214
|
+
readonly chineseEmail: RegExp;
|
|
215
|
+
/** 手机号(宽松:13-19 开头) */
|
|
216
|
+
readonly phone: RegExp;
|
|
217
|
+
/** 手机号(严谨,基于工信部 2019 年最新公布号段) */
|
|
218
|
+
readonly strictPhone: RegExp;
|
|
219
|
+
/** 座机 */
|
|
220
|
+
readonly telphone: RegExp;
|
|
221
|
+
/** 手机机身号码(IMEI) */
|
|
222
|
+
readonly IMEI: RegExp;
|
|
223
|
+
/** URL(http / https / ftp) */
|
|
224
|
+
readonly url: RegExp;
|
|
225
|
+
/** URL(仅 http / https) */
|
|
226
|
+
readonly link: RegExp;
|
|
227
|
+
/** 磁力链接(宽松匹配) */
|
|
228
|
+
readonly magnet: RegExp;
|
|
229
|
+
/** 图片地址 */
|
|
230
|
+
readonly image: RegExp;
|
|
231
|
+
/** 视频地址 */
|
|
232
|
+
readonly video: RegExp;
|
|
233
|
+
/** Base64 数据 URI */
|
|
234
|
+
readonly base64: RegExp;
|
|
235
|
+
/** 以 http/https 开头的绝对路径 */
|
|
236
|
+
readonly httpStart: RegExp;
|
|
237
|
+
/** 必须带端口号的网址或 IP */
|
|
238
|
+
readonly ipport: RegExp;
|
|
239
|
+
/** IPv4(可带端口) */
|
|
240
|
+
readonly ipv4Port: RegExp;
|
|
241
|
+
/** 子网掩码 */
|
|
242
|
+
readonly netmask: RegExp;
|
|
243
|
+
/** 24 小时制时间(HH:mm:ss) */
|
|
244
|
+
readonly '24Time': RegExp;
|
|
245
|
+
/** 12 小时制时间(hh:mm:ss) */
|
|
246
|
+
readonly '12Time': RegExp;
|
|
247
|
+
/** 日期(宽松,如 2022-9-1) */
|
|
248
|
+
readonly date: RegExp;
|
|
249
|
+
/** 日期(严谨,支持闰年判断) */
|
|
250
|
+
readonly strictDate: RegExp;
|
|
251
|
+
/** QQ 号 */
|
|
252
|
+
readonly qq: RegExp;
|
|
253
|
+
/** 微信号(6-20 位,字母开头) */
|
|
254
|
+
readonly wx: RegExp;
|
|
255
|
+
/** 邮政编码(中国) */
|
|
256
|
+
readonly postal: RegExp;
|
|
257
|
+
/** 匹配连续重复字符 */
|
|
258
|
+
readonly double: RegExp;
|
|
259
|
+
/** 密码强度(最少 6 位,含大小写字母、数字、特殊字符各至少 1 个) */
|
|
260
|
+
readonly passwordCheck: RegExp;
|
|
261
|
+
/** 16 进制颜色值 */
|
|
262
|
+
readonly color: RegExp;
|
|
263
|
+
};
|
|
167
264
|
|
|
168
265
|
/**
|
|
169
266
|
* 数组工具
|
|
@@ -356,6 +453,27 @@ declare const ObjectToQuery: (obj: Record<string, unknown>) => string;
|
|
|
356
453
|
* 依赖 `URLSearchParams`(WHATWG URL Standard)。
|
|
357
454
|
*/
|
|
358
455
|
declare const QueryToObject: (query: string) => Record<string, string>;
|
|
456
|
+
/**
|
|
457
|
+
* 将文本写入系统剪贴板。
|
|
458
|
+
*
|
|
459
|
+
* 优先使用现代 `navigator.clipboard.writeText()` API(异步、安全上下文);
|
|
460
|
+
* 在不支持或非安全上下文(非 HTTPS / localhost)时,降级为
|
|
461
|
+
* `document.execCommand('copy')`(已废弃但兼容性广)。
|
|
462
|
+
*
|
|
463
|
+
* @returns 成功时 resolve `true`,失败时 resolve `false`(不抛出异常)
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```ts
|
|
467
|
+
* const ok = await CopyToClipboard('Hello World')
|
|
468
|
+
* if (!ok) console.warn('复制失败')
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* @remarks
|
|
472
|
+
* 浏览器兼容性:
|
|
473
|
+
* - `navigator.clipboard`(优先):Chrome 66+ · Firefox 63+ · Safari 13.1+(需 HTTPS 或 localhost)
|
|
474
|
+
* - `execCommand` 降级:Chrome 1+ · Firefox 41+ · Safari 10+
|
|
475
|
+
*/
|
|
476
|
+
declare const CopyToClipboard: (str: string) => Promise<boolean>;
|
|
359
477
|
|
|
360
478
|
/**
|
|
361
479
|
* 时间日期工具
|
|
@@ -407,4 +525,4 @@ declare const GetDayRange: (date?: Date) => {
|
|
|
407
525
|
end: number;
|
|
408
526
|
};
|
|
409
527
|
|
|
410
|
-
export { CleanObject, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, Throttle, UUID, Unique, UniqueByKey };
|
|
528
|
+
export { CleanObject, CopyToClipboard, Debounce, DeepClone, Delay, FormatDate, GetDateOffset, GetDayRange, GetURLParam, GetURLParams, IsArray, IsBoolean, IsEmail, IsEqual, IsFunction, IsInteger, IsIpv4, IsNull, IsNumber, IsObject, IsPhone, IsPositiveInteger, IsRealNumber, IsString, IsUrl, Minus, ObjectToQuery, Omit, Pick, QueryToObject, REGEX, REGEXPRULES, Throttle, UUID, Unique, UniqueByKey };
|
package/dist/umd/index.global.js
CHANGED
|
@@ -11625,7 +11625,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
11625
11625
|
});
|
|
11626
11626
|
|
|
11627
11627
|
// package.json
|
|
11628
|
-
var version = "0.
|
|
11628
|
+
var version = "0.8.0";
|
|
11629
11629
|
|
|
11630
11630
|
// node_modules/axios/lib/helpers/bind.js
|
|
11631
11631
|
function bind(fn, thisArg) {
|
|
@@ -16528,6 +16528,98 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
16528
16528
|
var IsIpv4 = (val) => REGEX.ipv4.test(val);
|
|
16529
16529
|
var IsInteger = (val) => REGEX.integer.test(val);
|
|
16530
16530
|
var IsPositiveInteger = (val) => REGEX.positiveInteger.test(val);
|
|
16531
|
+
var REGEXPRULES = {
|
|
16532
|
+
// ── 数字 / 英文 / 中文 ──────────────────────────────────────────────────
|
|
16533
|
+
/** 只能是数字和字母 */
|
|
16534
|
+
numberEnglish: /^\w+$/,
|
|
16535
|
+
/** 只能是非数字和字母 */
|
|
16536
|
+
unnumberEnglish: /^\W*$/,
|
|
16537
|
+
/** 只能是数字 */
|
|
16538
|
+
number: /^\d+$/,
|
|
16539
|
+
/** 只能是非数字 */
|
|
16540
|
+
unnumber: /^\D*$/,
|
|
16541
|
+
/** 只能是英文 */
|
|
16542
|
+
english: /^[a-zA-Z]+$/,
|
|
16543
|
+
/** 只能是中文 */
|
|
16544
|
+
chinese: /^[\u4E00-\u9FA5]+$/,
|
|
16545
|
+
/** 不能包含中文 */
|
|
16546
|
+
unchinese: /^[^\u4e00-\u9fa5]*$/,
|
|
16547
|
+
/** 整数(含负数和零) */
|
|
16548
|
+
integer: /(^-|^)\d+$/,
|
|
16549
|
+
/** 中文、字母、数字 */
|
|
16550
|
+
chineseEnglishNumber: /^[\u4e00-\u9fa5\w]+$/,
|
|
16551
|
+
/** 浮点数 */
|
|
16552
|
+
floatNumber: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9]\d*|0\.0+)$/,
|
|
16553
|
+
/** 严格浮点数 */
|
|
16554
|
+
strictFloatNumber: /^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9])$/,
|
|
16555
|
+
// ── 身份证 ──────────────────────────────────────────────────────────────
|
|
16556
|
+
/** 二代身份证 */
|
|
16557
|
+
idcard: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
|
|
16558
|
+
/** 香港身份证 */
|
|
16559
|
+
hkIdcard: /^[a-zA-Z]\d{6}\([\dA]\)$/,
|
|
16560
|
+
/** 澳门身份证 */
|
|
16561
|
+
amIdcard: /^[1|5|7]\d{6}\(\d\)$/,
|
|
16562
|
+
/** 台湾身份证 */
|
|
16563
|
+
twIdcard: /^[a-zA-Z][0-9]{9}$/,
|
|
16564
|
+
// ── 邮箱 ────────────────────────────────────────────────────────────────
|
|
16565
|
+
/** 邮箱(符合 RFC 标准) */
|
|
16566
|
+
email: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-_0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
16567
|
+
/** 中文邮箱 */
|
|
16568
|
+
chineseEmail: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
|
16569
|
+
// ── 电话 ────────────────────────────────────────────────────────────────
|
|
16570
|
+
/** 手机号(宽松:13-19 开头) */
|
|
16571
|
+
phone: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
|
|
16572
|
+
/** 手机号(严谨,基于工信部 2019 年最新公布号段) */
|
|
16573
|
+
strictPhone: /^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[189]))\d{8}$/,
|
|
16574
|
+
/** 座机 */
|
|
16575
|
+
telphone: /^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/,
|
|
16576
|
+
/** 手机机身号码(IMEI) */
|
|
16577
|
+
IMEI: /^\d{15,17}$/,
|
|
16578
|
+
// ── URL / 地址 ──────────────────────────────────────────────────────────
|
|
16579
|
+
/** URL(http / https / ftp) */
|
|
16580
|
+
url: /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/,
|
|
16581
|
+
/** URL(仅 http / https) */
|
|
16582
|
+
link: /^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/,
|
|
16583
|
+
/** 磁力链接(宽松匹配) */
|
|
16584
|
+
magnet: /^magnet:\?xt=urn:btih:[0-9a-fA-F]{40,}.*$/,
|
|
16585
|
+
/** 图片地址 */
|
|
16586
|
+
image: /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
|
|
16587
|
+
/** 视频地址 */
|
|
16588
|
+
video: /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i,
|
|
16589
|
+
/** Base64 数据 URI */
|
|
16590
|
+
base64: /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*?)\s*$/i,
|
|
16591
|
+
/** 以 http/https 开头的绝对路径 */
|
|
16592
|
+
httpStart: /^(http|https):\/\/\S*/,
|
|
16593
|
+
// ── IP ──────────────────────────────────────────────────────────────────
|
|
16594
|
+
/** 必须带端口号的网址或 IP */
|
|
16595
|
+
ipport: /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/,
|
|
16596
|
+
/** IPv4(可带端口) */
|
|
16597
|
+
ipv4Port: /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/,
|
|
16598
|
+
/** 子网掩码 */
|
|
16599
|
+
netmask: /^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(255|254|252|248|240|224|192|128|0)$/,
|
|
16600
|
+
// ── 时间 ────────────────────────────────────────────────────────────────
|
|
16601
|
+
/** 24 小时制时间(HH:mm:ss) */
|
|
16602
|
+
"24Time": /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/,
|
|
16603
|
+
/** 12 小时制时间(hh:mm:ss) */
|
|
16604
|
+
"12Time": /^(?:1[0-2]|0?[1-9]):[0-5]\d:[0-5]\d$/,
|
|
16605
|
+
/** 日期(宽松,如 2022-9-1) */
|
|
16606
|
+
date: /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/,
|
|
16607
|
+
/** 日期(严谨,支持闰年判断) */
|
|
16608
|
+
strictDate: /^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/,
|
|
16609
|
+
// ── 其他 ────────────────────────────────────────────────────────────────
|
|
16610
|
+
/** QQ 号 */
|
|
16611
|
+
qq: /^[1-9][0-9]{4,10}$/,
|
|
16612
|
+
/** 微信号(6-20 位,字母开头) */
|
|
16613
|
+
wx: /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/,
|
|
16614
|
+
/** 邮政编码(中国) */
|
|
16615
|
+
postal: /^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/,
|
|
16616
|
+
/** 匹配连续重复字符 */
|
|
16617
|
+
double: /(.)\1+/g,
|
|
16618
|
+
/** 密码强度(最少 6 位,含大小写字母、数字、特殊字符各至少 1 个) */
|
|
16619
|
+
passwordCheck: /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/,
|
|
16620
|
+
/** 16 进制颜色值 */
|
|
16621
|
+
color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
|
|
16622
|
+
};
|
|
16531
16623
|
|
|
16532
16624
|
// src/utils/array.ts
|
|
16533
16625
|
var Unique = (arr) => [...new Set(arr)];
|
|
@@ -16659,6 +16751,34 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
16659
16751
|
});
|
|
16660
16752
|
return result;
|
|
16661
16753
|
};
|
|
16754
|
+
var CopyToClipboard = async (str) => {
|
|
16755
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
16756
|
+
try {
|
|
16757
|
+
await navigator.clipboard.writeText(str);
|
|
16758
|
+
return true;
|
|
16759
|
+
} catch {
|
|
16760
|
+
}
|
|
16761
|
+
}
|
|
16762
|
+
try {
|
|
16763
|
+
const el = document.createElement("textarea");
|
|
16764
|
+
el.value = str;
|
|
16765
|
+
el.setAttribute("readonly", "");
|
|
16766
|
+
el.style.cssText = "position:absolute;left:-9999px;top:-9999px";
|
|
16767
|
+
document.body.appendChild(el);
|
|
16768
|
+
const selection = document.getSelection();
|
|
16769
|
+
const prevRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
|
|
16770
|
+
el.select();
|
|
16771
|
+
const ok = document.execCommand("copy");
|
|
16772
|
+
document.body.removeChild(el);
|
|
16773
|
+
if (prevRange && selection) {
|
|
16774
|
+
selection.removeAllRanges();
|
|
16775
|
+
selection.addRange(prevRange);
|
|
16776
|
+
}
|
|
16777
|
+
return ok;
|
|
16778
|
+
} catch {
|
|
16779
|
+
return false;
|
|
16780
|
+
}
|
|
16781
|
+
};
|
|
16662
16782
|
|
|
16663
16783
|
// src/utils/time.ts
|
|
16664
16784
|
var FormatDate = (date = /* @__PURE__ */ new Date(), format = "yyyy-MM-dd HH:mm:ss") => {
|
|
@@ -16720,6 +16840,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
16720
16840
|
exports.CancelAll = CancelAll;
|
|
16721
16841
|
exports.CleanObject = CleanObject;
|
|
16722
16842
|
exports.Context = Context;
|
|
16843
|
+
exports.CopyToClipboard = CopyToClipboard;
|
|
16723
16844
|
exports.Ctx = Ctx;
|
|
16724
16845
|
exports.DEBUGGER_ACTIVE_KEY = DEBUGGER_ACTIVE_KEY;
|
|
16725
16846
|
exports.Debounce = Debounce;
|
|
@@ -16759,6 +16880,7 @@ var SnackKit = (function (exports, crypto2, url, http, https, http2, util2, zlib
|
|
|
16759
16880
|
exports.Put = Put;
|
|
16760
16881
|
exports.QueryToObject = QueryToObject;
|
|
16761
16882
|
exports.REGEX = REGEX;
|
|
16883
|
+
exports.REGEXPRULES = REGEXPRULES;
|
|
16762
16884
|
exports.Request = Request;
|
|
16763
16885
|
exports.Throttle = Throttle;
|
|
16764
16886
|
exports.UUID = UUID;
|