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
@@ -1,41 +1,15 @@
1
- /**
2
- * Fetch API 类型定义
3
- * 包含浏览器和 Node.js 环境都支持的 Fetch 相关 API
4
- */
1
+ import type { BufferSource } from './arraybuffer.d'
5
2
 
6
- /**
7
- * 请求凭据类型
8
- */
9
3
  type RequestCredentials = 'omit' | 'same-origin' | 'include'
10
-
11
- /**
12
- * 请求缓存类型
13
- */
14
4
  type RequestCache = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached'
15
-
16
- /**
17
- * 请求重定向类型
18
- */
19
5
  type RequestRedirect = 'follow' | 'error' | 'manual'
20
-
21
- /**
22
- * 引用策略类型
23
- */
24
6
  type ReferrerPolicy = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'
25
-
26
- /**
27
- * 请求模式类型
28
- */
29
7
  type RequestMode = 'cors' | 'no-cors' | 'same-origin' | 'navigate'
30
-
31
- /**
32
- * 请求体类型
33
- */
34
8
  type BodyInit = Blob | BufferSource | FormData | URLSearchParams | string
9
+ type HeadersInit = string[][] | Record<string, string> | Headers
10
+ type RequestInfo = Request | string
11
+ type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'
35
12
 
36
- /**
37
- * Headers 接口
38
- */
39
13
  export interface Headers {
40
14
  append(name: string, value: string): void
41
15
  delete(name: string): void
@@ -49,113 +23,42 @@ export interface Headers {
49
23
  values(): IterableIterator<string>
50
24
  }
51
25
 
52
- /**
53
- * Headers 构造函数
54
- */
55
26
  export declare const Headers: {
56
27
  new (init?: HeadersInit): Headers
57
28
  }
58
29
 
59
- /**
60
- * Headers 初始化类型
61
- */
62
- type HeadersInit = string[][] | Record<string, string> | Headers
63
-
64
- /**
65
- * 中止信号接口
66
- */
67
30
  export interface AbortSignal {
68
- /** 是否已中止 */
69
31
  aborted: boolean
70
-
71
- /** 中止原因 */
72
32
  reason?: any
73
-
74
- /**
75
- * 添加事件监听器
76
- * @param type 事件类型
77
- * @param listener 监听器函数
78
- */
79
33
  addEventListener(type: 'abort', listener: () => void): void
80
-
81
- /**
82
- * 移除事件监听器
83
- * @param type 事件类型
84
- * @param listener 监听器函数
85
- */
86
34
  removeEventListener(type: 'abort', listener: () => void): void
87
-
88
- /**
89
- * 抛出中止异常(如果已中止)
90
- */
91
35
  throwIfAborted(): void
92
36
  }
93
37
 
94
- /**
95
- * 中止控制器接口
96
- */
97
38
  export interface AbortController {
98
- /** 中止信号 */
99
39
  signal: AbortSignal
100
-
101
- /**
102
- * 中止操作
103
- * @param reason 中止原因
104
- */
105
40
  abort(reason?: any): void
106
41
  }
107
42
 
108
- /**
109
- * 中止控制器构造函数
110
- */
111
43
  export declare const AbortController: {
112
44
  new (): AbortController
113
45
  }
114
46
 
115
- /**
116
- * 请求初始化选项
117
- */
118
47
  export interface RequestInit {
119
- /** HTTP 方法 */
120
48
  method?: string
121
-
122
- /** 请求头 */
123
49
  headers?: HeadersInit
124
-
125
- /** 请求体 */
126
50
  body?: BodyInit | null
127
-
128
- /** 中止信号 */
129
51
  signal?: AbortSignal
130
-
131
- /** 凭据模式 */
132
52
  credentials?: RequestCredentials
133
-
134
- /** 缓存模式 */
135
53
  cache?: RequestCache
136
-
137
- /** 重定向模式 */
138
54
  redirect?: RequestRedirect
139
-
140
- /** 引用页面 */
141
55
  referrer?: string
142
-
143
- /** 引用策略 */
144
56
  referrerPolicy?: ReferrerPolicy
145
-
146
- /** 完整性校验 */
147
57
  integrity?: string
148
-
149
- /** 保持连接 */
150
58
  keepalive?: boolean
151
-
152
- /** 请求模式 */
153
59
  mode?: RequestMode
154
60
  }
155
61
 
156
- /**
157
- * Request 接口
158
- */
159
62
  export interface Request {
160
63
  readonly url: string
161
64
  readonly method: string
@@ -181,21 +84,10 @@ export interface Request {
181
84
  text(): Promise<string>
182
85
  }
183
86
 
184
- /**
185
- * Request 构造函数
186
- */
187
87
  export declare const Request: {
188
88
  new (input: RequestInfo, init?: RequestInit): Request
189
89
  }
190
90
 
191
- /**
192
- * RequestInfo 类型
193
- */
194
- type RequestInfo = Request | string
195
-
196
- /**
197
- * Response 接口
198
- */
199
91
  export interface Response {
200
92
  readonly ok: boolean
201
93
  readonly status: number
@@ -215,55 +107,18 @@ export interface Response {
215
107
  text(): Promise<string>
216
108
  }
217
109
 
218
- /**
219
- * Response 构造函数
220
- */
221
110
  export declare const Response: {
222
111
  new (body?: BodyInit | null, init?: ResponseInit): Response
223
112
  error(): Response
224
113
  redirect(url: string, status?: number): Response
225
114
  }
226
115
 
227
- /**
228
- * Response 初始化选项
229
- */
230
116
  export interface ResponseInit {
231
117
  status?: number
232
118
  statusText?: string
233
119
  headers?: HeadersInit
234
120
  }
235
121
 
236
- /**
237
- * Response 类型
238
- */
239
- type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'
240
-
241
- /**
242
- * Fetch 函数
243
- */
244
- export declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>
245
-
246
- /**
247
- * Fetch 环境类型定义
248
- */
249
- export interface FetchEnvironment {
250
- fetch: typeof fetch
251
- Request: typeof Request
252
- Response: typeof Response
253
- Headers: typeof Headers
254
- AbortController: typeof AbortController
255
- }
122
+ export declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
256
123
 
257
- // 导出 Fetch 相关 API
258
- // 导出类型别名
259
- export type {
260
- RequestCredentials,
261
- RequestCache,
262
- RequestRedirect,
263
- ReferrerPolicy,
264
- RequestMode,
265
- BodyInit,
266
- HeadersInit,
267
- RequestInfo,
268
- ResponseType
269
- }
124
+ export type FetchFunction = typeof fetch
@@ -0,0 +1,49 @@
1
+ // IndexedDB 相关类型声明
2
+
3
+ export interface IDBFactory {
4
+ open(name: string, version?: number): IDBOpenDBRequest
5
+ }
6
+
7
+ export interface IDBOpenDBRequest {
8
+ result: IDBDatabase
9
+ error: DOMException | null
10
+ onsuccess: ((event: Event) => void) | null
11
+ onerror: ((event: Event) => void) | null
12
+ onupgradeneeded: ((event: IDBVersionChangeEvent) => void) | null
13
+ }
14
+
15
+ export interface IDBDatabase {
16
+ objectStoreNames: DOMStringList
17
+ createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore
18
+ transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction
19
+ }
20
+
21
+ export interface IDBObjectStore {
22
+ get(key: IDBValidKey): IDBRequest
23
+ put(value: any, key?: IDBValidKey): IDBRequest
24
+ delete(key: IDBValidKey): IDBRequest
25
+ clear(): IDBRequest
26
+ }
27
+
28
+ export interface IDBTransaction {
29
+ objectStore(name: string): IDBObjectStore
30
+ }
31
+
32
+ export interface IDBRequest {
33
+ result: any
34
+ error: DOMException | null
35
+ onsuccess: ((event: Event) => void) | null
36
+ onerror: ((event: Event) => void) | null
37
+ }
38
+
39
+ export interface IDBVersionChangeEvent {
40
+ target: IDBOpenDBRequest
41
+ }
42
+
43
+ export type IDBValidKey = string | number | Date | ArrayBuffer | IDBValidKey[]
44
+ export type IDBTransactionMode = 'readonly' | 'readwrite' | 'versionchange'
45
+
46
+ export interface IDBObjectStoreParameters {
47
+ keyPath?: string | string[]
48
+ autoIncrement?: boolean
49
+ }
@@ -19,10 +19,3 @@ export interface JSON5Parser {
19
19
  */
20
20
  stringify(value: any, replacer?: any, space?: string | number): string
21
21
  }
22
-
23
- /**
24
- * JSON5 环境类型定义
25
- */
26
- export interface JSON5Environment {
27
- JSON5: JSON5Parser
28
- }
@@ -0,0 +1,16 @@
1
+ // 位置信息相关类型声明
2
+
3
+ export interface Location {
4
+ search: string
5
+ href: string
6
+ origin: string
7
+ pathname: string
8
+ hash: string
9
+ protocol: string
10
+ host: string
11
+ hostname: string
12
+ port: string
13
+ assign(url: string): void
14
+ reload(forcedReload?: boolean): void
15
+ replace(url: string): void
16
+ }
@@ -1,111 +1,122 @@
1
- // Node.js 类型定义文件
2
- // 仅包含必要的 Node.js 类型,避免全局污染
3
- import type { ConsoleInterface } from './console.d'
1
+ // Node.js 环境类型声明 - 统一的Global接口
2
+ import type { Console } from './console.d'
3
+ import type { TextDecoderConstructor, TextEncoderConstructor } from './encoding.d'
4
+ import type { ArrayBufferConstructor, Uint8ArrayConstructor, DataViewConstructor } from './arraybuffer.d'
5
+
6
+ // 基础类型定义
7
+ export interface ReadableStream {
8
+ // ReadableStream 基本接口
9
+ }
4
10
 
5
- export namespace Node {
6
- interface ReadableStream {
7
- [key: string]: any
8
- }
11
+ export interface WritableStream {
12
+ // WritableStream 基本接口
13
+ }
9
14
 
10
- interface WritableStream {
11
- [key: string]: any
12
- }
15
+ export interface Process {
16
+ env: Record<string, string | undefined>
17
+ argv: string[]
18
+ platform: string
19
+ cwd(): string
20
+ exit(code?: number): never
21
+ }
13
22
 
14
- interface Process {
15
- env: Record<string, string | undefined>
16
- argv: string[]
17
- cwd(): string
18
- exit(code?: number): never
19
- [key: string]: any
20
- }
23
+ export interface Buffer {
24
+ length: number
25
+ toString(encoding?: string): string
26
+ }
21
27
 
22
- interface Buffer {
23
- length: number
24
- toString(encoding?: string): string
25
- [key: string]: any
26
- }
27
- interface FileSystem {
28
- readFile(path: string): Promise<any>
29
- writeFile(path: string, data: any): Promise<void>
30
- mkdir(path: string, options?: any): Promise<void>
31
- [key: string]: any
28
+ export interface FileSystem {
29
+ readFile(path: string, encoding?: string): Promise<any>
30
+ readFileSync(path: string, encoding?: string): string
31
+ writeFile(path: string, data: any): Promise<void>
32
+ writeFileSync(path: string, data: any, encoding?: string): void
33
+ mkdir(path: string, options?: any): Promise<void>
34
+ mkdirSync(path: string, options?: any): void
35
+ copyFileSync(src: string, dest: string): void
36
+ existsSync(path: string): boolean
37
+ readdirSync(path: string): string[]
38
+ statSync(path: string): { isDirectory(): boolean; isFile(): boolean }
39
+ promises: {
40
+ cp(source: string, destination: string, options?: any): Promise<void>
32
41
  }
42
+ }
33
43
 
34
- interface Path {
44
+ export interface Path {
45
+ join(...paths: string[]): string
46
+ resolve(...paths: string[]): string
47
+ dirname(path: string): string
48
+ basename(path: string, ext?: string): string
49
+ extname(path: string): string
50
+ sep: string
51
+ posix: {
35
52
  join(...paths: string[]): string
36
- resolve(...paths: string[]): string
37
- dirname(path: string): string
38
- basename(path: string, ext?: string): string
39
- extname(path: string): string
40
- [key: string]: any
41
- }
42
-
43
- interface ChildProcess {
44
- exec(command: string, callback?: (error: any, stdout: string, stderr: string) => void): any
45
- [key: string]: any
46
- }
47
-
48
- interface Util {
49
- promisify<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => Promise<any>
50
- [key: string]: any
51
- }
52
-
53
- interface BufferConstructor {
54
- from(str: string, encoding?: string): Buffer
53
+ sep: string
55
54
  }
56
55
  }
57
56
 
58
- // NodeJS 命名空间
59
- export namespace NodeJS {
60
- interface Timeout {
61
- ref(): this
62
- unref(): this
63
- hasRef(): boolean
64
- refresh(): this
65
- [Symbol.toPrimitive](): number
66
- }
67
-
68
- interface Immediate {
69
- ref(): this
70
- unref(): this
71
- hasRef(): boolean
72
- _onImmediate: Function
73
- }
57
+ export interface ChildProcess {
58
+ exec(command: string, callback?: (error: any, stdout: string, stderr: string) => void): any
74
59
  }
75
60
 
76
- // 定时器函数
77
- export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate
78
- export function clearImmediate(immediateId: NodeJS.Immediate): void
79
-
61
+ export interface Util {
62
+ promisify<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => Promise<any>
63
+ }
80
64
 
81
- // 导出 Node.js 相关类型
82
- export type NodeFileSystem = Node.FileSystem
83
- export type NodePath = Node.Path
84
- export type NodeChildProcess = Node.ChildProcess
85
- export type NodeUtil = Node.Util
86
- export type NodeProcess = Node.Process
87
- export type NodeBuffer = Node.Buffer
88
- export type NodeBufferConstructor = Node.BufferConstructor
89
- export type NodeReadableStream = Node.ReadableStream
90
- export type NodeWritableStream = Node.WritableStream
65
+ export interface BufferConstructor {
66
+ from(str: string, encoding?: string): Buffer
67
+ }
91
68
 
92
- // 导出 NodeJS 命名空间类型
93
- export type NodeTimeout = NodeJS.Timeout
94
- export type NodeImmediate = NodeJS.Immediate
69
+ export interface Timeout {
70
+ ref(): this
71
+ unref(): this
72
+ hasRef(): boolean
73
+ refresh(): this
74
+ [Symbol.toPrimitive](): number
75
+ }
95
76
 
96
- // 重新导出函数类型
97
- export { setImmediate, clearImmediate }
77
+ export interface Immediate {
78
+ ref(): this
79
+ unref(): this
80
+ hasRef(): boolean
81
+ _onImmediate: Function
82
+ }
98
83
 
99
- // Node.js 调试环境接口
100
- export interface NodeEnvironment {
101
- process: NodeProcess
102
- fs: NodeFileSystem
103
- path: NodePath
104
- childProcess: NodeChildProcess
105
- util: NodeUtil
106
- Buffer: NodeBufferConstructor
107
- console: ConsoleInterface
108
- setImmediate: typeof setImmediate
109
- clearImmediate: typeof clearImmediate
84
+ // Node.js Global对象 - 包含所有Node.js API
85
+ export interface Global {
86
+ // 进程对象
87
+ process: Process
88
+
89
+ // 控制台
90
+ console: Console
91
+
92
+ // Buffer API
93
+ Buffer: BufferConstructor
94
+
95
+ // 编码API
96
+ TextDecoder: TextDecoderConstructor
97
+ TextEncoder: TextEncoderConstructor
98
+
99
+ // 定时器API
100
+ setTimeout(callback: (...args: any[]) => void, ms?: number, ...args: any[]): Timeout
101
+ clearTimeout(timeoutId: Timeout): void
102
+ setInterval(callback: (...args: any[]) => void, ms?: number, ...args: any[]): Timeout
103
+ clearInterval(intervalId: Timeout): void
104
+ setImmediate(callback: (...args: any[]) => void, ...args: any[]): Immediate
105
+ clearImmediate(immediateId: Immediate): void
106
+
107
+ // 类型化数组
108
+ ArrayBuffer: ArrayBufferConstructor
109
+ Uint8Array: Uint8ArrayConstructor
110
+ DataView: DataViewConstructor
111
+
112
+ // 全局变量
113
+ __dirname?: string
114
+ __filename?: string
115
+
116
+ // 开发环境标识
110
117
  __DEV__?: boolean
111
- }
118
+ }
119
+
120
+ // 定时器函数
121
+ export declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): Immediate
122
+ export declare function clearImmediate(immediateId: Immediate): void
@@ -7,106 +7,12 @@
7
7
  * 基础存储接口
8
8
  * 对应浏览器的 localStorage 和 sessionStorage API
9
9
  */
10
- export interface StorageInterface {
10
+ export interface Storage {
11
+ readonly length: number
12
+ clear(): void
11
13
  getItem(key: string): string | null
12
- setItem(key: string, value: string): void
14
+ key(index: number): string | null
13
15
  removeItem(key: string): void
14
- clear(): void
15
- }
16
-
17
- /**
18
- * IndexedDB 工厂接口
19
- * 已在 browser.d.ts 中定义,这里重新导出以保持一致性
20
- */
21
- export interface IDBFactory {
22
- open(name: string, version?: number): IDBOpenDBRequest
23
- }
24
-
25
- /**
26
- * IndexedDB 请求接口
27
- */
28
- export interface IDBOpenDBRequest extends EventTarget {
29
- result: IDBDatabase
30
- error: DOMException | null
31
- onsuccess: ((event: Event) => void) | null
32
- onerror: ((event: Event) => void) | null
33
- onupgradeneeded: ((event: IDBVersionChangeEvent) => void) | null
34
- }
35
-
36
- /**
37
- * IndexedDB 数据库接口
38
- */
39
- export interface IDBDatabase {
40
- objectStoreNames: DOMStringList
41
- createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore
42
- transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction
43
- }
44
-
45
- /**
46
- * IndexedDB 对象存储接口
47
- */
48
- export interface IDBObjectStore {
49
- get(key: IDBValidKey): IDBRequest
50
- put(value: any, key?: IDBValidKey): IDBRequest
51
- delete(key: IDBValidKey): IDBRequest
52
- clear(): IDBRequest
53
- }
54
-
55
- /**
56
- * IndexedDB 事务接口
57
- */
58
- export interface IDBTransaction {
59
- objectStore(name: string): IDBObjectStore
60
- }
61
-
62
- /**
63
- * IndexedDB 请求接口
64
- */
65
- export interface IDBRequest {
66
- result: any
67
- error: DOMException | null
68
- onsuccess: ((event: Event) => void) | null
69
- onerror: ((event: Event) => void) | null
70
- }
71
-
72
- /**
73
- * IndexedDB 版本变更事件接口
74
- */
75
- export interface IDBVersionChangeEvent extends Event {
76
- target: IDBOpenDBRequest
77
- }
78
-
79
- /**
80
- * DOM 字符串列表接口
81
- */
82
- export interface DOMStringList {
83
- contains(string: string): boolean
84
- }
85
-
86
- /**
87
- * IndexedDB 有效键类型
88
- */
89
- export type IDBValidKey = string | number | Date | ArrayBuffer | IDBValidKey[]
90
-
91
- /**
92
- * IndexedDB 事务模式类型
93
- */
94
- export type IDBTransactionMode = 'readonly' | 'readwrite' | 'versionchange'
95
-
96
- /**
97
- * IndexedDB 对象存储参数接口
98
- */
99
- export interface IDBObjectStoreParameters {
100
- keyPath?: string | string[]
101
- autoIncrement?: boolean
102
- }
103
-
104
- /**
105
- * 存储环境接口
106
- * 包含所有存储相关的环境 API
107
- */
108
- export interface StorageEnvironment {
109
- localStorage?: StorageInterface
110
- sessionStorage?: StorageInterface
111
- indexedDB?: IDBFactory
16
+ setItem(key: string, value: string): void
17
+ [name: string]: any
112
18
  }
@@ -34,13 +34,12 @@ export declare const setInterval: (callback: (...args: any[]) => void, ms?: numb
34
34
  export declare const clearInterval: (intervalId: any) => void
35
35
 
36
36
  /**
37
- * 定时器环境类型定义
37
+ * 定时器环境接口
38
+ * 包含所有定时器相关的 API
38
39
  */
39
- export interface TimerEnvironment {
40
+ export interface Timer {
40
41
  setTimeout: typeof setTimeout
41
42
  clearTimeout: typeof clearTimeout
42
43
  setInterval: typeof setInterval
43
44
  clearInterval: typeof clearInterval
44
- }
45
-
46
- // 定时器函数已在上面导出
45
+ }