zcw-shared 1.5.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +93 -363
  2. package/dist/constants/colorPatterns.d.ts +8 -2
  3. package/dist/constants/colorPatterns.js.map +1 -1
  4. package/dist/constants/namedColors.d.ts +16 -2
  5. package/dist/constants/namedColors.js.map +1 -1
  6. package/dist/constants/softwareConfigs.d.ts +0 -1
  7. package/dist/constants/softwareConfigs.js +0 -1
  8. package/dist/constants/softwareConfigs.js.map +1 -1
  9. package/dist/functions/ag-grid/generateLicense.d.ts +2 -2
  10. package/dist/functions/android/buildProject.d.ts +12 -0
  11. package/dist/functions/android/buildProject.js +123 -0
  12. package/dist/functions/android/buildProject.js.map +1 -0
  13. package/dist/functions/android/modifyGradle.d.ts +17 -0
  14. package/dist/functions/android/modifyGradle.js +69 -0
  15. package/dist/functions/android/modifyGradle.js.map +1 -0
  16. package/dist/functions/android/modifyManifest.d.ts +23 -0
  17. package/dist/functions/android/modifyManifest.js +198 -0
  18. package/dist/functions/android/modifyManifest.js.map +1 -0
  19. package/dist/functions/android/permission.d.ts +30 -0
  20. package/dist/functions/android/permission.js +65 -0
  21. package/dist/functions/android/permission.js.map +1 -0
  22. package/dist/functions/color/colorValidation.d.ts +11 -0
  23. package/dist/functions/color/colorValidation.js +35 -0
  24. package/dist/functions/color/colorValidation.js.map +1 -0
  25. package/dist/functions/color/convertColor.d.ts +0 -1
  26. package/dist/functions/color/convertColor.js +135 -166
  27. package/dist/functions/color/convertColor.js.map +1 -1
  28. package/dist/functions/color/deduplicateColors.js +23 -38
  29. package/dist/functions/color/deduplicateColors.js.map +1 -1
  30. package/dist/functions/color/detectColorFormat.d.ts +8 -2
  31. package/dist/functions/color/detectColorFormat.js +49 -51
  32. package/dist/functions/color/detectColorFormat.js.map +1 -1
  33. package/dist/functions/color/extractColors.js +48 -18
  34. package/dist/functions/color/extractColors.js.map +1 -1
  35. package/dist/functions/css/extractCssVariables.d.ts +1 -1
  36. package/dist/functions/css/extractCssVariables.js +1 -1
  37. package/dist/functions/css/extractCssVariables.js.map +1 -1
  38. package/dist/functions/debug/createDebugger.d.ts +8 -7
  39. package/dist/functions/debug/createDebugger.js +49 -39
  40. package/dist/functions/debug/createDebugger.js.map +1 -1
  41. package/dist/functions/dom/detectOverflow.d.ts +3 -3
  42. package/dist/functions/dom/detectOverflow.js +3 -3
  43. package/dist/functions/dom/detectOverflow.js.map +1 -1
  44. package/dist/functions/dom/getElementRect.d.ts +1 -1
  45. package/dist/functions/dom/getElementRect.js.map +1 -1
  46. package/dist/functions/dom/getRelativePosition.d.ts +1 -1
  47. package/dist/functions/dom/getRelativePosition.js.map +1 -1
  48. package/dist/functions/dom/getViewportRect.d.ts +2 -2
  49. package/dist/functions/dom/getViewportRect.js +2 -2
  50. package/dist/functions/dom/getViewportRect.js.map +1 -1
  51. package/dist/functions/dom/getViewportSize.d.ts +2 -2
  52. package/dist/functions/dom/getViewportSize.js.map +1 -1
  53. package/dist/functions/image/generateMacIcons.d.ts +3 -3
  54. package/dist/functions/image/generateMacIcons.js.map +1 -1
  55. package/dist/functions/image/generateMacTrayIcon.d.ts +3 -3
  56. package/dist/functions/image/generateMacTrayIcon.js.map +1 -1
  57. package/dist/functions/image/generatePaddedImage.d.ts +2 -2
  58. package/dist/functions/image/generatePaddedImage.js.map +1 -1
  59. package/dist/functions/image/generatePwaIcons.d.ts +3 -3
  60. package/dist/functions/image/generatePwaIcons.js.map +1 -1
  61. package/dist/functions/image/generateRoundedImage.d.ts +2 -2
  62. package/dist/functions/image/generateRoundedImage.js.map +1 -1
  63. package/dist/functions/ipc/dispatchIpcRequest.d.ts +2 -2
  64. package/dist/functions/ipc/dispatchIpcRequest.js +1 -1
  65. package/dist/functions/ipc/dispatchIpcRequest.js.map +1 -1
  66. package/dist/functions/software/findSoftware.d.ts +3 -3
  67. package/dist/functions/software/findSoftware.js +7 -9
  68. package/dist/functions/software/findSoftware.js.map +1 -1
  69. package/dist/functions/string/base64.d.ts +1 -1
  70. package/dist/functions/string/capitalize.js.map +1 -1
  71. package/dist/functions/string/caseConverter.d.ts +0 -1
  72. package/dist/functions/string/caseConverter.js +1 -8
  73. package/dist/functions/string/caseConverter.js.map +1 -1
  74. package/dist/functions/string/desensitize.js.map +1 -1
  75. package/dist/functions/string/htmlEscape.d.ts +4 -1
  76. package/dist/functions/string/htmlEscape.js +37 -25
  77. package/dist/functions/string/htmlEscape.js.map +1 -1
  78. package/dist/functions/string/levenshtein.js.map +1 -1
  79. package/dist/functions/string/normalize.js.map +1 -1
  80. package/dist/functions/string/pad.d.ts +0 -1
  81. package/dist/functions/string/pad.js +0 -3
  82. package/dist/functions/string/pad.js.map +1 -1
  83. package/dist/functions/string/palindrome.js.map +1 -1
  84. package/dist/functions/string/similarity.js.map +1 -1
  85. package/dist/functions/string/template.js.map +1 -1
  86. package/dist/functions/string/wordCount.js.map +1 -1
  87. package/dist/functions/tencent-cloud/getSecret.js.map +1 -1
  88. package/dist/functions/uniapp/app-plus/androidProjectStrategy.d.ts +7 -7
  89. package/dist/functions/uniapp/app-plus/androidProjectStrategy.js.map +1 -1
  90. package/dist/functions/uniapp/app-plus/buildAndroidApp.d.ts +2 -2
  91. package/dist/functions/uniapp/app-plus/buildAndroidApp.js +98 -24
  92. package/dist/functions/uniapp/app-plus/buildAndroidApp.js.map +1 -1
  93. package/dist/functions/uniapp/app-plus/configureAndroidManifest.d.ts +2 -2
  94. package/dist/functions/uniapp/app-plus/configureAndroidManifest.js.map +1 -1
  95. package/dist/functions/uniapp/app-plus/configureBuildGradle.d.ts +3 -3
  96. package/dist/functions/uniapp/app-plus/configureBuildGradle.js.map +1 -1
  97. package/dist/functions/uniapp/app-plus/configureDcloudControl.d.ts +2 -2
  98. package/dist/functions/uniapp/app-plus/configureDcloudControl.js.map +1 -1
  99. package/dist/functions/uniapp/app-plus/configureStrings.d.ts +2 -2
  100. package/dist/functions/uniapp/app-plus/configureStrings.js.map +1 -1
  101. package/dist/functions/uniapp/app-plus/copyAppResources.d.ts +2 -2
  102. package/dist/functions/uniapp/app-plus/copyAppResources.js.map +1 -1
  103. package/dist/functions/uniapp/app-plus/parseManifest.d.ts +2 -2
  104. package/dist/functions/uniapp/app-plus/parseManifest.js.map +1 -1
  105. package/dist/functions/uniapp/app-plus/validateOptions.d.ts +2 -2
  106. package/dist/functions/uniapp/app-plus/validateOptions.js.map +1 -1
  107. package/dist/functions/uniapp/build.d.ts +20 -0
  108. package/dist/functions/uniapp/build.js +84 -0
  109. package/dist/functions/uniapp/build.js.map +1 -0
  110. package/dist/functions/uniapp/detectAndroidProjectStructure.d.ts +7 -0
  111. package/dist/functions/uniapp/detectAndroidProjectStructure.js +30 -0
  112. package/dist/functions/uniapp/detectAndroidProjectStructure.js.map +1 -0
  113. package/dist/functions/uniapp/detectProjectType.d.ts +16 -0
  114. package/dist/functions/uniapp/detectProjectType.js +68 -0
  115. package/dist/functions/uniapp/detectProjectType.js.map +1 -0
  116. package/dist/functions/uniapp/parseManifest.d.ts +12 -0
  117. package/dist/functions/uniapp/parseManifest.js +46 -0
  118. package/dist/functions/uniapp/parseManifest.js.map +1 -0
  119. package/dist/functions/uniapp/waitForPages.d.ts +3 -2
  120. package/dist/functions/uniapp/waitForPages.js.map +1 -1
  121. package/dist/functions/utils/compose.js.map +1 -1
  122. package/dist/functions/utils/cond.js.map +1 -1
  123. package/dist/functions/utils/curry.js.map +1 -1
  124. package/dist/functions/utils/debounce.js.map +1 -1
  125. package/dist/functions/utils/evolve.js.map +1 -1
  126. package/dist/functions/utils/flow.js.map +1 -1
  127. package/dist/functions/utils/generateExports.d.ts +16 -0
  128. package/dist/functions/utils/generateExports.js +34 -0
  129. package/dist/functions/utils/generateExports.js.map +1 -0
  130. package/dist/functions/utils/isType.js.map +1 -1
  131. package/dist/functions/utils/memoize.js.map +1 -1
  132. package/dist/functions/utils/once.js.map +1 -1
  133. package/dist/functions/utils/partial.js.map +1 -1
  134. package/dist/functions/utils/pipe.js.map +1 -1
  135. package/dist/functions/utils/retryWithBackoff.js.map +1 -1
  136. package/dist/functions/utils/tap.js.map +1 -1
  137. package/dist/functions/utils/throttle.js.map +1 -1
  138. package/dist/functions/utils/until.js.map +1 -1
  139. package/dist/functions/utils/validate.js.map +1 -1
  140. package/dist/functions/utils/walk.d.ts +11 -0
  141. package/dist/functions/utils/walk.js +27 -0
  142. package/dist/functions/utils/walk.js.map +1 -0
  143. package/dist/functions/vue/dynamicMount.d.ts +5 -5
  144. package/dist/functions/vue/dynamicMount.js +3 -1
  145. package/dist/functions/vue/dynamicMount.js.map +1 -1
  146. package/dist/functions/vue/extractColorsFromVueFile.js +2 -11
  147. package/dist/functions/vue/extractColorsFromVueFile.js.map +1 -1
  148. package/dist/functions/vue/extractColorsFromVueSection.js.map +1 -1
  149. package/dist/functions/vue/filterSections.js.map +1 -1
  150. package/dist/functions/vue/isVNode.js +3 -1
  151. package/dist/functions/vue/isVNode.js.map +1 -1
  152. package/dist/functions/vue/isVueComponent.js.map +1 -1
  153. package/dist/functions/vue/parseVueFile.js.map +1 -1
  154. package/dist/functions/wechat/miniapp/downloadFile.d.ts +2 -2
  155. package/dist/functions/wechat/miniapp/downloadFile.js +8 -8
  156. package/dist/functions/wechat/miniapp/downloadFile.js.map +1 -1
  157. package/dist/functions/xml/modifyXml.d.ts +11 -0
  158. package/dist/functions/xml/modifyXml.js +46 -0
  159. package/dist/functions/xml/modifyXml.js.map +1 -0
  160. package/dist/hooks/useAi.d.ts +3 -3
  161. package/dist/hooks/useAi.js.map +1 -1
  162. package/dist/hooks/useAltool.d.ts +3 -32
  163. package/dist/hooks/useAltool.js.map +1 -1
  164. package/dist/hooks/useFetch.d.ts +2 -2
  165. package/dist/hooks/useFetch.js.map +1 -1
  166. package/dist/hooks/useLocalStorage.d.ts +4 -4
  167. package/dist/hooks/useLocalStorage.js +51 -18
  168. package/dist/hooks/useLocalStorage.js.map +1 -1
  169. package/dist/hooks/useSessionStorage.d.ts +4 -4
  170. package/dist/hooks/useSessionStorage.js +51 -18
  171. package/dist/hooks/useSessionStorage.js.map +1 -1
  172. package/dist/hooks/useStorage.d.ts +10 -3
  173. package/dist/hooks/useStorage.js +33 -35
  174. package/dist/hooks/useStorage.js.map +1 -1
  175. package/dist/hooks/useStorageWithIndexedDB.d.ts +4 -4
  176. package/dist/hooks/useStorageWithIndexedDB.js +39 -29
  177. package/dist/hooks/useStorageWithIndexedDB.js.map +1 -1
  178. package/dist/hooks/useWASM.d.ts +2 -2
  179. package/dist/hooks/useWASM.js +6 -10
  180. package/dist/hooks/useWASM.js.map +1 -1
  181. package/dist/hooks/useWebWorker.d.ts +25 -4
  182. package/dist/hooks/useWebWorker.js.map +1 -1
  183. package/dist/hooks/useWorkerFunction.d.ts +22 -4
  184. package/dist/hooks/useWorkerFunction.js +1 -1
  185. package/dist/hooks/useWorkerFunction.js.map +1 -1
  186. package/dist/hooks/useWorkerPool.d.ts +30 -4
  187. package/dist/hooks/useWorkerPool.js.map +1 -1
  188. package/package.json +17 -22
  189. package/references/arraybuffer.d.ts +109 -0
  190. package/references/blob.d.ts +37 -0
  191. package/references/browser.d.ts +55 -160
  192. package/references/chrome.extension.d.ts +83 -0
  193. package/references/console.d.ts +3 -142
  194. package/references/{crypto.d.ts → crypto-js.d.ts} +1 -1
  195. package/references/dom.d.ts +41 -0
  196. package/references/encoding.d.ts +24 -0
  197. package/references/fetch.d.ts +6 -151
  198. package/references/indexeddb.d.ts +49 -0
  199. package/references/json5.d.ts +0 -7
  200. package/references/location.d.ts +16 -0
  201. package/references/node.d.ts +105 -94
  202. package/references/storage.d.ts +6 -100
  203. package/references/timer.d.ts +4 -5
  204. package/references/uniapp.d.ts +47 -5
  205. package/references/url.d.ts +9 -114
  206. package/references/vue.d.ts +71 -98
  207. package/references/webassembly.d.ts +96 -122
  208. package/references/wechat.d.ts +1 -1
  209. package/references/worker.d.ts +78 -132
  210. package/references/xml.d.ts +71 -39
  211. package/types/altool.d.ts +49 -17
  212. package/types/android-build.d.ts +31 -56
  213. package/types/color.d.ts +0 -90
  214. package/types/geometry.d.ts +1 -38
  215. package/types/platform.d.ts +4 -0
  216. package/types/software.d.ts +0 -12
  217. package/types/storage.d.ts +3 -1
  218. package/types/uniapp-android-build.d.ts +49 -0
  219. package/types/worker.d.ts +3 -189
  220. package/references/browser.extension.d.ts +0 -14
  221. package/types/network.d.ts +0 -184
  222. package/types/util.d.ts +0 -27
  223. package/types/wasm.d.ts +0 -217
