Comparing version 3.15.36 to 3.15.37
@@ -32,3 +32,3 @@ "use strict"; | ||
exports.hasFrame = hasFrame; | ||
const version = '3.15.36'; | ||
const version = '3.15.37'; | ||
function getVersion() { | ||
@@ -35,0 +35,0 @@ return version; |
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
const version = '3.15.36'; | ||
const version = '3.15.37'; | ||
export function getVersion(): string { | ||
@@ -19,0 +19,0 @@ return version; |
@@ -310,2 +310,18 @@ "use strict"; | ||
'resolve': [] | ||
}, | ||
'compressorjs': { | ||
func: function () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield loader.loadScripts([ | ||
loader.cdn + '/npm/compressorjs@1.2.1/dist/compressor.min.js' | ||
]); | ||
if (!window.Compressor) { | ||
throw Error('Compressor load failed.'); | ||
} | ||
return [window.Compressor]; | ||
}); | ||
}, | ||
'obj': null, | ||
'loading': false, | ||
'resolve': [] | ||
} | ||
@@ -312,0 +328,0 @@ }; |
@@ -364,2 +364,16 @@ /** | ||
'resolve': [] | ||
}, | ||
'compressorjs': { | ||
func: async function() { | ||
await loader.loadScripts([ | ||
loader.cdn + '/npm/compressorjs@1.2.1/dist/compressor.min.js' | ||
]); | ||
if (!(window as any).Compressor) { | ||
throw Error('Compressor load failed.'); | ||
} | ||
return [(window as any).Compressor]; | ||
}, | ||
'obj': null, | ||
'loading': false, | ||
'resolve': [] | ||
} | ||
@@ -366,0 +380,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -13,2 +36,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
exports.RANDOM_LUNS = exports.RANDOM_V = exports.RANDOM_LUN = exports.RANDOM_LU = exports.RANDOM_LN = exports.RANDOM_UN = exports.RANDOM_L = exports.RANDOM_U = exports.RANDOM_N = void 0; | ||
exports.compressor = compressor; | ||
exports.getClassPrototype = getClassPrototype; | ||
@@ -60,2 +84,29 @@ exports.blob2ArrayBuffer = blob2ArrayBuffer; | ||
exports.queryParse = queryParse; | ||
const core = __importStar(require("./core")); | ||
let compressorjs = null; | ||
function compressor(file_1) { | ||
return __awaiter(this, arguments, void 0, function* (file, options = {}) { | ||
if (!compressorjs) { | ||
try { | ||
compressorjs = yield core.getModule('compressorjs'); | ||
} | ||
catch (_a) { | ||
return false; | ||
} | ||
} | ||
return new Promise((resolve) => { | ||
new compressorjs(file, { | ||
'quality': options.quality, | ||
'maxWidth': options.maxWidth, | ||
'maxHeight': options.maxHeight, | ||
success: (result) => { | ||
resolve(result); | ||
}, | ||
error: () => { | ||
resolve(false); | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
function getClassPrototype(obj, over = [], level = 0) { | ||
@@ -62,0 +113,0 @@ var _a; |
@@ -17,3 +17,43 @@ /** | ||
import * as types from '../../types'; | ||
import * as core from './core'; | ||
/** --- compressorjs, mit --- */ | ||
let compressorjs: any = null; | ||
/** | ||
* --- 压缩一个图片 --- | ||
* @param file 文件或 blob 类型 --- | ||
* @param options 参数 | ||
*/ | ||
export async function compressor<T extends File | Blob>(file: T, options: { | ||
/** --- 最大宽度,默认无限 --- */ | ||
'maxWidth'?: number; | ||
/** --- 最高高度,默认无限 --- */ | ||
'maxHeight'?: number; | ||
/** --- 压缩质量,默认 0.8 --- */ | ||
'quality'?: number; | ||
} = {}): Promise<File | Blob | false> { | ||
if (!compressorjs) { | ||
try { | ||
compressorjs = await core.getModule('compressorjs'); | ||
} | ||
catch { | ||
return false; | ||
} | ||
} | ||
return new Promise((resolve) => { | ||
new compressorjs(file, { | ||
'quality': options.quality, | ||
'maxWidth': options.maxWidth, | ||
'maxHeight': options.maxHeight, | ||
success: (result: T) => { | ||
resolve(result); | ||
}, | ||
error: () => { | ||
resolve(false); | ||
} | ||
}); | ||
}); | ||
} | ||
interface IClassPrototype { | ||
@@ -20,0 +60,0 @@ 'method': Record<string, any>; |
{ | ||
"name": "clickgo", | ||
"version": "3.15.36", | ||
"version": "3.15.37", | ||
"description": "Background interface, software interface, mobile phone APP interface operation library.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -28,3 +28,3 @@ # ClickGo | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.7/dist/loader.min.js?path=index&npm={'clickgo':'3.15.36'}"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.7/dist/loader.min.js?path=index&npm={'clickgo':'3.15.37'}"></script> | ||
``` | ||
@@ -31,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4651731
35126