@kepoai/provider 1.0.0
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/api/index.d.ts +121 -0
- package/package.json +27 -0
- package/tsconfig.json +22 -0
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {Page} from 'puppeteer-core'
|
|
2
|
+
import {size} from "@kepoai/types";
|
|
3
|
+
|
|
4
|
+
export class Storage {
|
|
5
|
+
static async get<T>(key: string): Promise<T | null>
|
|
6
|
+
static async get<T>(key: string, defaultValue: T): Promise<T>
|
|
7
|
+
|
|
8
|
+
static async set(key: string, value: any): Promise<void>
|
|
9
|
+
|
|
10
|
+
static async del(key: string): Promise<void>
|
|
11
|
+
|
|
12
|
+
static async clear(): Promise<boolean>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module 'puppeteer-core' {
|
|
16
|
+
interface Page {
|
|
17
|
+
show(): Promise<void>;
|
|
18
|
+
hide(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const page: Page
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export interface OptionEvent {
|
|
26
|
+
key: string
|
|
27
|
+
type: string
|
|
28
|
+
currentTarget: Options
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface OptionBase<T> {
|
|
32
|
+
key: string
|
|
33
|
+
title: string
|
|
34
|
+
description?: string
|
|
35
|
+
placeholder?: string
|
|
36
|
+
disable?: boolean
|
|
37
|
+
error?: string
|
|
38
|
+
value?: T
|
|
39
|
+
defaultValue?:T
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface InputOption extends OptionBase<string> {
|
|
43
|
+
type: 'input';
|
|
44
|
+
event?: {
|
|
45
|
+
onLoad?: (e: OptionEvent) => void;
|
|
46
|
+
onChange?: (e: OptionEvent) => void;
|
|
47
|
+
onFocus?: (e: OptionEvent) => void;
|
|
48
|
+
onBlur?: (e: OptionEvent) => void;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SelectOption extends OptionBase<string[]> {
|
|
53
|
+
type: 'select';
|
|
54
|
+
options: Array<{
|
|
55
|
+
label: string, value: string, description?: string, icon?: string
|
|
56
|
+
}>;
|
|
57
|
+
multiple: boolean;
|
|
58
|
+
search?: string,
|
|
59
|
+
event?: {
|
|
60
|
+
onLoad?: (e: OptionEvent) => void;
|
|
61
|
+
onSearch?: (e: OptionEvent) => void;
|
|
62
|
+
onChange?: (e: OptionEvent) => void;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SwitchOption extends OptionBase<boolean> {
|
|
67
|
+
type: 'switch';
|
|
68
|
+
event?: {
|
|
69
|
+
onLoad?: (e: OptionEvent) => void;
|
|
70
|
+
|
|
71
|
+
onChange?: (e: OptionEvent) => void;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ButtonOption extends OptionBase<string> {
|
|
76
|
+
type: 'button';
|
|
77
|
+
event:? {
|
|
78
|
+
onLoad?: (e: OptionEvent) => void;
|
|
79
|
+
onClick: (e: OptionEvent) => void;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type Options =
|
|
84
|
+
| InputOption
|
|
85
|
+
| SelectOption
|
|
86
|
+
| SwitchOption
|
|
87
|
+
| ButtonOption
|
|
88
|
+
|
|
89
|
+
type configExcludeKeys = 'event' | 'type' | "title" | "key"; // 添加您想排除的属性名
|
|
90
|
+
|
|
91
|
+
type ConfigWithExcludeKeys<T extends Options> = Partial<Omit<T, configExcludeKeys>>;
|
|
92
|
+
type ExcludeUndefined<T> = T extends undefined ? never : T;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export class Config {
|
|
96
|
+
static async get<T extends Options>(key: string): Promise<ExcludeUndefined<T['value']> | null>
|
|
97
|
+
static async get<T extends Options>(key: string, defaultValue: T['value']): Promise<ExcludeUndefined<T['value']>>
|
|
98
|
+
|
|
99
|
+
static async set<T extends Options>(key: string, value: T['value']): Promise<boolean>
|
|
100
|
+
|
|
101
|
+
static async updateStruct<T extends Options>(key: string, value: ConfigWithExcludeKeys<T>): Promise<boolean>
|
|
102
|
+
|
|
103
|
+
static async getStruct<T extends Options>(key: string): Promise<T>
|
|
104
|
+
|
|
105
|
+
static async setError(key: string, error: string): Promise<void>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type IConfig = Config;
|
|
109
|
+
|
|
110
|
+
export interface EventProps {
|
|
111
|
+
name: string;
|
|
112
|
+
size: size;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
export interface Events {
|
|
117
|
+
onScheduled: (props: EventProps) => void;
|
|
118
|
+
onCreated?: (props: EventProps) => void;
|
|
119
|
+
onShow?: (props: EventProps) => void;
|
|
120
|
+
onHide?: (props: EventProps) => void;
|
|
121
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kepoai/provider",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./api": {
|
|
7
|
+
"import": "./api/index.d.ts"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/node": "^20.10.6",
|
|
14
|
+
"@types/uuid": "^9.0.7",
|
|
15
|
+
"puppeteer-core": "^22.4.1",
|
|
16
|
+
"typescript": "^5.3.3"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@kepoai/types": "^0.0.3",
|
|
20
|
+
"electron": "25.9.8",
|
|
21
|
+
"uuid": "^9.0.1"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"watch": "tsc --watch"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext", // 根据您的Node.js版本,设置为适当的ECMAScript版本
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"sourceMap": true, // 生成源码映射文件以支持调试
|
|
6
|
+
"outDir": "./dist", // 编译后文件的输出目录
|
|
7
|
+
"rootDir": "./src", // 您的源文件所在的目录
|
|
8
|
+
"strict": true, // 启用所有严格类型检查选项
|
|
9
|
+
"esModuleInterop": true, // 启用esModule语法
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"resolveJsonModule": true, // 允许导入.json文件
|
|
12
|
+
"isolatedModules": true, // 确保每个文件可以单独编译
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"skipLibCheck": true, // 跳过库文件的类型检查,加快编译速度
|
|
15
|
+
"noImplicitAny": true,
|
|
16
|
+
"composite": true,
|
|
17
|
+
"types": ["node"], // 包含Node.js类型定义
|
|
18
|
+
"baseUrl": ".", // 基本URL设置为项目根目录
|
|
19
|
+
},
|
|
20
|
+
"include": ["**/*","types.d.ts"], // 包含src目录及其所有子目录中的文件
|
|
21
|
+
"exclude": ["node_modules", "dist"] // 排除不需要编译的目录
|
|
22
|
+
}
|