package/types/color.d.ts CHANGED
@@ -39,81 +39,6 @@ export interface HslaColor extends HslColor {
39
39
  a: number
40
40
  }
41
41
 
42
- /**
43
- * 颜色转换结果
44
- */
45
- export interface ColorConversionResult {
46
- /** 转换后的颜色值 */
47
- value: string
48
- /** 原始颜色格式 */
49
- originalFormat: ColorFormat
50
- /** 目标颜色格式 */
51
- targetFormat: ColorFormat
52
- /** 是否转换成功 */
53
- success: boolean
54
- }
55
-
56
- /**
57
- * 颜色验证结果
58
- */
59
- export interface ColorValidationResult {
60
- /** 是否为有效颜色 */
61
- isValid: boolean
62
- /** 检测到的颜色格式 */
63
- format?: ColorFormat
64
- /** 标准化后的颜色值 */
65
- normalizedValue?: string
66
- }
67
-
68
- /**
69
- * 颜色模式匹配正则表达式集合
70
- */
71
- export interface ColorPatterns {
72
- /** 十六进制颜色匹配 */
73
- hex: RegExp
74
- /** RGB颜色匹配 */
75
- rgb: RegExp
76
- /** RGBA颜色匹配 */
77
- rgba: RegExp
78
- /** HSL颜色匹配 */
79
- hsl: RegExp
80
- /** HSLA颜色匹配 */
81
- hsla: RegExp
82
- /** 命名颜色匹配 */
83
- namedColors: RegExp
84
- }
85
-
86
- /**
87
- * 命名颜色映射表类型
88
- */
89
- export type NamedColorMap = Record<string, string>
90
-
91
- /**
92
- * 颜色标准化选项
93
- */
94
- export interface ColorNormalizationOptions {
95
- /** 是否保留原始格式 */
96
- preserveFormat?: boolean
97
- /** 是否转换为小写 */
98
- toLowerCase?: boolean
99
- /** 是否移除空格 */
100
- trimSpaces?: boolean
101
- }
102
-
103
- /**
104
- * 颜色转换选项
105
- */
106
- export interface ColorConversionOptions {
107
- /** 目标格式 */
108
- targetFormat: ColorFormat
109
- /** 是否包含alpha通道 */
110
- includeAlpha?: boolean
111
- /** alpha值(0-1) */
112
- alphaValue?: number
113
- /** 是否使用8位十六进制格式 */
114
- use8BitHex?: boolean
115
- }
116
-
117
42
  /**
118
43
  * 颜色引用信息
119
44
  * 用于记录在代码中发现的颜色值及其位置信息
@@ -135,21 +60,6 @@ export interface ColorReference {
135
60
  variableName?: string
136
61
  }
137
62
 
138
- /**
139
- * 颜色提取器依赖注入接口
140
- * 定义颜色提取功能所需的外部依赖
141
- */
142
- export interface ColorExtractorDependencies {
143
- /** 获取颜色模式匹配正则表达式 */
144
- getColorPatterns: () => ColorPatterns
145
- /** 标准化颜色值为8位十六进制格式 */
146
- standardizeColor: (color: string) => string
147
- /** 检测颜色格式 */
148
- detectColorFormat: (color: string) => ColorFormat | null
149
- /** 验证是否为有效颜色值 */
150
- isColorValue: (value: string) => { isValid: boolean; format?: ColorFormat }
151
- }
152
-
153
63
  /**
154
64
  * 颜色提取选项
155
65
  */
