@plugin-light/shared 1.0.9 → 1.0.15

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 (38) hide show
  1. package/lib/email/index.d.ts +1 -0
  2. package/lib/email/watch-unread.d.ts +103 -0
  3. package/lib/font-project/config.d.ts +15 -0
  4. package/lib/font-project/font-project.d.ts +75 -0
  5. package/lib/font-project/index.d.ts +2 -0
  6. package/lib/icon-project/config.d.ts +23 -0
  7. package/lib/icon-project/icon-project.d.ts +83 -0
  8. package/lib/icon-project/index.d.ts +2 -0
  9. package/lib/image/config.d.ts +23 -0
  10. package/lib/image/image.d.ts +67 -0
  11. package/lib/image/index.d.ts +3 -0
  12. package/lib/image/upload-core.d.ts +83 -0
  13. package/lib/index.d.ts +10 -0
  14. package/lib/index.js +1900 -24047
  15. package/lib/index.mjs +2506 -0
  16. package/lib/landun/cos-sync-to-git.d.ts +12 -0
  17. package/lib/landun/index.d.ts +2 -0
  18. package/lib/landun/start.d.ts +42 -0
  19. package/lib/mcp/auth.d.ts +24 -0
  20. package/lib/mcp/http.d.ts +34 -0
  21. package/lib/mcp/index.d.ts +3 -0
  22. package/lib/mcp/mcp.d.ts +27 -0
  23. package/lib/mp-ci/config.d.ts +11 -0
  24. package/lib/mp-ci/helper.d.ts +12 -0
  25. package/lib/mp-ci/index.d.ts +5 -0
  26. package/lib/mp-ci/mp-ci.d.ts +73 -0
  27. package/lib/mp-ci/record.d.ts +39 -0
  28. package/lib/mp-ci/start-from-mcp.d.ts +42 -0
  29. package/lib/pipeline-npm-publish/core.d.ts +53 -0
  30. package/lib/pipeline-npm-publish/helper.d.ts +7 -0
  31. package/lib/pipeline-npm-publish/index.d.ts +2 -0
  32. package/lib/tinypng/index.d.ts +1 -0
  33. package/lib/tinypng/tinypng.d.ts +18 -0
  34. package/lib/white-user/config.d.ts +53 -0
  35. package/lib/white-user/cron.d.ts +15 -0
  36. package/lib/white-user/index.d.ts +3 -0
  37. package/lib/white-user/update-cos.d.ts +47 -0
  38. package/package.json +23 -4
