@allahjs/utils 1.10.0 → 1.12.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.
Files changed (88) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/core/arrayUtils/index.cjs +327 -3
  3. package/dist/core/arrayUtils/index.cjs.map +1 -1
  4. package/dist/core/arrayUtils/index.d.ts +137 -3
  5. package/dist/core/constants/asyncTaskScheduleVo.d.ts +1 -1
  6. package/dist/core/constants/comm.cjs +8 -8
  7. package/dist/core/constants/comm.cjs.map +1 -1
  8. package/dist/core/constants/comm.d.ts +4 -4
  9. package/dist/core/constants/index.cjs +2 -2
  10. package/dist/core/constants/index.d.ts +1 -1
  11. package/dist/core/diffUtils/index.cjs +219 -0
  12. package/dist/core/diffUtils/index.cjs.map +1 -0
  13. package/dist/core/diffUtils/index.d.ts +32 -0
  14. package/dist/core/fileUtils/index.cjs +21 -0
  15. package/dist/core/fileUtils/index.cjs.map +1 -0
  16. package/dist/core/fileUtils/index.d.ts +10 -0
  17. package/dist/core/index.cjs +20 -10
  18. package/dist/core/index.cjs.map +1 -1
  19. package/dist/core/index.d.ts +69 -1
  20. package/dist/core/pageUtils/index.cjs +21 -1
  21. package/dist/core/pageUtils/index.cjs.map +1 -1
  22. package/dist/core/pageUtils/index.d.ts +1 -0
  23. package/dist/esm/core/arrayUtils/index.d.ts +137 -3
  24. package/dist/esm/core/arrayUtils/index.js +327 -3
  25. package/dist/esm/core/arrayUtils/index.js.map +1 -1
  26. package/dist/esm/core/constants/asyncTaskScheduleVo.d.ts +1 -1
  27. package/dist/esm/core/constants/comm.d.ts +4 -4
  28. package/dist/esm/core/constants/comm.js +9 -9
  29. package/dist/esm/core/constants/comm.js.map +1 -1
  30. package/dist/esm/core/constants/index.d.ts +1 -1
  31. package/dist/esm/core/constants/index.js +1 -1
  32. package/dist/esm/core/diffUtils/index.d.ts +32 -0
  33. package/dist/esm/core/diffUtils/index.js +215 -0
  34. package/dist/esm/core/diffUtils/index.js.map +1 -0
  35. package/dist/esm/core/fileUtils/index.d.ts +10 -0
  36. package/dist/esm/core/fileUtils/index.js +16 -0
  37. package/dist/esm/core/fileUtils/index.js.map +1 -0
  38. package/dist/esm/core/index.d.ts +69 -1
  39. package/dist/esm/core/index.js +10 -0
  40. package/dist/esm/core/index.js.map +1 -1
  41. package/dist/esm/core/pageUtils/index.d.ts +1 -0
  42. package/dist/esm/core/pageUtils/index.js +21 -2
  43. package/dist/esm/core/pageUtils/index.js.map +1 -1
  44. package/dist/esm/form/attributes.d.ts +32 -0
  45. package/dist/esm/form/formItem.d.ts +163 -0
  46. package/dist/esm/form/index.d.ts +4 -1
  47. package/dist/esm/form/rule.d.ts +37 -0
  48. package/dist/esm/form/types.d.ts +12 -213
  49. package/dist/esm/index.d.ts +11 -2
  50. package/dist/esm/index.js +5 -0
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js +20 -0
  53. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js.map +1 -0
  54. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js +256 -0
  55. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js.map +1 -0
  56. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js +11 -0
  57. package/dist/esm/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js.map +1 -0
  58. package/dist/esm/request/ReqQueue/index.d.ts +25 -0
  59. package/dist/esm/request/httpCode/index.d.ts +9 -0
  60. package/dist/esm/request/index.d.ts +6 -3
  61. package/dist/esm/request/index.js +4 -2
  62. package/dist/esm/request/index.js.map +1 -1
  63. package/dist/esm/request/uniRequest/index.d.ts +5 -0
  64. package/dist/esm/types/dbData/index.d.ts +83 -0
  65. package/dist/esm/types/index.d.ts +1 -0
  66. package/dist/form/attributes.d.ts +32 -0
  67. package/dist/form/formItem.d.ts +163 -0
  68. package/dist/form/index.d.ts +4 -1
  69. package/dist/form/rule.d.ts +37 -0
  70. package/dist/form/types.d.ts +12 -213
  71. package/dist/index.cjs +61 -50
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.ts +11 -2
  74. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.cjs +23 -0
  75. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.cjs.map +1 -0
  76. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.cjs +260 -0
  77. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.cjs.map +1 -0
  78. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.cjs +14 -0
  79. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.cjs.map +1 -0
  80. package/dist/request/ReqQueue/index.d.ts +25 -0
  81. package/dist/request/httpCode/index.d.ts +9 -0
  82. package/dist/request/index.cjs +25 -20
  83. package/dist/request/index.cjs.map +1 -1
  84. package/dist/request/index.d.ts +6 -3
  85. package/dist/request/uniRequest/index.d.ts +5 -0
  86. package/dist/types/dbData/index.d.ts +83 -0
  87. package/dist/types/index.d.ts +1 -0
  88. package/package.json +28 -5