@@ -24,43 +24,6 @@ export interface Coordinate {
24
24
  y: number
25
25
  }
26
26
 
27
- /**
28
- * 尺寸定义
29
- */
30
- export interface Size {
31
- width: number
32
- height: number
33
- }
34
-
35
- /**
36
- * 边距定义
37
- */
38
- export interface Margin {
39
- top: number
40
- right: number
41
- bottom: number
42
- left: number
43
- }
44
-
45
- /**
46
- * 边框定义
47
- */
48
- export interface Border {
49
- width: number
50
- style: 'solid' | 'dashed' | 'dotted' | 'none'
51
- color: string
52
- }
53
-
54
- /**
55
- * 向量定义
56
- */
57
- export interface Vector2D {
58
- x: number
59
- y: number
60
- }
61
-
62
- /**
63
- * 类型别名,用于向后兼容
64
- */
27
+ // 类型别名 - 这些被DOM函数使用
65
28
  export type Rect = Rectangle
66
29
  export type Coords = Coordinate
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 平台类型定义
3
+ */
4
+ export type Platform = 'win32' | 'darwin' | 'linux'
@@ -12,16 +12,4 @@ export interface SoftwareConfig {
12
12
  registryKey?: string
13
13
  /** 环境变量名 */
14
14
  envVar: string
15
- }
16
-
17
- /**
18
- * 平台类型
19
- */
20
- export type Platform = 'win32' | 'darwin' | 'linux'
21
-
22
- /**
23
- * Process对象接口
24
- */
25
- export interface ProcessLike {
26
- platform: string
27
15
  }
