clickgo 7.4.0 → 7.4.1

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.
@@ -21,19 +21,33 @@ export type { TTextEncoding, ITextEncoding, IDecodedText } from './tool/encoding
21
21
  * @returns 模块对象
22
22
  */
23
23
  export declare function runIife(code: string): any;
24
- /**
25
- * --- 压缩一个图片 ---
26
- * @param file 文件或 blob 类型 ---
27
- * @param options 参数
28
- */
29
- export declare function compressor<T extends File | Blob>(file: T, options?: {
24
+ /** --- 图片压缩参数,未指定大小上限时仅使用第一档质量 --- */
25
+ export interface ICompressorOptions {
30
26
  /** --- 最大宽度,默认无限 --- */
31
27
  'maxWidth'?: number;
32
28
  /** --- 最高高度,默认无限 --- */
33
29
  'maxHeight'?: number;
34
- /** --- 压缩质量,默认 0.8 --- */
35
- 'quality'?: number;
36
- }): Promise<T | false>;
30
+ /** --- 编码质量,取值 0 至 1,默认 0.8;数组按顺序尝试,仅 JPEG/WebP 支持调节质量 --- */
31
+ 'quality'?: number | readonly number[];
32
+ /** --- 输出格式,默认 auto 保留压缩器的自动选择;JPEG 的透明区域填白 --- */
33
+ 'mimeType'?: 'auto' | 'image/jpeg' | 'image/png' | 'image/webp';
34
+ /** --- 文件大小上限,单位字节,须为正有限数;各档都超限时返回 false,不再额外缩小尺寸或降质 --- */
35
+ 'maxSize'?: number;
36
+ }
37
+ /**
38
+ * --- 压缩图片,质量降档复用同一画布,保留方向校正及等比缩放 ---
39
+ * @param file 图片文件或 Blob;File 输入返回 File,转换格式时同步扩展名和 MIME 类型
40
+ * @param options 压缩参数
41
+ * @returns 压缩后的图片;参数无效、加载或编码失败、指定格式不受支持或无法满足大小上限时返回 false
42
+ * @example
43
+ * const image = await clickgo.tool.compressor(file, {
44
+ * 'mimeType': 'image/jpeg',
45
+ * 'maxWidth': 2000,
46
+ * 'quality': [0.9, 0.6, 0.5],
47
+ * 'maxSize': 2 * 1024 * 1024,
48
+ * });
49
+ */
50
+ export declare function compressor<T extends File | Blob>(file: T, options?: ICompressorOptions): Promise<T | false>;
37
51
  /** --- 类原型信息 --- */
38
52
  export interface IClassPrototype {
39
53
  /** --- 方法列表,key 为方法名,value 为函数体,例如:{'method1': function() { ... }} --- */