@@ -1,4 +1,6 @@
1
1
  import { IOptions, ITreeNode } from '../types/data/index.js';
2
+ import { BaseRule } from './rule.js';
3
+ import { FormItemProps } from './formItem.js';
2
4
 
3
5
  /**
4
6
  * JSON规则项配置
@@ -145,7 +147,7 @@ type FilterFunc = (meta: Meta) => boolean;
145
147
  * 可以是任意类型,通常为字符串、数字或它们的数组
146
148
  * @template T 路径类型,默认为any
147
149
  */
148
- type NamePath<T = any> = any;
150
+ type NamePath = any;
149
151
  /**
150
152
  * 验证选项接口
151
153
  * 用于配置字段验证行为
@@ -236,11 +238,6 @@ interface FormInstance<Values = any> extends RcFormInstance<Values> {
236
238
  * 以上类型定义从 antdForm.d.ts 迁移而来
237
239
  * 提供了完整的表单实例和字段管理功能
238
240
  */
239
- /**
240
- * 必填标记类型
241
- * 用于控制表单项的必填显示方式
242
- */
243
- declare type RequiredMark = boolean | "optional";
244
241
  /**
245
242
  * 尺寸类型
246
243
  * 定义组件的大小规格
@@ -251,54 +248,6 @@ type ISizeType = "small" | "middle" | "large" | undefined;
251
248
  * 定义特殊的表单字段类型
252
249
  */
253
250
  declare type FormFieldType = "group" | "formList" | "formSet" | "divider" | "dependency";
254
- /**
255
- * 工具提示属性接口
256
- * 用于配置提示框的样式和行为
257
- */
258
- interface TooltipProps {
259
- /** 样式对象 */
260
- style?: any;
261
- /** CSS类名 */
262
- className?: string;
263
- /** 背景颜色 */
264
- color?: string;
265
- /** 打开状态的CSS类名 */
266
- openClassName?: string;
267
- /** 箭头是否指向中心 */
268
- arrowPointAtCenter?: boolean;
269
- /** 是否自动调整溢出 */
270
- autoAdjustOverflow?: boolean;
271
- /** 获取弹出容器的函数 */
272
- getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
273
- /** 子元素 */
274
- children?: any;
275
- /** 标题内容 */
276
- title?: any;
277
- /** 覆盖层内容 */
278
- overlay?: any;
279
- }
280
- /**
281
- * 包装工具提示属性
282
- * 在基础TooltipProps上增加图标配置
283
- */
284
- declare type WrapperTooltipProps = TooltipProps & {
285
- /** 图标元素 */
286
- icon?: any;
287
- };
288
- /**
289
- * 表单项标签属性接口
290
- * 用于配置表单项的标签显示
291
- */
292
- interface FormItemLabelProps {
293
- /** 是否显示冒号 */
294
- colon?: boolean;
295
- /** HTML for属性 */
296
- htmlFor?: string;
297
- /** 标签内容 */
298
- label?: any | string;
299
- /** 必填标记配置 */
300
- requiredMark?: RequiredMark;
301
- }
302
251
  /**
303
252
  * ProField值类型与字段属性映射
304
253
  * 定义了各种字段类型对应的属性配置
@@ -395,7 +344,7 @@ interface ProFieldValueTypeWithFieldProps {
395
344
  * 定义了表单项的通用配置
396
345
  * @template T 值类型,默认为any
397
346
  */