@@ -0,0 +1 @@
1
+ export { type ImapConfig, type EmailMessage, type WatchEmailsOptions, type EmailWatcher, watchEmails, } from './watch-unread';
@@ -0,0 +1,103 @@
1
+ /**
2
+ * 方案二:IMAP IDLE 实时监听新邮件
3
+ *
4
+ * 通过 IMAP IDLE 命令保持长连接,实时监听收件箱中的新邮件到达。
5
+ * 适用于需要实时感知新邮件的场景,如:监听邮件后自动触发业务逻辑。
6
+ *
7
+ * 依赖安装:npm install imapflow mailparser
8
+ * 类型安装:npm install -D @types/mailparser
9
+ *
10
+ * 注意事项:
11
+ * 1. IDLE 连接可能因网络问题断开,内置自动重连机制
12
+ * 2. 部分邮箱服务器对 IDLE 连接有超时限制(通常 29 分钟),imapflow 会自动处理
13
+ * 3. 生产环境建议配合进程管理工具(如 pm2)使用
14
+ */
15
+ /** 邮件连接配置 */
16
+ export interface ImapConfig {
17
+ /** IMAP 服务器地址,例如 'imap.exmail.qq.com' */
18
+ host: string;
19
+ /** IMAP 端口,默认 993(STARTTLS)或 993(隐式 TLS) */
20
+ port?: number;
21
+ /** 是否使用隐式 TLS(端口 993),默认 false(使用 STARTTLS) */
22
+ secure?: boolean;
23
+ /** 邮箱账号 */
24
+ user: string;
25
+ /** 邮箱密码或应用专用密码/授权码 */
26
+ password: string;
27
+ }
28
+ /** 解析后的邮件结构 */
29
+ export interface EmailMessage {
30
+ /** 邮件 UID */
31
+ uid: number;
32
+ /** 邮件主题 */
33
+ subject: string;
34
+ /** 发件人 */
35
+ from: string;
36
+ /** 收件人 */
37
+ to: string;
38
+ /** 邮件日期 */
39
+ date: Date | undefined;
40
+ /** 纯文本内容 */
41
+ text: string | undefined;
42
+ /** HTML 内容 */
43
+ html: string | false;
44
+ /** Markdown 内容(由 HTML 或纯文本转换而来) */
45
+ markdown: string;
46
+ /** 附件列表 */
47
+ attachments: Array<{
48
+ filename: string;
49
+ contentType: string;
50
+ size: number;
51
+ }>;
52
+ }
53
+ /** 邮件监听配置 */
54
+ export interface WatchEmailsOptions extends ImapConfig {
55
+ /** 邮箱文件夹,默认 'INBOX' */
56
+ mailbox?: string;
57
+ /** 新邮件到达时的回调 */
58
+ onNewEmail: (email: EmailMessage) => void | Promise<void>;
59
+ /** 连接错误时的回调 */
60
+ onError?: (error: Error) => void;
61
+ /** 连接成功时的回调 */
62
+ onConnected?: () => void;
63
+ /** 断开连接时的回调 */
64
+ onDisconnected?: () => void;
65
+ /** 断线后自动重连,默认 true */
66
+ autoReconnect?: boolean;
67
+ /** 重连间隔(毫秒),默认 5000 */
68
+ reconnectInterval?: number;
69
+ /** 最大重连次数,默认 Infinity */
70
+ maxReconnectAttempts?: number;
71
+ /** 是否开启调试日志,默认 false */
72
+ debug?: boolean;
73
+ }
74
+ /** 邮件监听器实例,用于管理生命周期 */
75
+ export interface EmailWatcher {
76
+ /** 停止监听并断开连接 */
77
+ stop: () => Promise<void>;
78
+ /** 当前是否已连接 */
79
+ isConnected: () => boolean;
80
+ }
81
+ /**
82
+ * 启动邮件监听(基于 IMAP IDLE)
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const watcher = await watchEmails({
87
+ * host: 'imap.exmail.qq.com',
88
+ * user: 'yourname@company.com',
89
+ * password: 'your-app-password',
90
+ * onNewEmail: (email) => {
91
+ * console.log('📬 收到新邮件:', email.subject);
92
+ * // 触发你的业务逻辑,比如推送到企微群
93
+ * },
94
+ * onError: (err) => {
95
+ * console.error('监听出错:', err.message);
96
+ * },
97
+ * });
98
+ *
99
+ * // 需要停止时
100
+ * // await watcher.stop();
101
+ * ```
102
+ */
103
+ export declare function watchEmails(options: WatchEmailsOptions): Promise<EmailWatcher>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 字体项目 CDN 地址
3
+ */
4
+ export declare const FONT_PROJECT_CDN = "https://image-1251917893.cos.ap-guangzhou.myqcloud.com/pmd-font/font-project.json";
5
+ /**
6
+ * 字体项目 COS 基础配置
7
+ */
8
+ export declare const FONT_PROJECT_COS_BASE: {
9
+ bucket: string;
10
+ region: string;
11
+ };
12
+ /**
13
+ * 字体项目 Webhook URL
14
+ */
15
+ export declare const FONT_PROJECT_WEBHOOK_URL = "9f673531-788b-4780-be72-93b16a62e3eb";
@@ -0,0 +1,75 @@
1
+ import { type CosConfig } from '../image/index';
2
+ /**
3
+ * 字体项目配置接口
4
+ */
5
+ export interface FontProject {
6
+ /** 项目中文名称 */
7
+ projectNameZN: string;
8
+ /** 项目英文名称 */
9
+ projectName: string;
10
+ /** 字体文件名 */
11
+ fontFileName: string;
12
+ /** 验证文本 */
13
+ validationText: string;
14
+ /** CDN 地址 */
15
+ cdn: string;
16
+ /** 标签列表 */
17
+ tags?: string[];
18
+ /** 创建者 */
19
+ creator?: string;
20
+ /** 创建时间戳 */
21
+ createTime?: number;
22
+ /** 更新时间戳 */
23
+ updateTime: number;
24
+ }
25
+ /**
26
+ * 字体项目数据集合
27
+ */
28
+ export interface FontProjectsData {
29
+ [key: string]: FontProject;
30
+ }
31
+ /**
32
+ * 创建/更新字体项目的选项
33
+ */
34
+ export interface CreateFontProjectOptions {
35
+ /** 项目中文名称 */
36
+ projectNameZN?: string;
37
+ /** 项目英文名称 */
38
+ projectName?: string;
39
+ /** 字体文件名 */
40
+ fontFileName?: string;
41
+ /** 验证文本 */
42
+ validationText?: string;
43
+ /** CDN 地址 */
44
+ cdn?: string;
45
+ /** COS 配置 */
46
+ cos: CosConfig;
47
+ /** 是否为创建操作 */
48
+ isCreate?: boolean;
49
+ /** 操作员名称 */
50
+ staffName?: string;
51
+ /** 标签列表 */
52
+ tags?: string[];
53
+ }
54
+ /**
55
+ * 创建字体项目的结果
56
+ */
57
+ export interface CreateFontProjectResult {
58
+ /** 是否为创建操作 */
59
+ isCreate?: boolean;
60
+ /** 错误信息 */
61
+ error?: string;
62
+ }
63
+ /**
64
+ * 获取所有字体项目配置
65
+ * @returns 包含字体项目数据的 Promise
66
+ */
67
+ export declare function genFontProjects(): Promise<{
68
+ data: FontProjectsData;
69
+ }>;
70
+ /**
71
+ * 创建或更新字体项目
72
+ * @param options - 创建/更新选项
73
+ * @returns 操作结果
74
+ */
75
+ export declare function createFontProjectOrUpdate({ projectNameZN, projectName, fontFileName, validationText, cdn, cos, staffName, isCreate, tags, }: CreateFontProjectOptions): Promise<CreateFontProjectResult>;
@@ -0,0 +1,2 @@
1
+ export { FONT_PROJECT_CDN, FONT_PROJECT_COS_BASE, FONT_PROJECT_WEBHOOK_URL, } from './config';
2
+ export { genFontProjects, createFontProjectOrUpdate, type CreateFontProjectResult, type CreateFontProjectOptions, type FontProject, type FontProjectsData, } from './font-project';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 图标项目 CDN 地址
3
+ */
4
+ export declare const ICON_PROJECT_CDN = "https://image-1251917893.cos.ap-guangzhou.myqcloud.com/pmd-icon/icon-project.json";
5
+ /**
6
+ * COS 基础配置
7
+ */
8
+ export declare const COS_BASE: {
9
+ bucket: string;
10
+ region: string;
11
+ };
12
+ /**
13
+ * 图标项目流水线配置
14
+ */
15
+ export declare const ICON_PROJECT_PIPELINE_CONFIG: {
16
+ mainRemotePipelineId: string;
17
+ mainPipelineId: string;
18
+ createDirRemotePipelineId: string;
19
+ };
20
+ /**
21
+ * 图标项目 Webhook URL
22
+ */
23
+ export declare const ICON_PROJECT_WEBHOOK_URL = "331402f8-c274-4b99-a302-4404759ca25a";
@@ -0,0 +1,83 @@
1
+ import { type CosConfig } from '../image/image';
2
+ /**
3
+ * 图标项目配置接口
4
+ */
5
+ export interface IconProject {
6
+ /** 项目中文名称 */
7
+ projectNameZN: string;
8
+ /** 项目英文名称 */
9
+ projectName: string;
10
+ /** Figma 文件 ID */
11
+ figmaFileId: string;
12
+ /** Figma 节点 ID */
13
+ figmaNodeId: string;
14
+ /** Iconfont 前缀 */
15
+ iconfontPrefix: string;
16
+ /** Iconfont 字体族名 */
17
+ iconfontFamily: string;
18
+ /** CDN 地址 */
19
+ cdn: string;
20
+ /** 标签列表 */
21
+ tags?: string[];
22
+ /** 创建者 */
23
+ creator?: string;
24
+ /** 创建时间戳 */
25
+ createTime?: number;
26
+ /** 更新时间戳 */
27
+ updateTime: number;
28
+ }
29
+ /**
30
+ * 图标项目数据集合
31
+ */
32
+ export interface IconProjectsData {
33
+ [key: string]: IconProject;
34
+ }
35
+ /**
36
+ * 创建/更新图标项目的选项
37
+ */
38
+ export interface CreateIconProjectOptions {
39
+ /** 项目中文名称 */
40
+ projectNameZN?: string;
41
+ /** 项目英文名称 */
42
+ projectName?: string;
43
+ /** Figma 文件 ID */
44
+ figmaFileId?: string;
45
+ /** Figma 节点 ID */
46
+ figmaNodeId?: string;
47
+ /** Iconfont 前缀 */
48
+ iconfontPrefix?: string;
49
+ /** Iconfont 字体族名 */
50
+ iconfontFamily?: string;
51
+ /** CDN 地址 */
52
+ cdn?: string;
53
+ /** COS 配置 */
54
+ cos: CosConfig;
55
+ /** 操作员名称 */
56
+ staffName?: string;
57
+ /** 是否为创建操作 */
58
+ isCreate?: boolean;
59
+ /** 标签列表 */
60
+ tags?: string[];
61
+ }
62
+ /**
63
+ * 创建图标项目的结果
64
+ */
65
+ export interface CreateIconProjectResult {
66
+ /** 是否为创建操作 */
67
+ isCreate?: boolean;
68
+ /** 错误信息 */
69
+ error?: string;
70
+ }
71
+ /**
72
+ * 获取所有图标项目配置
73
+ * @returns 包含图标项目数据的 Promise
74
+ */
75
+ export declare function genIconProjects(): Promise<{
76
+ data: IconProjectsData;
77
+ }>;
78
+ /**
79
+ * 创建或更新图标项目
80
+ * @param options - 创建/更新选项
81
+ * @returns 操作结果
82
+ */
83
+ export declare function createIconProjectOrUpdate({ projectNameZN, projectName, figmaFileId, figmaNodeId, iconfontPrefix, iconfontFamily, cdn, cos, staffName, isCreate, tags, }: CreateIconProjectOptions): Promise<CreateIconProjectResult>;
@@ -0,0 +1,2 @@
1
+ export { ICON_PROJECT_WEBHOOK_URL, ICON_PROJECT_PIPELINE_CONFIG, COS_BASE, ICON_PROJECT_CDN, } from './config';
2
+ export { genIconProjects, createIconProjectOrUpdate, type IconProject, type IconProjectsData, type CreateIconProjectOptions, type CreateIconProjectResult, } from './icon-project';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * CDN 配置接口
3
+ */
4
+ export interface CdnConfig {
5
+ /** CDN 域名 */
6
+ cdnDomain: string;
7
+ /** COS 域名 */
8
+ cosDomain: string;
9
+ /** 密钥 ID */
10
+ secretId: string | undefined;
11
+ /** 密钥 Key */
12
+ secretKey: string | undefined;
13
+ /** COS Bucket 名称 */
14
+ cosBucketName: string;
15
+ /** COS App ID */
16
+ cosAppId: string;
17
+ /** COS 基础域名 */
18
+ cosBaseDomain: string;
19
+ }
20
+ /**
21
+ * COS 同步到 Git 的远程流水线 ID
22
+ */
23
+ export declare const COS_TO_GIT_REMOTE_PIPELINE_ID = "df18b1dc954e49c98271c531a0f40812";
@@ -0,0 +1,67 @@
1
+ /**
2
+ * COS 配置接口
3
+ */
4
+ export interface CosConfig {
5
+ secretId?: string;
6
+ secretKey?: string;
7
+ bucket: string;
8
+ region: string;
9
+ cosPrefix?: string;
10
+ maxSize?: number;
11
+ }
12
+ /**
13
+ * 图片记录接口
14
+ */
15
+ export interface ImageRecord {
16
+ url: string;
17
+ parsedUrl: string;
18
+ [key: string]: any;
19
+ }
20
+ /**
21
+ * 获取上传图片的文件路径
22
+ * @param cdn - CDN 域名
23
+ * @returns 格式化的文件路径,包含年月信息
24
+ */
25
+ export declare function getUploadImageFilePath(cdn: string): string;
26
+ /**
27
+ * 获取上传 COS 配置
28
+ * @param cdn - CDN 域名
29
+ * @returns COS 配置对象,如果 CDN 无效则返回空对象
30
+ */
31
+ export declare function getUploadCosConfig(cdn: string): CosConfig | Record<string, never>;
32
+ /**
33
+ * 解析图片记录,将 COS URL 转换为 CDN URL
34
+ * @param image - 图片记录对象
35
+ * @returns 解析后的图片记录,包含 parsedUrl
36
+ */
37
+ export declare const parseImage: (image: ImageRecord) => ImageRecord;
38
+ /**
39
+ * 将 COS URL 转换为 CDN URL
40
+ * 支持 https://、http://、//、纯域名 等多种链接格式
41
+ * @param inUrl - 输入的 URL
42
+ * @returns 转换后的 CDN URL
43
+ * @example
44
+ * toCdnUrl('https://xxx.cos.ap-guangzhou.myqcloud.com/path/to/file')
45
+ * toCdnUrl('//xxx.cos.ap-guangzhou.myqcloud.com/path/to/file')
46
+ * toCdnUrl('http://xxx.cos.ap-guangzhou.myqcloud.com/path/to/file')
47
+ * toCdnUrl('xxx.cos.ap-guangzhou.myqcloud.com/path/to/file')
48
+ * toCdnUrl('xxx.cos.ap-guangzhou.myqcloud.com')
49
+ */
50
+ export declare function toCdnUrl(inUrl: string): string;
51
+ /**
52
+ * 将 COS URL 转换为 CDN URL
53
+ * @deprecated 请使用 toCdnUrl 代替
54
+ * @param inUrl - 输入的 URL
55
+ * @returns 转换后的 CDN URL
56
+ */
57
+ export declare const getOneCdnUrl: typeof toCdnUrl;
58
+ /**
59
+ * 中国大陆 CDN 列表
60
+ */
61
+ export declare const MAINLAND_CDN_LIST: string[];
62
+ /**
63
+ * 根据 CDN 获取推送 URL 缓存区域
64
+ * @param cdn - CDN 域名
65
+ * @returns 缓存区域,中国大陆返回 'mainland',否则返回 'overseas'
66
+ */
67
+ export declare const getPushUrlCacheArea: (cdn: string) => string;
@@ -0,0 +1,3 @@
1
+ export { getUploadImageFilePath, getUploadCosConfig, parseImage, toCdnUrl, getOneCdnUrl, MAINLAND_CDN_LIST, getPushUrlCacheArea, type CosConfig, type ImageRecord, } from './image';
2
+ export { uploadFilesCore, } from './upload-core';
3
+ export { COS_TO_GIT_REMOTE_PIPELINE_ID, } from './config';
@@ -0,0 +1,83 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { CosConfig } from './image';
4
+ /**
5
+ * 上传文件接口
6
+ */
7
+ interface UploadFile {
8
+ /** 文件大小 */
9
+ size: number;
10
+ /** MIME 类型 */
11
+ mimetype: string;
12
+ /** 原始文件名 */
13
+ originalname?: string;
14
+ /** 文件路径 */
15
+ path?: string;
16
+ /** 文件缓冲区 */
17
+ buffer?: Buffer;
18
+ }
19
+ /**
20
+ * 上传文件核心选项
21
+ */
22
+ interface UploadFileCoreOptions {
23
+ /** 上传的文件 */
24
+ file: UploadFile;
25
+ /** 原始文件名 */
26
+ originName: string;
27
+ /** 是否使用原始文件名 */
28
+ useOriginFilename: string;
29
+ /** 新文件 Key */
30
+ newFileKey: string;
31
+ /** 操作员名称 */
32
+ staffName: string;
33
+ /** 解析后的目录 */
34
+ parsedDir: string;
35
+ /** 上传文件标识 */
36
+ uploadFile: string;
37
+ /** CDN 域名 */
38
+ cdn: string;
39
+ /** COS 配置 */
40
+ cos: CosConfig;
41
+ /** 上传回调函数 */
42
+ uploadCallBack: () => Promise<{
43
+ r: number;
44
+ msg: string;
45
+ err?: any;
46
+ } | undefined>;
47
+ /** 是否来自 MCP */
48
+ fromMcp?: boolean;
49
+ /** MCP 数据库实例 */
50
+ mcpDB?: any;
51
+ /** MCP 名称 */
52
+ mcpName?: string;
53
+ /** MCP 版本 */
54
+ mcpVersion?: string;
55
+ /** 图片数据库实例 */
56
+ imageDB: any;
57
+ /** 操作记录工具 */
58
+ operationTool: any;
59
+ }
60
+ /**
61
+ * 上传结果接口
62
+ */
63
+ interface UploadResult {
64
+ /** 返回码 */
65
+ r: number;
66
+ /** 消息 */
67
+ msg: string;
68
+ /** COS URL */
69
+ url?: string;
70
+ /** CDN URL */
71
+ cdnUrl?: string;
72
+ /** 错误信息 */
73
+ err?: any;
74
+ /** 原始文件名 */
75
+ originalname?: string;
76
+ }
77
+ /**
78
+ * 文件上传核心处理函数
79
+ * @param options - 上传选项
80
+ * @returns 上传结果
81
+ */
82
+ export declare function uploadFilesCore({ file, originName, useOriginFilename, newFileKey, staffName, parsedDir, uploadFile, cdn, cos, uploadCallBack, fromMcp, mcpDB, mcpName, mcpVersion, imageDB, operationTool, }: UploadFileCoreOptions): Promise<UploadResult>;
83
+ export {};
package/lib/index.d.ts CHANGED
@@ -7,19 +7,27 @@ export * from './context';
7
7
  export * from './cross-game-style';
8
8
  export * from './css';
9
9
  export * from './deps';
10
+ export * from './email';
10
11
  export * from './eslint-rules';
11
12
  export * from './find-dependencies';
13
+ export * from './font-project';
12
14
  export * from './gen-version';
13
15
  export * from './h5';
14
16
  export * from './helper';
17
+ export * from './icon-project';
15
18
  export * from './ifdef';
19
+ export * from './image';
16
20
  export * from './inject-dynamic-style';
21
+ export * from './landun';
17
22
  export * from './loader-file';
18
23
  export * from './loader-log';
19
24
  export * from './loader-options';
25
+ export * from './mcp';
26
+ export * from './mp-ci';
20
27
  export * from './node-module-file';
21
28
  export * from './npm-publish';
22
29
  export * from './pipeline';
30
+ export * from './pipeline-npm-publish';
23
31
  export * from './platform';
24
32
  export * from './project-name';
25
33
  export * from './replace-manifest';
@@ -27,5 +35,7 @@ export * from './replace-vue-directive';
27
35
  export * from './repo';
28
36
  export * from './root';
29
37
  export * from './sub-project';
38
+ export * from './tinypng';
30
39
  export * from './uni-env';
31
40
  export * from './v-lazy';
41
+ export * from './white-user';