clickgo 4.0.0 → 4.0.2

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 (44) hide show
  1. package/dist/app/demo.cga +0 -0
  2. package/dist/app/task.cga +0 -0
  3. package/dist/clickgo.d.ts +128 -0
  4. package/dist/control/arteditor.cgc +0 -0
  5. package/dist/control/box.cgc +0 -0
  6. package/dist/control/captcha.cgc +0 -0
  7. package/dist/control/common.cgc +0 -0
  8. package/dist/control/desc.cgc +0 -0
  9. package/dist/control/drawer.cgc +0 -0
  10. package/dist/control/echarts.cgc +0 -0
  11. package/dist/control/form.cgc +0 -0
  12. package/dist/control/iconview.cgc +0 -0
  13. package/dist/control/jodit.cgc +0 -0
  14. package/dist/control/map.cgc +0 -0
  15. package/dist/control/monaco.cgc +0 -0
  16. package/dist/control/mpegts.cgc +0 -0
  17. package/dist/control/nav.cgc +0 -0
  18. package/dist/control/novnc.cgc +0 -0
  19. package/dist/control/page.cgc +0 -0
  20. package/dist/control/pdf.cgc +0 -0
  21. package/dist/control/property.cgc +0 -0
  22. package/dist/control/qrcode.cgc +0 -0
  23. package/dist/control/table.cgc +0 -0
  24. package/dist/control/task.cgc +0 -0
  25. package/dist/control/tplink.cgc +0 -0
  26. package/dist/control/tuieditor.cgc +0 -0
  27. package/dist/control/tuiviewer.cgc +0 -0
  28. package/dist/control/tums.cgc +0 -0
  29. package/dist/control/xterm.cgc +0 -0
  30. package/dist/index.js +1 -1
  31. package/dist/lib/control.d.ts +662 -0
  32. package/dist/lib/core.d.ts +337 -0
  33. package/dist/lib/dom.d.ts +491 -0
  34. package/dist/lib/form.d.ts +720 -0
  35. package/dist/lib/fs.d.ts +186 -0
  36. package/dist/lib/native.d.ts +134 -0
  37. package/dist/lib/storage.d.ts +39 -0
  38. package/dist/lib/task.d.ts +244 -0
  39. package/dist/lib/theme.d.ts +63 -0
  40. package/dist/lib/tool.d.ts +504 -0
  41. package/dist/lib/zip.d.ts +128 -0
  42. package/dist/theme/dark.cgt +0 -0
  43. package/dist/theme/light.cgt +0 -0
  44. package/package.json +1 -1
