@nokecy/qc-ui 1.0.65 → 1.0.67

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 (197) hide show
  1. package/dist/cjs/RuleBuilder/LogicSelector.d.ts +23 -0
  2. package/dist/cjs/RuleBuilder/LogicSelector.js +54 -0
  3. package/dist/cjs/RuleBuilder/RuleBuilderContainer.d.ts +20 -0
  4. package/dist/cjs/RuleBuilder/RuleBuilderContainer.js +209 -0
  5. package/dist/cjs/RuleBuilder/RuleCard.d.ts +20 -0
  6. package/dist/cjs/RuleBuilder/RuleCard.js +196 -0
  7. package/dist/cjs/RuleBuilder/RuleGroupEditor.d.ts +25 -0
  8. package/dist/cjs/RuleBuilder/RuleGroupEditor.js +191 -0
  9. package/dist/cjs/RuleBuilder/constants/operators.d.ts +47 -0
  10. package/dist/cjs/RuleBuilder/constants/operators.js +172 -0
  11. package/dist/cjs/RuleBuilder/context/RuleBuilderContext.d.ts +72 -0
  12. package/dist/cjs/RuleBuilder/context/RuleBuilderContext.js +286 -0
  13. package/dist/cjs/RuleBuilder/index.d.ts +25 -0
  14. package/dist/cjs/RuleBuilder/index.js +308 -0
  15. package/dist/cjs/RuleBuilder/inputs/BetweenValueInput.d.ts +23 -0
  16. package/dist/cjs/RuleBuilder/inputs/BetweenValueInput.js +80 -0
  17. package/dist/cjs/RuleBuilder/inputs/MultiValueInput.d.ts +21 -0
  18. package/dist/cjs/RuleBuilder/inputs/MultiValueInput.js +128 -0
  19. package/dist/cjs/RuleBuilder/inputs/SingleValueInput.d.ts +25 -0
  20. package/dist/cjs/RuleBuilder/inputs/SingleValueInput.js +81 -0
  21. package/dist/cjs/RuleBuilder/inputs/ValueInput.d.ts +29 -0
  22. package/dist/cjs/RuleBuilder/inputs/ValueInput.js +80 -0
  23. package/dist/cjs/RuleBuilder/selectors/FieldSelector.d.ts +22 -0
  24. package/dist/cjs/RuleBuilder/selectors/FieldSelector.js +45 -0
  25. package/dist/cjs/RuleBuilder/selectors/OperatorSelector.d.ts +22 -0
  26. package/dist/cjs/RuleBuilder/selectors/OperatorSelector.js +51 -0
  27. package/dist/cjs/RuleBuilder/styles/index.module.less +443 -0
  28. package/dist/cjs/RuleBuilder/styles/index.module.less.d.ts +43 -0
  29. package/dist/cjs/RuleBuilder/types/index.d.ts +232 -0
  30. package/dist/cjs/RuleBuilder/types/index.js +83 -0
  31. package/dist/cjs/RuleBuilder/utils/pathHelpers.d.ts +65 -0
  32. package/dist/cjs/RuleBuilder/utils/pathHelpers.js +241 -0
  33. package/dist/cjs/RuleBuilder/utils/ruleHelpers.d.ts +47 -0
  34. package/dist/cjs/RuleBuilder/utils/ruleHelpers.js +154 -0
  35. package/dist/cjs/RuleBuilder/utils/validation.d.ts +25 -0
  36. package/dist/cjs/RuleBuilder/utils/validation.js +241 -0
  37. package/dist/cjs/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  38. package/dist/cjs/components/RegexEditor/core/RegexEditor.js +223 -0
  39. package/dist/cjs/components/RegexEditor/core/RegexEditor.less +119 -0
  40. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  41. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.js +158 -0
  42. package/dist/cjs/components/RegexEditor/core/types.d.ts +79 -0
  43. package/dist/cjs/components/RegexEditor/core/types.js +5 -0
  44. package/dist/cjs/components/RegexEditor/hooks/index.d.ts +9 -0
  45. package/dist/cjs/components/RegexEditor/hooks/index.js +19 -0
  46. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  47. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.js +234 -0
  48. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  49. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +215 -0
  50. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  51. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +438 -0
  52. package/dist/cjs/components/RegexEditor/index.d.ts +16 -0
  53. package/dist/cjs/components/RegexEditor/index.js +232 -0
  54. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  55. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.js +322 -0
  56. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  57. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.js +340 -0
  58. package/dist/cjs/components/RegexEditor/templates/index.d.ts +10 -0
  59. package/dist/cjs/components/RegexEditor/templates/index.js +184 -0
  60. package/dist/cjs/components/RegexEditor/templates/storage.d.ts +74 -0
  61. package/dist/cjs/components/RegexEditor/templates/storage.js +337 -0
  62. package/dist/cjs/components/RegexEditor/templates/templateManager.d.ts +67 -0
  63. package/dist/cjs/components/RegexEditor/templates/templateManager.js +277 -0
  64. package/dist/cjs/components/RegexEditor/templates/types.d.ts +111 -0
  65. package/dist/cjs/components/RegexEditor/templates/types.js +94 -0
  66. package/dist/cjs/components/RegexEditor/testing/types.d.ts +55 -0
  67. package/dist/cjs/components/RegexEditor/testing/types.js +5 -0
  68. package/dist/cjs/components/RegexEditor/validation/complexity.d.ts +22 -0
  69. package/dist/cjs/components/RegexEditor/validation/complexity.js +196 -0
  70. package/dist/cjs/components/RegexEditor/validation/parser.d.ts +53 -0
  71. package/dist/cjs/components/RegexEditor/validation/parser.js +129 -0
  72. package/dist/cjs/components/RegexEditor/validation/types.d.ts +146 -0
  73. package/dist/cjs/components/RegexEditor/validation/types.js +5 -0
  74. package/dist/cjs/components/RegexEditor/validation/validator.d.ts +60 -0
  75. package/dist/cjs/components/RegexEditor/validation/validator.js +218 -0
  76. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  77. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.js +98 -0
  78. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  79. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.js +201 -0
  80. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  81. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.js +192 -0
  82. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  83. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.js +255 -0
  84. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +19 -0
  85. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.js +155 -0
  86. package/dist/cjs/components/RegexEditor/visualizer/index.d.ts +12 -0
  87. package/dist/cjs/components/RegexEditor/visualizer/index.js +76 -0
  88. package/dist/cjs/components/RegexEditor/visualizer/types.d.ts +131 -0
  89. package/dist/cjs/components/RegexEditor/visualizer/types.js +5 -0
  90. package/dist/cjs/components/RegexEditor/visualizer/utils.d.ts +106 -0
  91. package/dist/cjs/components/RegexEditor/visualizer/utils.js +268 -0
  92. package/dist/cjs/index.d.ts +5 -1
  93. package/dist/cjs/index.js +62 -0
  94. package/dist/cjs/standardFormDialog/StandardFormDialog.js +26 -5
  95. package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
  96. package/dist/cjs/standardFormDialog/withStandardForm.d.ts +2 -2
  97. package/dist/cjs/types/railroad-diagrams.d.ts +59 -0
  98. package/dist/cjs/types/regexp-tree.d.ts +175 -0
  99. package/dist/esm/RuleBuilder/LogicSelector.d.ts +23 -0
  100. package/dist/esm/RuleBuilder/LogicSelector.js +47 -0
  101. package/dist/esm/RuleBuilder/RuleBuilderContainer.d.ts +20 -0
  102. package/dist/esm/RuleBuilder/RuleBuilderContainer.js +203 -0
  103. package/dist/esm/RuleBuilder/RuleCard.d.ts +20 -0
  104. package/dist/esm/RuleBuilder/RuleCard.js +191 -0
  105. package/dist/esm/RuleBuilder/RuleGroupEditor.d.ts +25 -0
  106. package/dist/esm/RuleBuilder/RuleGroupEditor.js +184 -0
  107. package/dist/esm/RuleBuilder/constants/operators.d.ts +47 -0
  108. package/dist/esm/RuleBuilder/constants/operators.js +169 -0
  109. package/dist/esm/RuleBuilder/context/RuleBuilderContext.d.ts +72 -0
  110. package/dist/esm/RuleBuilder/context/RuleBuilderContext.js +271 -0
  111. package/dist/esm/RuleBuilder/index.d.ts +25 -0
  112. package/dist/esm/RuleBuilder/index.js +42 -0
  113. package/dist/esm/RuleBuilder/inputs/BetweenValueInput.d.ts +23 -0
  114. package/dist/esm/RuleBuilder/inputs/BetweenValueInput.js +73 -0
  115. package/dist/esm/RuleBuilder/inputs/MultiValueInput.d.ts +21 -0
  116. package/dist/esm/RuleBuilder/inputs/MultiValueInput.js +121 -0
  117. package/dist/esm/RuleBuilder/inputs/SingleValueInput.d.ts +25 -0
  118. package/dist/esm/RuleBuilder/inputs/SingleValueInput.js +74 -0
  119. package/dist/esm/RuleBuilder/inputs/ValueInput.d.ts +29 -0
  120. package/dist/esm/RuleBuilder/inputs/ValueInput.js +73 -0
  121. package/dist/esm/RuleBuilder/selectors/FieldSelector.d.ts +22 -0
  122. package/dist/esm/RuleBuilder/selectors/FieldSelector.js +38 -0
  123. package/dist/esm/RuleBuilder/selectors/OperatorSelector.d.ts +22 -0
  124. package/dist/esm/RuleBuilder/selectors/OperatorSelector.js +44 -0
  125. package/dist/esm/RuleBuilder/styles/index.module.less +443 -0
  126. package/dist/esm/RuleBuilder/styles/index.module.less.d.ts +43 -0
  127. package/dist/esm/RuleBuilder/types/index.d.ts +232 -0
  128. package/dist/esm/RuleBuilder/types/index.js +91 -0
  129. package/dist/esm/RuleBuilder/utils/pathHelpers.d.ts +65 -0
  130. package/dist/esm/RuleBuilder/utils/pathHelpers.js +228 -0
  131. package/dist/esm/RuleBuilder/utils/ruleHelpers.d.ts +47 -0
  132. package/dist/esm/RuleBuilder/utils/ruleHelpers.js +145 -0
  133. package/dist/esm/RuleBuilder/utils/validation.d.ts +25 -0
  134. package/dist/esm/RuleBuilder/utils/validation.js +236 -0
  135. package/dist/esm/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  136. package/dist/esm/components/RegexEditor/core/RegexEditor.js +214 -0
  137. package/dist/esm/components/RegexEditor/core/RegexEditor.less +119 -0
  138. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  139. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.js +154 -0
  140. package/dist/esm/components/RegexEditor/core/types.d.ts +79 -0
  141. package/dist/esm/components/RegexEditor/core/types.js +1 -0
  142. package/dist/esm/components/RegexEditor/hooks/index.d.ts +9 -0
  143. package/dist/esm/components/RegexEditor/hooks/index.js +8 -0
  144. package/dist/esm/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  145. package/dist/esm/components/RegexEditor/hooks/useRegexTester.js +230 -0
  146. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  147. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +211 -0
  148. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  149. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +430 -0
  150. package/dist/esm/components/RegexEditor/index.d.ts +16 -0
  151. package/dist/esm/components/RegexEditor/index.js +27 -0
  152. package/dist/esm/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  153. package/dist/esm/components/RegexEditor/templates/TemplateSelector.js +316 -0
  154. package/dist/esm/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  155. package/dist/esm/components/RegexEditor/templates/builtinTemplates.js +335 -0
  156. package/dist/esm/components/RegexEditor/templates/index.d.ts +10 -0
  157. package/dist/esm/components/RegexEditor/templates/index.js +19 -0
  158. package/dist/esm/components/RegexEditor/templates/storage.d.ts +74 -0
  159. package/dist/esm/components/RegexEditor/templates/storage.js +335 -0
  160. package/dist/esm/components/RegexEditor/templates/templateManager.d.ts +67 -0
  161. package/dist/esm/components/RegexEditor/templates/templateManager.js +274 -0
  162. package/dist/esm/components/RegexEditor/templates/types.d.ts +111 -0
  163. package/dist/esm/components/RegexEditor/templates/types.js +90 -0
  164. package/dist/esm/components/RegexEditor/testing/types.d.ts +55 -0
  165. package/dist/esm/components/RegexEditor/testing/types.js +1 -0
  166. package/dist/esm/components/RegexEditor/validation/complexity.d.ts +22 -0
  167. package/dist/esm/components/RegexEditor/validation/complexity.js +190 -0
  168. package/dist/esm/components/RegexEditor/validation/parser.d.ts +53 -0
  169. package/dist/esm/components/RegexEditor/validation/parser.js +123 -0
  170. package/dist/esm/components/RegexEditor/validation/types.d.ts +145 -0
  171. package/dist/esm/components/RegexEditor/validation/types.js +1 -0
  172. package/dist/esm/components/RegexEditor/validation/validator.d.ts +60 -0
  173. package/dist/esm/components/RegexEditor/validation/validator.js +213 -0
  174. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  175. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.js +93 -0
  176. package/dist/esm/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  177. package/dist/esm/components/RegexEditor/visualizer/MatchItem.js +194 -0
  178. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  179. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.js +186 -0
  180. package/dist/esm/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  181. package/dist/esm/components/RegexEditor/visualizer/RegexTester.js +248 -0
  182. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +18 -0
  183. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.js +150 -0
  184. package/dist/esm/components/RegexEditor/visualizer/index.d.ts +12 -0
  185. package/dist/esm/components/RegexEditor/visualizer/index.js +17 -0
  186. package/dist/esm/components/RegexEditor/visualizer/types.d.ts +131 -0
  187. package/dist/esm/components/RegexEditor/visualizer/types.js +1 -0
  188. package/dist/esm/components/RegexEditor/visualizer/utils.d.ts +106 -0
  189. package/dist/esm/components/RegexEditor/visualizer/utils.js +256 -0
  190. package/dist/esm/index.d.ts +5 -1
  191. package/dist/esm/index.js +6 -2
  192. package/dist/esm/standardFormDialog/StandardFormDialog.js +26 -5
  193. package/dist/esm/types/railroad-diagrams.d.ts +59 -0
  194. package/dist/esm/types/regexp-tree.d.ts +175 -0
  195. package/dist/umd/qc-ui.min.css +1 -1
  196. package/dist/umd/qc-ui.min.js +1 -1
  197. package/package.json +23 -7
