zcw-shared 1.14.0 → 1.16.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.
- package/dist/functions/image/compressToTargetSize.d.ts +6 -0
- package/dist/functions/image/compressToTargetSize.js +107 -0
- package/dist/functions/image/compressToTargetSize.js.map +1 -0
- package/dist/functions/ipc/dispatchIpcRequest.d.ts +11 -1
- package/dist/functions/ipc/dispatchIpcRequest.js +20 -7
- package/dist/functions/ipc/dispatchIpcRequest.js.map +1 -1
- package/dist/functions/tencent-cloud/deploy.tcb.d.ts +3 -0
- package/dist/functions/tencent-cloud/deploy.tcb.js +47 -0
- package/dist/functions/tencent-cloud/deploy.tcb.js.map +1 -0
- package/dist/functions/tencent-cloud/getSecret.d.ts +4 -6
- package/dist/functions/tencent-cloud/getSecret.js +1 -0
- package/dist/functions/tencent-cloud/getSecret.js.map +1 -1
- package/dist/functions/version/incrementVersion.d.ts +3 -0
- package/dist/functions/version/incrementVersion.js +57 -0
- package/dist/functions/version/incrementVersion.js.map +1 -0
- package/dist/functions/version/parseVersion.d.ts +4 -0
- package/dist/functions/version/parseVersion.js +35 -0
- package/dist/functions/version/parseVersion.js.map +1 -0
- package/package.json +13 -3
- package/references/browser.d.ts +23 -1
- package/references/dom.d.ts +20 -0
- package/references/tencent-cloud.d.ts +65 -0
- package/types/semver.d.ts +68 -0
- package/types/tencent-cloud.d.ts +44 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export async function compressToTargetSize(file, options = {}, window) {
|
|
2
|
+
const { targetSize = 30 * 1024, maxIterations = 30, mimeType = 'image/jpeg' } = options;
|
|
3
|
+
if (file.size <= targetSize) {
|
|
4
|
+
return file;
|
|
5
|
+
}
|
|
6
|
+
const dimensions = await getImageDimensions(file, window);
|
|
7
|
+
let currentWidth = dimensions.width;
|
|
8
|
+
let currentHeight = dimensions.height;
|
|
9
|
+
let currentQuality = 0.9;
|
|
10
|
+
let iteration = 0;
|
|
11
|
+
async function attemptCompress() {
|
|
12
|
+
iteration++;
|
|
13
|
+
if (iteration > maxIterations) {
|
|
14
|
+
throw new Error(`压缩失败:达到最大尝试次数(${maxIterations}),仍未达到目标大小`);
|
|
15
|
+
}
|
|
16
|
+
const result = await compressImage(file, {
|
|
17
|
+
quality: currentQuality,
|
|
18
|
+
maxWidth: currentWidth,
|
|
19
|
+
maxHeight: currentHeight,
|
|
20
|
+
mimeType
|
|
21
|
+
}, window);
|
|
22
|
+
if (result.size <= targetSize) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const ratio = targetSize / result.size;
|
|
26
|
+
if (ratio < 0.05) {
|
|
27
|
+
currentWidth = Math.max(50, Math.floor(currentWidth * 0.5));
|
|
28
|
+
currentHeight = Math.max(50, Math.floor(currentHeight * 0.5));
|
|
29
|
+
currentQuality = Math.max(0.05, currentQuality * 0.5);
|
|
30
|
+
}
|
|
31
|
+
else if (ratio < 0.15) {
|
|
32
|
+
currentWidth = Math.max(80, Math.floor(currentWidth * 0.6));
|
|
33
|
+
currentHeight = Math.max(80, Math.floor(currentHeight * 0.6));
|
|
34
|
+
currentQuality = Math.max(0.08, currentQuality * 0.6);
|
|
35
|
+
}
|
|
36
|
+
else if (ratio < 0.3) {
|
|
37
|
+
currentWidth = Math.max(100, Math.floor(currentWidth * 0.7));
|
|
38
|
+
currentHeight = Math.max(100, Math.floor(currentHeight * 0.7));
|
|
39
|
+
currentQuality = Math.max(0.1, currentQuality * 0.8);
|
|
40
|
+
}
|
|
41
|
+
else if (ratio < 0.7) {
|
|
42
|
+
currentWidth = Math.max(100, Math.floor(currentWidth * 0.85));
|
|
43
|
+
currentHeight = Math.max(100, Math.floor(currentHeight * 0.85));
|
|
44
|
+
currentQuality = Math.max(0.1, currentQuality * 0.85);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
currentQuality = Math.max(0.1, currentQuality * 0.9);
|
|
48
|
+
}
|
|
49
|
+
return attemptCompress();
|
|
50
|
+
}
|
|
51
|
+
return attemptCompress();
|
|
52
|
+
}
|
|
53
|
+
async function getImageDimensions(file, window) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const img = new window.Image();
|
|
56
|
+
img.onload = () => {
|
|
57
|
+
resolve({
|
|
58
|
+
width: img.naturalWidth,
|
|
59
|
+
height: img.naturalHeight
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
img.onerror = () => {
|
|
63
|
+
reject(new Error('获取图片尺寸失败'));
|
|
64
|
+
};
|
|
65
|
+
img.src = window.URL.createObjectURL(file);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function compressImage(file, options, window) {
|
|
69
|
+
const { quality, maxWidth, maxHeight, mimeType } = options;
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const img = new window.Image();
|
|
72
|
+
img.onload = () => {
|
|
73
|
+
const canvas = window.document.createElement('canvas');
|
|
74
|
+
let width = img.naturalWidth;
|
|
75
|
+
let height = img.naturalHeight;
|
|
76
|
+
if (width > maxWidth || height > maxHeight) {
|
|
77
|
+
const ratio = Math.min(maxWidth / width, maxHeight / height);
|
|
78
|
+
width = Math.floor(width * ratio);
|
|
79
|
+
height = Math.floor(height * ratio);
|
|
80
|
+
}
|
|
81
|
+
canvas.width = width;
|
|
82
|
+
canvas.height = height;
|
|
83
|
+
const ctx = canvas.getContext('2d');
|
|
84
|
+
if (!ctx) {
|
|
85
|
+
reject(new Error('无法创建canvas上下文'));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
89
|
+
canvas.toBlob((blob) => {
|
|
90
|
+
if (!blob) {
|
|
91
|
+
reject(new Error('图片压缩失败'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const newFile = new window.File([blob], file.name, {
|
|
95
|
+
type: mimeType,
|
|
96
|
+
lastModified: Date.now()
|
|
97
|
+
});
|
|
98
|
+
resolve(newFile);
|
|
99
|
+
}, mimeType, quality);
|
|
100
|
+
};
|
|
101
|
+
img.onerror = () => {
|
|
102
|
+
reject(new Error('图片加载失败'));
|
|
103
|
+
};
|
|
104
|
+
img.src = window.URL.createObjectURL(file);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=compressToTargetSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressToTargetSize.js","sourceRoot":"","sources":["../../../src/functions/image/compressToTargetSize.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAU,EACV,UAII,EAAE,EACN,MAAc;IAEd,MAAM,EACJ,UAAU,GAAG,EAAE,GAAG,IAAI,EACtB,aAAa,GAAG,EAAE,EAClB,QAAQ,GAAG,YAAY,EACxB,GAAG,OAAO,CAAA;IAGX,IAAI,IAAI,CAAC,IAAI,IAAI,UAAU,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAGD,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACzD,IAAI,YAAY,GAAG,UAAU,CAAC,KAAK,CAAA;IACnC,IAAI,aAAa,GAAG,UAAU,CAAC,MAAM,CAAA;IACrC,IAAI,cAAc,GAAG,GAAG,CAAA;IACxB,IAAI,SAAS,GAAG,CAAC,CAAA;IAGjB,KAAK,UAAU,eAAe;QAC5B,SAAS,EAAE,CAAA;QAEX,IAAI,SAAS,GAAG,aAAa,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,iBAAiB,aAAa,YAAY,CAAC,CAAA;QAC7D,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE;YACvC,OAAO,EAAE,cAAc;YACvB,QAAQ,EAAE,YAAY;YACtB,SAAS,EAAE,aAAa;YACxB,QAAQ;SACT,EAAE,MAAM,CAAC,CAAA;QAGV,IAAI,MAAM,CAAC,IAAI,IAAI,UAAU,EAA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AQ,CAAC,CAAC,CAAA;oBAC3B,OAAM;gBACR,CAAC;gBAED,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE;oBACjD,IAAI,EAAE,QAAQ;oBACd,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;iBACzB,CAAC,CAAA;gBACF,OAAO,CAAC,OAAO,CAAC,CAAA;YAClB,CAAC,EACD,QAAQ,EACR,OAAO,CACR,CAAA;QACH,CAAC,CAAA;QACD,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;YACjB,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC7B,CAAC,CAAA;QACD,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -3,4 +3,14 @@ export interface IpcRequest {
|
|
|
3
3
|
event: string;
|
|
4
4
|
args: any;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export interface IpcHandlerMap {
|
|
7
|
+
[eventName: string]: {
|
|
8
|
+
default: (...args: any[]) => any | Promise<any>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function dispatchIpcRequest(req: IpcRequest, options: {
|
|
12
|
+
handlerMap: IpcHandlerMap;
|
|
13
|
+
} | {
|
|
14
|
+
functionsDir: string;
|
|
15
|
+
path: Path;
|
|
16
|
+
}): Promise<any>;
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
export async function dispatchIpcRequest(req,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export async function dispatchIpcRequest(req, options) {
|
|
2
|
+
if ('handlerMap' in options) {
|
|
3
|
+
const module = options.handlerMap[req.event];
|
|
4
|
+
if (!module) {
|
|
5
|
+
throw new Error(`Handler not found for event: ${req.event}`);
|
|
6
|
+
}
|
|
7
|
+
if (typeof module.default !== 'function') {
|
|
8
|
+
throw new Error(`Handler for event '${req.event}' is not a function`);
|
|
9
|
+
}
|
|
10
|
+
return await module.default(req.args);
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
if ('functionsDir' in options && 'path' in options) {
|
|
13
|
+
const funcPath = options.path.resolve(options.functionsDir, req.event);
|
|
14
|
+
const mod = await import(funcPath);
|
|
15
|
+
if (typeof mod.default !== 'function') {
|
|
16
|
+
throw new Error('Handler not found or handler is not a function');
|
|
17
|
+
}
|
|
18
|
+
const data = await mod.default(req.args);
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Invalid options: must provide either handlerMap or functionsDir with path');
|
|
9
22
|
}
|
|
10
23
|
//# sourceMappingURL=dispatchIpcRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatchIpcRequest.js","sourceRoot":"","sources":["../../../src/functions/ipc/dispatchIpcRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatchIpcRequest.js","sourceRoot":"","sources":["../../../src/functions/ipc/dispatchIpcRequest.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAe,EACf,OAEwC;IAGxC,IAAI,YAAY,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,CAAC,KAAK,qBAAqB,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAGD,IAAI,cAAc,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;QACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export async function deployToTCB(options, dependencies) {
|
|
2
|
+
const { localPath, cloudPath = '/', envId, secretType, showProgress = true } = options;
|
|
3
|
+
const { cloudBase, path, fs, console, getSecret } = dependencies;
|
|
4
|
+
try {
|
|
5
|
+
if (!fs.existsSync(localPath)) {
|
|
6
|
+
return {
|
|
7
|
+
success: false,
|
|
8
|
+
error: `本地路径不存在: ${localPath}`
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const secret = getSecret(secretType);
|
|
12
|
+
if (!secret || !secret.secretId || !secret.secretKey) {
|
|
13
|
+
return {
|
|
14
|
+
success: false,
|
|
15
|
+
error: `无效的密钥类型: ${secretType}`
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const app = cloudBase.init({
|
|
19
|
+
secretId: secret.secretId,
|
|
20
|
+
secretKey: secret.secretKey,
|
|
21
|
+
envId
|
|
22
|
+
});
|
|
23
|
+
const hosting = app.hosting;
|
|
24
|
+
await hosting.uploadFiles({
|
|
25
|
+
localPath,
|
|
26
|
+
cloudPath,
|
|
27
|
+
onProgress: showProgress ? (progressData) => {
|
|
28
|
+
console.log(`上传进度: ${progressData.percent}%`);
|
|
29
|
+
} : undefined
|
|
30
|
+
});
|
|
31
|
+
console.log('文件上传成功');
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
message: '部署成功'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
39
|
+
console.error('部署失败:', error);
|
|
40
|
+
return {
|
|
41
|
+
success: false,
|
|
42
|
+
error: `部署失败: ${errorMessage}`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export default deployToTCB;
|
|
47
|
+
//# sourceMappingURL=deploy.tcb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.tcb.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/deploy.tcb.ts"],"names":[],"mappings":"AAwCA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAsB,EACtB,YAAgC;IAEhC,MAAM,EACJ,SAAS,EACT,SAAS,GAAG,GAAG,EACf,KAAK,EACL,UAAU,EACV,YAAY,GAAG,IAAI,EACpB,GAAG,OAAO,CAAA;IAEX,MAAM,EACJ,SAAS,EACT,IAAI,EACJ,EAAE,EACF,OAAO,EACP,SAAS,EACV,GAAG,YAAY,CAAA;IAEhB,IAAI,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,YAAY,SAAS,EAAE;aAC/B,CAAA;QACH,CAAC;QAGD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;QACpC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,I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1
|
+
import type { TencentCloudSecret } from '../../../references/tencent-cloud.d';
|
|
2
|
+
import type { SecretType } from '../../../types/tencent-cloud.d';
|
|
3
|
+
export declare function getSecret(type: SecretType): TencentCloudSecret;
|
|
4
|
+
export default getSecret;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSecret.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/getSecret.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSecret.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/getSecret.ts"],"names":[],"mappings":"AAIA,MAAM,SAAS,GAA2C;IACxD,QAAQ,EAAE;QAER,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;CACF,CAAA;AAoCD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAKD,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { parseVersion, stringifyVersion } from './parseVersion';
|
|
2
|
+
export function incrementVersion(currentVersion, type, prerelease) {
|
|
3
|
+
const version = parseVersion(currentVersion);
|
|
4
|
+
switch (type) {
|
|
5
|
+
case 'major':
|
|
6
|
+
return stringifyVersion({
|
|
7
|
+
major: version.major + 1,
|
|
8
|
+
minor: 0,
|
|
9
|
+
patch: 0
|
|
10
|
+
});
|
|
11
|
+
case 'minor':
|
|
12
|
+
return stringifyVersion({
|
|
13
|
+
major: version.major,
|
|
14
|
+
minor: version.minor + 1,
|
|
15
|
+
patch: 0
|
|
16
|
+
});
|
|
17
|
+
case 'patch':
|
|
18
|
+
return stringifyVersion({
|
|
19
|
+
major: version.major,
|
|
20
|
+
minor: version.minor,
|
|
21
|
+
patch: version.patch + 1
|
|
22
|
+
});
|
|
23
|
+
case 'prerelease':
|
|
24
|
+
if (!prerelease) {
|
|
25
|
+
throw new Error('预发布版本需要指定 prerelease 标识符');
|
|
26
|
+
}
|
|
27
|
+
if (version.prerelease) {
|
|
28
|
+
const match = version.prerelease.match(/^(.+?)\.(\d+)$/);
|
|
29
|
+
if (match && match[1] === prerelease) {
|
|
30
|
+
const prereleaseNumber = parseInt(match[2], 10) + 1;
|
|
31
|
+
return stringifyVersion({
|
|
32
|
+
...version,
|
|
33
|
+
prerelease: `${prerelease}.${prereleaseNumber}`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return stringifyVersion({
|
|
38
|
+
major: version.major,
|
|
39
|
+
minor: version.minor,
|
|
40
|
+
patch: version.patch + 1,
|
|
41
|
+
prerelease: `${prerelease}.0`
|
|
42
|
+
});
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`不支持的版本类型: ${type}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function suggestVersionType(changes) {
|
|
48
|
+
const changeText = changes.join(' ').toLowerCase();
|
|
49
|
+
if (changeText.includes('breaking') || changeText.includes('major')) {
|
|
50
|
+
return 'major';
|
|
51
|
+
}
|
|
52
|
+
if (changeText.includes('feat') || changeText.includes('feature') || changeText.includes('add')) {
|
|
53
|
+
return 'minor';
|
|
54
|
+
}
|
|
55
|
+
return 'patch';
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=incrementVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incrementVersion.js","sourceRoot":"","sources":["../../../src/functions/version/incrementVersion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAU/D,MAAM,UAAU,gBAAgB,CAC9B,cAAsB,EACtB,IAAiB,EACjB,UAAmB;IAEnB,MAAM,OAAO,G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CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;gBACxB,UAAU,EAAE,GAAG,UAAU,IAAI;aAC9B,CAAC,CAAA;QAEJ;YACE,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;AACH,CAAC;AAQD,MAAM,UAAU,kBAAkB,CAAC,OAAiB;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAGlD,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpE,OAAO,OAAO,CAAA;IAChB,CAAC;IAGD,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChG,OAAO,OAAO,CAAA;IAChB,CAAC;IAGD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function parseVersion(version) {
|
|
2
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
|
|
3
|
+
if (!match) {
|
|
4
|
+
throw new Error(`无效的版本号格式: ${version}`);
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
major: parseInt(match[1], 10),
|
|
8
|
+
minor: parseInt(match[2], 10),
|
|
9
|
+
patch: parseInt(match[3], 10),
|
|
10
|
+
prerelease: match[4]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function stringifyVersion(version) {
|
|
14
|
+
const base = `${version.major}.${version.minor}.${version.patch}`;
|
|
15
|
+
return version.prerelease ? `${base}-${version.prerelease}` : base;
|
|
16
|
+
}
|
|
17
|
+
export function compareVersions(a, b) {
|
|
18
|
+
if (a.major !== b.major) {
|
|
19
|
+
return a.major > b.major ? 1 : -1;
|
|
20
|
+
}
|
|
21
|
+
if (a.minor !== b.minor) {
|
|
22
|
+
return a.minor > b.minor ? 1 : -1;
|
|
23
|
+
}
|
|
24
|
+
if (a.patch !== b.patch) {
|
|
25
|
+
return a.patch > b.patch ? 1 : -1;
|
|
26
|
+
}
|
|
27
|
+
if (a.prerelease && !b.prerelease)
|
|
28
|
+
return -1;
|
|
29
|
+
if (!a.prerelease && b.prerelease)
|
|
30
|
+
return 1;
|
|
31
|
+
if (!a.prerelease && !b.prerelease)
|
|
32
|
+
return 0;
|
|
33
|
+
return a.prerelease > b.prerelease ? 1 : (a.prerelease < b.prerelease ? -1 : 0);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=parseVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseVersion.js","sourceRoot":"","sources":["../../../src/functions/version/parseVersion.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,aAAa,OAAO,EAAE,CAAC,CAAA;IACzC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;KACrB,CAAA;AACH,CAAC;AAQD,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,C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AC,CAAC,CAAC,CAAC,CAAA;AACrF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcw-shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"references",
|
|
6
6
|
"dist",
|
|
@@ -20,11 +20,15 @@
|
|
|
20
20
|
"publish:patch": "npx tsx scripts/publish.ts patch",
|
|
21
21
|
"publish:minor": "npx tsx scripts/publish.ts minor",
|
|
22
22
|
"publish:major": "npx tsx scripts/publish.ts major",
|
|
23
|
-
"publish:prerelease": "npx tsx scripts/publish.ts prerelease"
|
|
23
|
+
"publish:prerelease": "npx tsx scripts/publish.ts prerelease",
|
|
24
|
+
"docs:dev": "vitepress dev docs",
|
|
25
|
+
"docs:build": "vitepress build docs",
|
|
26
|
+
"docs:preview": "vitepress preview docs"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"tsx": "^4.20.3",
|
|
27
|
-
"typescript": "^5.8.3"
|
|
30
|
+
"typescript": "^5.8.3",
|
|
31
|
+
"vitepress": "^1.6.4"
|
|
28
32
|
},
|
|
29
33
|
"exports": {
|
|
30
34
|
"./constants/colorPatterns": "./dist/constants/colorPatterns.js",
|
|
@@ -47,6 +51,7 @@
|
|
|
47
51
|
"./functions/dom/getElementRect": "./dist/functions/dom/getElementRect.js",
|
|
48
52
|
"./functions/dom/getRelativePosition": "./dist/functions/dom/getRelativePosition.js",
|
|
49
53
|
"./functions/dom/getViewportRect": "./dist/functions/dom/getViewportRect.js",
|
|
54
|
+
"./functions/image/compressToTargetSize": "./dist/functions/image/compressToTargetSize.js",
|
|
50
55
|
"./functions/image/generateMacIcons": "./dist/functions/image/generateMacIcons.js",
|
|
51
56
|
"./functions/image/generateMacTrayIcon": "./dist/functions/image/generateMacTrayIcon.js",
|
|
52
57
|
"./functions/image/generatePaddedImage": "./dist/functions/image/generatePaddedImage.js",
|
|
@@ -66,6 +71,7 @@
|
|
|
66
71
|
"./functions/string/similarity": "./dist/functions/string/similarity.js",
|
|
67
72
|
"./functions/string/template": "./dist/functions/string/template.js",
|
|
68
73
|
"./functions/string/wordCount": "./dist/functions/string/wordCount.js",
|
|
74
|
+
"./functions/tencent-cloud/deploy.tcb": "./dist/functions/tencent-cloud/deploy.tcb.js",
|
|
69
75
|
"./functions/tencent-cloud/getSecret": "./dist/functions/tencent-cloud/getSecret.js",
|
|
70
76
|
"./functions/uniapp/app-plus/buildAndroidApp": "./dist/functions/uniapp/app-plus/buildAndroidApp.js",
|
|
71
77
|
"./functions/uniapp/build": "./dist/functions/uniapp/build.js",
|
|
@@ -91,6 +97,8 @@
|
|
|
91
97
|
"./functions/utils/until": "./dist/functions/utils/until.js",
|
|
92
98
|
"./functions/utils/validate": "./dist/functions/utils/validate.js",
|
|
93
99
|
"./functions/utils/walk": "./dist/functions/utils/walk.js",
|
|
100
|
+
"./functions/version/incrementVersion": "./dist/functions/version/incrementVersion.js",
|
|
101
|
+
"./functions/version/parseVersion": "./dist/functions/version/parseVersion.js",
|
|
94
102
|
"./functions/vue/dynamicMount": "./dist/functions/vue/dynamicMount.js",
|
|
95
103
|
"./functions/vue/extractColorsFromVueFile": "./dist/functions/vue/extractColorsFromVueFile.js",
|
|
96
104
|
"./functions/vue/extractColorsFromVueSection": "./dist/functions/vue/extractColorsFromVueSection.js",
|
|
@@ -116,8 +124,10 @@
|
|
|
116
124
|
"./types/design-system": "./types/design-system.d.ts",
|
|
117
125
|
"./types/geometry": "./types/geometry.d.ts",
|
|
118
126
|
"./types/platform": "./types/platform.d.ts",
|
|
127
|
+
"./types/semver": "./types/semver.d.ts",
|
|
119
128
|
"./types/software": "./types/software.d.ts",
|
|
120
129
|
"./types/storage": "./types/storage.d.ts",
|
|
130
|
+
"./types/tencent-cloud": "./types/tencent-cloud.d.ts",
|
|
121
131
|
"./types/uniapp-android-build": "./types/uniapp-android-build.d.ts",
|
|
122
132
|
"./types/vue": "./types/vue.d.ts",
|
|
123
133
|
"./types/worker": "./types/worker.d.ts"
|
package/references/browser.d.ts
CHANGED
|
@@ -4,13 +4,25 @@ import type { AbortController, Response, FetchFunction } from './fetch.d'
|
|
|
4
4
|
import type { URLSearchParams } from './url.d'
|
|
5
5
|
import type { Storage } from './storage.d'
|
|
6
6
|
import type { WorkerConstructor } from './worker.d'
|
|
7
|
-
import type { Document, HTMLElement, Element } from './dom.d'
|
|
7
|
+
import type { Document, HTMLElement, Element, HTMLImageElement } from './dom.d'
|
|
8
8
|
import type { IDBFactory } from './indexeddb.d'
|
|
9
9
|
import type { Blob, BlobPart, BlobPropertyBag, MediaSource, ReadableStream } from './blob.d'
|
|
10
10
|
import type { TextDecoderConstructor, TextEncoderConstructor } from './encoding.d'
|
|
11
11
|
import type { Location } from './location.d'
|
|
12
12
|
import type { ArrayBufferConstructor, Uint8ArrayConstructor, DataViewConstructor } from './arraybuffer.d'
|
|
13
13
|
|
|
14
|
+
// File 接口定义
|
|
15
|
+
export interface FilePropertyBag extends BlobPropertyBag {
|
|
16
|
+
lastModified?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface File extends Blob {
|
|
20
|
+
readonly name: string
|
|
21
|
+
readonly size: number
|
|
22
|
+
readonly type: string
|
|
23
|
+
readonly lastModified: number
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
|
|
15
27
|
|
|
16
28
|
// 浏览器Window对象 - 包含所有浏览器API
|
|
@@ -58,6 +70,16 @@ export interface Window {
|
|
|
58
70
|
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
// File API
|
|
74
|
+
File: {
|
|
75
|
+
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Image API
|
|
79
|
+
Image: {
|
|
80
|
+
new (width?: number, height?: number): HTMLImageElement
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
// ArrayBuffer API
|
|
62
84
|
ArrayBuffer: ArrayBufferConstructor
|
|
63
85
|
Uint8Array: Uint8ArrayConstructor
|
package/references/dom.d.ts
CHANGED
|
@@ -18,7 +18,27 @@ export interface HTMLElement extends Element {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface HTMLImageElement extends HTMLElement {
|
|
22
|
+
src: string
|
|
23
|
+
naturalWidth: number
|
|
24
|
+
naturalHeight: number
|
|
25
|
+
onload: (() => void) | null
|
|
26
|
+
onerror: (() => void) | null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CanvasRenderingContext2D {
|
|
30
|
+
drawImage(image: HTMLImageElement, dx: number, dy: number, dWidth: number, dHeight: number): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HTMLCanvasElement extends HTMLElement {
|
|
34
|
+
width: number
|
|
35
|
+
height: number
|
|
36
|
+
getContext(contextId: '2d'): CanvasRenderingContext2D | null
|
|
37
|
+
toBlob(callback: (blob: Blob | null) => void, type?: string, quality?: number): void
|
|
38
|
+
}
|
|
39
|
+
|
|
21
40
|
export interface Document {
|
|
41
|
+
createElement(tagName: 'canvas'): HTMLCanvasElement
|
|
22
42
|
createElement(tagName: string): HTMLElement
|
|
23
43
|
documentElement: {
|
|
24
44
|
clientWidth: number
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 腾讯云相关类型定义
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* 定义腾讯云服务相关的接口和类型,用于依赖注入
|
|
6
|
+
* 确保函数的环境无关性
|
|
7
|
+
*
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @author Assistant
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Console } from './console.d'
|
|
13
|
+
import type { FileSystem, Path, Process } from './node.d'
|
|
14
|
+
|
|
15
|
+
// 腾讯云密钥接口
|
|
16
|
+
export interface TencentCloudSecret {
|
|
17
|
+
secretId: string
|
|
18
|
+
secretKey: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 腾讯云配置接口
|
|
22
|
+
export interface TencentCloudConfig {
|
|
23
|
+
secretId: string
|
|
24
|
+
secretKey: string
|
|
25
|
+
envId: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 上传进度数据
|
|
29
|
+
export interface UploadProgressData {
|
|
30
|
+
percent: number
|
|
31
|
+
loaded: number
|
|
32
|
+
total: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 上传文件选项
|
|
36
|
+
export interface UploadFilesOptions {
|
|
37
|
+
localPath: string
|
|
38
|
+
cloudPath: string
|
|
39
|
+
onProgress?: (progressData: UploadProgressData) => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 静态网站托管服务接口
|
|
43
|
+
export interface HostingService {
|
|
44
|
+
uploadFiles(options: UploadFilesOptions): Promise<void>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// CloudBase 应用接口
|
|
48
|
+
export interface CloudBaseApp {
|
|
49
|
+
hosting: HostingService
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// CloudBase 管理器接口
|
|
53
|
+
export interface CloudBaseManager {
|
|
54
|
+
init(config: TencentCloudConfig): CloudBaseApp
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 腾讯云系统依赖接口
|
|
58
|
+
export interface TencentCloudSystemDependencies {
|
|
59
|
+
cloudBase: CloudBaseManager
|
|
60
|
+
path: Path
|
|
61
|
+
fs: FileSystem
|
|
62
|
+
process: Process
|
|
63
|
+
console: Console
|
|
64
|
+
getSecret: (type: string) => TencentCloudSecret
|
|
65
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Versioning (SemVer) 类型定义
|
|
3
|
+
* 遵循 https://semver.org/ 规范
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 版本递增类型
|
|
8
|
+
*/
|
|
9
|
+
export type VersionType = 'major' | 'minor' | 'patch' | 'prerelease'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 语义化版本对象
|
|
13
|
+
*/
|
|
14
|
+
export interface Version {
|
|
15
|
+
/** 主版本号 - 不兼容的 API 修改 */
|
|
16
|
+
major: number
|
|
17
|
+
/** 次版本号 - 向下兼容的功能性新增 */
|
|
18
|
+
minor: number
|
|
19
|
+
/** 修订号 - 向下兼容的问题修正 */
|
|
20
|
+
patch: number
|
|
21
|
+
/** 预发布版本标识符 */
|
|
22
|
+
prerelease?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 版本比较结果
|
|
27
|
+
*/
|
|
28
|
+
export type VersionComparison = -1 | 0 | 1
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 版本范围操作符
|
|
32
|
+
*/
|
|
33
|
+
export type VersionRangeOperator =
|
|
34
|
+
| '^' // 兼容版本(不改变主版本号)
|
|
35
|
+
| '~' // 近似版本(不改变主次版本号)
|
|
36
|
+
| '>=' // 大于等于
|
|
37
|
+
| '>' // 大于
|
|
38
|
+
| '<=' // 小于等于
|
|
39
|
+
| '<' // 小于
|
|
40
|
+
| '=' // 等于
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 版本范围
|
|
44
|
+
*/
|
|
45
|
+
export interface VersionRange {
|
|
46
|
+
operator: VersionRangeOperator
|
|
47
|
+
version: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 版本解析选项
|
|
52
|
+
*/
|
|
53
|
+
export interface VersionParseOptions {
|
|
54
|
+
/** 是否允许前缀 'v' */
|
|
55
|
+
allowPrefix?: boolean
|
|
56
|
+
/** 是否严格模式(严格遵循 SemVer 规范) */
|
|
57
|
+
strict?: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 版本递增选项
|
|
62
|
+
*/
|
|
63
|
+
export interface VersionIncrementOptions {
|
|
64
|
+
/** 预发布标识符(如 'alpha', 'beta', 'rc') */
|
|
65
|
+
prerelease?: string
|
|
66
|
+
/** 预发布版本号 */
|
|
67
|
+
prereleaseNumber?: number
|
|
68
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 腾讯云相关应用层类型定义
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* 定义腾讯云部署功能使用的接口和类型
|
|
6
|
+
* 不包含环境相关的类型,环境相关类型请从 references/tencent-cloud.d 导入
|
|
7
|
+
*
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @author Assistant
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
TencentCloudSystemDependencies,
|
|
14
|
+
TencentCloudSecret
|
|
15
|
+
} from '../references/tencent-cloud.d'
|
|
16
|
+
|
|
17
|
+
// 密钥类型
|
|
18
|
+
export type SecretType = 'personal' | 'individual' | 'enterprise'
|
|
19
|
+
|
|
20
|
+
// 部署配置选项
|
|
21
|
+
export interface DeployOptions {
|
|
22
|
+
/** 本地文件路径 */
|
|
23
|
+
localPath: string
|
|
24
|
+
/** 云端路径 */
|
|
25
|
+
cloudPath?: string
|
|
26
|
+
/** 环境ID */
|
|
27
|
+
envId: string
|
|
28
|
+
/** 密钥类型 */
|
|
29
|
+
secretType: SecretType
|
|
30
|
+
/** 是否显示进度 */
|
|
31
|
+
showProgress?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 部署结果
|
|
35
|
+
export interface DeployResult {
|
|
36
|
+
success: boolean
|
|
37
|
+
message?: string
|
|
38
|
+
error?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 部署函数依赖接口
|
|
42
|
+
export interface DeployDependencies extends TencentCloudSystemDependencies {
|
|
43
|
+
// 可以扩展特定于部署功能的依赖
|
|
44
|
+
}
|