398
- interface IZlFormItemProps<T = any> {
347
+ interface IAhFormItemProps<T = any> {
399
348
  /** 当前值 */
400
349
  value?: T;
401
350
  /** 值变化回调 */
@@ -501,121 +450,6 @@ declare type ProSchemaValueEnumObj = Record<string, ProSchemaValueEnumType | (Om
501
450
  * 支持 Map 数据结构,键可以是多种基础类型
502
451
  */
503
452
  declare type ProSchemaValueEnumMap = Map<string | number | bigint, ProSchemaValueEnumType>;
504
- /**
505
- * 验证状态常量数组
506
- */
507
- declare const ValidateStatuses: [
508
- "success",
509
- "warning",
510
- "error",
511
- "validating",
512
- ""
513
- ];
514
- /**
515
- * 验证状态类型
516
- * 表示字段的验证结果状态
517
- */
518
- declare type ValidateStatus = typeof ValidateStatuses[number];
519
- /**
520
- * 文件上传配置接口
521
- * 用于配置文件上传相关参数
522
- */
523
- interface IUploadProps {
524
- /** 上传组件引用 */
525
- uploadRef?: any;
526
- /**
527
- * 业务场景枚举
528
- * 用于区分不同的上传场景
529
- */
530
- busiScene?: string;
531
- /**
532
- * 权限枚举
533
- * 基于ZlPermissionEnum的权限控制
534
- */
535
- permission?: string;
536
- /** 文件大小限制,单位MB,默认10MB */
537
- fileSize?: number;
538
- /** 接受的文件类型 */
539
- accept?: string;
540
- /** 是否支持多文件上传 */
541
- multiple?: boolean;
542
- }
543
- /**
544
- * 表单项属性接口
545
- * 继承标签属性和上传属性,提供完整的表单项配置
546
- */
547
- interface FormItemProps extends FormItemLabelProps, IUploadProps {
548
- /** 样式前缀 */
549
- prefixCls?: string;
550
- /** 是否无样式模式 */
551
- noStyle?: boolean;
552
- /** 内联样式 */
553
- style?: any;
554
- /** CSS类名 */
555
- className?: string;
556
- /** 子元素 */
557
- children?: any;
558
- /** 元素ID */
559
- id?: string;
560
- /** 是否有反馈效果 */
561
- hasFeedback?: boolean;
562
- /** 验证状态 */
563
- validateStatus?: ValidateStatus;
564
- /** 是否必填 */
565
- required?: boolean;
566
- /** 是否隐藏 */
567
- hidden?: boolean;
568
- /** 初始值 */
569
- initialValue?: any;
570
- /** 消息变量映射 */
571
- messageVariables?: Record<string, string>;
572
- /** 工具提示内容 */
573
- tooltip?: any;
574
- /** 字段键值 */
575
- fieldKey?: (string | number | bigint) | (string | number | bigint)[];
576
- /**
577
- * 级联选择最少选择层级
578
- * 如果不设置,则需要选择到最底层
579
- */
580
- minLevel?: number;
581
- /**
582
- * 点击事件回调
583
- */
584
- onPress?: () => void;
585
- /**
586
- * 可上传的文件数量限制
587
- */
588
- maxNum?: number;
589
- /** 验证规则数组 */
590
- rules?: BaseRule[];
591
- /**
592
- * 值格式化函数
593
- * 用于显示时格式化值
594
- */
595
- format?: (value: any) => string;
596
- /**
597
- * 货币符号
598
- * 用于金额类型字段
599
- */
600
- moneySymbol?: string;
601
- /**
602
- * 选项数组
603
- * 用于选择类型字段
604
- */
605
- options?: IOptions<any>[];
606
- /**
607
- * 点击事件
608
- */
609
- onClick?: () => void;
610
- /**
611
- * 禁用
612
- */
613
- disabled?: boolean;
614
- /**
615
- * 占位
616
- */
617
- placeholder?: string;
618
- }
619
453
  /**
620
454
  * 依赖关系配置接口
621
455
  * 用于配置字段间的依赖逻辑
@@ -643,46 +477,11 @@ interface IDependent {
643
477
  message?: string;
644
478
  }
645
479
  /**
646
- * 验证规则类型枚举
647
- * 定义了支持的数据类型验证
648
- */
649
- type RuleType = "string" | "number" | "boolean" | "method" | "regexp" | "integer" | "float" | "object" | "enum" | "date" | "url" | "hex" | "email";
650
- /**
651
- * 基础验证规则接口
652
- * 定义字段验证的各种规则配置
653
- */
654
- interface BaseRule {
655
- /** 是否仅警告,不阻止提交 */
656
- warningOnly?: boolean;
657
- /** 枚举值数组 */
658
- enum?: any[];
659
- /** 精确长度 */
660
- len?: number;
661
- /** 最大值/长度 */
662
- max?: number;
663
- /** 错误消息 */
664
- message?: string | any;
665
- /** 最小值/长度 */
666
- min?: number;
667
- /** 正则表达式模式 */
668
- pattern?: RegExp;
669
- /** 是否必填 */
670
- required?: boolean;
671
- /** 值转换函数 */
672
- transform?: (value: any) => any;
673
- /** 验证类型 */
674
- type?: RuleType;
675
- /** 是否检查空白字符 */
676
- whitespace?: boolean;
677
- /** 自定义验证触发时机,必须是字段validateTrigger的子集 */
678
- validateTrigger?: string | string[];
679
- }
680
- /**
681
- * ZlForm列配置接口
480
+ * 表单列配置接口
682
481
  * 定义表单列的完整配置选项
683
482
  * @template Entity 实体类型,默认为Record<string, any>
684
483
  */
685
- interface IZlFormColumns<Entity = Record<string, any>> {
484
+ interface IAhFormColumns<Entity = Record<string, any>> {
686
485
  /**
687
486
  * 列的唯一标识符
688
487
  * 一般用于 dataIndex 重复的情况
@@ -723,14 +522,14 @@ interface IZlFormColumns<Entity = Record<string, any>> {
723
522
  usage?: string;
724
523
  };
725
524
  /** 子列配置,用于嵌套表单结构 */
726
- columns?: IZlFormColumns<Entity>[];
525
+ columns?: IAhFormColumns<Entity>[];
727
526
  /** 字段初始值 */
728
527
  initialValue?: any;
729
528
  /**
730
529
  * 请求远程数据的函数
731
530
  * 用于动态获取选项数据
732
531
  */
733
- request?: IZlFormItemProps["request"];
532
+ request?: IAhFormItemProps["request"];
734
533
  /**
735
534
  * 是否禁用字段
736
535
  * @default false
@@ -819,16 +618,16 @@ interface IZlFormColumns<Entity = Record<string, any>> {
819
618
  }
820
619
  /**
821
620
  * 表单列接口
822
- * IZlFormColumns的别名,提供更简洁的命名
621
+ * IAhFormColumns的别名,提供更简洁的命名
823
622
  * @template T 实体类型,默认为any
824
623
  */
825
- interface IFormColumns<T = any> extends IZlFormColumns<T> {
624
+ interface IFormColumns<T = any> extends IAhFormColumns<T> {
826
625
  }
827
626
  /**
828
627
  * 级联选择器属性接口
829
628
  * 继承基础表单项属性,专门用于级联选择组件
830
629
  */
831
- type IZlCascaderProps = IZlFormItemProps<string> & {
630
+ type IAhCascaderProps = IAhFormItemProps<string> & {
832
631
  /**
833
632
  * 选择模式
834
633
  * - multiple: 多选模式
@@ -875,4 +674,4 @@ type IEnumObj = Record<string, IOptions<any> & {
875
674
  text: string;
876
675
  }>;
877
676
 
878
- export type { FieldData, FieldError, FilterFunc, FormFieldType, FormInstance, FormItemLabelProps, FormItemProps, GetFieldsValueConfig, IDependent, IEnumObj, IEnumObjAll, IFormColumns, IJsonRuleItem, IJsonRuleListItem, ISizeType, IUploadProps, IValueType, IZlCascaderProps, IZlFormColumns, IZlFormItemProps, InternalFieldData, InternalNamePath, Meta, NamePath, ProFieldValueType, ProFieldValueTypeWithFieldProps, ProFormInstance, ProFormInstanceType, ProSchemaValueEnumMap, ProSchemaValueEnumObj, ProSchemaValueEnumType, RcFormInstance, RequiredMark, RuleType, TooltipProps, ValidateFields, ValidateOptions, ValidateStatus, WrapperTooltipProps };
677
+ export type { FieldData, FieldError, FilterFunc, FormFieldType, FormInstance, GetFieldsValueConfig, IAhCascaderProps, IAhFormColumns, IAhFormItemProps, IDependent, IEnumObj, IEnumObjAll, IFormColumns, IJsonRuleItem, IJsonRuleListItem, ISizeType, IValueType, InternalFieldData, InternalNamePath, Meta, NamePath, ProFieldValueType, ProFieldValueTypeWithFieldProps, ProFormInstance, ProFormInstanceType, ProSchemaValueEnumMap, ProSchemaValueEnumObj, ProSchemaValueEnumType, RcFormInstance, ValidateFields, ValidateOptions };
@@ -8,20 +8,29 @@ export { default as asyncUtils } from './core/asyncUtils/index.js';
8
8
  export { default as colorUtils } from './core/colorUtils/index.js';
9
9
  export { default as cryptoUtils } from './core/cryptoUtils/index.js';
10
10
  export { ITablePage, defTableData, default as pageUtils } from './core/pageUtils/index.js';
11
+ export { default as diffUtils } from './core/diffUtils/index.js';
12
+ export { default as fileUtils } from './core/fileUtils/index.js';
11
13
  export { default as storageUtils } from './core/storageUtils/index.js';
12
14
  import * as index from './core/constants/index.js';
13
15
  export { index as constants };
14
16
  export { default as domUtils } from './browser/domUtils/index.js';
15
17
  export { default as cookieUtils } from './browser/cookieUtils/index.js';
16
18
  export { default as urlUtils } from './browser/urlUtils/index.js';
17
- export { IZlResponse, default as request } from './request/index.js';
19
+ export { IResponse, default as request } from './request/index.js';
18
20
  export { ExistenceValidationResponse, FamilyValidationResponse, StandardResponse, createTimestampedData, createUpdateData, deepClone, ensureArray, findById, formatDate, formatRelativeTime, handleError, handleSuccess, isDataExists, isValidFamilyMember, safeGetResponseData, validateRequiredFields } from './uniapp/uniUtils/index.js';
19
21
  export { ActionSheetItem, ActionSheetOptions, BatchOperationTips, ModalButton, ModalOptions, Tips, ToastPosition, ToastType, hideLoading, hideToast, showActionSheet, showConfirmDialog, showDeleteConfirm, showErrorToast, showErrorToastDebounced, showErrorToastWithCallback, showInputDialog, showLoading, showLoadingWithAsync, showModal, showNetworkError, showPermissionRequest, showSuccessToast, showSuccessToastDebounced, showSuccessToastWithCallback, showToast, showUpdateDialog, showWarningToast } from './uniapp/Tips/index.js';
20
22
  export { cloudUtils } from './uniapp/cloudUtils/index.js';
21
23
  export { IInitialUmiState, IInitialUmiStateParams, buildLoginPath, getJwtToken, initialUmiState, isLogin, loginOk, toLogin } from './umijs/initialUmiState.js';
22
- export { FieldData, FieldError, FilterFunc, FormFieldType, FormInstance, FormItemLabelProps, FormItemProps, GetFieldsValueConfig, IDependent, IEnumObj, IEnumObjAll, IFormColumns, IJsonRuleItem, IJsonRuleListItem, ISizeType, IUploadProps, IValueType, IZlCascaderProps, IZlFormColumns, IZlFormItemProps, InternalFieldData, InternalNamePath, Meta, NamePath, ProFieldValueType, ProFieldValueTypeWithFieldProps, ProFormInstance, ProFormInstanceType, ProSchemaValueEnumMap, ProSchemaValueEnumObj, ProSchemaValueEnumType, RcFormInstance, RequiredMark, RuleType, TooltipProps, ValidateFields, ValidateOptions, ValidateStatus, WrapperTooltipProps } from './form/types.js';
24
+ export { FieldData, FieldError, FilterFunc, FormFieldType, FormInstance, GetFieldsValueConfig, IAhCascaderProps, IAhFormColumns, IAhFormItemProps, IDependent, IEnumObj, IEnumObjAll, IFormColumns, IJsonRuleItem, IJsonRuleListItem, ISizeType, IValueType, InternalFieldData, InternalNamePath, Meta, NamePath, ProFieldValueType, ProFieldValueTypeWithFieldProps, ProFormInstance, ProFormInstanceType, ProSchemaValueEnumMap, ProSchemaValueEnumObj, ProSchemaValueEnumType, RcFormInstance, ValidateFields, ValidateOptions } from './form/types.js';
25
+ export { IDefSysDefinedAttributes } from './form/attributes.js';
26
+ export { FormItemLabelProps, FormItemProps, IUploadProps, RequiredMark, TooltipProps, ValidateStatus, WrapperTooltipProps } from './form/formItem.js';
27
+ export { BaseRule, RuleType } from './form/rule.js';
23
28
  export { IBaseFilter, IOptions, IOptions2, IOptions61, ITreeNode, IValidityNum, IWaterInfo, IWaterLives, defBaseFilter } from './types/data/index.js';
29
+ export { ISysDisFilter, ISysDistrict } from './types/dbData/index.js';
30
+ export { default as ReqQueue } from './request/ReqQueue/index.js';
31
+ export { default as uniRequest } from './request/uniRequest/index.js';
24
32
  export { ICacheData, ICallBack, IRequestOption } from './request/typings/index.js';
33
+ export { codeMessage, defOption } from './request/httpCode/index.js';
25
34
 
26
35
  declare const version = "1.0.0";
27
36
 
package/dist/esm/index.js CHANGED
@@ -8,6 +8,8 @@ export { default as asyncUtils } from './core/asyncUtils/index.js';
8
8
  export { default as colorUtils } from './core/colorUtils/index.js';
9
9
  export { default as cryptoUtils } from './core/cryptoUtils/index.js';
10
10
  export { defTableData, default as pageUtils } from './core/pageUtils/index.js';
11
+ export { default as diffUtils } from './core/diffUtils/index.js';
12
+ export { default as fileUtils } from './core/fileUtils/index.js';
11
13
  export { default as storageUtils } from './core/storageUtils/index.js';
12
14
  import * as index from './core/constants/index.js';
13
15
  export { index as constants };
@@ -20,6 +22,9 @@ export { BatchOperationTips, Tips, ToastPosition, ToastType, hideLoading, hideTo
20
22
  export { cloudUtils } from './uniapp/cloudUtils/index.js';
21
23
  export { buildLoginPath, getJwtToken, initialUmiState, isLogin, loginOk, toLogin } from './umijs/initialUmiState.js';
22
24
  export { defBaseFilter } from './types/data/index.js';
25
+ export { default as ReqQueue } from './request/ReqQueue/index.js';
26
+ export { default as uniRequest } from './request/uniRequest/index.js';
27
+ export { codeMessage, defOption } from './request/httpCode/index.js';
23
28
 
24
29
  // 主入口文件 - 导出所有工具函数
25
30
  // 核心工具函数(适用于 Node.js、UniApp、React Native 等)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAEA;AAoCA;AACO,MAAM,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAEA;AAsCA;AACO,MAAM,OAAO,GAAG;;;;"}
@@ -0,0 +1,20 @@
1
+ import Diff from './base.js';
2
+
3
+ class ArrayDiff extends Diff {
4
+ tokenize(value) {
5
+ return value.slice();
6
+ }
7
+ join(value) {
8
+ return value;
9
+ }
10
+ removeEmpty(value) {
11
+ return value;
12
+ }
13
+ }
14
+ const arrayDiff = new ArrayDiff();
15
+ function diffArrays(oldArr, newArr, options) {
16
+ return arrayDiff.diff(oldArr, newArr, options);
17
+ }
18
+
19
+ export { arrayDiff, diffArrays };
20
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sources":["../../../../../../../../../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js"],"sourcesContent":["import Diff from './base.js';\nclass ArrayDiff extends Diff {\n tokenize(value) {\n return value.slice();\n }\n join(value) {\n return value;\n }\n removeEmpty(value) {\n return value;\n }\n}\nexport const arrayDiff = new ArrayDiff();\nexport function diffArrays(oldArr, newArr, options) {\n return arrayDiff.diff(oldArr, newArr, options);\n}\n"],"names":[],"mappings":";;AACA,MAAM,SAAS,SAAS,IAAI,CAAC;AAC7B,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,OAAO,KAAK,CAAC,KAAK,EAAE;AAC5B,IAAI;AACJ,IAAI,IAAI,CAAC,KAAK,EAAE;AAChB,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ;AACY,MAAC,SAAS,GAAG,IAAI,SAAS;AAC/B,SAAS,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;AACpD,IAAI,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AAClD;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,256 @@
1
+ class Diff {
2
+ diff(oldStr, newStr,
3
+ // Type below is not accurate/complete - see above for full possibilities - but it compiles
4
+ options = {}) {
5
+ let callback;
6
+ if (typeof options === 'function') {
7
+ callback = options;
8
+ options = {};
9
+ }
10
+ else if ('callback' in options) {
11
+ callback = options.callback;
12
+ }
13
+ // Allow subclasses to massage the input prior to running
14
+ const oldString = this.castInput(oldStr, options);
15
+ const newString = this.castInput(newStr, options);
16
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
17
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
18
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
19
+ }
20
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
21
+ var _a;
22
+ const done = (value) => {
23
+ value = this.postProcess(value, options);
24
+ if (callback) {
25
+ setTimeout(function () { callback(value); }, 0);
26
+ return undefined;
27
+ }
28
+ else {
29
+ return value;
30
+ }
31
+ };
32
+ const newLen = newTokens.length, oldLen = oldTokens.length;
33
+ let editLength = 1;
34
+ let maxEditLength = newLen + oldLen;
35
+ if (options.maxEditLength != null) {
36
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
37
+ }
38
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
39
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
40
+ const bestPath = [{ oldPos: -1, lastComponent: undefined }];
41
+ // Seed editLength = 0, i.e. the content starts with the same values
42
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
43
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
44
+ // Identity per the equality and tokenizer
45
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
46
+ }
47
+ // Once we hit the right edge of the edit graph on some diagonal k, we can
48
+ // definitely reach the end of the edit graph in no more than k edits, so
49
+ // there's no point in considering any moves to diagonal k+1 any more (from
50
+ // which we're guaranteed to need at least k+1 more edits).
51
+ // Similarly, once we've reached the bottom of the edit graph, there's no
52
+ // point considering moves to lower diagonals.
53
+ // We record this fact by setting minDiagonalToConsider and
54
+ // maxDiagonalToConsider to some finite value once we've hit the edge of
55
+ // the edit graph.
56
+ // This optimization is not faithful to the original algorithm presented in
57
+ // Myers's paper, which instead pointlessly extends D-paths off the end of
58
+ // the edit graph - see page 7 of Myers's paper which notes this point
59
+ // explicitly and illustrates it with a diagram. This has major performance
60
+ // implications for some common scenarios. For instance, to compute a diff
61
+ // where the new text simply appends d characters on the end of the
62
+ // original text of length n, the true Myers algorithm will take O(n+d^2)
63
+ // time while this optimization needs only O(n+d) time.
64
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
65
+ // Main worker method. checks all permutations of a given edit length for acceptance.
66
+ const execEditLength = () => {
67
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
68
+ let basePath;
69
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
70
+ if (removePath) {
71
+ // No one else is going to attempt to use this value, clear it
72
+ // @ts-expect-error - perf optimisation. This type-violating value will never be read.
73
+ bestPath[diagonalPath - 1] = undefined;
74
+ }
75
+ let canAdd = false;
76
+ if (addPath) {
77
+ // what newPos will be after we do an insertion:
78
+ const addPathNewPos = addPath.oldPos - diagonalPath;
79
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
80
+ }
81
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
82
+ if (!canAdd && !canRemove) {
83
+ // If this path is a terminal then prune
84
+ // @ts-expect-error - perf optimisation. This type-violating value will never be read.
85
+ bestPath[diagonalPath] = undefined;
86
+ continue;
87
+ }
88
+ // Select the diagonal that we want to branch from. We select the prior
89
+ // path whose position in the old string is the farthest from the origin
90
+ // and does not pass the bounds of the diff graph
91
+ if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
92
+ basePath = this.addToPath(addPath, true, false, 0, options);
93
+ }
94
+ else {
95
+ basePath = this.addToPath(removePath, false, true, 1, options);
96
+ }
97
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
98
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
99
+ // If we have hit the end of both strings, then we are done
100
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
101
+ }
102
+ else {
103
+ bestPath[diagonalPath] = basePath;
104
+ if (basePath.oldPos + 1 >= oldLen) {
105
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
106
+ }
107
+ if (newPos + 1 >= newLen) {
108
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
109
+ }
110
+ }
111
+ }
112
+ editLength++;
113
+ };
114
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
115
+ // sync and async mode which is never fun. Loops over execEditLength until a value
116
+ // is produced, or until the edit length exceeds options.maxEditLength (if given),
117
+ // in which case it will return undefined.
118
+ if (callback) {
119
+ (function exec() {
120
+ setTimeout(function () {
121
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
122
+ return callback(undefined);
123
+ }
124
+ if (!execEditLength()) {
125
+ exec();
126
+ }
127
+ }, 0);
128
+ }());
129
+ }
130
+ else {
131
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
132
+ const ret = execEditLength();
133
+ if (ret) {
134
+ return ret;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ addToPath(path, added, removed, oldPosInc, options) {
140
+ const last = path.lastComponent;
141
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
142
+ return {
143
+ oldPos: path.oldPos + oldPosInc,
144
+ lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }
145
+ };
146
+ }
147
+ else {
148
+ return {
149
+ oldPos: path.oldPos + oldPosInc,
150
+ lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
151
+ };
152
+ }
153
+ }
154
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
155
+ const newLen = newTokens.length, oldLen = oldTokens.length;
156
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
157
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
158
+ newPos++;
159
+ oldPos++;
160
+ commonCount++;
161
+ if (options.oneChangePerToken) {
162
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
163
+ }
164
+ }
165
+ if (commonCount && !options.oneChangePerToken) {
166
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
167
+ }
168
+ basePath.oldPos = oldPos;
169
+ return newPos;
170
+ }
171
+ equals(left, right, options) {
172
+ if (options.comparator) {
173
+ return options.comparator(left, right);
174
+ }
175
+ else {
176
+ return left === right
177
+ || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
178
+ }
179
+ }
180
+ removeEmpty(array) {
181
+ const ret = [];
182
+ for (let i = 0; i < array.length; i++) {
183
+ if (array[i]) {
184
+ ret.push(array[i]);
185
+ }
186
+ }
187
+ return ret;
188
+ }
189
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
190
+ castInput(value, options) {
191
+ return value;
192
+ }
193
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
194
+ tokenize(value, options) {
195
+ return Array.from(value);
196
+ }
197
+ join(chars) {
198
+ // Assumes ValueT is string, which is the case for most subclasses.
199
+ // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
200
+ // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
201
+ // assume tokens and values are strings, but not completely - is weird and janky.
202
+ return chars.join('');
203
+ }
204
+ postProcess(changeObjects,
205
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
206
+ options) {
207
+ return changeObjects;
208
+ }
209
+ get useLongestToken() {
210
+ return false;
211
+ }
212
+ buildValues(lastComponent, newTokens, oldTokens) {
213
+ // First we convert our linked list of components in reverse order to an
214
+ // array in the right order:
215
+ const components = [];
216
+ let nextComponent;
217
+ while (lastComponent) {
218
+ components.push(lastComponent);
219
+ nextComponent = lastComponent.previousComponent;
220
+ delete lastComponent.previousComponent;
221
+ lastComponent = nextComponent;
222
+ }
223
+ components.reverse();
224
+ const componentLen = components.length;
225
+ let componentPos = 0, newPos = 0, oldPos = 0;
226
+ for (; componentPos < componentLen; componentPos++) {
227
+ const component = components[componentPos];
228
+ if (!component.removed) {
229
+ if (!component.added && this.useLongestToken) {
230
+ let value = newTokens.slice(newPos, newPos + component.count);
231
+ value = value.map(function (value, i) {
232
+ const oldValue = oldTokens[oldPos + i];
233
+ return oldValue.length > value.length ? oldValue : value;
234
+ });
235
+ component.value = this.join(value);
236
+ }
237
+ else {
238
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
239
+ }
240
+ newPos += component.count;
241
+ // Common case
242
+ if (!component.added) {
243
+ oldPos += component.count;
244
+ }
245
+ }
246
+ else {
247
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
248
+ oldPos += component.count;
249
+ }
250
+ }
251
+ return components;
252
+ }
253
+ }
254
+
255
+ export { Diff as default };
256
+ //# sourceMappingURL=base.js.map