@@ -34,7 +34,7 @@ export interface IndexedDBStorageOptions extends StorageOptions {
34
34
 
35
35
  // 存储 Hook 返回值接口
36
36
  export interface UseStorageReturn<T> {
37
- value: T | null
37
+ get value(): T | null
38
38
  setValue: (value: T | null) => Promise<void>
39
39
  removeValue: () => Promise<void>
40
40
  clear: () => Promise<void>
@@ -46,4 +46,6 @@ export interface StorageAdapter<T> {
46
46
  set: (key: string, value: T) => Promise<void>
47
47
  remove: (key: string) => Promise<void>
48
48
  clear: () => Promise<void>
49
+ getAll: () => Promise<Record<string, T>>
50
+ getKeys: () => Promise<string[]>
49
51
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * UniApp Android 离线打包相关类型定义
3
+ *
4
+ * @description
5
+ * 定义 UniApp Android 离线打包功能使用的接口和类型
6
+ *
7
+ * @since 1.0.0
8
+ * @author Assistant
9
+ */
10
+
11
+ import type { ChildProcess, FileSystem, Path, Process } from '../references/node.d'
12
+ import type { XMLParser, XMLSerializer, XMLParserConstructor, XMLSerializerConstructor } from '../references/xml.d'
13
+ import type { JSON5Parser } from '../references/json5.d'
14
+ import type { AndroidBuildOptions, AndroidBuildResult } from './android-build.d'
15
+
16
+ /**
17
+ * UniApp Android 构建选项
18
+ */
19
+ export interface UniAppAndroidBuildOptions extends AndroidBuildOptions {
20
+ /** UniApp 工程路径 */
21
+ uniappProjectPath: string
22
+ /** Android 应用包名 */
23
+ applicationId?: string
24
+ /** UniApp 应用密钥 */
25
+ appkey?: string
26
+ }
27
+
28
+ /**
29
+ * UniApp Android 构建结果
30
+ */
31
+ export interface UniAppAndroidBuildResult extends AndroidBuildResult {
32
+ // 可以添加 UniApp 特有的结果属性
33
+ }
34
+
35
+ /**
36
+ * UniApp 系统依赖接口
37
+ * 用于依赖注入,确保函数的环境无关性
38
+ */
39
+ export interface UniAppSystemDependencies {
40
+ childProcess: ChildProcess
41
+ fs: FileSystem
42
+ path: Path
43
+ process: Process
44
+ setTimeout: (callback: () => void, delay: number) => any
45
+ require: (id: string) => any
46
+ json5: JSON5Parser
47
+ xmlParser: XMLParserConstructor
48
+ xmlSerializer: XMLSerializerConstructor
49
+ }
package/types/worker.d.ts CHANGED
@@ -9,6 +9,8 @@
9
9
  * @author Assistant
10
10
  */
11
11
 
12
+ import type { Timeout } from '../../references/node.d'
13
+
12
14
  /**
13
15
  * 响应式值接口
14
16
  */
@@ -58,33 +60,6 @@ export interface WebWorkerResult<T> {
58
60
  error: Error | null
59
61
  }
60
62
 
61
- /**
62
- * useWebWorker返回值接口
63
- */
64
- export interface UseWebWorkerReturn {
65
- /** Worker是否准备就绪 */
66
- isReady: ReactiveValue<boolean>
67
- /** 是否正在加载 */
68
- isLoading: ReactiveValue<boolean>
69
- /** 错误状态 */
70
- error: ReactiveValue<Error | null>
71
- /** 发送消息 */
72
- postMessage: <T>(data: any, transfer?: Transferable[]) => Promise<WebWorkerResult<T>>
73
- /** 批量发送消息 */
74
- postMessages: <T>(messages: any[], transfer?: Transferable[][]) => Promise<WebWorkerResult<T>[]>
75
- /** 终止Worker */
76
- terminate: () => void
77
- /** 重启Worker */
78
- restart: () => Promise<void>
79
- /** 获取状态 */
80
- getStatus: () => {
81
- isReady: boolean
82
- isLoading: boolean
83
- error: Error | null
84
- pendingMessages: number
85
- }
86
- }
87
-
88
63
  /**
89
64
  * Worker任务接口
90
65
  */
@@ -192,64 +167,6 @@ export interface WorkerFunctionResult<R> {
192
167
  executionTime: number
193
168
  }
194
169
 
195
- /**
196
- * useWorkerFunction返回类型
197
- */
198
- export interface UseWorkerFunctionReturn<T extends any[], R> {
199
- /** Worker是否准备就绪 */
200
- isReady: ReactiveValue<boolean>
201
- /** 是否正在加载 */
202
- isLoading: ReactiveValue<boolean>
203
- /** 错误状态 */
204
- error: ReactiveValue<Error | null>
205
- /** 执行函数 */
206
- execute: (...args: T) => Promise<WorkerFunctionResult<R>>
207
- /** 终止Worker */
208
- terminate: () => void
209
- /** 获取状态信息 */
210
- getStatus: () => {
211
- isReady: boolean
212
- isLoading: boolean
213
- error: Error | null
214
- executionCount: number
215
- }
216
- }
217
-
218
- /**
219
- * useWorkerPool返回值接口
220
- */
221
- export interface UseWorkerPoolReturn {
222
- /** 池是否准备就绪 */
223
- isReady: ReactiveValue<boolean>
224
- /** 是否正在加载 */
225
- isLoading: ReactiveValue<boolean>
226
- /** 错误状态 */
227
- error: ReactiveValue<Error | null>
228
- /** 执行任务 */
229
- execute: <T>(task: WorkerTask) => Promise<WorkerPoolResult<T>>
230
- /** 批量执行任务 */
231
- executeBatch: <T>(tasks: WorkerTask[]) => Promise<WorkerPoolResult<T>[]>
232
- /** 取消任务 */
233
- cancelTask: (taskId: number) => boolean
234
- /** 清空队列 */
235
- clearQueue: () => void
236
- /** 调整池大小 */
237
- resize: (newSize: number) => Promise<void>
238
- /** 获取统计信息 */
239
- getStats: () => WorkerPoolStats
240
- /** 终止池 */
241
- terminate: () => void
242
- /** 重启池 */
243
- restart: () => Promise<void>
244
- /** 清理资源 */
245
- cleanup: () => void
246
- }
247
-
248
- /**
249
- * Worker事件类型
250
- */
251
- export type WorkerEventType = 'message' | 'error' | 'messageerror'
252
-
253
170
  /**
254
171
  * Worker状态类型
255
172
  */
@@ -258,107 +175,4 @@ export type WorkerStatus = 'idle' | 'loading' | 'ready' | 'busy' | 'error' | 'te
258
175
  /**
259
176
  * 任务优先级类型
260
177
  */
261
- export type TaskPriority = 'low' | 'normal' | 'high'
262
-
263
- /**
264
- * Worker池策略类型
265
- */
266
- export type PoolStrategy = 'round-robin' | 'least-busy' | 'random' | 'priority'
267
-
268
- /**
269
- * 负载均衡策略接口
270
- */
271
- export interface LoadBalancingStrategy {
272
- /** 策略名称 */
273
- name: PoolStrategy
274
- /** 选择Worker的函数 */
275
- selectWorker: (workers: WorkerInfo[], task: WorkerTask) => number
276
- }
277
-
278
- /**
279
- * Worker信息接口
280
- */
281
- export interface WorkerInfo {
282
- /** Worker ID */
283
- id: number
284
- /** 是否忙碌 */
285
- busy: boolean
286
- /** 任务计数 */
287
- taskCount: number
288
- /** 最后使用时间 */
289
- lastUsed: number
290
- /** Worker状态 */
291
- status: WorkerStatus
292
- /** 错误计数 */
293
- errorCount: number
294
- }
295
-
296
- /**
297
- * 任务执行上下文
298
- */
299
- export interface TaskExecutionContext {
300
- /** 任务ID */
301
- taskId: number
302
- /** Worker ID */
303
- workerId: number
304
- /** 开始时间 */
305
- startTime: number
306
- /** 超时ID */
307
- timeoutId: NodeJS.Timeout
308
- /** 任务数据 */
309
- task: WorkerTask
310
- }
311
-
312
- /**
313
- * Worker池配置
314
- */
315
- export interface WorkerPoolConfig extends WorkerPoolOptions {
316
- /** 负载均衡策略 */
317
- strategy?: PoolStrategy
318
- /** 健康检查间隔(毫秒) */
319
- healthCheckInterval?: number
320
- /** Worker空闲超时(毫秒) */
321
- idleTimeout?: number
322
- /** 最大错误次数 */
323
- maxErrors?: number
324
- }
325
-
326
- /**
327
- * 任务队列项
328
- */
329
- export interface TaskQueueItem {
330
- /** 任务 */
331
- task: WorkerTask
332
- /** 解决函数 */
333
- resolve: (value: WorkerPoolResult<any>) => void
334
- /** 拒绝函数 */
335
- reject: (error: Error) => void
336
- /** 优先级数值 */
337
- priority: number
338
- /** 时间戳 */
339
- timestamp: number
340
- /** 任务ID */
341
- taskId: number
342
- }
343
-
344
- /**
345
- * Worker性能指标
346
- */
347
- export interface WorkerMetrics {
348
- /** 总任务数 */
349
- totalTasks: number
350
- /** 成功任务数 */
351
- successfulTasks: number
352
- /** 失败任务数 */
353
- failedTasks: number
354
- /** 平均执行时间 */
355
- averageExecutionTime: number
356
- /** 最大执行时间 */
357
- maxExecutionTime: number
358
- /** 最小执行时间 */
359
- minExecutionTime: number
360
- /** 错误率 */
361
- errorRate: number
362
- /** 吞吐量(任务/秒) */
363
- throughput: number
364
- }
178
+ export type TaskPriority = 'low' | 'normal' | 'high'
@@ -1,14 +0,0 @@
1
- export interface TabInfo {
2
- id?: number;
3
- windowId?: number;
4
- }
5
-
6
- export type SenderType = 'content' | 'background' | 'popup' | 'sidepanel' | 'options';
7
-
8
- export interface MessageSender {
9
- type: SenderType;
10
- tab?: TabInfo;
11
- id?: string;
12
- url?: string;
13
- frameId?: number;
14
- }
@@ -1,184 +0,0 @@
1
- /**
2
- * 网络请求相关类型定义
3
- *
4
- * @description
5
- * 定义网络请求hooks使用的接口和类型
6
- *
7
- * @since 1.0.0
8
- * @author Assistant
9
- */
10
-
11
- import type { Response } from '../../references/fetch.d'
12
-
13
- /**
14
- * 请求选项接口
15
- */
16
- export interface RequestOptions extends RequestInit {
17
- /** 是否启用缓存 */
18
- cache?: boolean
19
- /** 缓存TTL(毫秒) */
20
- cacheTTL?: number
21
- /** 重试次数 */
22
- retry?: number
23
- /** 重试延迟(毫秒) */
24
- retryDelay?: number
25
- /** 请求超时(毫秒) */
26
- timeout?: number
27
- }
28
-
29
- /**
30
- * 请求结果接口
31
- */
32
- export interface RequestResult<T> {
33
- /** 请求是否成功 */
34
- success: boolean
35
- /** 响应数据 */
36
- data: T | null
37
- /** 错误信息 */
38
- error: Error | null
39
- /** 是否来自缓存 */
40
- fromCache: boolean
41
- }
42
-
43
- /**
44
- * 响应式值接口
45
- */
46
- export interface ReactiveValue<T> {
47
- value: T
48
- }
49
-
50
- /**
51
- * useRequest返回值接口
52
- */
53
- export interface UseRequestReturn<T> {
54
- /** 加载状态 */
55
- loading: ReactiveValue<boolean>
56
- /** 错误状态 */
57
- error: ReactiveValue<Error | null>
58
- /** 数据状态 */
59
- data: ReactiveValue<T | null>
60
- /** 执行请求 */
61
- execute: (url: string, options?: RequestOptions) => Promise<RequestResult<T>>
62
- /** 取消请求 */
63
- cancel: () => void
64
- /** 清除缓存 */
65
- clearCache: (url?: string) => void
66
- /** 获取缓存统计 */
67
- getCacheStats: () => {
68
- total: number
69
- valid: number
70
- expired: number
71
- }
72
- }
73
-
74
- /**
75
- * 请求数据类型
76
- */
77
- export type RequestData = string | FormData | Blob | ArrayBuffer | URLSearchParams | Record<string, unknown> | null
78
-
79
- /**
80
- * Fetch选项接口
81
- */
82
- export interface FetchOptions {
83
- /** 基础URL */
84
- baseURL?: string
85
- /** 请求数据 */
86
- data?: RequestData
87
- /** HTTP方法 */
88
- method?: string
89
- /** 请求头 */
90
- headers?: Record<string, string> | Headers
91
- /** 请求体 */
92
- body?: BodyInit | null
93
- /** 中止信号 */
94
- signal?: AbortSignal
95
- /** 凭据模式 */
96
- credentials?: RequestCredentials
97
- /** 缓存模式 */
98
- cache?: RequestCache
99
- /** 重定向模式 */
100
- redirect?: RequestRedirect
101
- /** 引用者 */
102
- referrer?: string
103
- /** 引用者策略 */
104
- referrerPolicy?: ReferrerPolicy
105
- /** 完整性 */
106
- integrity?: string
107
- /** 保持连接 */
108
- keepalive?: boolean
109
- /** 模式 */
110
- mode?: RequestMode
111
- }
112
-
113
- /**
114
- * Fetch结果接口
115
- */
116
- export interface FetchResult<T> {
117
- /** 请求是否成功 */
118
- success: boolean
119
- /** 响应数据 */
120
- data: T | null
121
- /** 响应数据 */
122
- response: Response | null
123
- /** 错误信息 */
124
- error: Error | null
125
- }
126
-
127
- /**
128
- * useFetch返回值接口
129
- */
130
- export interface UseFetchReturn {
131
- /** 加载状态 */
132
- loading: ReactiveValue<boolean>
133
- /** 错误状态 */
134
- error: ReactiveValue<Error | null>
135
- /** 通用请求方法 */
136
- request: <T>(url: string, options?: FetchOptions) => Promise<FetchResult<T>>
137
- /** GET请求 */
138
- get: <T>(url: string, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<T>>
139
- /** POST请求 */
140
- post: <T>(url: string, data?: RequestData, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<T>>
141
- /** PUT请求 */
142
- put: <T>(url: string, data?: RequestData, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<T>>
143
- /** DELETE请求 */
144
- delete: <T>(url: string, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<T>>
145
- /** PATCH请求 */
146
- patch: <T>(url: string, data?: RequestData, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<T>>
147
- /** HEAD请求 */
148
- head: (url: string, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<unknown>>
149
- /** OPTIONS请求 */
150
- options: (url: string, options?: Omit<FetchOptions, 'method' | 'data'>) => Promise<FetchResult<unknown>>
151
- /** 添加请求拦截器 */
152
- addRequestInterceptor: (interceptor: (config: FetchOptions) => FetchOptions | Promise<FetchOptions>) => void
153
- /** 添加响应拦截器 */
154
- addResponseInterceptor: (interceptor: (response: Response) => Response | Promise<Response>) => void
155
- /** 移除请求拦截器 */
156
- removeRequestInterceptor: (interceptor: (config: FetchOptions) => FetchOptions | Promise<FetchOptions>) => void
157
- /** 移除响应拦截器 */
158
- removeResponseInterceptor: (interceptor: (response: Response) => Response | Promise<Response>) => void
159
- }
160
-
161
- /**
162
- * 请求拦截器函数类型
163
- */
164
- export type RequestInterceptor = (config: FetchOptions) => FetchOptions | Promise<FetchOptions>
165
-
166
- /**
167
- * 响应拦截器类型
168
- */
169
- export type ResponseInterceptor = (response: Response) => Response | Promise<Response>
170
-
171
- /**
172
- * HTTP方法类型
173
- */
174
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'
175
-
176
- /**
177
- * 缓存策略类型
178
- */
179
- export type CacheStrategy = 'no-cache' | 'memory' | 'storage'
180
-
181
- /**
182
- * 请求状态类型
183
- */
184
- export type RequestStatus = 'idle' | 'loading' | 'success' | 'error'
package/types/util.d.ts DELETED
@@ -1,27 +0,0 @@
1
- /**
2
- * 通用工具类型定义
3
- */
4
-
5
- // 忽略所有body开头的属性
6
- export type OmitBodyProperties<T> = {
7
- [K in keyof T as K extends `body${string}` ? never : K]: T[K]
8
- }
9
-
10
- // 深度可选类型
11
- export type DeepPartial<T> = {
12
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
13
- }
14
-
15
- // 可选属性类型
16
- export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
17
-
18
- // 必需属性类型
19
- export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>
20
-
21
- // 非空类型
22
- export type NonNullable<T> = T extends null | undefined ? never : T
23
-
24
- // 键值对类型
25
- export type KeyValuePair<K extends string | number | symbol, V> = {
26
- [P in K]: V
27
- }