@@ -0,0 +1,504 @@
1
+ /**
2
+ * Copyright 2007-2025 MAIYUN.NET
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * --- 运行 iife 代码 ---
18
+ * @param code iife 代码
19
+ * @returns 模块对象
20
+ */
21
+ export declare function runIife(code: string): any;
22
+ /**
23
+ * --- 压缩一个图片 ---
24
+ * @param file 文件或 blob 类型 ---
25
+ * @param options 参数
26
+ */
27
+ export declare function compressor<T extends File | Blob>(file: T, options?: {
28
+ /** --- 最大宽度,默认无限 --- */
29
+ 'maxWidth'?: number;
30
+ /** --- 最高高度,默认无限 --- */
31
+ 'maxHeight'?: number;
32
+ /** --- 压缩质量,默认 0.8 --- */
33
+ 'quality'?: number;
34
+ }): Promise<File | Blob | false>;
35
+ interface IClassPrototype {
36
+ 'method': Record<string, any>;
37
+ 'access': Record<string, {
38
+ 'get': any;
39
+ 'set': any;
40
+ }>;
41
+ }
42
+ /**
43
+ * --- 获取 class 的所有 method 和 get/set ---
44
+ * @param obj 实例化 class 对象
45
+ * @param over 不传入此参数
46
+ * @param level 不传入此参数
47
+ */
48
+ export declare function getClassPrototype(obj: object, over?: string[], level?: number): IClassPrototype;
49
+ /**
50
+ * --- 将 blob 对象转换为 ArrayBuffer ---
51
+ * @param blob 对象
52
+ */
53
+ export declare function blob2ArrayBuffer(blob: Blob): Promise<ArrayBuffer>;
54
+ /**
55
+ * --- 将文件大小格式化为带单位的字符串 ---
56
+ * @param size 文件大小
57
+ * @param spliter 分隔符
58
+ */
59
+ export declare function sizeFormat(size: number, spliter?: string): string;
60
+ /**
61
+ * --- 将毫克重量格式化为带单位的字符串 ---
62
+ * @param weight 毫克重量
63
+ * @param spliter 分隔符
64
+ */
65
+ export declare function weightFormat(weight: number, spliter?: string): string;
66
+ /**
67
+ * --- 完整的克隆一份数组/对象 ---
68
+ * @param obj 要克隆的对象
69
+ */
70
+ export declare function clone<T>(obj: T): T;
71
+ /**
72
+ * --- 等待毫秒 ---
73
+ * @param ms 等待的毫秒,默认 0,最大 30 秒
74
+ */
75
+ export declare function sleep(ms?: number): Promise<boolean>;
76
+ /**
77
+ * --- 等待浏览器帧 ---
78
+ */
79
+ export declare function nextFrame(): Promise<void>;
80
+ /**
81
+ * --- 等待浏览器帧 ---
82
+ * @param count 等待帧数最高 10 帧
83
+ */
84
+ export declare function sleepFrame(count: number): Promise<void>;
85
+ /**
86
+ * --- 去除 html 的空白符、换行以及注释 ---
87
+ * @param text 要纯净的字符串
88
+ */
89
+ export declare function purify(text: string): string;
90
+ /**
91
+ * --- 传入正则进行匹配 str 是否有一项满足 ---
92
+ * @param str 要检测的字符串
93
+ * @param regs 正则列表
94
+ */
95
+ export declare function match(str: string, regs: RegExp[]): boolean;
96
+ /**
97
+ * --- 将 style 中的 url 转换成 base64 data url ---
98
+ * @param path 路径基准或以文件的路径为基准,以 / 结尾
99
+ * @param style 样式表
100
+ * @param files 在此文件列表中查找
101
+ */
102
+ export declare function styleUrl2DataUrl(path: string, style: string, files: Record<string, Blob | string>): Promise<string>;
103
+ /**
104
+ * --- 给标签增加 tag-tagname 的 class,同时给标签增加 cg- 前导(仅字符串,不是操作真实 dom) ---
105
+ * @param layout layout
106
+ * @param retagname 是否更改 tagname 为 cg-tagname
107
+ */
108
+ export declare function layoutAddTagClassAndReTagName(layout: string, retagname: boolean): string;
109
+ /**
110
+ * --- 给标签追加 attr,即使 attr 存在也会追加上一个新的(非真实 DOM 操作,仅仅是对字符串进行处理) ---
111
+ * @param layout 被追加
112
+ * @param insert 要追加
113
+ * @param opt 选项, ignore 忽略的标签,include 包含的标签
114
+ */
115
+ export declare function layoutInsertAttr(layout: string, insert: string, opt?: {
116
+ 'ignore'?: RegExp[];
117
+ 'include'?: RegExp[];
118
+ }): string;
119
+ /**
120
+ * --- 给 class 增加 scope 的随机前缀,给 id 新增前缀 ---
121
+ * @param layout layout
122
+ * @param preps 前置标识符列表,特殊字符串 scope 会被替换为随机前缀
123
+ */
124
+ export declare function layoutClassPrepend(layout: string, preps: string[]): string;
125
+ /**
126
+ * --- 对 layout 的 @events 事件进行包裹 ---
127
+ * @param layout 要包裹的 layout
128
+ */
129
+ export declare function eventsAttrWrap(layout: string): string;
130
+ /**
131
+ * --- 对 layout 的 teleport 做转义处理为 vue 识别的内容 ---
132
+ * @param layout 要处理的窗体或控件的 layout
133
+ * @param formId 要加入的 formId
134
+ */
135
+ export declare function teleportGlue(layout: string, formId: string): string;
136
+ /**
137
+ * --- 给 class 前部增加唯一标识符 ---
138
+ * @param style 样式内容
139
+ * @param prep 给 class、font 等增加前置
140
+ */
141
+ export declare function stylePrepend(style: string, prep?: string): {
142
+ 'style': string;
143
+ 'prep': string;
144
+ };
145
+ /**
146
+ * --- 根据后缀、文件名或路径获取 mime 类型(简单版,完整版请使用 @litert/mime.js) ---
147
+ * @param path 后缀、文件名或路径
148
+ */
149
+ export declare function getMimeByPath(path: string): {
150
+ 'mime': string;
151
+ 'ext': string;
152
+ };
153
+ /**
154
+ * --- 生成范围内的随机数 ---
155
+ * @param min 最新范围
156
+ * @param max 最大范围
157
+ */
158
+ export declare function rand(min: number, max: number): number;
159
+ export declare const RANDOM_N = "0123456789";
160
+ export declare const RANDOM_U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
161
+ export declare const RANDOM_L = "abcdefghijklmnopqrstuvwxyz";
162
+ export declare const RANDOM_UN: string;
163
+ export declare const RANDOM_LN: string;
164
+ export declare const RANDOM_LU: string;
165
+ export declare const RANDOM_LUN: string;
166
+ export declare const RANDOM_V = "ACEFGHJKLMNPRSTWXY34567";
167
+ export declare const RANDOM_LUNS: string;
168
+ /**
169
+ * --- 生成随机字符串 ---
170
+ * @param length 长度
171
+ * @param source 字符源
172
+ * @param block 剔除字符
173
+ * @returns 随机字符串
174
+ */
175
+ export declare function random(length?: number, source?: string, block?: string): string;
176
+ /**
177
+ * --- 根据参数获取最终的布尔值 ---
178
+ * @param param 参数
179
+ */
180
+ export declare function getBoolean(param: boolean | string | number | undefined): boolean;
181
+ /**
182
+ * --- 根据参数获取最终的数字型 ---
183
+ * @param param 参数
184
+ */
185
+ export declare function getNumber(param: string | number): number;
186
+ /**
187
+ * --- 根据参数获取最终的数组型,可传入类似 [1,2,3] 或 1,2,3 ---
188
+ * @param param 参数
189
+ */
190
+ export declare function getArray(param: string | any[]): any[];
191
+ /**
192
+ * --- 转义 HTML ---
193
+ * @param html HTML 字符
194
+ */
195
+ export declare function escapeHTML(html: string): string;
196
+ /**
197
+ * --- 将 rgb 或 hsl 等颜色转换为数字数组 ---
198
+ * @param color 颜色字符串
199
+ */
200
+ export declare function formatColor(color: string): number[];
201
+ /**
202
+ * --- 将 r, g, b 转换为 hex 字符串,不含 # ---
203
+ * @param r r 或 rgb 用 , 分隔的字符串
204
+ * @param g 可留空,g
205
+ * @param b 可留空,b
206
+ */
207
+ export declare function rgb2hex(r: string | number, g?: string | number, b?: string | number, a?: string | number): string;
208
+ /**
209
+ * --- hex 转换为 rgba,#27ae60ff, 27ae60 #fff
210
+ * @param hex hex 字符串,无所谓带不带 #
211
+ */
212
+ export declare function hex2rgb(hex: string): {
213
+ 'r': number;
214
+ 'g': number;
215
+ 'b': number;
216
+ 'a': number;
217
+ 'rgb': string;
218
+ };
219
+ /**
220
+ * --- rgb 字符串转 hsl 数组 ---
221
+ * @param rgb rgb(x, x, x) 或直接 x,x,x
222
+ */
223
+ export declare function rgb2hsl(r: string | number, g?: string | number, b?: string | number, a?: string | number, decimal?: boolean): {
224
+ 'h': number;
225
+ 's': number;
226
+ 'l': number;
227
+ 'a': number;
228
+ 'hsl': string;
229
+ };
230
+ /**
231
+ * --- hsl 字符串转 rgb 数组 ---
232
+ * @param hsl hsl(x, x, x) 或直接 x,x,x
233
+ */
234
+ export declare function hsl2rgb(h: string | number, s?: string | number, l?: string | number, a?: string | number, decimal?: boolean): {
235
+ 'r': number;
236
+ 'g': number;
237
+ 'b': number;
238
+ 'a': number;
239
+ 'rgb': string;
240
+ };
241
+ /**
242
+ * --- 发起一个网络请求,若是返回值是 JSON 则自动解析,否则直接返回字符串 ---
243
+ * @param url 网址
244
+ * @param opt 选项
245
+ */
246
+ export declare function request(url: string, opt: IRequestOptions): Promise<null | any>;
247
+ /**
248
+ * --- 发起 fetch 请求 ---
249
+ * @param url 网址
250
+ * @param init 选项
251
+ * @returns 文本或二进制数据,失败时返回 null
252
+ */
253
+ export declare function fetch(url: string, init?: RequestInit): Promise<string | Blob | null>;
254
+ /**
255
+ * --- 发起 GET 请求 ---
256
+ * @param url 网址
257
+ * @param init 选项
258
+ * @param opt 选项
259
+ * @returns 文本或二进制数据,失败时返回 null
260
+ */
261
+ export declare function get(url: string, init?: RequestInit, opt?: {
262
+ /** --- 重试次数,默认 3 次 --- */
263
+ 'retry'?: number;
264
+ }): Promise<string | Blob | null>;
265
+ /**
266
+ * --- 发起 POST 请求 ---
267
+ * @param url 网址
268
+ * @param data 数据
269
+ * @param init 选项
270
+ * @returns 文本或二进制数据,失败时返回 null
271
+ */
272
+ export declare function post(url: string, data: Record<string, any> | FormData, init?: RequestInit): Promise<string | Blob | null>;
273
+ /**
274
+ * --- 发起 GET 请求并解析 JSON 响应 ---
275
+ * @param url 网址
276
+ * @param init 选项
277
+ * @returns JSON 数据,失败时返回 null
278
+ */
279
+ export declare function getResponseJson(url: string, init?: RequestInit): Promise<any | null>;
280
+ /**
281
+ * --- 发起 POST 请求并解析 JSON 响应 ---
282
+ * @param url 网址
283
+ * @param data 数据
284
+ * @param init 选项
285
+ * @returns JSON 数据,失败时返回 null
286
+ */
287
+ export declare function postResponseJson(url: string, data: Record<string, any> | FormData, init?: RequestInit): Promise<any | null>;
288
+ /**
289
+ * --- 传输 url 并解析为 IUrl 对象 ---
290
+ * @param url url 字符串
291
+ */
292
+ export declare function parseUrl(url: string): IUrl;
293
+ /**
294
+ * --- 将相对路径根据基准路径进行转换 ---
295
+ * @param from 基准路径
296
+ * @param to 相对路径
297
+ */
298
+ export declare function urlResolve(from: string, to: string): string;
299
+ /** --- 处理 URL 中的 .. / . 等 --- */
300
+ export declare function urlAtom(url: string): string;
301
+ /**
302
+ * --- 将 blob 对象转换为 text ---
303
+ * @param blob 对象
304
+ */
305
+ export declare function blob2Text(blob: Blob): Promise<string>;
306
+ /**
307
+ * --- 将 blob 对象转换为 base64 url ---
308
+ * @param blob 对象
309
+ */
310
+ export declare function blob2DataUrl(blob: Blob): Promise<string>;
311
+ export declare function execCommand(ac: string): void;
312
+ /**
313
+ * ---- 对比老值和新值,看看新值中哪些移除了,哪些新增了 ---
314
+ * @param before 老值
315
+ * @param after 新值
316
+ */
317
+ export declare function compar(before: Array<string | number>, after: Array<string | number>): {
318
+ 'remove': Record<string, number>;
319
+ 'add': Record<string, number>;
320
+ 'length': {
321
+ 'remove': number;
322
+ 'add': number;
323
+ };
324
+ };
325
+ /** --- 将秒数格式化为 0:0:0 的字符串 --- */
326
+ export declare function formatSecond(second: number): string;
327
+ /**
328
+ * --- 将日期对象或毫秒级时间戳转换为字符串 ---
329
+ * @param ts 时间戳或日期对象
330
+ * @param tz 传入要显示的时区,小时,如 8,默认以当前客户端时区为准
331
+ */
332
+ export declare function formatTime(ts: number | Date, tz?: number): {
333
+ 'date': string;
334
+ 'time': string;
335
+ 'zone': string;
336
+ };
337
+ /**
338
+ * --- 是否是毫秒 ---
339
+ * @param time 要判断的时间戳
340
+ */
341
+ export declare function isMs(time: number): boolean;
342
+ /**
343
+ * --- 将对象转换为 query string ---
344
+ * @param query 要转换的对象
345
+ * @param encode 是否转义
346
+ */
347
+ export declare function queryStringify(query: Record<string, any>, encode?: boolean): string;
348
+ /**
349
+ * --- 将 query string 转换为对象 ---
350
+ * @param query 要转换的字符串
351
+ */
352
+ export declare function queryParse(query: string): Record<string, string | string[]>;
353
+ /**
354
+ * --- 转义字符检查 ---
355
+ * 检查指定位置的字符是否被转义
356
+ * @param str 字符串
357
+ * @param pos 检查位置
358
+ * @returns 是否被转义
359
+ */
360
+ export declare function isEscaped(str: string, pos: number): boolean;
361
+ /**
362
+ * --- 数组字符串解析器 ---
363
+ * 解析数组字符串为各元素组成的字符串数组
364
+ * @param arrayStr 数组字符串
365
+ * @returns 解析后的字符串数组
366
+ */
367
+ export declare function parseArrayString(arrayStr: string): string[];
368
+ /**
369
+ * --- 判断字符是否是转义字符 ---
370
+ * @param code 字符串
371
+ * @param index 字符在字符串中的位置
372
+ * @returns 是否是转义字符
373
+ */
374
+ export declare function isEscapeChar(code: string, index: number): boolean;
375
+ /** --- 状态机状态 --- */
376
+ export declare enum ESTATE {
377
+ /** --- 普通 --- */
378
+ 'NORMAL' = 0,
379
+ /** --- 单词 --- */
380
+ 'WORD' = 1,
381
+ /** --- 字符串 --- */
382
+ 'STRING' = 2,
383
+ /** --- 正则 --- */
384
+ 'REG' = 3,
385
+ /** --- 注释 --- */
386
+ 'COMMENT' = 4
387
+ }
388
+ /**
389
+ * --- 状态机 ---
390
+ * @param code 代码
391
+ * @param start 开始位置
392
+ * @param process 处理函数
393
+ * @returns 是否继续
394
+ */
395
+ export declare function stateMachine(code: string, start: number, process: (event: {
396
+ 'state': ESTATE;
397
+ 'start': number;
398
+ 'end': number;
399
+ 'word': string;
400
+ 'pre': {
401
+ 'state': ESTATE;
402
+ 'word': string;
403
+ 'nonnull': string;
404
+ };
405
+ 'bracket': {
406
+ 's': number;
407
+ 'm': number;
408
+ 'l': number;
409
+ };
410
+ }) => boolean): void;
411
+ /**
412
+ * --- 加载脚本 ---
413
+ * @param url 脚本网址
414
+ */
415
+ export declare function loadScript(url: string): Promise<boolean>;
416
+ /**
417
+ * --- 批量加载 js 文件 ---
418
+ * @param urls js 文件列表
419
+ * @param opt 选项
420
+ */
421
+ export declare function loadScripts(urls: string[], opt?: {
422
+ 'loaded'?: (url: string, state: number) => void;
423
+ }): Promise<void>;
424
+ /**
425
+ * --- 加载 css 文件 ---
426
+ * @param url css 文件网址
427
+ * @returns 加载是否成功
428
+ */
429
+ export declare function loadLink(url: string): Promise<boolean>;
430
+ /**
431
+ * --- 批量加载 css 文件 ---
432
+ * @param urls css 文件列表
433
+ * @param opt 选项
434
+ */
435
+ export declare function loadLinks(urls: string[], opt?: {
436
+ 'loaded'?: (url: string, state: number) => void;
437
+ }): Promise<void>;
438
+ /**
439
+ * --- 加载 css 字符串 ---
440
+ * @param style css 字符串
441
+ */
442
+ export declare function loadStyle(style: string): void;
443
+ /**
444
+ * --- 判断一个值是否是虚假的(为 null/undefined/空字符串/false/0) ---
445
+ * @param val 要判断的值
446
+ */
447
+ export declare function isFalsy(val: any): val is TFalsy;
448
+ /**
449
+ * --- 判断一个值是否是真实的(不为 null/undefined/空字符串/false/0) ---
450
+ * @param val 要判断的值
451
+ */
452
+ export declare function isTruthy(val: any): val is Exclude<typeof val, TFalsy>;
453
+ /**
454
+ * --- 类似 || 运算符的效果 ---
455
+ * @param v1 比对值
456
+ * @param v2 比对值
457
+ */
458
+ export declare function logicalOr<T, T2>(v1: T, v2: T2): [T] extends [TFalsy] ? T2 : T;
459
+ /** --- 语言相关 --- */
460
+ export declare const lang: {
461
+ /** --- 语言代号 --- */
462
+ 'codes': string[];
463
+ /** --- 语言名称 --- */
464
+ 'names': string[];
465
+ /** --- 浏览器常用映射为本语言 --- */
466
+ 'map': Record<string, string>;
467
+ /**
468
+ * --- 根据常用语言字符串获取语言 code ---
469
+ * @param accept 常用字符串,如 zh-cn,或包含 zh-cn 的字符串,默认取浏览器的语言
470
+ */
471
+ getCodeByAccept: (accept?: string) => string;
472
+ };
473
+ /** --- 网址对象 --- */
474
+ export interface IUrl {
475
+ 'auth': string | null;
476
+ 'hash': string | null;
477
+ 'host': string | null;
478
+ 'hostname': string | null;
479
+ 'pass': string | null;
480
+ 'path': string | null;
481
+ 'pathname': string;
482
+ 'protocol': string | null;
483
+ 'port': string | null;
484
+ 'query': string | null;
485
+ 'user': string | null;
486
+ }
487
+ export interface IRequestOptions {
488
+ 'credentials'?: boolean;
489
+ 'method'?: 'GET' | 'POST';
490
+ 'body'?: FormData;
491
+ 'timeout'?: number;
492
+ 'responseType'?: XMLHttpRequestResponseType;
493
+ 'headers'?: HeadersInit;
494
+ 'uploadStart'?: (total: number) => void | Promise<void>;
495
+ 'uploadProgress'?: (loaded: number, total: number) => void | Promise<void>;
496
+ 'uploadEnd'?: () => void | Promise<void>;
497
+ 'start'?: (total: number) => void | Promise<void>;
498
+ 'end'?: () => void | Promise<void>;
499
+ 'progress'?: (loaded: number, total: number) => void | Promise<void>;
500
+ 'load'?: (res: any) => void | Promise<void>;
501
+ 'error'?: () => void | Promise<void>;
502
+ }
503
+ export type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
504
+ export {};
@@ -0,0 +1,128 @@
1
+ import jszip from 'jszip';
2
+ export declare class Zip {
3
+ /** --- zip 对象 --- */
4
+ private readonly _zip;
5
+ /** --- 当前路径,以 / 开头以 / 结尾 --- */
6
+ private _path;
7
+ constructor(zip: jszip);
8
+ getContent(path: string): Promise<string | null>;
9
+ getContent<T extends TZipOutputType>(path: string, type: T): Promise<IZipOutputByType[T] | null>;
10
+ /**
11
+ * --- 写入文件内容 ---
12
+ * @param path 文件路径
13
+ * @param data 要写入的内容
14
+ * @param options 选项
15
+ */
16
+ putContent<T extends TZipInputType>(path: string, data: IZipInputByType[T], options?: {
17
+ 'base64'?: boolean;
18
+ 'binary'?: boolean;
19
+ 'date'?: Date;
20
+ }): void;
21
+ /**
22
+ * --- 删除一个文件/文件夹(深度删除) ---
23
+ * @param path 要删除的文件路径
24
+ */
25
+ unlink(path: string): void;
26
+ /**
27
+ * --- 获取对象是否存在,存在则返回 stats 对象,否则返回 null ---
28
+ * @param path 对象路径
29
+ * @param options 选项
30
+ */
31
+ stats(path: string): IZipStats | null;
32
+ /**
33
+ * --- 判断是否是目录或目录是否存在,是的话返回 stats ---
34
+ * @param path 判断路径
35
+ */
36
+ isDir(path: string): IZipStats | false;
37
+ /**
38
+ * --- 判断是否是文件或文件是否存在,是的话返回 stats ---
39
+ * @param path 判断路径
40
+ */
41
+ isFile(path: string): IZipStats | false;
42
+ /** --- 读取目录,hasChildren: false, hasDir: true, pathAsKey: false --- */
43
+ readDir(path?: string, opt?: {
44
+ 'hasChildren'?: boolean;
45
+ 'hasDir'?: boolean;
46
+ 'pathAsKey'?: false;
47
+ }): IZipItem[];
48
+ readDir(path?: string, opt?: {
49
+ 'hasChildren'?: boolean;
50
+ 'hasDir'?: boolean;
51
+ 'pathAsKey': true;
52
+ }): Record<string, IZipItem>;
53
+ private _readDir;
54
+ /** --- 目录列表缓存 --- */
55
+ private _list;
56
+ /**
57
+ * --- 重建目录列表缓存 ---
58
+ */
59
+ private _refreshList;
60
+ /**
61
+ * --- 获取当前目录,末尾不带 / ---
62
+ * @return string
63
+ */
64
+ pwd(): string;
65
+ /**
66
+ * --- 进入一个目录(不存在也能进入,需要自行判断) ---
67
+ * --- 返回进入后的路径值 ---
68
+ * @param dir 相对路径或绝对路径
69
+ */
70
+ cd(dir: string): string;
71
+ /**
72
+ * --- 打包 zip ---
73
+ * @param options 选项
74
+ */
75
+ generate<T extends TZipOutputType>(options?: {
76
+ 'type'?: T;
77
+ 'level'?: number;
78
+ 'onUpdate'?: (percent: number, currentFile: string | null) => void;
79
+ }): Promise<IZipOutputByType[T]>;
80
+ /**
81
+ * --- 获取 path 和 string/Blob 对应的文件列表 ---
82
+ */
83
+ getList(): Promise<Record<string, Blob | string>>;
84
+ }
85
+ /**
86
+ * --- 获取 zip 对象 ---
87
+ * @param data 对象数据
88
+ */
89
+ export declare function get(data?: TZipInputFileFormat): Promise<Zip | null>;
90
+ export interface IZipItem {
91
+ 'name': string;
92
+ 'compressedSize': number;
93
+ 'uncompressedSize': number;
94
+ 'date': Date;
95
+ 'isFile': boolean;
96
+ 'isDirectory': boolean;
97
+ 'path': string;
98
+ }
99
+ export interface IZipStats {
100
+ 'compressedSize': number;
101
+ 'uncompressedSize': number;
102
+ 'date': Date;
103
+ 'isFile': boolean;
104
+ 'isDirectory': boolean;
105
+ }
106
+ export interface IZipOutputByType {
107
+ 'base64': string;
108
+ 'string': string;
109
+ 'array': number[];
110
+ 'uint8array': Uint8Array;
111
+ 'arraybuffer': ArrayBuffer;
112
+ 'blob': Blob;
113
+ }
114
+ export type TZipOutputType = keyof IZipOutputByType;
115
+ export interface IZipInputByType {
116
+ 'base64': string;
117
+ 'string': string;
118
+ 'array': number[];
119
+ 'uint8array': Uint8Array;
120
+ 'arraybuffer': ArrayBuffer;
121
+ 'blob': Blob;
122
+ }
123
+ export type TZipInputType = keyof IZipInputByType;
124
+ export type TZipInputFileFormat = IZipInputByType[keyof IZipInputByType];
125
+ export interface IZipMetadata {
126
+ percent: number;
127
+ currentFile: string | null;
128
+ }
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Background interface, software interface, mobile phone APP interface operation library.",
5
5
  "type": "module",
6
6
  "keywords": [