@pawover/kit 0.3.1 → 0.4.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/package.json +9 -9
- package/packages/hooks/dist/index.d.ts +1 -1
- package/packages/hooks/dist/react.js +4 -3
- package/packages/utils/dist/index.d.ts +1129 -923
- package/packages/utils/dist/index.js +141 -2
- package/packages/utils/dist/{stringUtil-DbYpnL4l.js → math-Cvy9HBP0.js} +58 -3
- package/packages/utils/dist/math.js +1 -55
- package/packages/utils/dist/metadata.json +1 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MathJsInstance } from "mathjs";
|
|
1
2
|
//#region src/array/index.type.d.ts
|
|
2
3
|
type MatchFunction<T, R = unknown> = (row: T, index: number) => R;
|
|
3
4
|
//#endregion
|
|
@@ -305,678 +306,6 @@ declare class ArrayUtil {
|
|
|
305
306
|
static zipToObject<const K extends PropertyKey, const V>(keys: readonly K[], value: V): Record<K, V>;
|
|
306
307
|
}
|
|
307
308
|
//#endregion
|
|
308
|
-
//#region src/dateTime/dateTimeUtil.d.ts
|
|
309
|
-
/**
|
|
310
|
-
* 日期工具类
|
|
311
|
-
*/
|
|
312
|
-
declare class DateTimeUtil {
|
|
313
|
-
/**
|
|
314
|
-
* 每秒的毫秒数
|
|
315
|
-
* @example
|
|
316
|
-
* ```ts
|
|
317
|
-
* DateTimeUtil.MILLISECONDS_PER_SECOND; // 1000
|
|
318
|
-
* ```
|
|
319
|
-
*/
|
|
320
|
-
static readonly MILLISECONDS_PER_SECOND: number;
|
|
321
|
-
/**
|
|
322
|
-
* 每分钟的秒数
|
|
323
|
-
* @example
|
|
324
|
-
* ```ts
|
|
325
|
-
* DateTimeUtil.SECOND_PER_MINUTE; // 60
|
|
326
|
-
* ```
|
|
327
|
-
*/
|
|
328
|
-
static readonly SECOND_PER_MINUTE: number;
|
|
329
|
-
/**
|
|
330
|
-
* 每小时的分钟数
|
|
331
|
-
* @example
|
|
332
|
-
* ```ts
|
|
333
|
-
* DateTimeUtil.MINUTE_PER_HOUR; // 60
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
static readonly MINUTE_PER_HOUR: number;
|
|
337
|
-
/**
|
|
338
|
-
* 每小时的秒数
|
|
339
|
-
* @example
|
|
340
|
-
* ```ts
|
|
341
|
-
* DateTimeUtil.SECOND_PER_HOUR; // 3600
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
static readonly SECOND_PER_HOUR: number;
|
|
345
|
-
/**
|
|
346
|
-
* 每天小时数
|
|
347
|
-
* @example
|
|
348
|
-
* ```ts
|
|
349
|
-
* DateTimeUtil.HOUR_PER_DAY; // 24
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
static readonly HOUR_PER_DAY: number;
|
|
353
|
-
/**
|
|
354
|
-
* 每天秒数
|
|
355
|
-
* @example
|
|
356
|
-
* ```ts
|
|
357
|
-
* DateTimeUtil.SECOND_PER_DAY; // 86400
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
static readonly SECOND_PER_DAY: number;
|
|
361
|
-
/**
|
|
362
|
-
* 每周天数
|
|
363
|
-
* @example
|
|
364
|
-
* ```ts
|
|
365
|
-
* DateTimeUtil.DAY_PER_WEEK; // 7
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
static readonly DAY_PER_WEEK: number;
|
|
369
|
-
/**
|
|
370
|
-
* 每月天数
|
|
371
|
-
* @example
|
|
372
|
-
* ```ts
|
|
373
|
-
* DateTimeUtil.DAY_PER_MONTH; // 30
|
|
374
|
-
* ```
|
|
375
|
-
*/
|
|
376
|
-
static readonly DAY_PER_MONTH: number;
|
|
377
|
-
/**
|
|
378
|
-
* 每年天数
|
|
379
|
-
* @example
|
|
380
|
-
* ```ts
|
|
381
|
-
* DateTimeUtil.DAY_PER_YEAR; // 365
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
static readonly DAY_PER_YEAR: number;
|
|
385
|
-
/**
|
|
386
|
-
* 每年月数
|
|
387
|
-
* @example
|
|
388
|
-
* ```ts
|
|
389
|
-
* DateTimeUtil.MONTH_PER_YEAR; // 12
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
static readonly MONTH_PER_YEAR: number;
|
|
393
|
-
/**
|
|
394
|
-
* 每年平均周
|
|
395
|
-
* @example
|
|
396
|
-
* ```ts
|
|
397
|
-
* DateTimeUtil.WEEK_PER_YEAR; // 52
|
|
398
|
-
* ```
|
|
399
|
-
*/
|
|
400
|
-
static readonly WEEK_PER_YEAR: number;
|
|
401
|
-
/**
|
|
402
|
-
* 每月平均周
|
|
403
|
-
* @example
|
|
404
|
-
* ```ts
|
|
405
|
-
* DateTimeUtil.WEEK_PER_MONTH; // 4
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
static readonly WEEK_PER_MONTH: number;
|
|
409
|
-
/**
|
|
410
|
-
* 常用时间格式模板集合
|
|
411
|
-
*
|
|
412
|
-
* @example
|
|
413
|
-
* ```ts
|
|
414
|
-
* DateTimeUtil.FORMAT.ISO_DATE; // "yyyy-MM-dd"
|
|
415
|
-
* DateTimeUtil.FORMAT.CN_DATE_TIME; // "yyyy年MM月dd日 HH时mm分ss秒"
|
|
416
|
-
* ```
|
|
417
|
-
*/
|
|
418
|
-
static readonly FORMAT: {
|
|
419
|
-
readonly ISO_DATE: "yyyy-MM-dd";
|
|
420
|
-
readonly ISO_TIME: "HH:mm:ss";
|
|
421
|
-
readonly ISO_DATE_TIME: "yyyy-MM-dd HH:mm:ss";
|
|
422
|
-
readonly ISO_DATE_TIME_MS: "yyyy-MM-dd HH:mm:ss.SSS";
|
|
423
|
-
readonly ISO_DATETIME_TZ: "yyyy-MM-dd'T'HH:mm:ssXXX";
|
|
424
|
-
readonly ISO_DATETIME_TZ_MS: "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
|
425
|
-
readonly US_DATE: "MM/dd/yyyy";
|
|
426
|
-
readonly US_DATE_TIME: "MM/dd/yyyy HH:mm:ss";
|
|
427
|
-
readonly US_DATE_SHORT_YEAR: "MM/dd/yy";
|
|
428
|
-
readonly EU_DATE: "dd/MM/yyyy";
|
|
429
|
-
readonly EU_DATE_TIME: "dd/MM/yyyy HH:mm:ss";
|
|
430
|
-
readonly CN_DATE: "yyyy年MM月dd日";
|
|
431
|
-
readonly CN_DATE_TIME: "yyyy年MM月dd日 HH时mm分ss秒";
|
|
432
|
-
readonly CN_DATE_WEEKDAY: "yyyy年MM月dd日 EEE";
|
|
433
|
-
readonly CN_WEEKDAY_FULL: "EEEE";
|
|
434
|
-
readonly SHORT_DATE: "yy-MM-dd";
|
|
435
|
-
readonly SHORT_DATE_SLASH: "yy/MM/dd";
|
|
436
|
-
readonly MONTH_DAY: "MM-dd";
|
|
437
|
-
readonly MONTH_DAY_CN: "MM月dd日";
|
|
438
|
-
readonly DATE_WITH_WEEKDAY_SHORT: "yyyy-MM-dd (EEE)";
|
|
439
|
-
readonly DATE_WITH_WEEKDAY_FULL: "yyyy-MM-dd (EEEE)";
|
|
440
|
-
readonly TIME_24: "HH:mm:ss";
|
|
441
|
-
readonly TIME_24_NO_SEC: "HH:mm";
|
|
442
|
-
readonly TIME_12: "hh:mm:ss a";
|
|
443
|
-
readonly TIME_12_NO_SEC: "hh:mm a";
|
|
444
|
-
readonly TIMESTAMP: "yyyyMMddHHmmss";
|
|
445
|
-
readonly TIMESTAMP_MS: "yyyyMMddHHmmssSSS";
|
|
446
|
-
readonly RFC2822: "EEE, dd MMM yyyy HH:mm:ss xxx";
|
|
447
|
-
readonly READABLE_DATE: "MMM dd, yyyy";
|
|
448
|
-
readonly READABLE_DATE_TIME: "MMM dd, yyyy HH:mm";
|
|
449
|
-
readonly COMPACT_DATETIME: "yyyyMMdd_HHmmss";
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* 获取当前时区信息
|
|
453
|
-
*
|
|
454
|
-
* @returns 时区信息对象 (UTC偏移和时区名称)
|
|
455
|
-
* @example
|
|
456
|
-
* ```ts
|
|
457
|
-
* DateTimeUtil.getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
|
|
458
|
-
* ```
|
|
459
|
-
*/
|
|
460
|
-
static getTimeZone(): {
|
|
461
|
-
UTC: string;
|
|
462
|
-
timeZone: string;
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
//#endregion
|
|
466
|
-
//#region src/env/envUtil.d.ts
|
|
467
|
-
/**
|
|
468
|
-
* 环境检查工具类
|
|
469
|
-
*/
|
|
470
|
-
declare class EnvUtil {
|
|
471
|
-
private static readonly _isBrowser;
|
|
472
|
-
private static readonly _isWebWorker;
|
|
473
|
-
private static readonly _isReactNative;
|
|
474
|
-
/**
|
|
475
|
-
* 检测是否处于浏览器环境
|
|
476
|
-
*
|
|
477
|
-
* @returns 是否为浏览器环境
|
|
478
|
-
* @example
|
|
479
|
-
* ```ts
|
|
480
|
-
* EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
static isBrowser(): boolean;
|
|
484
|
-
/**
|
|
485
|
-
* 检测是否处于 Web Worker 环境
|
|
486
|
-
*
|
|
487
|
-
* @returns 是否为 Web Worker 环境
|
|
488
|
-
* @example
|
|
489
|
-
* ```ts
|
|
490
|
-
* EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
|
|
491
|
-
* ```
|
|
492
|
-
*/
|
|
493
|
-
static isWebWorker(): boolean;
|
|
494
|
-
/**
|
|
495
|
-
* 检测是否处于 React Native 环境
|
|
496
|
-
*
|
|
497
|
-
* @returns 是否为 React Native 环境
|
|
498
|
-
* @example
|
|
499
|
-
* ```ts
|
|
500
|
-
* EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
|
|
501
|
-
* ```
|
|
502
|
-
*/
|
|
503
|
-
static isReactNative(): boolean;
|
|
504
|
-
/**
|
|
505
|
-
* 检查是否在 iframe 环境中
|
|
506
|
-
*
|
|
507
|
-
* @returns 是否在 iframe 中
|
|
508
|
-
* @example
|
|
509
|
-
* ```ts
|
|
510
|
-
* EnvUtil.isIframe(); // true: 当前页面在 iframe 中
|
|
511
|
-
* ```
|
|
512
|
-
*/
|
|
513
|
-
static isIframe(): boolean;
|
|
514
|
-
/**
|
|
515
|
-
* 检测当前设备是否为桌面设备
|
|
516
|
-
*
|
|
517
|
-
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
518
|
-
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
519
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
520
|
-
* @returns 是否为桌面设备
|
|
521
|
-
* @example
|
|
522
|
-
* ```ts
|
|
523
|
-
* // 假设 window.innerWidth = 1920
|
|
524
|
-
* EnvUtil.isDesktop(); // true
|
|
525
|
-
*
|
|
526
|
-
* // 自定义阈值
|
|
527
|
-
* EnvUtil.isDesktop(1440, 13); // 更严格的桌面检测
|
|
528
|
-
* ```
|
|
529
|
-
*/
|
|
530
|
-
static isDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
531
|
-
/**
|
|
532
|
-
* 检测当前设备是否为 Windows 桌面设备
|
|
533
|
-
*
|
|
534
|
-
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
535
|
-
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
536
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
537
|
-
* @returns 是否为 Windows 桌面设备
|
|
538
|
-
* @example
|
|
539
|
-
* ```ts
|
|
540
|
-
* // UA contains Windows
|
|
541
|
-
* EnvUtil.isWindowsDesktop(); // true
|
|
542
|
-
* ```
|
|
543
|
-
*/
|
|
544
|
-
static isWindowsDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
545
|
-
/**
|
|
546
|
-
* 检测当前设备是否为 macOS 桌面设备
|
|
547
|
-
*
|
|
548
|
-
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
549
|
-
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
550
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
551
|
-
* @returns 是否为 macOS 桌面设备
|
|
552
|
-
* @example
|
|
553
|
-
* ```ts
|
|
554
|
-
* // UA contains Macintosh
|
|
555
|
-
* EnvUtil.isMacOSDesktop(); // true
|
|
556
|
-
* ```
|
|
557
|
-
*/
|
|
558
|
-
static isMacOSDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
559
|
-
/**
|
|
560
|
-
* 检测当前设备是否为移动设备
|
|
561
|
-
*
|
|
562
|
-
* @param maxWidth - 移动设备最大宽度(默认 768px)
|
|
563
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
564
|
-
* @returns 是否为移动设备
|
|
565
|
-
* @example
|
|
566
|
-
* ```ts
|
|
567
|
-
* // 假设 window.innerWidth = 500
|
|
568
|
-
* EnvUtil.isMobile(); // true
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
static isMobile(maxWidth?: number, dpi?: number): boolean;
|
|
572
|
-
/**
|
|
573
|
-
* 检测当前设备是否为IOS移动设备
|
|
574
|
-
*
|
|
575
|
-
* @param maxWidth - 移动设备最大宽度(默认 768px)
|
|
576
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
577
|
-
* @returns 是否为 iOS 移动设备 (iPhone/iPod)
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* // UA contains iPhone
|
|
581
|
-
* EnvUtil.isIOSMobile(); // true
|
|
582
|
-
* ```
|
|
583
|
-
*/
|
|
584
|
-
static isIOSMobile(maxWidth?: number, dpi?: number): boolean;
|
|
585
|
-
/**
|
|
586
|
-
* 检测当前设备是否为平板
|
|
587
|
-
*
|
|
588
|
-
* @param minWidth - 平板最小宽度(默认 768px)
|
|
589
|
-
* @param maxWidth - 平板最大宽度(默认 1200px)
|
|
590
|
-
* @param dpi - 标准 DPI 基准(默认 160)
|
|
591
|
-
* @returns 是否为平板设备
|
|
592
|
-
* @example
|
|
593
|
-
* ```ts
|
|
594
|
-
* // 假设 window.innerWidth = 1000
|
|
595
|
-
* EnvUtil.isTablet(); // true
|
|
596
|
-
* ```
|
|
597
|
-
*/
|
|
598
|
-
static isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
|
|
599
|
-
}
|
|
600
|
-
//#endregion
|
|
601
|
-
//#region ../../node_modules/.pnpm/@pawover+types@0.0.2_@types+react@19.2.15_typescript@6.0.3/node_modules/@pawover/types/dist/index.d.ts
|
|
602
|
-
//#endregion
|
|
603
|
-
//#region src/global.d.ts
|
|
604
|
-
/** 任意对象类型 */
|
|
605
|
-
type AnyObject<K extends PropertyKey = PropertyKey, T = any> = Record<K, T>;
|
|
606
|
-
/** 普通对象类型 */
|
|
607
|
-
type PlainObject<K extends PropertyKey = PropertyKey, T = unknown> = Record<K, T>;
|
|
608
|
-
/** 描述树类型 */
|
|
609
|
-
type TreeLike<T extends AnyObject, CK extends string = "children"> = T & Record<CK, TreeLike<T, CK>[]>;
|
|
610
|
-
/** 描述函数类型 */
|
|
611
|
-
type AnyFunction<P extends any[] = any[], R = any> = (...arg: P) => R;
|
|
612
|
-
/** 描述异步函数类型 */
|
|
613
|
-
type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promise<R>;
|
|
614
|
-
/** 描述生成器函数类型 */
|
|
615
|
-
type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
|
|
616
|
-
/** 描述异步生成器函数类型 */
|
|
617
|
-
type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
|
|
618
|
-
//#endregion
|
|
619
|
-
//#region src/function/functionUtil.d.ts
|
|
620
|
-
/**
|
|
621
|
-
* 函数工具类
|
|
622
|
-
*/
|
|
623
|
-
declare class FunctionUtil {
|
|
624
|
-
/**
|
|
625
|
-
*将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
|
|
626
|
-
*
|
|
627
|
-
* @param promise 待处理的 Promise
|
|
628
|
-
* @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
|
|
629
|
-
* @returns `[err, null]` 或 `[null, data]`
|
|
630
|
-
* @example
|
|
631
|
-
* ```ts
|
|
632
|
-
* const [err, data] = await FunctionUtil.to(someAsyncFunc());
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
|
-
static to<T, U = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U, undefined] | [null, T]>;
|
|
636
|
-
/**
|
|
637
|
-
* 将 Arguments 对象转换为数组
|
|
638
|
-
*
|
|
639
|
-
* ⚠️ 注意:TypeScript 官方推荐使用 rest parameters (...args) 替代 arguments
|
|
640
|
-
* 本函数仅用于处理遗留代码或特殊场景(如装饰器中需保留 this 绑定)
|
|
641
|
-
*
|
|
642
|
-
* @param args Arguments 对象(必须为类数组对象)
|
|
643
|
-
* @param start 起始索引(可选,默认为 0)
|
|
644
|
-
* @returns 转换后的数组,元素类型为 T
|
|
645
|
-
*
|
|
646
|
-
* @throws TypeError 如果 args 为 null 或 undefined
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* ```ts
|
|
650
|
-
* // 遗留代码场景
|
|
651
|
-
* function legacyFn(a: number, b: string) {
|
|
652
|
-
* const argsArray = FunctionUtil.toArgs(arguments);
|
|
653
|
-
* // argsArray: unknown[]
|
|
654
|
-
* }
|
|
655
|
-
*
|
|
656
|
-
* // 现代替代方案(推荐)
|
|
657
|
-
* function modernFn(a: number, b: string, ...rest: unknown[]) {
|
|
658
|
-
* // rest 已经是数组,无需 toArgs
|
|
659
|
-
* }
|
|
660
|
-
*
|
|
661
|
-
* // 参数截取
|
|
662
|
-
* function skipFirst(...args: unknown[]) {
|
|
663
|
-
* const rest = FunctionUtil.toArgs(arguments, 1);
|
|
664
|
-
* // rest: unknown[],跳过第一个参数
|
|
665
|
-
* }
|
|
666
|
-
* ```
|
|
667
|
-
*/
|
|
668
|
-
static toArgs<T = unknown>(args: IArguments, start?: number | undefined): T[];
|
|
669
|
-
/**
|
|
670
|
-
* 将同步或异步函数统一包装为 Promise
|
|
671
|
-
* - 自动捕获同步异常
|
|
672
|
-
*
|
|
673
|
-
* @param fn 返回值可为同步值或 Promise 的函数
|
|
674
|
-
* @returns 标准化的 Promise
|
|
675
|
-
*
|
|
676
|
-
* @example
|
|
677
|
-
* ```ts
|
|
678
|
-
* // 同步函数
|
|
679
|
-
* FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
|
|
680
|
-
*
|
|
681
|
-
* // 异步函数
|
|
682
|
-
* FunctionUtil.toPromise(async () => await fetchData()).then(data => ...);
|
|
683
|
-
*
|
|
684
|
-
* // 异常处理
|
|
685
|
-
* FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
|
|
686
|
-
* ```
|
|
687
|
-
*/
|
|
688
|
-
static toPromise<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
689
|
-
}
|
|
690
|
-
//#endregion
|
|
691
|
-
//#region src/mime/mimeUtil.d.ts
|
|
692
|
-
/**
|
|
693
|
-
* MIME 工具类
|
|
694
|
-
*/
|
|
695
|
-
declare class MimeUtil {
|
|
696
|
-
/**
|
|
697
|
-
* 文件类型 MIME 常量
|
|
698
|
-
* - 每个类型对应具体的文件扩展名
|
|
699
|
-
*/
|
|
700
|
-
static readonly FILE_MIME: {
|
|
701
|
-
/** 普通文本文件(.txt) */
|
|
702
|
-
readonly TEXT: "text/plain";
|
|
703
|
-
/** 超文本标记语言文档(.html/.htm) */
|
|
704
|
-
readonly HTML: "text/html";
|
|
705
|
-
/** 层叠样式表文件(.css) */
|
|
706
|
-
readonly CSS: "text/css";
|
|
707
|
-
/** 逗号分隔值文件/表格数据(.csv) */
|
|
708
|
-
readonly CSV: "text/csv";
|
|
709
|
-
/** 制表符分隔值文件(.tsv) */
|
|
710
|
-
readonly TSV: "text/tab-separated-values";
|
|
711
|
-
/** XML 文档(.xml) */
|
|
712
|
-
readonly XML: "application/xml";
|
|
713
|
-
/** XML 文档/兼容值 */
|
|
714
|
-
readonly XML_LEGACY: "text/xml";
|
|
715
|
-
/** XHTML 文档(.xhtml/.xht) */
|
|
716
|
-
readonly XHTML: "application/xhtml+xml";
|
|
717
|
-
/** JavaScript 文件(.js) */
|
|
718
|
-
readonly JS: "text/javascript";
|
|
719
|
-
/** TypeScript 文件(.ts) */
|
|
720
|
-
readonly TS: "text/typescript";
|
|
721
|
-
/** Python 文件(.py) */
|
|
722
|
-
readonly PY: "text/x-python";
|
|
723
|
-
/** Shell 脚本 (.sh) */
|
|
724
|
-
readonly SH: "text/x-sh";
|
|
725
|
-
/** C 语言源文件(.c) */
|
|
726
|
-
readonly C: "text/x-c";
|
|
727
|
-
/** C++ 源文件(.cpp/.cc/.cxx) */
|
|
728
|
-
readonly CPP: "text/x-c++";
|
|
729
|
-
/** C# 源文件(.cs) */
|
|
730
|
-
readonly CSHARP: "text/x-csharp";
|
|
731
|
-
/** Java 源文件(.java) */
|
|
732
|
-
readonly JAVA: "text/x-java";
|
|
733
|
-
/** Go 源文件(.go) */
|
|
734
|
-
readonly GO: "text/x-go";
|
|
735
|
-
/** Rust 源文件(.rs) */
|
|
736
|
-
readonly RUST: "text/x-rust";
|
|
737
|
-
/** PHP 文件(.php) */
|
|
738
|
-
readonly PHP: "text/x-php";
|
|
739
|
-
/** Ruby 文件(.rb) */
|
|
740
|
-
readonly RUBY: "text/x-ruby";
|
|
741
|
-
/** Swift 源文件(.swift) */
|
|
742
|
-
readonly SWIFT: "text/x-swift";
|
|
743
|
-
/** YAML 文档(.yaml/.yml) */
|
|
744
|
-
readonly YAML: "application/yaml";
|
|
745
|
-
/** YAML 文档/兼容值 */
|
|
746
|
-
readonly YAML_LEGACY: "text/vnd.yaml";
|
|
747
|
-
/** TOML 文档(.toml) */
|
|
748
|
-
readonly TOML: "application/toml";
|
|
749
|
-
/** TOML 文档/兼容值 */
|
|
750
|
-
readonly TOML_LEGACY: "text/x-toml";
|
|
751
|
-
/** SQL 脚本(.sql) */
|
|
752
|
-
readonly SQL: "application/sql";
|
|
753
|
-
/** SQL 脚本/兼容值 */
|
|
754
|
-
readonly SQL_LEGACY: "text/x-sql";
|
|
755
|
-
/** Markdown 格式文档(.md/.markdown) */
|
|
756
|
-
readonly MARKDOWN: "text/markdown";
|
|
757
|
-
/** 富文本格式文档(.rtf) */
|
|
758
|
-
readonly RTF: "application/rtf";
|
|
759
|
-
/** iCalendar 日历格式(.ics) */
|
|
760
|
-
readonly CALENDAR: "text/calendar";
|
|
761
|
-
/** JPEG 图像(.jpg/.jpeg) */
|
|
762
|
-
readonly JPEG: "image/jpeg";
|
|
763
|
-
/** JPG 图像(JPEG 别名,.jpg) */
|
|
764
|
-
readonly JPG: "image/jpeg";
|
|
765
|
-
/** PNG 图像/无损压缩,支持透明(.png) */
|
|
766
|
-
readonly PNG: "image/png";
|
|
767
|
-
/** GIF 图像/支持动画(.gif) */
|
|
768
|
-
readonly GIF: "image/gif";
|
|
769
|
-
/** Windows 位图(.bmp) */
|
|
770
|
-
readonly BMP: "image/bmp";
|
|
771
|
-
/** SVG 向量图形(.svg) */
|
|
772
|
-
readonly SVG: "image/svg+xml";
|
|
773
|
-
/** APNG 动态图像(.apng) */
|
|
774
|
-
readonly APNG: "image/apng";
|
|
775
|
-
/** AVIF 图像/高效压缩(.avif) */
|
|
776
|
-
readonly AVIF: "image/avif";
|
|
777
|
-
/** 图标文件格式(.ico) */
|
|
778
|
-
readonly ICO: "image/vnd.microsoft.icon";
|
|
779
|
-
/** 图标文件格式/兼容值(.ico) */
|
|
780
|
-
readonly ICO_LEGACY: "image/x-icon";
|
|
781
|
-
/** WebP 图像/高效压缩(.webp) */
|
|
782
|
-
readonly WEBP: "image/webp";
|
|
783
|
-
/** TIFF 图像(.tif/.tiff) */
|
|
784
|
-
readonly TIFF: "image/tiff";
|
|
785
|
-
/** HEIC 图像/高效编码(.heic) */
|
|
786
|
-
readonly HEIC: "image/heic";
|
|
787
|
-
/** HEIF 图像/高效编码(.heif) */
|
|
788
|
-
readonly HEIF: "image/heif";
|
|
789
|
-
/** Adobe Photoshop 文件(.psd) */
|
|
790
|
-
readonly PSD: "image/vnd.adobe.photoshop";
|
|
791
|
-
/** MP3 音频(.mp3) */
|
|
792
|
-
readonly MP3: "audio/mpeg";
|
|
793
|
-
/** AAC 音频(.aac) */
|
|
794
|
-
readonly AAC: "audio/aac";
|
|
795
|
-
/** MIDI 音乐文件(.mid/.midi) */
|
|
796
|
-
readonly MIDI: "audio/midi";
|
|
797
|
-
/** OGG 音频(.oga) */
|
|
798
|
-
readonly OGG_AUDIO: "audio/ogg";
|
|
799
|
-
/** Opus 音频(.opus) */
|
|
800
|
-
readonly OPUS: "audio/opus";
|
|
801
|
-
/** FLAC 无损音频(.flac) */
|
|
802
|
-
readonly FLAC: "audio/flac";
|
|
803
|
-
/** WAV 音频(.wav) */
|
|
804
|
-
readonly WAV: "audio/wav";
|
|
805
|
-
/** WebM 音频(.weba) */
|
|
806
|
-
readonly WEBM_AUDIO: "audio/webm";
|
|
807
|
-
/** RealAudio 音频(.ra/.ram) */
|
|
808
|
-
readonly REAL_AUDIO: "audio/x-pn-realaudio";
|
|
809
|
-
/** MP4 视频(.mp4) */
|
|
810
|
-
readonly MP4: "video/mp4";
|
|
811
|
-
/** MPEG 视频(.mpeg/.mpg) */
|
|
812
|
-
readonly MPEG: "video/mpeg";
|
|
813
|
-
/** OGG 视频(.ogv) */
|
|
814
|
-
readonly OGG_VIDEO: "video/ogg";
|
|
815
|
-
/** AVI 视频(.avi) */
|
|
816
|
-
readonly AVI: "video/x-msvideo";
|
|
817
|
-
/** 3GPP 视频(.3gp) */
|
|
818
|
-
readonly THREE_GPP: "video/3gpp";
|
|
819
|
-
/** 3GPP2 视频(.3g2) */
|
|
820
|
-
readonly THREE_GPP2: "video/3gpp2";
|
|
821
|
-
/** WebM 视频(.webm) */
|
|
822
|
-
readonly WEBM: "video/webm";
|
|
823
|
-
/** Matroska 视频(.mkv) */
|
|
824
|
-
readonly MKV: "video/x-matroska";
|
|
825
|
-
/** Matroska 音频(.mka) */
|
|
826
|
-
readonly MKA: "audio/x-matroska";
|
|
827
|
-
/** QuickTime 视频(.mov) */
|
|
828
|
-
readonly QUICKTIME: "video/quicktime";
|
|
829
|
-
/** PDF 文档(.pdf) */
|
|
830
|
-
readonly PDF: "application/pdf";
|
|
831
|
-
/** Word 97-2003 文档(.doc) */
|
|
832
|
-
readonly DOC: "application/msword";
|
|
833
|
-
/** Word 2007+ 文档(.docx) */
|
|
834
|
-
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
835
|
-
/** Excel 2007+ 工作簿(.xlsx) */
|
|
836
|
-
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
837
|
-
/** 启用宏的Excel工作簿(.xlsm) */
|
|
838
|
-
readonly XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
839
|
-
/** Excel模板文件(.xltx) */
|
|
840
|
-
readonly XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template";
|
|
841
|
-
/** PowerPoint 2007+ 演示文稿(.pptx) */
|
|
842
|
-
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
843
|
-
/** PowerPoint 97-2003 演示文稿(.ppt) */
|
|
844
|
-
readonly PPT: "application/vnd.ms-powerpoint";
|
|
845
|
-
/** OpenDocument 文本文档(.odt) */
|
|
846
|
-
readonly ODT: "application/vnd.oasis.opendocument.text";
|
|
847
|
-
/** OpenDocument 表格文档(.ods) */
|
|
848
|
-
readonly ODS: "application/vnd.oasis.opendocument.spreadsheet";
|
|
849
|
-
/** OpenDocument 演示文稿(.odp) */
|
|
850
|
-
readonly ODP: "application/vnd.oasis.opendocument.presentation";
|
|
851
|
-
/** EPUB 电子书(.epub) */
|
|
852
|
-
readonly EPUB: "application/epub+zip";
|
|
853
|
-
/** Kindle 电子书(.azw) */
|
|
854
|
-
readonly AZW: "application/vnd.amazon.ebook";
|
|
855
|
-
/** ZIP 压缩文件(.zip) */
|
|
856
|
-
readonly ZIP: "application/zip";
|
|
857
|
-
/** GZIP 压缩文件(.gz) */
|
|
858
|
-
readonly GZIP: "application/gzip";
|
|
859
|
-
/** TAR 归档文件(.tar) */
|
|
860
|
-
readonly TAR: "application/x-tar";
|
|
861
|
-
/** BZip 归档(.bz) */
|
|
862
|
-
readonly BZIP: "application/x-bzip";
|
|
863
|
-
/** BZip2 归档(.bz2) */
|
|
864
|
-
readonly BZIP2: "application/x-bzip2";
|
|
865
|
-
/** 7-Zip 压缩文件(.7z) */
|
|
866
|
-
readonly SEVEN_Z: "application/x-7z-compressed";
|
|
867
|
-
/** RAR 压缩文件(.rar) */
|
|
868
|
-
readonly RAR: "application/vnd.rar";
|
|
869
|
-
/** XZ 压缩文件(.xz) */
|
|
870
|
-
readonly XZ: "application/x-xz";
|
|
871
|
-
/** Zstandard 压缩文件(.zst) */
|
|
872
|
-
readonly ZSTD: "application/zstd";
|
|
873
|
-
/** ISO 光盘镜像(.iso) */
|
|
874
|
-
readonly ISO9660_IMAGE: "application/x-iso9660-image";
|
|
875
|
-
/** JSON 数据格式(.json) */
|
|
876
|
-
readonly JSON: "application/json";
|
|
877
|
-
/** JSON-LD 格式(.jsonld) */
|
|
878
|
-
readonly LD_JSON: "application/ld+json";
|
|
879
|
-
/** Web App Manifest(.webmanifest) */
|
|
880
|
-
readonly MANIFEST: "application/manifest+json";
|
|
881
|
-
/** Java 归档文件(.jar) */
|
|
882
|
-
readonly JAR: "application/java-archive";
|
|
883
|
-
/** WebAssembly 二进制指令格式(.wasm) */
|
|
884
|
-
readonly WASM: "application/wasm";
|
|
885
|
-
/** MS 嵌入式 OpenType 字体(.eot) */
|
|
886
|
-
readonly EOT: "application/vnd.ms-fontobject";
|
|
887
|
-
/** OpenType 字体(.otf) */
|
|
888
|
-
readonly OTF: "font/otf";
|
|
889
|
-
/** WOFF 字体(.woff) */
|
|
890
|
-
readonly WOFF: "font/woff";
|
|
891
|
-
/** WOFF2 字体(.woff2) */
|
|
892
|
-
readonly WOFF2: "font/woff2";
|
|
893
|
-
/** TrueType 字体(.ttf) */
|
|
894
|
-
readonly TTF: "font/ttf";
|
|
895
|
-
/** Excel 97-2003 工作簿(.xls) */
|
|
896
|
-
readonly XLS: "application/vnd.ms-excel";
|
|
897
|
-
/** Microsoft XPS 文档(.xps) */
|
|
898
|
-
readonly XPS: "application/vnd.ms-xpsdocument";
|
|
899
|
-
/** Word 启用宏文档(.docm) */
|
|
900
|
-
readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
|
|
901
|
-
};
|
|
902
|
-
/**
|
|
903
|
-
* 协议/内容类型 MIME 常量
|
|
904
|
-
* - 用于 HTTP 请求/响应内容协商,无对应文件扩展名
|
|
905
|
-
*/
|
|
906
|
-
static readonly PROTOCOL_MIME: {
|
|
907
|
-
/** 通用二进制数据流 */
|
|
908
|
-
readonly OCTET_STREAM: "application/octet-stream";
|
|
909
|
-
/** URL 编码表单 */
|
|
910
|
-
readonly FORM_URLENCODED: "application/x-www-form-urlencoded";
|
|
911
|
-
/** multipart 表单 */
|
|
912
|
-
readonly FORM_DATA: "multipart/form-data";
|
|
913
|
-
/** Server-Sent Events 数据流 */
|
|
914
|
-
readonly EVENT_STREAM: "text/event-stream";
|
|
915
|
-
/** 问题详情 JSON(RFC 9457) */
|
|
916
|
-
readonly PROBLEM_JSON: "application/problem+json";
|
|
917
|
-
/** JSON Patch(RFC 6902) */
|
|
918
|
-
readonly JSON_PATCH: "application/json-patch+json";
|
|
919
|
-
/** JSON Merge Patch(RFC 7386) */
|
|
920
|
-
readonly MERGE_PATCH_JSON: "application/merge-patch+json";
|
|
921
|
-
};
|
|
922
|
-
/**
|
|
923
|
-
* 根据文件后缀名获取对应的标准 MIME 类型(含历史兼容值)
|
|
924
|
-
* - 支持带 `.` 或不带 `.` 的后缀名,不区分大小写
|
|
925
|
-
* - 元组第一项始终为 IANA 官方标准 MIME,后续项为历史兼容值
|
|
926
|
-
* - 仅查询文件类型 MIME,不包含无后缀对应的协议类型
|
|
927
|
-
*
|
|
928
|
-
* @param extension 文件后缀名(如 `".png"` / `"png"` / `".PNG"`)
|
|
929
|
-
* @returns 标准 MIME + 兼容值的元组;如无匹配则返回 `undefined`
|
|
930
|
-
* @example
|
|
931
|
-
* ```ts
|
|
932
|
-
* MimeUtil.fromExtension(".png"); // ["image/png"]
|
|
933
|
-
* MimeUtil.fromExtension("ico"); // ["image/vnd.microsoft.icon", "image/x-icon"]
|
|
934
|
-
* MimeUtil.fromExtension(".xml"); // ["application/xml", "text/xml"]
|
|
935
|
-
* MimeUtil.fromExtension(".xyz"); // undefined
|
|
936
|
-
* ```
|
|
937
|
-
*/
|
|
938
|
-
static fromExtension(extension: string): readonly [string, ...string[]] | undefined;
|
|
939
|
-
/**
|
|
940
|
-
* 根据 MIME 类型获取对应的文件后缀名列表
|
|
941
|
-
* - 一个 MIME 类型可能对应多个后缀名(如 `text/html` → `.html` / `.htm`)
|
|
942
|
-
* - 兼容值和标准值映射到相同的后缀(如 `image/x-icon` 和 `image/vnd.microsoft.icon` 均返回 `[".ico"]`)
|
|
943
|
-
* - 仅查询文件类型 MIME,协议类型无对应后缀
|
|
944
|
-
*
|
|
945
|
-
* @param mime MIME 类型字符串(如 `"image/png"` / `"IMAGE/PNG"`)
|
|
946
|
-
* @returns 文件后缀名列表;如无匹配则返回 `undefined`
|
|
947
|
-
* @example
|
|
948
|
-
* ```ts
|
|
949
|
-
* MimeUtil.toExtension("IMAGE/PNG"); // [".png"]
|
|
950
|
-
* MimeUtil.toExtension("text/html"); // [".html", ".htm"]
|
|
951
|
-
* MimeUtil.toExtension("image/jpeg"); // [".jpg", ".jpeg"]
|
|
952
|
-
* MimeUtil.toExtension("application/octet-stream"); // undefined
|
|
953
|
-
* ```
|
|
954
|
-
*/
|
|
955
|
-
static toExtension(mime: string): readonly [string, ...string[]] | undefined;
|
|
956
|
-
}
|
|
957
|
-
//#endregion
|
|
958
|
-
//#region src/number/numberUtil.d.ts
|
|
959
|
-
/**
|
|
960
|
-
* 数字工具类
|
|
961
|
-
*/
|
|
962
|
-
declare class NumberUtil {
|
|
963
|
-
/**
|
|
964
|
-
* 数字区间检查函数
|
|
965
|
-
*
|
|
966
|
-
* @param input 待检查数字
|
|
967
|
-
* @param interval 由两个数字组成的元组 [left, right]
|
|
968
|
-
* @param includeLeft 是否包含左边界(默认 true)
|
|
969
|
-
* @param includeRight 是否包含右边界(默认 false)
|
|
970
|
-
* @returns 是否在区间内
|
|
971
|
-
* @example
|
|
972
|
-
* ```ts
|
|
973
|
-
* NumberUtil.within(5, [1, 10]); // true
|
|
974
|
-
* NumberUtil.within(1, [1, 10], false); // false
|
|
975
|
-
* ```
|
|
976
|
-
*/
|
|
977
|
-
static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
|
|
978
|
-
}
|
|
979
|
-
//#endregion
|
|
980
309
|
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/typed-array.d.ts
|
|
981
310
|
/**
|
|
982
311
|
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
@@ -2878,283 +2207,1154 @@ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, {
|
|
|
2878
2207
|
//#endregion
|
|
2879
2208
|
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-member.d.ts
|
|
2880
2209
|
/**
|
|
2881
|
-
Returns an arbitrary member of a union type.
|
|
2210
|
+
Returns an arbitrary member of a union type.
|
|
2211
|
+
|
|
2212
|
+
Use-cases:
|
|
2213
|
+
- Implementing recursive type functions that accept a union type.
|
|
2214
|
+
|
|
2215
|
+
@example
|
|
2216
|
+
```
|
|
2217
|
+
import type {UnionMember, IsNever} from 'type-fest';
|
|
2218
|
+
|
|
2219
|
+
type UnionLength<T, Acc extends any[] = []> =
|
|
2220
|
+
UnionMember<T> extends infer Member
|
|
2221
|
+
? IsNever<Member> extends false
|
|
2222
|
+
? UnionLength<Exclude<T, Member>, [...Acc, Member]>
|
|
2223
|
+
: Acc['length']
|
|
2224
|
+
: never;
|
|
2225
|
+
|
|
2226
|
+
type T1 = UnionLength<'foo' | 'bar' | 'baz'>;
|
|
2227
|
+
//=> 3
|
|
2228
|
+
|
|
2229
|
+
type T2 = UnionLength<{a: string}>;
|
|
2230
|
+
//=> 1
|
|
2231
|
+
```
|
|
2232
|
+
|
|
2233
|
+
- Picking an arbitrary member from a union
|
|
2234
|
+
|
|
2235
|
+
@example
|
|
2236
|
+
```
|
|
2237
|
+
import type {UnionMember, Primitive, LiteralToPrimitive} from 'type-fest';
|
|
2238
|
+
|
|
2239
|
+
type IsHomogenous<T extends Primitive> = [T] extends [LiteralToPrimitive<UnionMember<T>>] ? true : false;
|
|
2240
|
+
|
|
2241
|
+
type T1 = IsHomogenous<1 | 2 | 3 | 4>;
|
|
2242
|
+
//=> true
|
|
2243
|
+
|
|
2244
|
+
type T2 = IsHomogenous<'foo' | 'bar'>;
|
|
2245
|
+
//=> true
|
|
2246
|
+
|
|
2247
|
+
type T3 = IsHomogenous<'foo' | 'bar' | 1>;
|
|
2248
|
+
//=> false
|
|
2249
|
+
```
|
|
2250
|
+
|
|
2251
|
+
Returns `never` when the input is `never`.
|
|
2252
|
+
|
|
2253
|
+
@example
|
|
2254
|
+
```
|
|
2255
|
+
import type {UnionMember} from 'type-fest';
|
|
2256
|
+
|
|
2257
|
+
type LastNever = UnionMember<never>;
|
|
2258
|
+
//=> never
|
|
2259
|
+
```
|
|
2260
|
+
|
|
2261
|
+
@category Type
|
|
2262
|
+
*/
|
|
2263
|
+
type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
2264
|
+
//#endregion
|
|
2265
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
2266
|
+
/**
|
|
2267
|
+
Convert a union type into an unordered tuple type of its elements.
|
|
2268
|
+
|
|
2269
|
+
"Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
|
|
2270
|
+
|
|
2271
|
+
This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
|
|
2272
|
+
|
|
2273
|
+
@example
|
|
2274
|
+
```
|
|
2275
|
+
import type {UnionToTuple} from 'type-fest';
|
|
2276
|
+
|
|
2277
|
+
type Numbers = 1 | 2 | 3;
|
|
2278
|
+
type NumbersTuple = UnionToTuple<Numbers>;
|
|
2279
|
+
//=> [1, 2, 3]
|
|
2280
|
+
```
|
|
2281
|
+
|
|
2282
|
+
@example
|
|
2283
|
+
```
|
|
2284
|
+
import type {UnionToTuple} from 'type-fest';
|
|
2285
|
+
|
|
2286
|
+
const pets = {
|
|
2287
|
+
dog: '🐶',
|
|
2288
|
+
cat: '🐱',
|
|
2289
|
+
snake: '🐍',
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2292
|
+
type Pet = keyof typeof pets;
|
|
2293
|
+
//=> 'dog' | 'cat' | 'snake'
|
|
2294
|
+
|
|
2295
|
+
const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
2296
|
+
//=> ['dog', 'cat', 'snake']
|
|
2297
|
+
```
|
|
2298
|
+
|
|
2299
|
+
@category Array
|
|
2300
|
+
*/
|
|
2301
|
+
type UnionToTuple<Union> = _UnionToTuple<Union> extends (infer Result extends UnknownArray) ? Result : never; // Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2302
|
+
type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
|
|
2303
|
+
//#endregion
|
|
2304
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/set-optional.d.ts
|
|
2305
|
+
/**
|
|
2306
|
+
Create a type that makes the given keys optional, while keeping the remaining keys as is.
|
|
2307
|
+
|
|
2308
|
+
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
|
|
2309
|
+
|
|
2310
|
+
@example
|
|
2311
|
+
```
|
|
2312
|
+
import type {SetOptional} from 'type-fest';
|
|
2313
|
+
|
|
2314
|
+
type Foo = {
|
|
2315
|
+
a: number;
|
|
2316
|
+
b?: string;
|
|
2317
|
+
c: boolean;
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
2321
|
+
//=> {a: number; b?: string; c?: boolean}
|
|
2322
|
+
```
|
|
2323
|
+
|
|
2324
|
+
@category Object
|
|
2325
|
+
*/
|
|
2326
|
+
type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
|
|
2327
|
+
type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
|
|
2328
|
+
? Simplify<
|
|
2329
|
+
// Pick just the keys that are readonly from the base type.
|
|
2330
|
+
Except<BaseType, Keys> &
|
|
2331
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
2332
|
+
Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
2333
|
+
//#endregion
|
|
2334
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/value-of.d.ts
|
|
2335
|
+
/**
|
|
2336
|
+
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
2337
|
+
|
|
2338
|
+
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
|
2339
|
+
|
|
2340
|
+
@example
|
|
2341
|
+
```
|
|
2342
|
+
import type {ValueOf} from 'type-fest';
|
|
2343
|
+
|
|
2344
|
+
type A = ValueOf<{id: number; name: string; active: boolean}>;
|
|
2345
|
+
//=> string | number | boolean
|
|
2346
|
+
|
|
2347
|
+
type B = ValueOf<{id: number; name: string; active: boolean}, 'name'>;
|
|
2348
|
+
//=> string
|
|
2349
|
+
|
|
2350
|
+
type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
|
|
2351
|
+
//=> string | number
|
|
2352
|
+
```
|
|
2353
|
+
|
|
2354
|
+
@category Object
|
|
2355
|
+
*/
|
|
2356
|
+
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
2357
|
+
//#endregion
|
|
2358
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/split.d.ts
|
|
2359
|
+
/**
|
|
2360
|
+
Split options.
|
|
2361
|
+
|
|
2362
|
+
@see {@link Split}
|
|
2363
|
+
*/
|
|
2364
|
+
type SplitOptions = {
|
|
2365
|
+
/**
|
|
2366
|
+
When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
|
|
2367
|
+
|
|
2368
|
+
@default true
|
|
2369
|
+
|
|
2370
|
+
@example
|
|
2371
|
+
```ts
|
|
2372
|
+
import type {Split} from 'type-fest';
|
|
2373
|
+
|
|
2374
|
+
type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
|
|
2375
|
+
//=> ['foo', string, 'bar']
|
|
2376
|
+
|
|
2377
|
+
type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
|
|
2378
|
+
//=> string[]
|
|
2379
|
+
|
|
2380
|
+
type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
|
|
2381
|
+
//=> ['foo', 'r', 'z']
|
|
2382
|
+
|
|
2383
|
+
type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
|
|
2384
|
+
//=> string[]
|
|
2385
|
+
```
|
|
2386
|
+
*/
|
|
2387
|
+
strictLiteralChecks?: boolean;
|
|
2388
|
+
};
|
|
2389
|
+
type DefaultSplitOptions = {
|
|
2390
|
+
strictLiteralChecks: true;
|
|
2391
|
+
};
|
|
2392
|
+
/**
|
|
2393
|
+
Represents an array of strings split using a given character or character set.
|
|
2882
2394
|
|
|
2883
|
-
Use-
|
|
2884
|
-
- Implementing recursive type functions that accept a union type.
|
|
2395
|
+
Use-case: Defining the return type of a method like `String.prototype.split`.
|
|
2885
2396
|
|
|
2886
2397
|
@example
|
|
2887
2398
|
```
|
|
2888
|
-
import type {
|
|
2889
|
-
|
|
2890
|
-
type UnionLength<T, Acc extends any[] = []> =
|
|
2891
|
-
UnionMember<T> extends infer Member
|
|
2892
|
-
? IsNever<Member> extends false
|
|
2893
|
-
? UnionLength<Exclude<T, Member>, [...Acc, Member]>
|
|
2894
|
-
: Acc['length']
|
|
2895
|
-
: never;
|
|
2399
|
+
import type {Split} from 'type-fest';
|
|
2896
2400
|
|
|
2897
|
-
|
|
2898
|
-
//=> 3
|
|
2401
|
+
declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
|
|
2899
2402
|
|
|
2900
|
-
type
|
|
2901
|
-
|
|
2403
|
+
type Item = 'foo' | 'bar' | 'baz' | 'waldo';
|
|
2404
|
+
const items = 'foo,bar,baz,waldo';
|
|
2405
|
+
const array: Item[] = split(items, ',');
|
|
2902
2406
|
```
|
|
2903
2407
|
|
|
2904
|
-
|
|
2408
|
+
@see {@link SplitOptions}
|
|
2409
|
+
|
|
2410
|
+
@category String
|
|
2411
|
+
@category Template literal
|
|
2412
|
+
*/
|
|
2413
|
+
type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
|
|
2414
|
+
type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
|
|
2415
|
+
? Delimiter extends string // For distributing `Delimiter`
|
|
2416
|
+
?
|
|
2417
|
+
// If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
|
|
2418
|
+
Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S] :
|
|
2419
|
+
// Otherwise, return `string[]`
|
|
2420
|
+
string[] : never // Should never happen
|
|
2421
|
+
: never; // Should never happen
|
|
2422
|
+
//#endregion
|
|
2423
|
+
//#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/replace.d.ts
|
|
2424
|
+
type ReplaceOptions = {
|
|
2425
|
+
all?: boolean;
|
|
2426
|
+
};
|
|
2427
|
+
type DefaultReplaceOptions = {
|
|
2428
|
+
all: false;
|
|
2429
|
+
};
|
|
2430
|
+
/**
|
|
2431
|
+
Represents a string with some or all matches replaced by a replacement.
|
|
2432
|
+
|
|
2433
|
+
Use-case:
|
|
2434
|
+
- `kebab-case-path` to `dotted.path.notation`
|
|
2435
|
+
- Changing date/time format: `01-08-2042` → `01/08/2042`
|
|
2436
|
+
- Manipulation of type properties, for example, removal of prefixes
|
|
2905
2437
|
|
|
2906
2438
|
@example
|
|
2907
2439
|
```
|
|
2908
|
-
import type {
|
|
2440
|
+
import type {Replace} from 'type-fest';
|
|
2909
2441
|
|
|
2910
|
-
|
|
2442
|
+
declare function replace<
|
|
2443
|
+
Input extends string,
|
|
2444
|
+
Search extends string,
|
|
2445
|
+
Replacement extends string,
|
|
2446
|
+
>(
|
|
2447
|
+
input: Input,
|
|
2448
|
+
search: Search,
|
|
2449
|
+
replacement: Replacement,
|
|
2450
|
+
): Replace<Input, Search, Replacement>;
|
|
2911
2451
|
|
|
2912
|
-
|
|
2913
|
-
|
|
2452
|
+
declare function replaceAll<
|
|
2453
|
+
Input extends string,
|
|
2454
|
+
Search extends string,
|
|
2455
|
+
Replacement extends string,
|
|
2456
|
+
>(
|
|
2457
|
+
input: Input,
|
|
2458
|
+
search: Search,
|
|
2459
|
+
replacement: Replacement,
|
|
2460
|
+
): Replace<Input, Search, Replacement, {all: true}>;
|
|
2914
2461
|
|
|
2915
|
-
type
|
|
2916
|
-
//=> true
|
|
2462
|
+
// The return type is the exact string literal, not just `string`.
|
|
2917
2463
|
|
|
2918
|
-
|
|
2919
|
-
//=>
|
|
2920
|
-
```
|
|
2464
|
+
replace('hello ?', '?', '🦄');
|
|
2465
|
+
//=> 'hello 🦄'
|
|
2921
2466
|
|
|
2922
|
-
|
|
2467
|
+
replace('hello ??', '?', '❓');
|
|
2468
|
+
//=> 'hello ❓?'
|
|
2923
2469
|
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
import type {UnionMember} from 'type-fest';
|
|
2470
|
+
replaceAll('10:42:00', ':', '-');
|
|
2471
|
+
//=> '10-42-00'
|
|
2927
2472
|
|
|
2928
|
-
|
|
2929
|
-
//=>
|
|
2473
|
+
replaceAll('__userName__', '__', '');
|
|
2474
|
+
//=> 'userName'
|
|
2475
|
+
|
|
2476
|
+
replaceAll('My Cool Title', ' ', '');
|
|
2477
|
+
//=> 'MyCoolTitle'
|
|
2930
2478
|
```
|
|
2931
2479
|
|
|
2932
|
-
@category
|
|
2480
|
+
@category String
|
|
2481
|
+
@category Template literal
|
|
2933
2482
|
*/
|
|
2934
|
-
type
|
|
2483
|
+
type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
|
|
2484
|
+
type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
|
|
2485
|
+
? Replacement extends string // For distributing `Replacement`
|
|
2486
|
+
? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
|
|
2487
|
+
//#endregion
|
|
2488
|
+
//#region src/currency/index.type.d.ts
|
|
2489
|
+
type CurrencyCode = keyof typeof CurrencyUtil.CURRENCY_ENUM;
|
|
2490
|
+
type CurrencyLocale = ValueOf<typeof CurrencyUtil.CURRENCY_ENUM>;
|
|
2491
|
+
interface FormatterOptions {
|
|
2492
|
+
locales: [CurrencyLocale, CurrencyLocale];
|
|
2493
|
+
currencySign: string;
|
|
2494
|
+
currencySignPosition: "prefix" | "suffix" | "start" | "end";
|
|
2495
|
+
currencyFormatOptions: Intl.NumberFormatOptions;
|
|
2496
|
+
precision?: number | undefined;
|
|
2497
|
+
}
|
|
2498
|
+
//#endregion
|
|
2499
|
+
//#region src/currency/currencyUtil.d.ts
|
|
2500
|
+
/**
|
|
2501
|
+
* 货币工具类
|
|
2502
|
+
* - 基于 [`Intl.NumberFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) 进行本地化格式化
|
|
2503
|
+
* - 支持精确小数位处理(依赖 `mathjs`)
|
|
2504
|
+
*/
|
|
2505
|
+
declare class CurrencyUtil {
|
|
2506
|
+
/**
|
|
2507
|
+
* 货币代码到 Locale 的映射枚举
|
|
2508
|
+
* - 键为 ISO 4217 货币代码,值为 BCP 47 语言标签
|
|
2509
|
+
* - 用于 `Intl.NumberFormat` 的本地化数字格式化
|
|
2510
|
+
* - 格式示例基于 `Intl.NumberFormat` 对 `1,234,567.89` 的输出
|
|
2511
|
+
*
|
|
2512
|
+
* @example
|
|
2513
|
+
* ```ts
|
|
2514
|
+
* import { CurrencyUtil } from "@pawover/kit/utils";
|
|
2515
|
+
* // 获取人民币的格式化 locale
|
|
2516
|
+
* const locale = CurrencyUtil.CURRENCY_ENUM.CNY; // "zh-CN"
|
|
2517
|
+
*
|
|
2518
|
+
* // 结合 Intl.NumberFormat 使用
|
|
2519
|
+
* new Intl.NumberFormat(CurrencyUtil.CURRENCY_ENUM.USD, {
|
|
2520
|
+
* style: "currency",
|
|
2521
|
+
* currency: "USD",
|
|
2522
|
+
* }).format(1234.56); // "$1,234.56"
|
|
2523
|
+
* ```
|
|
2524
|
+
*/
|
|
2525
|
+
static readonly CURRENCY_ENUM: {
|
|
2526
|
+
/** 美元(美国及美元化国家,Locale: 美式英语) → 1,234,567.89 */
|
|
2527
|
+
readonly USD: "en-US";
|
|
2528
|
+
/** 加拿大元(加拿大,Locale: 加拿大英语) → 1,234,567.89 */
|
|
2529
|
+
readonly CAD: "en-CA";
|
|
2530
|
+
/** 墨西哥比索(墨西哥,Locale: 墨西哥西班牙语) → 1,234,567.89 */
|
|
2531
|
+
readonly MXN: "es-MX";
|
|
2532
|
+
/** 巴西雷亚尔(巴西,Locale: 巴西葡萄牙语) → 1.234.567,89 */
|
|
2533
|
+
readonly BRL: "pt-BR";
|
|
2534
|
+
/** 阿根廷比索(阿根廷,Locale: 阿根廷西班牙语) → 1.234.567,89 */
|
|
2535
|
+
readonly ARS: "es-AR";
|
|
2536
|
+
/** 智利比索(智利,Locale: 智利西班牙语) → 1.234.567,89 */
|
|
2537
|
+
readonly CLP: "es-CL";
|
|
2538
|
+
/** 秘鲁新索尔(秘鲁,Locale: 秘鲁西班牙语) → 1,234,567.89 */
|
|
2539
|
+
readonly PEN: "es-PE";
|
|
2540
|
+
/** 哥伦比亚比索(哥伦比亚,Locale: 哥伦比亚西班牙语) → 1.234.567,89 */
|
|
2541
|
+
readonly COP: "es-CO";
|
|
2542
|
+
/** 哥斯达黎加科朗(哥斯达黎加,Locale: 哥斯达黎加西班牙语) → 1 234 567,89(空格千分位) */
|
|
2543
|
+
readonly CRC: "es-CR";
|
|
2544
|
+
/** 人民币(中国,Locale: 简体中文) → 1,234,567.89 */
|
|
2545
|
+
readonly CNY: "zh-CN";
|
|
2546
|
+
/** 港元(中国香港,Locale: 繁体中文+香港) → 1,234,567.89 */
|
|
2547
|
+
readonly HKD: "zh-HK";
|
|
2548
|
+
/** 澳门元(中国澳门,Locale: 繁体中文+澳门) → 1,234,567.89 */
|
|
2549
|
+
readonly MOP: "zh-MO";
|
|
2550
|
+
/** 日元(日本,Locale: 日语) → 1,234,567.89 */
|
|
2551
|
+
readonly JPY: "ja-JP";
|
|
2552
|
+
/** 韩元(韩国,Locale: 韩语) → 1,234,567.89 */
|
|
2553
|
+
readonly KRW: "ko-KR";
|
|
2554
|
+
/** 新加坡元(新加坡,Locale: 英语+新加坡) → 1,234,567.89 */
|
|
2555
|
+
readonly SGD: "en-SG";
|
|
2556
|
+
/** 泰铢(泰国,Locale: 泰语) → 1,234,567.89 */
|
|
2557
|
+
readonly THB: "th-TH";
|
|
2558
|
+
/** 印度卢比(印度,Locale: 英语+印度) → 12,34,567.89(2,2,3 分组) */
|
|
2559
|
+
readonly INR: "en-IN";
|
|
2560
|
+
/** 沙特里亚尔(沙特,Locale: 阿拉伯语+沙特) → ١٬٢٣٤٬٥٦٧٫٨٩(阿拉伯数字) */
|
|
2561
|
+
readonly SAR: "ar-SA";
|
|
2562
|
+
/** 阿联酋迪拉姆(阿联酋,Locale: 阿拉伯语+阿联酋) → 1,234,567.89 */
|
|
2563
|
+
readonly AED: "ar-AE";
|
|
2564
|
+
/** 印尼盾(印尼,Locale: 印尼语) → 1.234.567,89 */
|
|
2565
|
+
readonly IDR: "id-ID";
|
|
2566
|
+
/** 马来西亚林吉特(马来西亚,Locale: 马来语) → 1,234,567.89 */
|
|
2567
|
+
readonly MYR: "ms-MY";
|
|
2568
|
+
/** 越南盾(越南,Locale: 越南语) → 1.234.567,89 */
|
|
2569
|
+
readonly VND: "vi-VN";
|
|
2570
|
+
/** 菲律宾比索(菲律宾,Locale: 英语+菲律宾) → 1,234,567.89 */
|
|
2571
|
+
readonly PHP: "en-PH";
|
|
2572
|
+
/** 巴基斯坦卢比(巴基斯坦,Locale: 英语+巴基斯坦) → 1,234,567.89 */
|
|
2573
|
+
readonly PKR: "en-PK";
|
|
2574
|
+
/** 新台币(中国台湾地区,Locale: 繁体中文+台湾) → 1,234,567.89 */
|
|
2575
|
+
readonly TWD: "zh-TW";
|
|
2576
|
+
/** 欧元(德国,Locale: 德语+德国,代表欧元区) → 1.234.567,89 */
|
|
2577
|
+
readonly EUR: "de-DE";
|
|
2578
|
+
/** 英镑(英国,Locale: 英式英语) → 1,234,567.89 */
|
|
2579
|
+
readonly GBP: "en-GB";
|
|
2580
|
+
/** 瑞士法郎(瑞士,Locale: 德语+瑞士) → 1'234'567.89 */
|
|
2581
|
+
readonly CHF: "de-CH";
|
|
2582
|
+
/** 瑞典克朗(瑞典,Locale: 瑞典语) → 1 234 567,89(空格千分位) */
|
|
2583
|
+
readonly SEK: "sv-SE";
|
|
2584
|
+
/** 挪威克朗(挪威,Locale: 挪威语) → 1 234 567,89(空格千分位) */
|
|
2585
|
+
readonly NOK: "no-NO";
|
|
2586
|
+
/** 丹麦克朗(丹麦,Locale: 丹麦语) → 1.234.567,89 */
|
|
2587
|
+
readonly DKK: "da-DK";
|
|
2588
|
+
/** 波兰兹罗提(波兰,Locale: 波兰语) → 1 234 567,89(空格千分位) */
|
|
2589
|
+
readonly PLN: "pl-PL";
|
|
2590
|
+
/** 捷克克朗(捷克,Locale: 捷克语) → 1 234 567,89(空格千分位) */
|
|
2591
|
+
readonly CZK: "cs-CZ";
|
|
2592
|
+
/** 匈牙利福林(匈牙利,Locale: 匈牙利语) → 1 234 567,89(空格千分位) */
|
|
2593
|
+
readonly HUF: "hu-HU";
|
|
2594
|
+
/** 俄罗斯卢布(俄罗斯,Locale: 俄语) → 1 234 567,89(空格千分位) */
|
|
2595
|
+
readonly RUB: "ru-RU";
|
|
2596
|
+
/** 罗马尼亚列伊(罗马尼亚,Locale: 罗马尼亚语) → 1.234.567,89 */
|
|
2597
|
+
readonly RON: "ro-RO";
|
|
2598
|
+
/** 乌克兰格里夫纳(乌克兰,Locale: 乌克兰语) → 1 234 567,89(空格千分位) */
|
|
2599
|
+
readonly UAH: "uk-UA";
|
|
2600
|
+
/** 澳大利亚元(澳大利亚,Locale: 澳大利亚英语) → 1,234,567.89 */
|
|
2601
|
+
readonly AUD: "en-AU";
|
|
2602
|
+
/** 新西兰元(新西兰,Locale: 新西兰英语) → 1,234,567.89 */
|
|
2603
|
+
readonly NZD: "en-NZ";
|
|
2604
|
+
/** 南非兰特(南非,Locale: 英语+南非) → 1 234 567,89(空格千分位) */
|
|
2605
|
+
readonly ZAR: "en-ZA";
|
|
2606
|
+
/** 埃及镑(埃及,Locale: 阿拉伯语+埃及) → ١٬٢٣٤٬٥٦٧٫٨٩(阿拉伯数字) */
|
|
2607
|
+
readonly EGP: "ar-EG";
|
|
2608
|
+
/** 土耳其里拉(土耳其,Locale: 土耳其语) → 1.234.567,89 */
|
|
2609
|
+
readonly TRY: "tr-TR";
|
|
2610
|
+
/** 以色列新谢克尔(以色列,Locale: 希伯来语) → 1,234,567.89 */
|
|
2611
|
+
readonly ILS: "he-IL";
|
|
2612
|
+
/** 摩洛哥迪拉姆(摩洛哥,Locale: 阿拉伯语+摩洛哥) → 1.234.567,89 */
|
|
2613
|
+
readonly MAD: "ar-MA";
|
|
2614
|
+
/** 科威特第纳尔(科威特,Locale: 阿拉伯语+科威特) → ١٬٢٣٤٬٥٦٧٫٨٩(阿拉伯数字) */
|
|
2615
|
+
readonly KWD: "ar-KW";
|
|
2616
|
+
/** 卡塔尔里亚尔(卡塔尔,Locale: 阿拉伯语+卡塔尔) → ١٬٢٣٤٬٥٦٧٫٨٩(阿拉伯数字) */
|
|
2617
|
+
readonly QAR: "ar-QA";
|
|
2618
|
+
/** 尼日利亚奈拉(尼日利亚,Locale: 英语+尼日利亚) → 1,234,567.89 */
|
|
2619
|
+
readonly NGN: "en-NG";
|
|
2620
|
+
/** 太平洋法郎(法属波利尼西亚,Locale: 法语+太平洋) → 1[U+202F]234[U+202F]567,89(窄空格千分位) */
|
|
2621
|
+
readonly XPF: "fr-PF";
|
|
2622
|
+
};
|
|
2623
|
+
/**
|
|
2624
|
+
* 货币格式化
|
|
2625
|
+
* - 使用 `Intl.NumberFormat` 进行本地化数字格式化
|
|
2626
|
+
* - 支持自定义货币符号及位置(前缀/后缀/首/尾)
|
|
2627
|
+
* - 当值为 `null` 或 `undefined` 时返回 `null`
|
|
2628
|
+
*
|
|
2629
|
+
* @param value 待格式化的数值
|
|
2630
|
+
* @param options 格式化选项
|
|
2631
|
+
* @param options.locales locale 元组,同时指定格式化语言和货币所属地区
|
|
2632
|
+
* @param options.currencySign 货币符号(如 `¥`、`$`、`€`)
|
|
2633
|
+
* @param options.currencySignPosition 货币符号位置
|
|
2634
|
+
* @param options.currencyFormatOptions `Intl.NumberFormatOptions` 格式化选项
|
|
2635
|
+
* @returns 格式化后的货币字符串,无效输入返回 `null`
|
|
2636
|
+
*
|
|
2637
|
+
* @example
|
|
2638
|
+
* ```ts
|
|
2639
|
+
* import { CurrencyUtil } from "@pawover/kit/utils";
|
|
2640
|
+
*
|
|
2641
|
+
* // 重载 1: 有效数值
|
|
2642
|
+
* CurrencyUtil.currencyFormatter(1234.56, {
|
|
2643
|
+
* locales: [CurrencyUtil.CURRENCY_ENUM.CNY, CurrencyUtil.CURRENCY_ENUM.USD],
|
|
2644
|
+
* currencySign: "¥",
|
|
2645
|
+
* currencySignPosition: "prefix",
|
|
2646
|
+
* currencyFormatOptions: { style: "currency", currency: "CNY" },
|
|
2647
|
+
* }); // "¥ 1,234.56"
|
|
2648
|
+
*
|
|
2649
|
+
* // 重载 2: null / undefined
|
|
2650
|
+
* CurrencyUtil.currencyFormatter(null, options); // null
|
|
2651
|
+
* CurrencyUtil.currencyFormatter(undefined, options); // null
|
|
2652
|
+
* ```
|
|
2653
|
+
*/
|
|
2654
|
+
static currencyFormatter(value: string | number, options: FormatterOptions): string;
|
|
2655
|
+
static currencyFormatter(value: string | number | null | undefined, options: FormatterOptions): string | null;
|
|
2656
|
+
/**
|
|
2657
|
+
* 将任意数值转换为精确的十进制值
|
|
2658
|
+
* - 基于 `mathjs` 的 `bignumber` 处理,避免浮点数精度问题
|
|
2659
|
+
* - 当值为 `null` 或 `undefined` 时返回 `null`
|
|
2660
|
+
*
|
|
2661
|
+
* @param mathJsInstance `mathjs` 实例
|
|
2662
|
+
* @param value 待转换的数值
|
|
2663
|
+
* @param precision 小数精度位数
|
|
2664
|
+
* @param stringMode 是否返回字符串类型,默认 `true`
|
|
2665
|
+
* @returns 精确的十进制值,无效输入返回 `null`
|
|
2666
|
+
*
|
|
2667
|
+
* @example
|
|
2668
|
+
* ```ts
|
|
2669
|
+
* import { create, all } from "mathjs";
|
|
2670
|
+
* import { CurrencyUtil } from "@pawover/kit/utils";
|
|
2671
|
+
*
|
|
2672
|
+
* const math = create(all);
|
|
2673
|
+
*
|
|
2674
|
+
* // 重载 1: 有效值 + stringMode = true(默认)
|
|
2675
|
+
* CurrencyUtil.toRealValue(math, "0.1"); // "0.1"
|
|
2676
|
+
* CurrencyUtil.toRealValue(math, 0.1 + 0.2, 2); // "0.30"
|
|
2677
|
+
*
|
|
2678
|
+
* // 重载 2: stringMode = false → number
|
|
2679
|
+
* CurrencyUtil.toRealValue(math, "0.1", undefined, false); // 0.1
|
|
2680
|
+
*
|
|
2681
|
+
* // 重载 3: null / undefined
|
|
2682
|
+
* CurrencyUtil.toRealValue(math, null); // null
|
|
2683
|
+
* ```
|
|
2684
|
+
*/
|
|
2685
|
+
static toRealValue(mathJsInstance: MathJsInstance, value: string | number, precision?: number | undefined, stringMode?: boolean | undefined): string | number;
|
|
2686
|
+
static toRealValue(mathJsInstance: MathJsInstance, value: string | number | null | undefined, precision?: number | undefined, stringMode?: boolean | undefined): string | number | null;
|
|
2687
|
+
}
|
|
2688
|
+
//#endregion
|
|
2689
|
+
//#region src/dateTime/dateTimeUtil.d.ts
|
|
2690
|
+
/**
|
|
2691
|
+
* 日期工具类
|
|
2692
|
+
*/
|
|
2693
|
+
declare class DateTimeUtil {
|
|
2694
|
+
/**
|
|
2695
|
+
* 每秒的毫秒数
|
|
2696
|
+
* @example
|
|
2697
|
+
* ```ts
|
|
2698
|
+
* DateTimeUtil.MILLISECONDS_PER_SECOND; // 1000
|
|
2699
|
+
* ```
|
|
2700
|
+
*/
|
|
2701
|
+
static readonly MILLISECONDS_PER_SECOND: number;
|
|
2702
|
+
/**
|
|
2703
|
+
* 每分钟的秒数
|
|
2704
|
+
* @example
|
|
2705
|
+
* ```ts
|
|
2706
|
+
* DateTimeUtil.SECOND_PER_MINUTE; // 60
|
|
2707
|
+
* ```
|
|
2708
|
+
*/
|
|
2709
|
+
static readonly SECOND_PER_MINUTE: number;
|
|
2710
|
+
/**
|
|
2711
|
+
* 每小时的分钟数
|
|
2712
|
+
* @example
|
|
2713
|
+
* ```ts
|
|
2714
|
+
* DateTimeUtil.MINUTE_PER_HOUR; // 60
|
|
2715
|
+
* ```
|
|
2716
|
+
*/
|
|
2717
|
+
static readonly MINUTE_PER_HOUR: number;
|
|
2718
|
+
/**
|
|
2719
|
+
* 每小时的秒数
|
|
2720
|
+
* @example
|
|
2721
|
+
* ```ts
|
|
2722
|
+
* DateTimeUtil.SECOND_PER_HOUR; // 3600
|
|
2723
|
+
* ```
|
|
2724
|
+
*/
|
|
2725
|
+
static readonly SECOND_PER_HOUR: number;
|
|
2726
|
+
/**
|
|
2727
|
+
* 每天小时数
|
|
2728
|
+
* @example
|
|
2729
|
+
* ```ts
|
|
2730
|
+
* DateTimeUtil.HOUR_PER_DAY; // 24
|
|
2731
|
+
* ```
|
|
2732
|
+
*/
|
|
2733
|
+
static readonly HOUR_PER_DAY: number;
|
|
2734
|
+
/**
|
|
2735
|
+
* 每天秒数
|
|
2736
|
+
* @example
|
|
2737
|
+
* ```ts
|
|
2738
|
+
* DateTimeUtil.SECOND_PER_DAY; // 86400
|
|
2739
|
+
* ```
|
|
2740
|
+
*/
|
|
2741
|
+
static readonly SECOND_PER_DAY: number;
|
|
2742
|
+
/**
|
|
2743
|
+
* 每周天数
|
|
2744
|
+
* @example
|
|
2745
|
+
* ```ts
|
|
2746
|
+
* DateTimeUtil.DAY_PER_WEEK; // 7
|
|
2747
|
+
* ```
|
|
2748
|
+
*/
|
|
2749
|
+
static readonly DAY_PER_WEEK: number;
|
|
2750
|
+
/**
|
|
2751
|
+
* 每月天数
|
|
2752
|
+
* @example
|
|
2753
|
+
* ```ts
|
|
2754
|
+
* DateTimeUtil.DAY_PER_MONTH; // 30
|
|
2755
|
+
* ```
|
|
2756
|
+
*/
|
|
2757
|
+
static readonly DAY_PER_MONTH: number;
|
|
2758
|
+
/**
|
|
2759
|
+
* 每年天数
|
|
2760
|
+
* @example
|
|
2761
|
+
* ```ts
|
|
2762
|
+
* DateTimeUtil.DAY_PER_YEAR; // 365
|
|
2763
|
+
* ```
|
|
2764
|
+
*/
|
|
2765
|
+
static readonly DAY_PER_YEAR: number;
|
|
2766
|
+
/**
|
|
2767
|
+
* 每年月数
|
|
2768
|
+
* @example
|
|
2769
|
+
* ```ts
|
|
2770
|
+
* DateTimeUtil.MONTH_PER_YEAR; // 12
|
|
2771
|
+
* ```
|
|
2772
|
+
*/
|
|
2773
|
+
static readonly MONTH_PER_YEAR: number;
|
|
2774
|
+
/**
|
|
2775
|
+
* 每年平均周
|
|
2776
|
+
* @example
|
|
2777
|
+
* ```ts
|
|
2778
|
+
* DateTimeUtil.WEEK_PER_YEAR; // 52
|
|
2779
|
+
* ```
|
|
2780
|
+
*/
|
|
2781
|
+
static readonly WEEK_PER_YEAR: number;
|
|
2782
|
+
/**
|
|
2783
|
+
* 每月平均周
|
|
2784
|
+
* @example
|
|
2785
|
+
* ```ts
|
|
2786
|
+
* DateTimeUtil.WEEK_PER_MONTH; // 4
|
|
2787
|
+
* ```
|
|
2788
|
+
*/
|
|
2789
|
+
static readonly WEEK_PER_MONTH: number;
|
|
2790
|
+
/**
|
|
2791
|
+
* 常用时间格式模板集合
|
|
2792
|
+
*
|
|
2793
|
+
* @example
|
|
2794
|
+
* ```ts
|
|
2795
|
+
* DateTimeUtil.FORMAT.ISO_DATE; // "yyyy-MM-dd"
|
|
2796
|
+
* DateTimeUtil.FORMAT.CN_DATE_TIME; // "yyyy年MM月dd日 HH时mm分ss秒"
|
|
2797
|
+
* ```
|
|
2798
|
+
*/
|
|
2799
|
+
static readonly FORMAT: {
|
|
2800
|
+
readonly ISO_DATE: "yyyy-MM-dd";
|
|
2801
|
+
readonly ISO_TIME: "HH:mm:ss";
|
|
2802
|
+
readonly ISO_DATE_TIME: "yyyy-MM-dd HH:mm:ss";
|
|
2803
|
+
readonly ISO_DATE_TIME_MS: "yyyy-MM-dd HH:mm:ss.SSS";
|
|
2804
|
+
readonly ISO_DATETIME_TZ: "yyyy-MM-dd'T'HH:mm:ssXXX";
|
|
2805
|
+
readonly ISO_DATETIME_TZ_MS: "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
|
2806
|
+
readonly US_DATE: "MM/dd/yyyy";
|
|
2807
|
+
readonly US_DATE_TIME: "MM/dd/yyyy HH:mm:ss";
|
|
2808
|
+
readonly US_DATE_SHORT_YEAR: "MM/dd/yy";
|
|
2809
|
+
readonly EU_DATE: "dd/MM/yyyy";
|
|
2810
|
+
readonly EU_DATE_TIME: "dd/MM/yyyy HH:mm:ss";
|
|
2811
|
+
readonly CN_DATE: "yyyy年MM月dd日";
|
|
2812
|
+
readonly CN_DATE_TIME: "yyyy年MM月dd日 HH时mm分ss秒";
|
|
2813
|
+
readonly CN_DATE_WEEKDAY: "yyyy年MM月dd日 EEE";
|
|
2814
|
+
readonly CN_WEEKDAY_FULL: "EEEE";
|
|
2815
|
+
readonly SHORT_DATE: "yy-MM-dd";
|
|
2816
|
+
readonly SHORT_DATE_SLASH: "yy/MM/dd";
|
|
2817
|
+
readonly MONTH_DAY: "MM-dd";
|
|
2818
|
+
readonly MONTH_DAY_CN: "MM月dd日";
|
|
2819
|
+
readonly DATE_WITH_WEEKDAY_SHORT: "yyyy-MM-dd (EEE)";
|
|
2820
|
+
readonly DATE_WITH_WEEKDAY_FULL: "yyyy-MM-dd (EEEE)";
|
|
2821
|
+
readonly TIME_24: "HH:mm:ss";
|
|
2822
|
+
readonly TIME_24_NO_SEC: "HH:mm";
|
|
2823
|
+
readonly TIME_12: "hh:mm:ss a";
|
|
2824
|
+
readonly TIME_12_NO_SEC: "hh:mm a";
|
|
2825
|
+
readonly TIMESTAMP: "yyyyMMddHHmmss";
|
|
2826
|
+
readonly TIMESTAMP_MS: "yyyyMMddHHmmssSSS";
|
|
2827
|
+
readonly RFC2822: "EEE, dd MMM yyyy HH:mm:ss xxx";
|
|
2828
|
+
readonly READABLE_DATE: "MMM dd, yyyy";
|
|
2829
|
+
readonly READABLE_DATE_TIME: "MMM dd, yyyy HH:mm";
|
|
2830
|
+
readonly COMPACT_DATETIME: "yyyyMMdd_HHmmss";
|
|
2831
|
+
};
|
|
2832
|
+
/**
|
|
2833
|
+
* 获取当前时区信息
|
|
2834
|
+
*
|
|
2835
|
+
* @returns 时区信息对象 (UTC偏移和时区名称)
|
|
2836
|
+
* @example
|
|
2837
|
+
* ```ts
|
|
2838
|
+
* DateTimeUtil.getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
|
|
2839
|
+
* ```
|
|
2840
|
+
*/
|
|
2841
|
+
static getTimeZone(): {
|
|
2842
|
+
UTC: string;
|
|
2843
|
+
timeZone: string;
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2935
2846
|
//#endregion
|
|
2936
|
-
//#region
|
|
2847
|
+
//#region src/env/envUtil.d.ts
|
|
2937
2848
|
/**
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
```
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2849
|
+
* 环境检查工具类
|
|
2850
|
+
*/
|
|
2851
|
+
declare class EnvUtil {
|
|
2852
|
+
private static readonly _isBrowser;
|
|
2853
|
+
private static readonly _isWebWorker;
|
|
2854
|
+
private static readonly _isReactNative;
|
|
2855
|
+
/**
|
|
2856
|
+
* 检测是否处于浏览器环境
|
|
2857
|
+
*
|
|
2858
|
+
* @returns 是否为浏览器环境
|
|
2859
|
+
* @example
|
|
2860
|
+
* ```ts
|
|
2861
|
+
* EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
|
|
2862
|
+
* ```
|
|
2863
|
+
*/
|
|
2864
|
+
static isBrowser(): boolean;
|
|
2865
|
+
/**
|
|
2866
|
+
* 检测是否处于 Web Worker 环境
|
|
2867
|
+
*
|
|
2868
|
+
* @returns 是否为 Web Worker 环境
|
|
2869
|
+
* @example
|
|
2870
|
+
* ```ts
|
|
2871
|
+
* EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
|
|
2872
|
+
* ```
|
|
2873
|
+
*/
|
|
2874
|
+
static isWebWorker(): boolean;
|
|
2875
|
+
/**
|
|
2876
|
+
* 检测是否处于 React Native 环境
|
|
2877
|
+
*
|
|
2878
|
+
* @returns 是否为 React Native 环境
|
|
2879
|
+
* @example
|
|
2880
|
+
* ```ts
|
|
2881
|
+
* EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
|
|
2882
|
+
* ```
|
|
2883
|
+
*/
|
|
2884
|
+
static isReactNative(): boolean;
|
|
2885
|
+
/**
|
|
2886
|
+
* 检查是否在 iframe 环境中
|
|
2887
|
+
*
|
|
2888
|
+
* @returns 是否在 iframe 中
|
|
2889
|
+
* @example
|
|
2890
|
+
* ```ts
|
|
2891
|
+
* EnvUtil.isIframe(); // true: 当前页面在 iframe 中
|
|
2892
|
+
* ```
|
|
2893
|
+
*/
|
|
2894
|
+
static isIframe(): boolean;
|
|
2895
|
+
/**
|
|
2896
|
+
* 检测当前设备是否为桌面设备
|
|
2897
|
+
*
|
|
2898
|
+
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
2899
|
+
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
2900
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2901
|
+
* @returns 是否为桌面设备
|
|
2902
|
+
* @example
|
|
2903
|
+
* ```ts
|
|
2904
|
+
* // 假设 window.innerWidth = 1920
|
|
2905
|
+
* EnvUtil.isDesktop(); // true
|
|
2906
|
+
*
|
|
2907
|
+
* // 自定义阈值
|
|
2908
|
+
* EnvUtil.isDesktop(1440, 13); // 更严格的桌面检测
|
|
2909
|
+
* ```
|
|
2910
|
+
*/
|
|
2911
|
+
static isDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
2912
|
+
/**
|
|
2913
|
+
* 检测当前设备是否为 Windows 桌面设备
|
|
2914
|
+
*
|
|
2915
|
+
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
2916
|
+
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
2917
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2918
|
+
* @returns 是否为 Windows 桌面设备
|
|
2919
|
+
* @example
|
|
2920
|
+
* ```ts
|
|
2921
|
+
* // UA contains Windows
|
|
2922
|
+
* EnvUtil.isWindowsDesktop(); // true
|
|
2923
|
+
* ```
|
|
2924
|
+
*/
|
|
2925
|
+
static isWindowsDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
2926
|
+
/**
|
|
2927
|
+
* 检测当前设备是否为 macOS 桌面设备
|
|
2928
|
+
*
|
|
2929
|
+
* @param minWidth - 桌面设备最小宽度(默认 1200px)
|
|
2930
|
+
* @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
|
|
2931
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2932
|
+
* @returns 是否为 macOS 桌面设备
|
|
2933
|
+
* @example
|
|
2934
|
+
* ```ts
|
|
2935
|
+
* // UA contains Macintosh
|
|
2936
|
+
* EnvUtil.isMacOSDesktop(); // true
|
|
2937
|
+
* ```
|
|
2938
|
+
*/
|
|
2939
|
+
static isMacOSDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
|
|
2940
|
+
/**
|
|
2941
|
+
* 检测当前设备是否为移动设备
|
|
2942
|
+
*
|
|
2943
|
+
* @param maxWidth - 移动设备最大宽度(默认 768px)
|
|
2944
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2945
|
+
* @returns 是否为移动设备
|
|
2946
|
+
* @example
|
|
2947
|
+
* ```ts
|
|
2948
|
+
* // 假设 window.innerWidth = 500
|
|
2949
|
+
* EnvUtil.isMobile(); // true
|
|
2950
|
+
* ```
|
|
2951
|
+
*/
|
|
2952
|
+
static isMobile(maxWidth?: number, dpi?: number): boolean;
|
|
2953
|
+
/**
|
|
2954
|
+
* 检测当前设备是否为IOS移动设备
|
|
2955
|
+
*
|
|
2956
|
+
* @param maxWidth - 移动设备最大宽度(默认 768px)
|
|
2957
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2958
|
+
* @returns 是否为 iOS 移动设备 (iPhone/iPod)
|
|
2959
|
+
* @example
|
|
2960
|
+
* ```ts
|
|
2961
|
+
* // UA contains iPhone
|
|
2962
|
+
* EnvUtil.isIOSMobile(); // true
|
|
2963
|
+
* ```
|
|
2964
|
+
*/
|
|
2965
|
+
static isIOSMobile(maxWidth?: number, dpi?: number): boolean;
|
|
2966
|
+
/**
|
|
2967
|
+
* 检测当前设备是否为平板
|
|
2968
|
+
*
|
|
2969
|
+
* @param minWidth - 平板最小宽度(默认 768px)
|
|
2970
|
+
* @param maxWidth - 平板最大宽度(默认 1200px)
|
|
2971
|
+
* @param dpi - 标准 DPI 基准(默认 160)
|
|
2972
|
+
* @returns 是否为平板设备
|
|
2973
|
+
* @example
|
|
2974
|
+
* ```ts
|
|
2975
|
+
* // 假设 window.innerWidth = 1000
|
|
2976
|
+
* EnvUtil.isTablet(); // true
|
|
2977
|
+
* ```
|
|
2978
|
+
*/
|
|
2979
|
+
static isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
|
|
2980
|
+
}
|
|
2974
2981
|
//#endregion
|
|
2975
|
-
//#region ../../node_modules/.pnpm
|
|
2976
|
-
/**
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
type
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
2992
|
-
//=> {a: number; b?: string; c?: boolean}
|
|
2993
|
-
```
|
|
2994
|
-
|
|
2995
|
-
@category Object
|
|
2996
|
-
*/
|
|
2997
|
-
type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
|
|
2998
|
-
type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
|
|
2999
|
-
? Simplify<
|
|
3000
|
-
// Pick just the keys that are readonly from the base type.
|
|
3001
|
-
Except<BaseType, Keys> &
|
|
3002
|
-
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
3003
|
-
Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
2982
|
+
//#region ../../node_modules/.pnpm/@pawover+types@0.0.4_@types+react@19.2.15_typescript@6.0.3/node_modules/@pawover/types/dist/index.d.ts
|
|
2983
|
+
/** 任意对象类型 */
|
|
2984
|
+
type AnyObject<K extends PropertyKey = PropertyKey, T = any> = Record<K, T>;
|
|
2985
|
+
/** 普通对象类型 */
|
|
2986
|
+
type PlainObject<K extends PropertyKey = PropertyKey, T = unknown> = Record<K, T>;
|
|
2987
|
+
/** 描述树类型 */
|
|
2988
|
+
type TreeLike<T extends AnyObject, CK extends string = "children"> = T & Record<CK, TreeLike<T, CK>[]>;
|
|
2989
|
+
/** 描述函数类型 */
|
|
2990
|
+
type AnyFunction<P extends any[] = any[], R = any> = (...arg: P) => R;
|
|
2991
|
+
/** 描述异步函数类型 */
|
|
2992
|
+
type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promise<R>;
|
|
2993
|
+
/** 描述生成器函数类型 */
|
|
2994
|
+
type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
|
|
2995
|
+
/** 描述异步生成器函数类型 */
|
|
2996
|
+
type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
|
|
3004
2997
|
//#endregion
|
|
3005
|
-
//#region
|
|
2998
|
+
//#region src/function/functionUtil.d.ts
|
|
3006
2999
|
/**
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3000
|
+
* 函数工具类
|
|
3001
|
+
*/
|
|
3002
|
+
declare class FunctionUtil {
|
|
3003
|
+
/**
|
|
3004
|
+
*将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
|
|
3005
|
+
*
|
|
3006
|
+
* @param promise 待处理的 Promise
|
|
3007
|
+
* @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
|
|
3008
|
+
* @returns `[err, null]` 或 `[null, data]`
|
|
3009
|
+
* @example
|
|
3010
|
+
* ```ts
|
|
3011
|
+
* const [err, data] = await FunctionUtil.to(someAsyncFunc());
|
|
3012
|
+
* ```
|
|
3013
|
+
*/
|
|
3014
|
+
static to<T, U = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U, undefined] | [null, T]>;
|
|
3015
|
+
/**
|
|
3016
|
+
* 将 Arguments 对象转换为数组
|
|
3017
|
+
*
|
|
3018
|
+
* ⚠️ 注意:TypeScript 官方推荐使用 rest parameters (...args) 替代 arguments
|
|
3019
|
+
* 本函数仅用于处理遗留代码或特殊场景(如装饰器中需保留 this 绑定)
|
|
3020
|
+
*
|
|
3021
|
+
* @param args Arguments 对象(必须为类数组对象)
|
|
3022
|
+
* @param start 起始索引(可选,默认为 0)
|
|
3023
|
+
* @returns 转换后的数组,元素类型为 T
|
|
3024
|
+
*
|
|
3025
|
+
* @throws TypeError 如果 args 为 null 或 undefined
|
|
3026
|
+
*
|
|
3027
|
+
* @example
|
|
3028
|
+
* ```ts
|
|
3029
|
+
* // 遗留代码场景
|
|
3030
|
+
* function legacyFn(a: number, b: string) {
|
|
3031
|
+
* const argsArray = FunctionUtil.toArgs(arguments);
|
|
3032
|
+
* // argsArray: unknown[]
|
|
3033
|
+
* }
|
|
3034
|
+
*
|
|
3035
|
+
* // 现代替代方案(推荐)
|
|
3036
|
+
* function modernFn(a: number, b: string, ...rest: unknown[]) {
|
|
3037
|
+
* // rest 已经是数组,无需 toArgs
|
|
3038
|
+
* }
|
|
3039
|
+
*
|
|
3040
|
+
* // 参数截取
|
|
3041
|
+
* function skipFirst(...args: unknown[]) {
|
|
3042
|
+
* const rest = FunctionUtil.toArgs(arguments, 1);
|
|
3043
|
+
* // rest: unknown[],跳过第一个参数
|
|
3044
|
+
* }
|
|
3045
|
+
* ```
|
|
3046
|
+
*/
|
|
3047
|
+
static toArgs<T = unknown>(args: IArguments, start?: number | undefined): T[];
|
|
3048
|
+
/**
|
|
3049
|
+
* 将同步或异步函数统一包装为 Promise
|
|
3050
|
+
* - 自动捕获同步异常
|
|
3051
|
+
*
|
|
3052
|
+
* @param fn 返回值可为同步值或 Promise 的函数
|
|
3053
|
+
* @returns 标准化的 Promise
|
|
3054
|
+
*
|
|
3055
|
+
* @example
|
|
3056
|
+
* ```ts
|
|
3057
|
+
* // 同步函数
|
|
3058
|
+
* FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
|
|
3059
|
+
*
|
|
3060
|
+
* // 异步函数
|
|
3061
|
+
* FunctionUtil.toPromise(async () => await fetchData()).then(data => ...);
|
|
3062
|
+
*
|
|
3063
|
+
* // 异常处理
|
|
3064
|
+
* FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
|
|
3065
|
+
* ```
|
|
3066
|
+
*/
|
|
3067
|
+
static toPromise<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
3068
|
+
}
|
|
3028
3069
|
//#endregion
|
|
3029
|
-
//#region
|
|
3070
|
+
//#region src/mime/mimeUtil.d.ts
|
|
3030
3071
|
/**
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3072
|
+
* MIME 工具类
|
|
3073
|
+
*/
|
|
3074
|
+
declare class MimeUtil {
|
|
3075
|
+
/**
|
|
3076
|
+
* 文件类型 MIME 常量
|
|
3077
|
+
* - 每个类型对应具体的文件扩展名
|
|
3078
|
+
*/
|
|
3079
|
+
static readonly FILE_MIME: {
|
|
3080
|
+
/** 普通文本文件(.txt) */
|
|
3081
|
+
readonly TEXT: "text/plain";
|
|
3082
|
+
/** 超文本标记语言文档(.html/.htm) */
|
|
3083
|
+
readonly HTML: "text/html";
|
|
3084
|
+
/** 层叠样式表文件(.css) */
|
|
3085
|
+
readonly CSS: "text/css";
|
|
3086
|
+
/** 逗号分隔值文件/表格数据(.csv) */
|
|
3087
|
+
readonly CSV: "text/csv";
|
|
3088
|
+
/** 制表符分隔值文件(.tsv) */
|
|
3089
|
+
readonly TSV: "text/tab-separated-values";
|
|
3090
|
+
/** XML 文档(.xml) */
|
|
3091
|
+
readonly XML: "application/xml";
|
|
3092
|
+
/** XML 文档/兼容值 */
|
|
3093
|
+
readonly XML_LEGACY: "text/xml";
|
|
3094
|
+
/** XHTML 文档(.xhtml/.xht) */
|
|
3095
|
+
readonly XHTML: "application/xhtml+xml";
|
|
3096
|
+
/** JavaScript 文件(.js) */
|
|
3097
|
+
readonly JS: "text/javascript";
|
|
3098
|
+
/** TypeScript 文件(.ts) */
|
|
3099
|
+
readonly TS: "text/typescript";
|
|
3100
|
+
/** Python 文件(.py) */
|
|
3101
|
+
readonly PY: "text/x-python";
|
|
3102
|
+
/** Shell 脚本 (.sh) */
|
|
3103
|
+
readonly SH: "text/x-sh";
|
|
3104
|
+
/** C 语言源文件(.c) */
|
|
3105
|
+
readonly C: "text/x-c";
|
|
3106
|
+
/** C++ 源文件(.cpp/.cc/.cxx) */
|
|
3107
|
+
readonly CPP: "text/x-c++";
|
|
3108
|
+
/** C# 源文件(.cs) */
|
|
3109
|
+
readonly CSHARP: "text/x-csharp";
|
|
3110
|
+
/** Java 源文件(.java) */
|
|
3111
|
+
readonly JAVA: "text/x-java";
|
|
3112
|
+
/** Go 源文件(.go) */
|
|
3113
|
+
readonly GO: "text/x-go";
|
|
3114
|
+
/** Rust 源文件(.rs) */
|
|
3115
|
+
readonly RUST: "text/x-rust";
|
|
3116
|
+
/** PHP 文件(.php) */
|
|
3117
|
+
readonly PHP: "text/x-php";
|
|
3118
|
+
/** Ruby 文件(.rb) */
|
|
3119
|
+
readonly RUBY: "text/x-ruby";
|
|
3120
|
+
/** Swift 源文件(.swift) */
|
|
3121
|
+
readonly SWIFT: "text/x-swift";
|
|
3122
|
+
/** YAML 文档(.yaml/.yml) */
|
|
3123
|
+
readonly YAML: "application/yaml";
|
|
3124
|
+
/** YAML 文档/兼容值 */
|
|
3125
|
+
readonly YAML_LEGACY: "text/vnd.yaml";
|
|
3126
|
+
/** TOML 文档(.toml) */
|
|
3127
|
+
readonly TOML: "application/toml";
|
|
3128
|
+
/** TOML 文档/兼容值 */
|
|
3129
|
+
readonly TOML_LEGACY: "text/x-toml";
|
|
3130
|
+
/** SQL 脚本(.sql) */
|
|
3131
|
+
readonly SQL: "application/sql";
|
|
3132
|
+
/** SQL 脚本/兼容值 */
|
|
3133
|
+
readonly SQL_LEGACY: "text/x-sql";
|
|
3134
|
+
/** Markdown 格式文档(.md/.markdown) */
|
|
3135
|
+
readonly MARKDOWN: "text/markdown";
|
|
3136
|
+
/** 富文本格式文档(.rtf) */
|
|
3137
|
+
readonly RTF: "application/rtf";
|
|
3138
|
+
/** iCalendar 日历格式(.ics) */
|
|
3139
|
+
readonly CALENDAR: "text/calendar";
|
|
3140
|
+
/** JPEG 图像(.jpg/.jpeg) */
|
|
3141
|
+
readonly JPEG: "image/jpeg";
|
|
3142
|
+
/** JPG 图像(JPEG 别名,.jpg) */
|
|
3143
|
+
readonly JPG: "image/jpeg";
|
|
3144
|
+
/** PNG 图像/无损压缩,支持透明(.png) */
|
|
3145
|
+
readonly PNG: "image/png";
|
|
3146
|
+
/** GIF 图像/支持动画(.gif) */
|
|
3147
|
+
readonly GIF: "image/gif";
|
|
3148
|
+
/** Windows 位图(.bmp) */
|
|
3149
|
+
readonly BMP: "image/bmp";
|
|
3150
|
+
/** SVG 向量图形(.svg) */
|
|
3151
|
+
readonly SVG: "image/svg+xml";
|
|
3152
|
+
/** APNG 动态图像(.apng) */
|
|
3153
|
+
readonly APNG: "image/apng";
|
|
3154
|
+
/** AVIF 图像/高效压缩(.avif) */
|
|
3155
|
+
readonly AVIF: "image/avif";
|
|
3156
|
+
/** 图标文件格式(.ico) */
|
|
3157
|
+
readonly ICO: "image/vnd.microsoft.icon";
|
|
3158
|
+
/** 图标文件格式/兼容值(.ico) */
|
|
3159
|
+
readonly ICO_LEGACY: "image/x-icon";
|
|
3160
|
+
/** WebP 图像/高效压缩(.webp) */
|
|
3161
|
+
readonly WEBP: "image/webp";
|
|
3162
|
+
/** TIFF 图像(.tif/.tiff) */
|
|
3163
|
+
readonly TIFF: "image/tiff";
|
|
3164
|
+
/** HEIC 图像/高效编码(.heic) */
|
|
3165
|
+
readonly HEIC: "image/heic";
|
|
3166
|
+
/** HEIF 图像/高效编码(.heif) */
|
|
3167
|
+
readonly HEIF: "image/heif";
|
|
3168
|
+
/** Adobe Photoshop 文件(.psd) */
|
|
3169
|
+
readonly PSD: "image/vnd.adobe.photoshop";
|
|
3170
|
+
/** MP3 音频(.mp3) */
|
|
3171
|
+
readonly MP3: "audio/mpeg";
|
|
3172
|
+
/** AAC 音频(.aac) */
|
|
3173
|
+
readonly AAC: "audio/aac";
|
|
3174
|
+
/** MIDI 音乐文件(.mid/.midi) */
|
|
3175
|
+
readonly MIDI: "audio/midi";
|
|
3176
|
+
/** OGG 音频(.oga) */
|
|
3177
|
+
readonly OGG_AUDIO: "audio/ogg";
|
|
3178
|
+
/** Opus 音频(.opus) */
|
|
3179
|
+
readonly OPUS: "audio/opus";
|
|
3180
|
+
/** FLAC 无损音频(.flac) */
|
|
3181
|
+
readonly FLAC: "audio/flac";
|
|
3182
|
+
/** WAV 音频(.wav) */
|
|
3183
|
+
readonly WAV: "audio/wav";
|
|
3184
|
+
/** WebM 音频(.weba) */
|
|
3185
|
+
readonly WEBM_AUDIO: "audio/webm";
|
|
3186
|
+
/** RealAudio 音频(.ra/.ram) */
|
|
3187
|
+
readonly REAL_AUDIO: "audio/x-pn-realaudio";
|
|
3188
|
+
/** MP4 视频(.mp4) */
|
|
3189
|
+
readonly MP4: "video/mp4";
|
|
3190
|
+
/** MPEG 视频(.mpeg/.mpg) */
|
|
3191
|
+
readonly MPEG: "video/mpeg";
|
|
3192
|
+
/** OGG 视频(.ogv) */
|
|
3193
|
+
readonly OGG_VIDEO: "video/ogg";
|
|
3194
|
+
/** AVI 视频(.avi) */
|
|
3195
|
+
readonly AVI: "video/x-msvideo";
|
|
3196
|
+
/** 3GPP 视频(.3gp) */
|
|
3197
|
+
readonly THREE_GPP: "video/3gpp";
|
|
3198
|
+
/** 3GPP2 视频(.3g2) */
|
|
3199
|
+
readonly THREE_GPP2: "video/3gpp2";
|
|
3200
|
+
/** WebM 视频(.webm) */
|
|
3201
|
+
readonly WEBM: "video/webm";
|
|
3202
|
+
/** Matroska 视频(.mkv) */
|
|
3203
|
+
readonly MKV: "video/x-matroska";
|
|
3204
|
+
/** Matroska 音频(.mka) */
|
|
3205
|
+
readonly MKA: "audio/x-matroska";
|
|
3206
|
+
/** QuickTime 视频(.mov) */
|
|
3207
|
+
readonly QUICKTIME: "video/quicktime";
|
|
3208
|
+
/** PDF 文档(.pdf) */
|
|
3209
|
+
readonly PDF: "application/pdf";
|
|
3210
|
+
/** Word 97-2003 文档(.doc) */
|
|
3211
|
+
readonly DOC: "application/msword";
|
|
3212
|
+
/** Word 2007+ 文档(.docx) */
|
|
3213
|
+
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
3214
|
+
/** Excel 2007+ 工作簿(.xlsx) */
|
|
3215
|
+
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
3216
|
+
/** 启用宏的Excel工作簿(.xlsm) */
|
|
3217
|
+
readonly XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
3218
|
+
/** Excel模板文件(.xltx) */
|
|
3219
|
+
readonly XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template";
|
|
3220
|
+
/** PowerPoint 2007+ 演示文稿(.pptx) */
|
|
3221
|
+
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
3222
|
+
/** PowerPoint 97-2003 演示文稿(.ppt) */
|
|
3223
|
+
readonly PPT: "application/vnd.ms-powerpoint";
|
|
3224
|
+
/** OpenDocument 文本文档(.odt) */
|
|
3225
|
+
readonly ODT: "application/vnd.oasis.opendocument.text";
|
|
3226
|
+
/** OpenDocument 表格文档(.ods) */
|
|
3227
|
+
readonly ODS: "application/vnd.oasis.opendocument.spreadsheet";
|
|
3228
|
+
/** OpenDocument 演示文稿(.odp) */
|
|
3229
|
+
readonly ODP: "application/vnd.oasis.opendocument.presentation";
|
|
3230
|
+
/** EPUB 电子书(.epub) */
|
|
3231
|
+
readonly EPUB: "application/epub+zip";
|
|
3232
|
+
/** Kindle 电子书(.azw) */
|
|
3233
|
+
readonly AZW: "application/vnd.amazon.ebook";
|
|
3234
|
+
/** ZIP 压缩文件(.zip) */
|
|
3235
|
+
readonly ZIP: "application/zip";
|
|
3236
|
+
/** GZIP 压缩文件(.gz) */
|
|
3237
|
+
readonly GZIP: "application/gzip";
|
|
3238
|
+
/** TAR 归档文件(.tar) */
|
|
3239
|
+
readonly TAR: "application/x-tar";
|
|
3240
|
+
/** BZip 归档(.bz) */
|
|
3241
|
+
readonly BZIP: "application/x-bzip";
|
|
3242
|
+
/** BZip2 归档(.bz2) */
|
|
3243
|
+
readonly BZIP2: "application/x-bzip2";
|
|
3244
|
+
/** 7-Zip 压缩文件(.7z) */
|
|
3245
|
+
readonly SEVEN_Z: "application/x-7z-compressed";
|
|
3246
|
+
/** RAR 压缩文件(.rar) */
|
|
3247
|
+
readonly RAR: "application/vnd.rar";
|
|
3248
|
+
/** XZ 压缩文件(.xz) */
|
|
3249
|
+
readonly XZ: "application/x-xz";
|
|
3250
|
+
/** Zstandard 压缩文件(.zst) */
|
|
3251
|
+
readonly ZSTD: "application/zstd";
|
|
3252
|
+
/** ISO 光盘镜像(.iso) */
|
|
3253
|
+
readonly ISO9660_IMAGE: "application/x-iso9660-image";
|
|
3254
|
+
/** JSON 数据格式(.json) */
|
|
3255
|
+
readonly JSON: "application/json";
|
|
3256
|
+
/** JSON-LD 格式(.jsonld) */
|
|
3257
|
+
readonly LD_JSON: "application/ld+json";
|
|
3258
|
+
/** Web App Manifest(.webmanifest) */
|
|
3259
|
+
readonly MANIFEST: "application/manifest+json";
|
|
3260
|
+
/** Java 归档文件(.jar) */
|
|
3261
|
+
readonly JAR: "application/java-archive";
|
|
3262
|
+
/** WebAssembly 二进制指令格式(.wasm) */
|
|
3263
|
+
readonly WASM: "application/wasm";
|
|
3264
|
+
/** MS 嵌入式 OpenType 字体(.eot) */
|
|
3265
|
+
readonly EOT: "application/vnd.ms-fontobject";
|
|
3266
|
+
/** OpenType 字体(.otf) */
|
|
3267
|
+
readonly OTF: "font/otf";
|
|
3268
|
+
/** WOFF 字体(.woff) */
|
|
3269
|
+
readonly WOFF: "font/woff";
|
|
3270
|
+
/** WOFF2 字体(.woff2) */
|
|
3271
|
+
readonly WOFF2: "font/woff2";
|
|
3272
|
+
/** TrueType 字体(.ttf) */
|
|
3273
|
+
readonly TTF: "font/ttf";
|
|
3274
|
+
/** Excel 97-2003 工作簿(.xls) */
|
|
3275
|
+
readonly XLS: "application/vnd.ms-excel";
|
|
3276
|
+
/** Microsoft XPS 文档(.xps) */
|
|
3277
|
+
readonly XPS: "application/vnd.ms-xpsdocument";
|
|
3278
|
+
/** Word 启用宏文档(.docm) */
|
|
3279
|
+
readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
|
|
3280
|
+
};
|
|
3036
3281
|
/**
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
@
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
string[] : never // Should never happen
|
|
3092
|
-
: never; // Should never happen
|
|
3282
|
+
* 协议/内容类型 MIME 常量
|
|
3283
|
+
* - 用于 HTTP 请求/响应内容协商,无对应文件扩展名
|
|
3284
|
+
*/
|
|
3285
|
+
static readonly PROTOCOL_MIME: {
|
|
3286
|
+
/** 通用二进制数据流 */
|
|
3287
|
+
readonly OCTET_STREAM: "application/octet-stream";
|
|
3288
|
+
/** URL 编码表单 */
|
|
3289
|
+
readonly FORM_URLENCODED: "application/x-www-form-urlencoded";
|
|
3290
|
+
/** multipart 表单 */
|
|
3291
|
+
readonly FORM_DATA: "multipart/form-data";
|
|
3292
|
+
/** Server-Sent Events 数据流 */
|
|
3293
|
+
readonly EVENT_STREAM: "text/event-stream";
|
|
3294
|
+
/** 问题详情 JSON(RFC 9457) */
|
|
3295
|
+
readonly PROBLEM_JSON: "application/problem+json";
|
|
3296
|
+
/** JSON Patch(RFC 6902) */
|
|
3297
|
+
readonly JSON_PATCH: "application/json-patch+json";
|
|
3298
|
+
/** JSON Merge Patch(RFC 7386) */
|
|
3299
|
+
readonly MERGE_PATCH_JSON: "application/merge-patch+json";
|
|
3300
|
+
};
|
|
3301
|
+
/**
|
|
3302
|
+
* 根据文件后缀名获取对应的标准 MIME 类型(含历史兼容值)
|
|
3303
|
+
* - 支持带 `.` 或不带 `.` 的后缀名,不区分大小写
|
|
3304
|
+
* - 元组第一项始终为 IANA 官方标准 MIME,后续项为历史兼容值
|
|
3305
|
+
* - 仅查询文件类型 MIME,不包含无后缀对应的协议类型
|
|
3306
|
+
*
|
|
3307
|
+
* @param extension 文件后缀名(如 `".png"` / `"png"` / `".PNG"`)
|
|
3308
|
+
* @returns 标准 MIME + 兼容值的元组;如无匹配则返回 `undefined`
|
|
3309
|
+
* @example
|
|
3310
|
+
* ```ts
|
|
3311
|
+
* MimeUtil.fromExtension(".png"); // ["image/png"]
|
|
3312
|
+
* MimeUtil.fromExtension("ico"); // ["image/vnd.microsoft.icon", "image/x-icon"]
|
|
3313
|
+
* MimeUtil.fromExtension(".xml"); // ["application/xml", "text/xml"]
|
|
3314
|
+
* MimeUtil.fromExtension(".xyz"); // undefined
|
|
3315
|
+
* ```
|
|
3316
|
+
*/
|
|
3317
|
+
static fromExtension(extension: string): readonly [string, ...string[]] | undefined;
|
|
3318
|
+
/**
|
|
3319
|
+
* 根据 MIME 类型获取对应的文件后缀名列表
|
|
3320
|
+
* - 一个 MIME 类型可能对应多个后缀名(如 `text/html` → `.html` / `.htm`)
|
|
3321
|
+
* - 兼容值和标准值映射到相同的后缀(如 `image/x-icon` 和 `image/vnd.microsoft.icon` 均返回 `[".ico"]`)
|
|
3322
|
+
* - 仅查询文件类型 MIME,协议类型无对应后缀
|
|
3323
|
+
*
|
|
3324
|
+
* @param mime MIME 类型字符串(如 `"image/png"` / `"IMAGE/PNG"`)
|
|
3325
|
+
* @returns 文件后缀名列表;如无匹配则返回 `undefined`
|
|
3326
|
+
* @example
|
|
3327
|
+
* ```ts
|
|
3328
|
+
* MimeUtil.toExtension("IMAGE/PNG"); // [".png"]
|
|
3329
|
+
* MimeUtil.toExtension("text/html"); // [".html", ".htm"]
|
|
3330
|
+
* MimeUtil.toExtension("image/jpeg"); // [".jpg", ".jpeg"]
|
|
3331
|
+
* MimeUtil.toExtension("application/octet-stream"); // undefined
|
|
3332
|
+
* ```
|
|
3333
|
+
*/
|
|
3334
|
+
static toExtension(mime: string): readonly [string, ...string[]] | undefined;
|
|
3335
|
+
}
|
|
3093
3336
|
//#endregion
|
|
3094
|
-
//#region
|
|
3095
|
-
type ReplaceOptions = {
|
|
3096
|
-
all?: boolean;
|
|
3097
|
-
};
|
|
3098
|
-
type DefaultReplaceOptions = {
|
|
3099
|
-
all: false;
|
|
3100
|
-
};
|
|
3337
|
+
//#region src/number/numberUtil.d.ts
|
|
3101
3338
|
/**
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
@
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
): Replace<Input, Search, Replacement>;
|
|
3122
|
-
|
|
3123
|
-
declare function replaceAll<
|
|
3124
|
-
Input extends string,
|
|
3125
|
-
Search extends string,
|
|
3126
|
-
Replacement extends string,
|
|
3127
|
-
>(
|
|
3128
|
-
input: Input,
|
|
3129
|
-
search: Search,
|
|
3130
|
-
replacement: Replacement,
|
|
3131
|
-
): Replace<Input, Search, Replacement, {all: true}>;
|
|
3132
|
-
|
|
3133
|
-
// The return type is the exact string literal, not just `string`.
|
|
3134
|
-
|
|
3135
|
-
replace('hello ?', '?', '🦄');
|
|
3136
|
-
//=> 'hello 🦄'
|
|
3137
|
-
|
|
3138
|
-
replace('hello ??', '?', '❓');
|
|
3139
|
-
//=> 'hello ❓?'
|
|
3140
|
-
|
|
3141
|
-
replaceAll('10:42:00', ':', '-');
|
|
3142
|
-
//=> '10-42-00'
|
|
3143
|
-
|
|
3144
|
-
replaceAll('__userName__', '__', '');
|
|
3145
|
-
//=> 'userName'
|
|
3146
|
-
|
|
3147
|
-
replaceAll('My Cool Title', ' ', '');
|
|
3148
|
-
//=> 'MyCoolTitle'
|
|
3149
|
-
```
|
|
3150
|
-
|
|
3151
|
-
@category String
|
|
3152
|
-
@category Template literal
|
|
3153
|
-
*/
|
|
3154
|
-
type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
|
|
3155
|
-
type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
|
|
3156
|
-
? Replacement extends string // For distributing `Replacement`
|
|
3157
|
-
? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
|
|
3339
|
+
* 数字工具类
|
|
3340
|
+
*/
|
|
3341
|
+
declare class NumberUtil {
|
|
3342
|
+
/**
|
|
3343
|
+
* 数字区间检查函数
|
|
3344
|
+
*
|
|
3345
|
+
* @param input 待检查数字
|
|
3346
|
+
* @param interval 由两个数字组成的元组 [left, right]
|
|
3347
|
+
* @param includeLeft 是否包含左边界(默认 true)
|
|
3348
|
+
* @param includeRight 是否包含右边界(默认 false)
|
|
3349
|
+
* @returns 是否在区间内
|
|
3350
|
+
* @example
|
|
3351
|
+
* ```ts
|
|
3352
|
+
* NumberUtil.within(5, [1, 10]); // true
|
|
3353
|
+
* NumberUtil.within(1, [1, 10], false); // false
|
|
3354
|
+
* ```
|
|
3355
|
+
*/
|
|
3356
|
+
static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
|
|
3357
|
+
}
|
|
3158
3358
|
//#endregion
|
|
3159
3359
|
//#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
|
|
3160
3360
|
/**
|
|
@@ -3875,6 +4075,7 @@ declare class StringUtil {
|
|
|
3875
4075
|
*
|
|
3876
4076
|
* @param candidate 待转换的值
|
|
3877
4077
|
* @param checkEmpty 是否检查空值(`null` / `undefined` / 空白字符串),默认为 `true`
|
|
4078
|
+
* @param trim 是否去除结果首尾空白,默认为 `true`
|
|
3878
4079
|
* @returns 转换后的字符串
|
|
3879
4080
|
* @example
|
|
3880
4081
|
* ```ts
|
|
@@ -3896,12 +4097,17 @@ declare class StringUtil {
|
|
|
3896
4097
|
*
|
|
3897
4098
|
* // 重载 4: 其他类型 → string
|
|
3898
4099
|
* StringUtil.cast(Symbol("foo")); // "Symbol(foo)" (类型为 string)
|
|
4100
|
+
*
|
|
4101
|
+
* // trim 参数(默认 true)
|
|
4102
|
+
* StringUtil.cast(" hello "); // "hello"
|
|
4103
|
+
* StringUtil.cast("\n abc \n"); // "abc"
|
|
4104
|
+
* StringUtil.cast("\n abc \n", true, false); // "\n abc \n"
|
|
3899
4105
|
* ```
|
|
3900
4106
|
*/
|
|
3901
|
-
static cast<T extends null | undefined>(candidate: T, checkEmpty?: true): "";
|
|
3902
|
-
static cast<T extends null | undefined>(candidate: T, checkEmpty: false): `${T}`;
|
|
3903
|
-
static cast<T extends string | number | bigint | boolean>(candidate: T, checkEmpty?: boolean): `${T}`;
|
|
3904
|
-
static cast(candidate: unknown, checkEmpty?: boolean): string;
|
|
4107
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty?: true, trim?: boolean): "";
|
|
4108
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty: false, trim?: boolean): `${T}`;
|
|
4109
|
+
static cast<T extends string | number | bigint | boolean>(candidate: T, checkEmpty?: boolean, trim?: boolean): `${T}`;
|
|
4110
|
+
static cast(candidate: unknown, checkEmpty?: boolean, trim?: boolean): string;
|
|
3905
4111
|
/**
|
|
3906
4112
|
* 从字符串中提取数字字符串
|
|
3907
4113
|
* - 移除非数字字符,保留符号和小数点
|
|
@@ -5085,4 +5291,4 @@ declare class ValidateUtil {
|
|
|
5085
5291
|
static isSpaceStartOrEnd(input: string): boolean;
|
|
5086
5292
|
}
|
|
5087
5293
|
//#endregion
|
|
5088
|
-
export { ArrayUtil, DateTimeUtil, EnvUtil, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, type THEME_MODE_TYPE, type THEME_TYPE, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };
|
|
5294
|
+
export { ArrayUtil, type CurrencyCode, type CurrencyLocale, CurrencyUtil, DateTimeUtil, EnvUtil, type FormatterOptions, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, type THEME_MODE_TYPE, type THEME_TYPE, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };
|