@@ -0,0 +1,111 @@
1
+ /**
2
+ * 正则表达式模板系统 - 类型定义
3
+ *
4
+ * @module RegexEditor/templates/types
5
+ * @description 定义正则表达式模板库相关的核心类型
6
+ */
7
+ /**
8
+ * 正则表达式模板
9
+ *
10
+ * @interface RegexTemplate
11
+ * @property {string} id - 模板唯一标识符
12
+ * @property {string} name - 模板名称(显示用)
13
+ * @property {string} pattern - 正则表达式字符串
14
+ * @property {string} description - 模板详细描述
15
+ * @property {TemplateCategory} category - 模板分类
16
+ * @property {string[]} tags - 标签列表(用于搜索和过滤)
17
+ * @property {Object} examples - 匹配示例
18
+ * @property {string[]} examples.valid - 有效匹配示例
19
+ * @property {string[]} examples.invalid - 无效匹配示例
20
+ * @property {'simple' | 'medium' | 'complex'} complexity - 复杂度等级
21
+ * @property {number} [useCount] - 使用次数(用于热门排序)
22
+ * @property {Date} [lastUsed] - 最后使用时间
23
+ * @property {boolean} [isCustom] - 是否为用户自定义模板
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const lotNumberTemplate: RegexTemplate = {
28
+ * id: 'lot-number',
29
+ * name: '批次号',
30
+ * pattern: '^LOT\\d{6}$',
31
+ * description: '标准批次号格式:LOT + 6位数字',
32
+ * category: TemplateCategory.BUSINESS,
33
+ * tags: ['批次', 'LOT', '业务'],
34
+ * examples: {
35
+ * valid: ['LOT123456', 'LOT000001'],
36
+ * invalid: ['LOT12345', 'lot123456', 'LOT1234567']
37
+ * },
38
+ * complexity: 'simple',
39
+ * useCount: 42,
40
+ * lastUsed: new Date('2025-01-27'),
41
+ * isCustom: false
42
+ * };
43
+ * ```
44
+ */
45
+ export interface RegexTemplate {
46
+ id: string;
47
+ name: string;
48
+ pattern: string;
49
+ description: string;
50
+ category: TemplateCategory;
51
+ tags: string[];
52
+ examples: {
53
+ valid: string[];
54
+ invalid: string[];
55
+ };
56
+ complexity: 'simple' | 'medium' | 'complex';
57
+ useCount?: number;
58
+ lastUsed?: Date;
59
+ isCustom?: boolean;
60
+ }
61
+ /**
62
+ * 模板分类枚举
63
+ *
64
+ * @enum TemplateCategory
65
+ * @property {string} BUSINESS - 业务相关(批次号、订单号等)
66
+ * @property {string} COMMON - 通用模式(邮箱、电话等)
67
+ * @property {string} DATE_TIME - 日期时间格式
68
+ * @property {string} NUMBER - 数字格式(整数、小数、科学计数法等)
69
+ * @property {string} TEXT - 文本格式(中文、英文、特殊字符等)
70
+ * @property {string} VALIDATION - 数据验证(长度、范围等)
71
+ * @property {string} EXTRACTION - 数据提取(提取特定部分)
72
+ * @property {string} CUSTOM - 用户自定义
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // 按分类过滤模板
77
+ * const businessTemplates = allTemplates.filter(
78
+ * t => t.category === TemplateCategory.BUSINESS
79
+ * );
80
+ *
81
+ * // 获取分类显示名称
82
+ * const categoryNames = {
83
+ * [TemplateCategory.BUSINESS]: '业务模板',
84
+ * [TemplateCategory.COMMON]: '通用模板',
85
+ * [TemplateCategory.DATE_TIME]: '日期时间',
86
+ * [TemplateCategory.NUMBER]: '数字格式',
87
+ * [TemplateCategory.TEXT]: '文本格式',
88
+ * [TemplateCategory.VALIDATION]: '数据验证',
89
+ * [TemplateCategory.EXTRACTION]: '数据提取',
90
+ * [TemplateCategory.CUSTOM]: '自定义'
91
+ * };
92
+ * ```
93
+ */
94
+ export declare enum TemplateCategory {
95
+ /** 业务相关模板 */
96
+ BUSINESS = "business",
97
+ /** 通用模式模板 */
98
+ COMMON = "common",
99
+ /** 日期时间格式 */
100
+ DATE_TIME = "datetime",
101
+ /** 数字格式 */
102
+ NUMBER = "number",
103
+ /** 文本格式 */
104
+ TEXT = "text",
105
+ /** 数据验证 */
106
+ VALIDATION = "validation",
107
+ /** 数据提取 */
108
+ EXTRACTION = "extraction",
109
+ /** 用户自定义 */
110
+ CUSTOM = "custom"
111
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TemplateCategory = void 0;
7
+ /**
8
+ * 正则表达式模板系统 - 类型定义
9
+ *
10
+ * @module RegexEditor/templates/types
11
+ * @description 定义正则表达式模板库相关的核心类型
12
+ */
13
+ /**
14
+ * 正则表达式模板
15
+ *
16
+ * @interface RegexTemplate
17
+ * @property {string} id - 模板唯一标识符
18
+ * @property {string} name - 模板名称(显示用)
19
+ * @property {string} pattern - 正则表达式字符串
20
+ * @property {string} description - 模板详细描述
21
+ * @property {TemplateCategory} category - 模板分类
22
+ * @property {string[]} tags - 标签列表(用于搜索和过滤)
23
+ * @property {Object} examples - 匹配示例
24
+ * @property {string[]} examples.valid - 有效匹配示例
25
+ * @property {string[]} examples.invalid - 无效匹配示例
26
+ * @property {'simple' | 'medium' | 'complex'} complexity - 复杂度等级
27
+ * @property {number} [useCount] - 使用次数(用于热门排序)
28
+ * @property {Date} [lastUsed] - 最后使用时间
29
+ * @property {boolean} [isCustom] - 是否为用户自定义模板
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const lotNumberTemplate: RegexTemplate = {
34
+ * id: 'lot-number',
35
+ * name: '批次号',
36
+ * pattern: '^LOT\\d{6}$',
37
+ * description: '标准批次号格式:LOT + 6位数字',
38
+ * category: TemplateCategory.BUSINESS,
39
+ * tags: ['批次', 'LOT', '业务'],
40
+ * examples: {
41
+ * valid: ['LOT123456', 'LOT000001'],
42
+ * invalid: ['LOT12345', 'lot123456', 'LOT1234567']
43
+ * },
44
+ * complexity: 'simple',
45
+ * useCount: 42,
46
+ * lastUsed: new Date('2025-01-27'),
47
+ * isCustom: false
48
+ * };
49
+ * ```
50
+ */
51
+ /**
52
+ * 模板分类枚举
53
+ *
54
+ * @enum TemplateCategory
55
+ * @property {string} BUSINESS - 业务相关(批次号、订单号等)
56
+ * @property {string} COMMON - 通用模式(邮箱、电话等)
57
+ * @property {string} DATE_TIME - 日期时间格式
58
+ * @property {string} NUMBER - 数字格式(整数、小数、科学计数法等)
59
+ * @property {string} TEXT - 文本格式(中文、英文、特殊字符等)
60
+ * @property {string} VALIDATION - 数据验证(长度、范围等)
61
+ * @property {string} EXTRACTION - 数据提取(提取特定部分)
62
+ * @property {string} CUSTOM - 用户自定义
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // 按分类过滤模板
67
+ * const businessTemplates = allTemplates.filter(
68
+ * t => t.category === TemplateCategory.BUSINESS
69
+ * );
70
+ *
71
+ * // 获取分类显示名称
72
+ * const categoryNames = {
73
+ * [TemplateCategory.BUSINESS]: '业务模板',
74
+ * [TemplateCategory.COMMON]: '通用模板',
75
+ * [TemplateCategory.DATE_TIME]: '日期时间',
76
+ * [TemplateCategory.NUMBER]: '数字格式',
77
+ * [TemplateCategory.TEXT]: '文本格式',
78
+ * [TemplateCategory.VALIDATION]: '数据验证',
79
+ * [TemplateCategory.EXTRACTION]: '数据提取',
80
+ * [TemplateCategory.CUSTOM]: '自定义'
81
+ * };
82
+ * ```
83
+ */
84
+ var TemplateCategory = exports.TemplateCategory = /*#__PURE__*/function (TemplateCategory) {
85
+ TemplateCategory["BUSINESS"] = "business";
86
+ TemplateCategory["COMMON"] = "common";
87
+ TemplateCategory["DATE_TIME"] = "datetime";
88
+ TemplateCategory["NUMBER"] = "number";
89
+ TemplateCategory["TEXT"] = "text";
90
+ TemplateCategory["VALIDATION"] = "validation";
91
+ TemplateCategory["EXTRACTION"] = "extraction";
92
+ TemplateCategory["CUSTOM"] = "custom";
93
+ return TemplateCategory;
94
+ }({});
@@ -0,0 +1,55 @@
1
+ /**
2
+ * 正则表达式测试工具 - 类型定义
3
+ *
4
+ * @module RegexEditor/testing/types
5
+ * @description 定义正则表达式测试功能相关的核心类型
6
+ */
7
+ /**
8
+ * 正则表达式测试结果
9
+ *
10
+ * @interface TestResult
11
+ * @property {string} input - 测试输入字符串
12
+ * @property {string[] | null} matches - 匹配结果数组(未匹配时为 null)
13
+ * @property {boolean} isMatch - 是否匹配成功
14
+ * @property {number} [executionTime] - 执行耗时(毫秒)
15
+ * @property {string} [error] - 执行错误信息(如果有)
16
+ * @property {Record<string, string>} [groups] - 命名捕获组结果
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // 成功匹配的结果
21
+ * const successResult: TestResult = {
22
+ * input: 'LOT123456',
23
+ * matches: ['LOT123456', '123456'],
24
+ * isMatch: true,
25
+ * executionTime: 0.42,
26
+ * groups: {
27
+ * number: '123456'
28
+ * }
29
+ * };
30
+ *
31
+ * // 未匹配的结果
32
+ * const failureResult: TestResult = {
33
+ * input: 'LOT12345',
34
+ * matches: null,
35
+ * isMatch: false,
36
+ * executionTime: 0.15
37
+ * };
38
+ *
39
+ * // 执行错误的结果
40
+ * const errorResult: TestResult = {
41
+ * input: 'test',
42
+ * matches: null,
43
+ * isMatch: false,
44
+ * error: 'Invalid regular expression'
45
+ * };
46
+ * ```
47
+ */
48
+ export interface TestResult {
49
+ input: string;
50
+ matches: string[] | null;
51
+ isMatch: boolean;
52
+ executionTime?: number;
53
+ error?: string;
54
+ groups?: Record<string, string>;
55
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 正则表达式复杂度分析器
3
+ *
4
+ * @module RegexEditor/validation/complexity
5
+ * @description 分析正则表达式的复杂度,评估性能风险并提供优化建议
6
+ *
7
+ * @remarks
8
+ * 该模块通过遍历 AST 来统计以下复杂度指标:
9
+ * - 节点总数
10
+ * - 最大嵌套深度
11
+ * - 分支数量(alternation)
12
+ * - 量词数量(quantifier)
13
+ * - 捕获组数量
14
+ * - 字符类数量
15
+ *
16
+ * 基于这些指标计算:
17
+ * - 回溯风险等级(low/medium/high)
18
+ * - 性能评分(0-100分)
19
+ * - 优化建议列表
20
+ */
21
+ import type { ASTNode, ComplexityMetrics } from './types';
22
+ export declare const analyzeComplexity: (ast: ASTNode) => ComplexityMetrics;
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.analyzeComplexity = void 0;
7
+ var _parser = require("./parser");
8
+ /**
9
+ * 正则表达式复杂度分析器
10
+ *
11
+ * @module RegexEditor/validation/complexity
12
+ * @description 分析正则表达式的复杂度,评估性能风险并提供优化建议
13
+ *
14
+ * @remarks
15
+ * 该模块通过遍历 AST 来统计以下复杂度指标:
16
+ * - 节点总数
17
+ * - 最大嵌套深度
18
+ * - 分支数量(alternation)
19
+ * - 量词数量(quantifier)
20
+ * - 捕获组数量
21
+ * - 字符类数量
22
+ *
23
+ * 基于这些指标计算:
24
+ * - 回溯风险等级(low/medium/high)
25
+ * - 性能评分(0-100分)
26
+ * - 优化建议列表
27
+ */
28
+
29
+ /**
30
+ * 分析正则表达式复杂度
31
+ *
32
+ * @param ast - 正则表达式的抽象语法树
33
+ * @returns {ComplexityMetrics} 复杂度指标
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const result = parseRegex('(a+)+b');
38
+ * const metrics = analyzeComplexity(result.ast!);
39
+ *
40
+ * if (metrics.backtrackingRisk === 'high') {
41
+ * console.warn('警告: 高回溯风险');
42
+ * console.log('建议:', metrics.suggestions);
43
+ * }
44
+ *
45
+ * console.log('性能评分:', metrics.performanceScore);
46
+ * ```
47
+ */
48
+ /**
49
+ * 计算节点深度
50
+ * 通过递归遍历 parentPath 计算从根节点到当前节点的深度
51
+ */
52
+ var calculateDepth = function calculateDepth(path) {
53
+ var depth = 1;
54
+ var currentPath = path;
55
+
56
+ // 递归向上查找父节点
57
+ while (currentPath.parentPath) {
58
+ depth++;
59
+ currentPath = currentPath.parentPath;
60
+ }
61
+ return depth;
62
+ };
63
+ var analyzeComplexity = exports.analyzeComplexity = function analyzeComplexity(ast) {
64
+ // 统计指标
65
+ var nodeCount = 0;
66
+ var maxDepth = 1; // 初始深度为1
67
+ var alternationCount = 0;
68
+ var quantifierCount = 0;
69
+ var groupCount = 0;
70
+ var characterClassCount = 0;
71
+ var nestedQuantifiers = 0;
72
+
73
+ // 遍历 AST 统计各项指标
74
+ (0, _parser.traverseAST)(ast, {
75
+ // 通配符: 统计所有节点
76
+ '*': function _(path) {
77
+ nodeCount++;
78
+
79
+ // 计算深度: 递归计算父节点数量
80
+ var depth = calculateDepth(path);
81
+ maxDepth = Math.max(maxDepth, depth);
82
+ },
83
+ // 分支(Disjunction): a|b|c
84
+ // 注意: regexp-tree 中使用 Disjunction 表示分支(|)
85
+ // 每个 Disjunction 节点有 left 和 right 两个分支
86
+ Disjunction: function Disjunction() {
87
+ alternationCount++;
88
+ },
89
+ // 量词(Repetition): +, *, ?, {n,m}
90
+ Repetition: function Repetition(path) {
91
+ var _path$parent, _path$node$expression;
92
+ quantifierCount++;
93
+
94
+ // 检测嵌套量词: (a+)+ 或 (a*)*
95
+ // 检查父节点是否也是量词
96
+ if (((_path$parent = path.parent) === null || _path$parent === void 0 ? void 0 : _path$parent.type) === 'Repetition') {
97
+ nestedQuantifiers++;
98
+ }
99
+
100
+ // 检查子节点是否包含量词
101
+ // 如果子节点是分组,且分组内有量词,也算嵌套
102
+ if (((_path$node$expression = path.node.expression) === null || _path$node$expression === void 0 ? void 0 : _path$node$expression.type) === 'Group') {
103
+ var _group$expression;
104
+ var group = path.node.expression;
105
+ if (((_group$expression = group.expression) === null || _group$expression === void 0 ? void 0 : _group$expression.type) === 'Repetition') {
106
+ nestedQuantifiers++;
107
+ }
108
+ }
109
+ },
110
+ // 捕获组(Group): (...)
111
+ Group: function Group() {
112
+ groupCount++;
113
+ },
114
+ // 字符类(CharacterClass): [abc], [a-z], [^0-9]
115
+ CharacterClass: function CharacterClass() {
116
+ characterClassCount++;
117
+ },
118
+ // 元字符: \d, \w, \s 等
119
+ // regexp-tree 将 \d 等解析为 type='Char', kind='meta' 的节点
120
+ Char: function Char(path) {
121
+ if (path.node.kind === 'meta') {
122
+ characterClassCount++;
123
+ }
124
+ }
125
+ });
126
+
127
+ // 计算回溯风险
128
+ var backtrackingRisk = 'low';
129
+ if (nestedQuantifiers > 0) {
130
+ // 嵌套量词必然导致高风险
131
+ backtrackingRisk = 'high';
132
+ } else if (alternationCount > 3 && quantifierCount > 5) {
133
+ // 多分支 + 多量词 = 中等风险
134
+ backtrackingRisk = 'medium';
135
+ } else if (alternationCount > 5 || quantifierCount > 10) {
136
+ // 单独过多分支或量词 = 中等风险
137
+ backtrackingRisk = 'medium';
138
+ }
139
+
140
+ // 计算性能评分 (0-100)
141
+ // 基础分: 100
142
+ // 扣分规则:
143
+ // - 每个节点 -0.5分
144
+ // - 每层嵌套深度 -2分
145
+ // - 每个分支 -3分
146
+ // - 每个量词 -1.5分
147
+ // - 每个嵌套量词 -30分 (灾难性回溯风险,重度惩罚)
148
+ var performanceScore = 100;
149
+ performanceScore -= nodeCount * 0.5;
150
+ performanceScore -= maxDepth * 2;
151
+ performanceScore -= alternationCount * 3;
152
+ performanceScore -= quantifierCount * 1.5;
153
+ performanceScore -= nestedQuantifiers * 30;
154
+
155
+ // 确保分数在 0-100 之间
156
+ performanceScore = Math.max(0, Math.min(100, performanceScore));
157
+
158
+ // 生成优化建议
159
+ var suggestions = [];
160
+
161
+ // 建议1: 嵌套量词
162
+ if (nestedQuantifiers > 0) {
163
+ suggestions.push('避免嵌套量词,考虑使用原子组或重新设计表达式');
164
+ }
165
+
166
+ // 建议2: 过多分支
167
+ if (alternationCount > 5) {
168
+ suggestions.push('过多的分支可能影响性能,考虑拆分或优化');
169
+ }
170
+
171
+ // 建议3: 表达式过于复杂
172
+ if (nodeCount > 50) {
173
+ suggestions.push('表达式过于复杂,建议拆分为多个简单的表达式');
174
+ }
175
+
176
+ // 建议4: 量词使用过多
177
+ if (quantifierCount > 10) {
178
+ suggestions.push('量词使用过多,考虑优化匹配逻辑');
179
+ }
180
+
181
+ // 建议5: 嵌套层级过深
182
+ if (maxDepth > 5) {
183
+ suggestions.push('嵌套层级过深,建议简化结构');
184
+ }
185
+ return {
186
+ nodeCount: nodeCount,
187
+ depth: maxDepth,
188
+ alternationCount: alternationCount,
189
+ quantifierCount: quantifierCount,
190
+ groupCount: groupCount,
191
+ characterClassCount: characterClassCount,
192
+ backtrackingRisk: backtrackingRisk,
193
+ performanceScore: Math.round(performanceScore),
194
+ suggestions: suggestions
195
+ };
196
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * 正则表达式解析器
3
+ *
4
+ * @module RegexEditor/validation/parser
5
+ * @description 基于 regexp-tree 的正则表达式解析器,提供 AST 解析和遍历功能
6
+ *
7
+ * @remarks
8
+ * 该模块封装了 regexp-tree 库,提供类型安全的解析和遍历功能。
9
+ * 主要功能:
10
+ * - 将正则表达式字符串解析为抽象语法树(AST)
11
+ * - 统一的错误处理和转换
12
+ * - AST 节点遍历工具
13
+ *
14
+ * @see https://github.com/DmitrySoshnikov/regexp-tree
15
+ */
16
+ import type { ParseResult, ASTNode } from './types';
17
+ /**
18
+ * 解析正则表达式
19
+ *
20
+ * @param pattern - 正则表达式字符串
21
+ * @param flags - 可选的正则表达式标志(g, i, m, s, u, y)
22
+ * @returns {ParseResult} 解析结果,包含 AST 或错误信息
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const result = parseRegex('^LOT\\d{6}$');
27
+ * if (result.success) {
28
+ * console.log('AST:', result.ast);
29
+ * } else {
30
+ * console.error('Error:', result.error);
31
+ * }
32
+ * ```
33
+ */
34
+ export declare const parseRegex: (pattern: string, flags?: string) => ParseResult;
35
+ /**
36
+ * 遍历 AST 节点
37
+ *
38
+ * @param ast - 抽象语法树节点
39
+ * @param handlers - 节点类型处理器映射
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const result = parseRegex('(\\d+)');
44
+ * const groups: any[] = [];
45
+ *
46
+ * traverseAST(result.ast!, {
47
+ * Group(path) {
48
+ * groups.push(path.node);
49
+ * }
50
+ * });
51
+ * ```
52
+ */
53
+ export declare const traverseAST: (ast: ASTNode | undefined, handlers: Record<string, (path: any) => void>) => void;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.traverseAST = exports.parseRegex = void 0;
7
+ var _regexpTree = require("regexp-tree");
8
+ /**
9
+ * 正则表达式解析器
10
+ *
11
+ * @module RegexEditor/validation/parser
12
+ * @description 基于 regexp-tree 的正则表达式解析器,提供 AST 解析和遍历功能
13
+ *
14
+ * @remarks
15
+ * 该模块封装了 regexp-tree 库,提供类型安全的解析和遍历功能。
16
+ * 主要功能:
17
+ * - 将正则表达式字符串解析为抽象语法树(AST)
18
+ * - 统一的错误处理和转换
19
+ * - AST 节点遍历工具
20
+ *
21
+ * @see https://github.com/DmitrySoshnikov/regexp-tree
22
+ */
23
+
24
+ /**
25
+ * 解析正则表达式
26
+ *
27
+ * @param pattern - 正则表达式字符串
28
+ * @param flags - 可选的正则表达式标志(g, i, m, s, u, y)
29
+ * @returns {ParseResult} 解析结果,包含 AST 或错误信息
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const result = parseRegex('^LOT\\d{6}$');
34
+ * if (result.success) {
35
+ * console.log('AST:', result.ast);
36
+ * } else {
37
+ * console.error('Error:', result.error);
38
+ * }
39
+ * ```
40
+ */
41
+ var parseRegex = exports.parseRegex = function parseRegex(pattern, flags) {
42
+ try {
43
+ // 空字符串特殊处理
44
+ if (pattern === '') {
45
+ // regexp-tree 可以解析空字符串,使用非捕获组表示
46
+ var _ast = (0, _regexpTree.parse)('/(?:)/');
47
+ return {
48
+ success: true,
49
+ ast: _ast,
50
+ pattern: pattern
51
+ };
52
+ }
53
+
54
+ // 构建完整的正则表达式字符串
55
+ // regexp-tree 需要完整的 /pattern/flags 格式
56
+ var regexStr = flags ? "/".concat(pattern, "/").concat(flags) : "/".concat(pattern, "/");
57
+
58
+ // 尝试解析
59
+ var ast = (0, _regexpTree.parse)(regexStr);
60
+ return {
61
+ success: true,
62
+ ast: ast,
63
+ pattern: pattern
64
+ };
65
+ } catch (error) {
66
+ // 提取错误信息
67
+ var errorMessage = error.message || '解析失败';
68
+
69
+ // 处理不同格式的位置信息
70
+ var startPos = 0;
71
+ var endPos = pattern.length;
72
+ if (error.position !== undefined) {
73
+ if (typeof error.position === 'number') {
74
+ startPos = error.position;
75
+ endPos = error.position + 1;
76
+ } else if (error.position.start !== undefined) {
77
+ startPos = error.position.start;
78
+ endPos = error.position.end || startPos + 1;
79
+ }
80
+ }
81
+
82
+ // 转换为标准错误格式
83
+ var regexError = {
84
+ type: 'syntax_error',
85
+ message: errorMessage,
86
+ position: {
87
+ start: startPos,
88
+ end: endPos
89
+ },
90
+ severity: 'error'
91
+ };
92
+ return {
93
+ success: false,
94
+ pattern: pattern,
95
+ error: regexError
96
+ };
97
+ }
98
+ };
99
+
100
+ /**
101
+ * 遍历 AST 节点
102
+ *
103
+ * @param ast - 抽象语法树节点
104
+ * @param handlers - 节点类型处理器映射
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const result = parseRegex('(\\d+)');
109
+ * const groups: any[] = [];
110
+ *
111
+ * traverseAST(result.ast!, {
112
+ * Group(path) {
113
+ * groups.push(path.node);
114
+ * }
115
+ * });
116
+ * ```
117
+ */
118
+ var traverseAST = exports.traverseAST = function traverseAST(ast, handlers) {
119
+ // 安全处理空 AST
120
+ if (!ast) {
121
+ return;
122
+ }
123
+ try {
124
+ (0, _regexpTree.traverse)(ast, handlers);
125
+ } catch (error) {
126
+ // 遍历错误时静默失败,避免影响主流程
127
+ console.error('AST traversal error:', error);
128
+ }
129
+ };