intools-cli 1.0.0 → 1.0.2
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/README.md +46 -3
- package/dist/commands/create/assets.js +53 -0
- package/dist/commands/create/basic.js +58 -0
- package/dist/commands/create/index.js +68 -0
- package/dist/commands/create/react.js +106 -0
- package/dist/commands/create/templates/basic.js +95 -0
- package/dist/commands/create/templates/react.js +1196 -0
- package/package.json +3 -3
- package/dist/commands/create.js +0 -1038
|
@@ -0,0 +1,1196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildReactManifest = buildReactManifest;
|
|
4
|
+
exports.buildReactPackageJson = buildReactPackageJson;
|
|
5
|
+
exports.buildTsConfig = buildTsConfig;
|
|
6
|
+
exports.buildViteConfig = buildViteConfig;
|
|
7
|
+
exports.buildBackendMain = buildBackendMain;
|
|
8
|
+
exports.buildIndexHtml = buildIndexHtml;
|
|
9
|
+
exports.buildMainTsx = buildMainTsx;
|
|
10
|
+
exports.buildAppTsx = buildAppTsx;
|
|
11
|
+
exports.buildStylesCss = buildStylesCss;
|
|
12
|
+
exports.buildUseIntools = buildUseIntools;
|
|
13
|
+
exports.buildIntoolsTypes = buildIntoolsTypes;
|
|
14
|
+
function buildReactManifest(name) {
|
|
15
|
+
return {
|
|
16
|
+
id: name,
|
|
17
|
+
name,
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
displayName: name,
|
|
20
|
+
description: '插件描述',
|
|
21
|
+
main: 'dist/main.js',
|
|
22
|
+
ui: 'ui/index.html',
|
|
23
|
+
icon: 'icon.png',
|
|
24
|
+
features: [
|
|
25
|
+
{
|
|
26
|
+
code: 'main',
|
|
27
|
+
explain: '主功能',
|
|
28
|
+
cmds: [{ type: 'keyword', value: name }]
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function buildReactPackageJson(name) {
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
version: '1.0.0',
|
|
37
|
+
type: 'module',
|
|
38
|
+
scripts: {
|
|
39
|
+
dev: 'intools dev',
|
|
40
|
+
build: 'npm run build:backend && npm run build:ui',
|
|
41
|
+
'build:backend': 'esbuild src/main.ts --bundle --platform=node --outfile=dist/main.js',
|
|
42
|
+
'build:ui': 'vite build',
|
|
43
|
+
pack: 'intools pack'
|
|
44
|
+
},
|
|
45
|
+
dependencies: {
|
|
46
|
+
react: '^18.2.0',
|
|
47
|
+
'react-dom': '^18.2.0'
|
|
48
|
+
},
|
|
49
|
+
devDependencies: {
|
|
50
|
+
'@types/react': '^18.2.0',
|
|
51
|
+
'@types/react-dom': '^18.2.0',
|
|
52
|
+
'@vitejs/plugin-react': '^4.2.0',
|
|
53
|
+
esbuild: '^0.20.0',
|
|
54
|
+
typescript: '^5.3.0',
|
|
55
|
+
vite: '^5.0.0'
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildTsConfig() {
|
|
60
|
+
return {
|
|
61
|
+
compilerOptions: {
|
|
62
|
+
target: 'ES2020',
|
|
63
|
+
useDefineForClassFields: true,
|
|
64
|
+
lib: ['ES2020', 'DOM', 'DOM.Iterable'],
|
|
65
|
+
module: 'ESNext',
|
|
66
|
+
skipLibCheck: true,
|
|
67
|
+
moduleResolution: 'bundler',
|
|
68
|
+
allowImportingTsExtensions: true,
|
|
69
|
+
resolveJsonModule: true,
|
|
70
|
+
isolatedModules: true,
|
|
71
|
+
noEmit: true,
|
|
72
|
+
jsx: 'react-jsx',
|
|
73
|
+
strict: true,
|
|
74
|
+
noUnusedLocals: true,
|
|
75
|
+
noUnusedParameters: true,
|
|
76
|
+
noFallthroughCasesInSwitch: true
|
|
77
|
+
},
|
|
78
|
+
include: ['src']
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function buildViteConfig() {
|
|
82
|
+
return `import { defineConfig } from 'vite'
|
|
83
|
+
import react from '@vitejs/plugin-react'
|
|
84
|
+
import path from 'path'
|
|
85
|
+
|
|
86
|
+
export default defineConfig({
|
|
87
|
+
plugins: [react()],
|
|
88
|
+
root: 'src/ui',
|
|
89
|
+
base: './',
|
|
90
|
+
build: {
|
|
91
|
+
outDir: '../../ui',
|
|
92
|
+
emptyOutDir: true
|
|
93
|
+
},
|
|
94
|
+
resolve: {
|
|
95
|
+
alias: {
|
|
96
|
+
'@': path.resolve(__dirname, 'src')
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
function buildBackendMain(name) {
|
|
103
|
+
return `interface PluginContext {
|
|
104
|
+
api: {
|
|
105
|
+
clipboard: {
|
|
106
|
+
readText: () => string
|
|
107
|
+
writeText: (text: string) => Promise<void>
|
|
108
|
+
readImage: () => ArrayBuffer | null
|
|
109
|
+
getFormat: () => string
|
|
110
|
+
}
|
|
111
|
+
notification: {
|
|
112
|
+
show: (message: string, type?: string) => void
|
|
113
|
+
}
|
|
114
|
+
features?: {
|
|
115
|
+
getFeatures: (codes?: string[]) => Array<{ code: string }>
|
|
116
|
+
setFeature: (feature: {
|
|
117
|
+
code: string
|
|
118
|
+
explain?: string
|
|
119
|
+
icon?: string
|
|
120
|
+
platform?: string | string[]
|
|
121
|
+
mode?: 'ui' | 'silent' | 'detached'
|
|
122
|
+
route?: string
|
|
123
|
+
mainHide?: boolean
|
|
124
|
+
mainPush?: boolean
|
|
125
|
+
cmds: Array<string | { type: 'keyword' | 'regex'; value?: string; match?: string; explain?: string }>
|
|
126
|
+
}) => void
|
|
127
|
+
removeFeature: (code: string) => boolean
|
|
128
|
+
redirectHotKeySetting: (cmdLabel: string, autocopy?: boolean) => void
|
|
129
|
+
redirectAiModelsSetting: () => void
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
input?: string
|
|
133
|
+
featureCode?: string
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function onLoad() {
|
|
137
|
+
console.log('[${name}] 插件已加载')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function onUnload() {
|
|
141
|
+
console.log('[${name}] 插件已卸载')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function onEnable() {
|
|
145
|
+
console.log('[${name}] 插件已启用')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function onDisable() {
|
|
149
|
+
console.log('[${name}] 插件已禁用')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function run(context: PluginContext) {
|
|
153
|
+
const { notification } = context.api
|
|
154
|
+
notification.show('插件已启动')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const plugin = { onLoad, onUnload, onEnable, onDisable, run }
|
|
158
|
+
export default plugin
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
function buildIndexHtml(name) {
|
|
162
|
+
return `<!DOCTYPE html>
|
|
163
|
+
<html lang="zh-CN">
|
|
164
|
+
<head>
|
|
165
|
+
<meta charset="UTF-8">
|
|
166
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
167
|
+
<title>${name}</title>
|
|
168
|
+
</head>
|
|
169
|
+
<body>
|
|
170
|
+
<div id="root"></div>
|
|
171
|
+
<script type="module" src="./main.tsx"></script>
|
|
172
|
+
</body>
|
|
173
|
+
</html>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
function buildMainTsx() {
|
|
177
|
+
return `import React from 'react'
|
|
178
|
+
import ReactDOM from 'react-dom/client'
|
|
179
|
+
import App from './App'
|
|
180
|
+
import './styles.css'
|
|
181
|
+
|
|
182
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
183
|
+
<React.StrictMode>
|
|
184
|
+
<App />
|
|
185
|
+
</React.StrictMode>
|
|
186
|
+
)
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
function buildAppTsx(name) {
|
|
190
|
+
return `import { useEffect, useState } from 'react'
|
|
191
|
+
import { useIntools } from './hooks/useIntools'
|
|
192
|
+
|
|
193
|
+
interface PluginInitData {
|
|
194
|
+
pluginName: string
|
|
195
|
+
featureCode: string
|
|
196
|
+
input: string
|
|
197
|
+
mode?: string
|
|
198
|
+
route?: string
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default function App() {
|
|
202
|
+
const [input, setInput] = useState('')
|
|
203
|
+
const [output, setOutput] = useState('')
|
|
204
|
+
const { clipboard, notification } = useIntools('${name}')
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
// 接收插件初始化数据
|
|
208
|
+
window.intools?.onPluginInit?.((data: PluginInitData) => {
|
|
209
|
+
if (data.input) {
|
|
210
|
+
setInput(data.input)
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}, [])
|
|
214
|
+
|
|
215
|
+
const handleProcess = async () => {
|
|
216
|
+
// 示例:将输入转为大写
|
|
217
|
+
const result = input.toUpperCase()
|
|
218
|
+
setOutput(result)
|
|
219
|
+
|
|
220
|
+
// 复制到剪贴板并通知
|
|
221
|
+
await clipboard.writeText(result)
|
|
222
|
+
notification.show('已复制到剪贴板')
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div className="app">
|
|
227
|
+
<div className="titlebar">${name}</div>
|
|
228
|
+
<div className="container">
|
|
229
|
+
<div className="field">
|
|
230
|
+
<label>输入</label>
|
|
231
|
+
<textarea
|
|
232
|
+
value={input}
|
|
233
|
+
onChange={(e) => setInput(e.target.value)}
|
|
234
|
+
placeholder="请输入内容..."
|
|
235
|
+
/>
|
|
236
|
+
</div>
|
|
237
|
+
<div className="actions">
|
|
238
|
+
<button className="btn-primary" onClick={handleProcess}>
|
|
239
|
+
处理
|
|
240
|
+
</button>
|
|
241
|
+
</div>
|
|
242
|
+
<div className="field">
|
|
243
|
+
<label>输出</label>
|
|
244
|
+
<textarea
|
|
245
|
+
value={output}
|
|
246
|
+
readOnly
|
|
247
|
+
placeholder="结果将显示在这里..."
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
function buildStylesCss() {
|
|
257
|
+
return `* {
|
|
258
|
+
margin: 0;
|
|
259
|
+
padding: 0;
|
|
260
|
+
box-sizing: border-box;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
body {
|
|
264
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
265
|
+
background: #1e1e1e;
|
|
266
|
+
color: #e0e0e0;
|
|
267
|
+
min-height: 100vh;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.app {
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-direction: column;
|
|
273
|
+
height: 100vh;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.titlebar {
|
|
277
|
+
height: 32px;
|
|
278
|
+
background: #2d2d2d;
|
|
279
|
+
display: flex;
|
|
280
|
+
align-items: center;
|
|
281
|
+
justify-content: center;
|
|
282
|
+
font-size: 13px;
|
|
283
|
+
color: #999;
|
|
284
|
+
-webkit-app-region: drag;
|
|
285
|
+
flex-shrink: 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.container {
|
|
289
|
+
flex: 1;
|
|
290
|
+
padding: 16px;
|
|
291
|
+
display: flex;
|
|
292
|
+
flex-direction: column;
|
|
293
|
+
gap: 12px;
|
|
294
|
+
overflow: auto;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.field {
|
|
298
|
+
display: flex;
|
|
299
|
+
flex-direction: column;
|
|
300
|
+
gap: 6px;
|
|
301
|
+
flex: 1;
|
|
302
|
+
min-height: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.field label {
|
|
306
|
+
font-size: 12px;
|
|
307
|
+
color: #999;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.field textarea {
|
|
311
|
+
flex: 1;
|
|
312
|
+
background: #2d2d2d;
|
|
313
|
+
border: 1px solid #3d3d3d;
|
|
314
|
+
border-radius: 6px;
|
|
315
|
+
padding: 12px;
|
|
316
|
+
color: #fff;
|
|
317
|
+
font-family: 'Monaco', 'Consolas', monospace;
|
|
318
|
+
font-size: 13px;
|
|
319
|
+
resize: none;
|
|
320
|
+
outline: none;
|
|
321
|
+
min-height: 80px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.field textarea:focus {
|
|
325
|
+
border-color: #0078d4;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.field textarea::placeholder {
|
|
329
|
+
color: #666;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.actions {
|
|
333
|
+
display: flex;
|
|
334
|
+
gap: 12px;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
button {
|
|
339
|
+
padding: 8px 24px;
|
|
340
|
+
border: none;
|
|
341
|
+
border-radius: 4px;
|
|
342
|
+
font-size: 14px;
|
|
343
|
+
cursor: pointer;
|
|
344
|
+
transition: background 0.2s;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.btn-primary {
|
|
348
|
+
background: #0078d4;
|
|
349
|
+
color: #fff;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.btn-primary:hover {
|
|
353
|
+
background: #1084d8;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.btn-secondary {
|
|
357
|
+
background: #3d3d3d;
|
|
358
|
+
color: #fff;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.btn-secondary:hover {
|
|
362
|
+
background: #4d4d4d;
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
function buildUseIntools() {
|
|
367
|
+
return `import { useMemo } from 'react'
|
|
368
|
+
|
|
369
|
+
export function useIntools(pluginId?: string) {
|
|
370
|
+
return useMemo(() => ({
|
|
371
|
+
// Clipboard API
|
|
372
|
+
clipboard: {
|
|
373
|
+
readText: () => window.intools?.clipboard?.readText(),
|
|
374
|
+
writeText: (text: string) => window.intools?.clipboard?.writeText(text),
|
|
375
|
+
readImage: () => window.intools?.clipboard?.readImage(),
|
|
376
|
+
writeImage: (image: string | ArrayBuffer) => window.intools?.clipboard?.writeImage(image),
|
|
377
|
+
readFiles: () => window.intools?.clipboard?.readFiles(),
|
|
378
|
+
writeFiles: (files: string | string[]) => window.intools?.clipboard?.writeFiles(files),
|
|
379
|
+
getFormat: () => window.intools?.clipboard?.getFormat(),
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
// Input API
|
|
383
|
+
input: {
|
|
384
|
+
hideMainWindowPasteText: (text: string) => window.intools?.input?.hideMainWindowPasteText(text),
|
|
385
|
+
hideMainWindowPasteImage: (image: string | ArrayBuffer) => window.intools?.input?.hideMainWindowPasteImage(image),
|
|
386
|
+
hideMainWindowPasteFile: (filePaths: string | string[]) => window.intools?.input?.hideMainWindowPasteFile(filePaths),
|
|
387
|
+
hideMainWindowTypeString: (text: string) => window.intools?.input?.hideMainWindowTypeString(text),
|
|
388
|
+
simulateKeyboardTap: (key: string, ...modifiers: string[]) =>
|
|
389
|
+
window.intools?.input?.simulateKeyboardTap(key, ...modifiers),
|
|
390
|
+
simulateMouseMove: (x: number, y: number) => window.intools?.input?.simulateMouseMove(x, y),
|
|
391
|
+
simulateMouseClick: (x: number, y: number) => window.intools?.input?.simulateMouseClick(x, y),
|
|
392
|
+
simulateMouseDoubleClick: (x: number, y: number) => window.intools?.input?.simulateMouseDoubleClick(x, y),
|
|
393
|
+
simulateMouseRightClick: (x: number, y: number) => window.intools?.input?.simulateMouseRightClick(x, y),
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
// Storage API
|
|
397
|
+
storage: {
|
|
398
|
+
get: (key: string) => window.intools?.storage?.get(key, pluginId),
|
|
399
|
+
set: (key: string, value: unknown) => window.intools?.storage?.set(key, value, pluginId),
|
|
400
|
+
remove: (key: string) => window.intools?.storage?.remove(key, pluginId),
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
// Notification API
|
|
404
|
+
notification: {
|
|
405
|
+
show: (message: string, type?: 'info' | 'success' | 'warning' | 'error') =>
|
|
406
|
+
window.intools?.notification?.show(message, type),
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
// Window API
|
|
410
|
+
window: {
|
|
411
|
+
setSize: (width: number, height: number) => window.intools?.window?.setSize(width, height),
|
|
412
|
+
setExpendHeight: (height: number) => window.intools?.window?.setExpendHeight?.(height),
|
|
413
|
+
center: () => window.intools?.window?.center?.(),
|
|
414
|
+
hide: (isRestorePreWindow?: boolean) => window.intools?.window?.hide?.(isRestorePreWindow),
|
|
415
|
+
show: () => window.intools?.window?.show(),
|
|
416
|
+
close: () => window.intools?.window?.close(),
|
|
417
|
+
create: (url: string, options?: { width?: number; height?: number; title?: string }) =>
|
|
418
|
+
window.intools?.window?.create(url, options),
|
|
419
|
+
detach: () => window.intools?.window?.detach?.(),
|
|
420
|
+
setAlwaysOnTop: (flag: boolean) => window.intools?.window?.setAlwaysOnTop?.(flag),
|
|
421
|
+
getMode: () => window.intools?.window?.getMode?.(),
|
|
422
|
+
getWindowType: () => window.intools?.window?.getWindowType?.(),
|
|
423
|
+
minimize: () => window.intools?.window?.minimize?.(),
|
|
424
|
+
maximize: () => window.intools?.window?.maximize?.(),
|
|
425
|
+
getState: () => window.intools?.window?.getState?.(),
|
|
426
|
+
reload: () => window.intools?.window?.reload?.(),
|
|
427
|
+
sendToParent: (channel: string, ...args: unknown[]) =>
|
|
428
|
+
window.intools?.window?.sendToParent?.(channel, ...args),
|
|
429
|
+
onChildMessage: (callback: (channel: string, ...args: unknown[]) => void) =>
|
|
430
|
+
window.intools?.window?.onChildMessage?.(callback),
|
|
431
|
+
findInPage: (text: string, options?: { forward?: boolean; findNext?: boolean; matchCase?: boolean }) =>
|
|
432
|
+
window.intools?.window?.findInPage?.(text, options),
|
|
433
|
+
stopFindInPage: (action?: 'clearSelection' | 'keepSelection' | 'activateSelection') =>
|
|
434
|
+
window.intools?.window?.stopFindInPage?.(action),
|
|
435
|
+
startDrag: (filePath: string | string[]) => window.intools?.window?.startDrag?.(filePath),
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
// SubInput API
|
|
439
|
+
subInput: {
|
|
440
|
+
set: (placeholder?: string, isFocus?: boolean) => window.intools?.subInput?.set?.(placeholder, isFocus),
|
|
441
|
+
remove: () => window.intools?.subInput?.remove?.(),
|
|
442
|
+
setValue: (text: string) => window.intools?.subInput?.setValue?.(text),
|
|
443
|
+
focus: () => window.intools?.subInput?.focus?.(),
|
|
444
|
+
blur: () => window.intools?.subInput?.blur?.(),
|
|
445
|
+
select: () => window.intools?.subInput?.select?.(),
|
|
446
|
+
onChange: (callback: (data: { text: string }) => void) => window.intools?.subInput?.onChange?.(callback),
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
// Plugin API
|
|
450
|
+
plugin: {
|
|
451
|
+
redirect: (label: string | [string, string], payload?: unknown) =>
|
|
452
|
+
window.intools?.plugin?.redirect?.(label, payload),
|
|
453
|
+
outPlugin: (isKill?: boolean) => window.intools?.plugin?.outPlugin?.(isKill),
|
|
454
|
+
},
|
|
455
|
+
|
|
456
|
+
// HTTP API
|
|
457
|
+
http: {
|
|
458
|
+
request: (options: {
|
|
459
|
+
url: string
|
|
460
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD'
|
|
461
|
+
headers?: Record<string, string>
|
|
462
|
+
body?: unknown
|
|
463
|
+
timeout?: number
|
|
464
|
+
}) => window.intools?.http?.request(options),
|
|
465
|
+
get: (url: string, headers?: Record<string, string>) => window.intools?.http?.get(url, headers),
|
|
466
|
+
post: (url: string, body?: unknown, headers?: Record<string, string>) =>
|
|
467
|
+
window.intools?.http?.post(url, body, headers),
|
|
468
|
+
put: (url: string, body?: unknown, headers?: Record<string, string>) =>
|
|
469
|
+
window.intools?.http?.put(url, body, headers),
|
|
470
|
+
delete: (url: string, headers?: Record<string, string>) => window.intools?.http?.delete(url, headers),
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
// Filesystem API
|
|
474
|
+
filesystem: {
|
|
475
|
+
readFile: (path: string, encoding?: 'utf-8' | 'base64') => window.intools?.filesystem?.readFile(path, encoding),
|
|
476
|
+
writeFile: (path: string, data: string | ArrayBuffer, encoding?: 'utf-8' | 'base64') =>
|
|
477
|
+
window.intools?.filesystem?.writeFile(path, data, encoding),
|
|
478
|
+
exists: (path: string) => window.intools?.filesystem?.exists(path),
|
|
479
|
+
readdir: (path: string) => window.intools?.filesystem?.readdir(path),
|
|
480
|
+
mkdir: (path: string) => window.intools?.filesystem?.mkdir(path),
|
|
481
|
+
stat: (path: string) => window.intools?.filesystem?.stat(path),
|
|
482
|
+
copy: (src: string, dest: string) => window.intools?.filesystem?.copy(src, dest),
|
|
483
|
+
move: (src: string, dest: string) => window.intools?.filesystem?.move(src, dest),
|
|
484
|
+
unlink: (path: string) => window.intools?.filesystem?.unlink(path),
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
// Screen API
|
|
488
|
+
screen: {
|
|
489
|
+
getAllDisplays: () => window.intools?.screen?.getAllDisplays(),
|
|
490
|
+
getPrimaryDisplay: () => window.intools?.screen?.getPrimaryDisplay(),
|
|
491
|
+
getCursorScreenPoint: () => window.intools?.screen?.getCursorScreenPoint(),
|
|
492
|
+
getDisplayNearestPoint: (point: { x: number; y: number }) =>
|
|
493
|
+
window.intools?.screen?.getDisplayNearestPoint?.(point),
|
|
494
|
+
getDisplayMatching: (rect: { x: number; y: number; width: number; height: number }) =>
|
|
495
|
+
window.intools?.screen?.getDisplayMatching?.(rect),
|
|
496
|
+
getSources: (options?: { types?: ('screen' | 'window')[]; thumbnailSize?: { width: number; height: number } }) =>
|
|
497
|
+
window.intools?.screen?.getSources(options),
|
|
498
|
+
capture: (options?: { sourceId?: string; format?: 'png' | 'jpeg'; quality?: number }) =>
|
|
499
|
+
window.intools?.screen?.capture(options),
|
|
500
|
+
captureRegion: (region: { x: number; y: number; width: number; height: number }, options?: { format?: 'png' | 'jpeg'; quality?: number }) =>
|
|
501
|
+
window.intools?.screen?.captureRegion(region, options),
|
|
502
|
+
screenCapture: () => window.intools?.screen?.screenCapture(),
|
|
503
|
+
colorPick: () => window.intools?.screen?.colorPick?.(),
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
// Shell API
|
|
507
|
+
shell: {
|
|
508
|
+
openPath: (path: string) => window.intools?.shell?.openPath(path),
|
|
509
|
+
openExternal: (url: string) => window.intools?.shell?.openExternal(url),
|
|
510
|
+
showItemInFolder: (path: string) => window.intools?.shell?.showItemInFolder(path),
|
|
511
|
+
openFolder: (path: string) => window.intools?.shell?.openFolder(path),
|
|
512
|
+
trashItem: (path: string) => window.intools?.shell?.trashItem(path),
|
|
513
|
+
beep: () => window.intools?.shell?.beep(),
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
// Dialog API
|
|
517
|
+
dialog: {
|
|
518
|
+
showOpenDialog: (options?: {
|
|
519
|
+
title?: string
|
|
520
|
+
defaultPath?: string
|
|
521
|
+
filters?: { name: string; extensions: string[] }[]
|
|
522
|
+
properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles')[]
|
|
523
|
+
}) => window.intools?.dialog?.showOpenDialog(options),
|
|
524
|
+
showSaveDialog: (options?: {
|
|
525
|
+
title?: string
|
|
526
|
+
defaultPath?: string
|
|
527
|
+
filters?: { name: string; extensions: string[] }[]
|
|
528
|
+
}) => window.intools?.dialog?.showSaveDialog(options),
|
|
529
|
+
showMessageBox: (options: {
|
|
530
|
+
type?: 'none' | 'info' | 'error' | 'question' | 'warning'
|
|
531
|
+
title?: string
|
|
532
|
+
message: string
|
|
533
|
+
detail?: string
|
|
534
|
+
buttons?: string[]
|
|
535
|
+
}) => window.intools?.dialog?.showMessageBox(options),
|
|
536
|
+
},
|
|
537
|
+
|
|
538
|
+
// System API
|
|
539
|
+
system: {
|
|
540
|
+
getSystemInfo: () => window.intools?.system?.getSystemInfo(),
|
|
541
|
+
getAppInfo: () => window.intools?.system?.getAppInfo(),
|
|
542
|
+
getPath: (name: string) => window.intools?.system?.getPath(name as any),
|
|
543
|
+
getEnv: (name: string) => window.intools?.system?.getEnv(name),
|
|
544
|
+
getIdleTime: () => window.intools?.system?.getIdleTime(),
|
|
545
|
+
getFileIcon: (filePath: string) => window.intools?.system?.getFileIcon?.(filePath),
|
|
546
|
+
getNativeId: () => window.intools?.system?.getNativeId?.(),
|
|
547
|
+
isDev: () => window.intools?.system?.isDev?.(),
|
|
548
|
+
isMacOS: () => window.intools?.system?.isMacOS?.(),
|
|
549
|
+
isWindows: () => window.intools?.system?.isWindows?.(),
|
|
550
|
+
isLinux: () => window.intools?.system?.isLinux?.(),
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
// Permission API
|
|
554
|
+
permission: {
|
|
555
|
+
getStatus: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
|
|
556
|
+
window.intools?.permission?.getStatus(type),
|
|
557
|
+
request: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
|
|
558
|
+
window.intools?.permission?.request(type),
|
|
559
|
+
canRequest: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
|
|
560
|
+
window.intools?.permission?.canRequest(type),
|
|
561
|
+
openSystemSettings: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
|
|
562
|
+
window.intools?.permission?.openSystemSettings(type),
|
|
563
|
+
isAccessibilityTrusted: () => window.intools?.permission?.isAccessibilityTrusted()
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
// Power API
|
|
567
|
+
power: {
|
|
568
|
+
getSystemIdleTime: () => window.intools?.power?.getSystemIdleTime(),
|
|
569
|
+
getSystemIdleState: (threshold: number) => window.intools?.power?.getSystemIdleState(threshold),
|
|
570
|
+
isOnBatteryPower: () => window.intools?.power?.isOnBatteryPower(),
|
|
571
|
+
getCurrentThermalState: () => window.intools?.power?.getCurrentThermalState(),
|
|
572
|
+
},
|
|
573
|
+
|
|
574
|
+
// Network API
|
|
575
|
+
network: {
|
|
576
|
+
isOnline: () => window.intools?.network?.isOnline(),
|
|
577
|
+
},
|
|
578
|
+
|
|
579
|
+
// Geolocation API
|
|
580
|
+
geolocation: {
|
|
581
|
+
getAccessStatus: () => window.intools?.geolocation?.getAccessStatus(),
|
|
582
|
+
requestAccess: () => window.intools?.geolocation?.requestAccess(),
|
|
583
|
+
canGetPosition: () => window.intools?.geolocation?.canGetPosition(),
|
|
584
|
+
openSettings: () => window.intools?.geolocation?.openSettings(),
|
|
585
|
+
getCurrentPosition: () => window.intools?.geolocation?.getCurrentPosition(),
|
|
586
|
+
},
|
|
587
|
+
|
|
588
|
+
// TTS API
|
|
589
|
+
tts: {
|
|
590
|
+
speak: (text: string, options?: { lang?: string; rate?: number; pitch?: number; volume?: number }) =>
|
|
591
|
+
window.intools?.tts?.speak(text, options),
|
|
592
|
+
stop: () => window.intools?.tts?.stop(),
|
|
593
|
+
pause: () => window.intools?.tts?.pause(),
|
|
594
|
+
resume: () => window.intools?.tts?.resume(),
|
|
595
|
+
getVoices: () => window.intools?.tts?.getVoices(),
|
|
596
|
+
isSpeaking: () => window.intools?.tts?.isSpeaking(),
|
|
597
|
+
},
|
|
598
|
+
|
|
599
|
+
// Media API
|
|
600
|
+
media: {
|
|
601
|
+
getAccessStatus: (type: 'camera' | 'microphone') => window.intools?.media?.getAccessStatus(type),
|
|
602
|
+
askForAccess: (type: 'camera' | 'microphone') => window.intools?.media?.askForAccess(type),
|
|
603
|
+
hasCameraAccess: () => window.intools?.media?.hasCameraAccess(),
|
|
604
|
+
hasMicrophoneAccess: () => window.intools?.media?.hasMicrophoneAccess(),
|
|
605
|
+
},
|
|
606
|
+
|
|
607
|
+
// Shortcut API
|
|
608
|
+
shortcut: {
|
|
609
|
+
register: (accelerator: string) => window.intools?.shortcut?.register(accelerator),
|
|
610
|
+
unregister: (accelerator: string) => window.intools?.shortcut?.unregister(accelerator),
|
|
611
|
+
unregisterAll: () => window.intools?.shortcut?.unregisterAll(),
|
|
612
|
+
isRegistered: (accelerator: string) => window.intools?.shortcut?.isRegistered(accelerator),
|
|
613
|
+
},
|
|
614
|
+
|
|
615
|
+
// Security API
|
|
616
|
+
security: {
|
|
617
|
+
isEncryptionAvailable: () => window.intools?.security?.isEncryptionAvailable(),
|
|
618
|
+
encryptString: (text: string) => window.intools?.security?.encryptString(text),
|
|
619
|
+
decryptString: (data: ArrayBuffer) => window.intools?.security?.decryptString(data),
|
|
620
|
+
},
|
|
621
|
+
|
|
622
|
+
// Tray API
|
|
623
|
+
tray: {
|
|
624
|
+
create: (options: { icon: string; tooltip?: string; title?: string }) =>
|
|
625
|
+
window.intools?.tray?.create(options),
|
|
626
|
+
destroy: () => window.intools?.tray?.destroy(),
|
|
627
|
+
setIcon: (icon: string) => window.intools?.tray?.setIcon(icon),
|
|
628
|
+
setTooltip: (tooltip: string) => window.intools?.tray?.setTooltip(tooltip),
|
|
629
|
+
setTitle: (title: string) => window.intools?.tray?.setTitle(title),
|
|
630
|
+
exists: () => window.intools?.tray?.exists(),
|
|
631
|
+
},
|
|
632
|
+
|
|
633
|
+
// Menu API
|
|
634
|
+
menu: {
|
|
635
|
+
showContextMenu: (items: {
|
|
636
|
+
label?: string
|
|
637
|
+
type?: 'normal' | 'separator' | 'checkbox' | 'radio'
|
|
638
|
+
checked?: boolean
|
|
639
|
+
enabled?: boolean
|
|
640
|
+
id?: string
|
|
641
|
+
submenu?: unknown[]
|
|
642
|
+
}[]) => window.intools?.menu?.showContextMenu(items as Parameters<typeof window.intools.menu.showContextMenu>[0]),
|
|
643
|
+
},
|
|
644
|
+
|
|
645
|
+
// Theme API
|
|
646
|
+
theme: {
|
|
647
|
+
get: () => window.intools?.theme?.get(),
|
|
648
|
+
set: (mode: 'light' | 'dark' | 'system') => window.intools?.theme?.set(mode),
|
|
649
|
+
getActual: () => window.intools?.theme?.getActual(),
|
|
650
|
+
},
|
|
651
|
+
|
|
652
|
+
// Host API
|
|
653
|
+
host: {
|
|
654
|
+
invoke: (pluginName: string, method: string, ...args: unknown[]) => window.intools?.host?.invoke(pluginName, method, ...args),
|
|
655
|
+
status: (pluginName: string) => window.intools?.host?.status(pluginName),
|
|
656
|
+
restart: (pluginName: string) => window.intools?.host?.restart(pluginName),
|
|
657
|
+
},
|
|
658
|
+
|
|
659
|
+
// InBrowser API
|
|
660
|
+
inbrowser: window.intools?.inbrowser,
|
|
661
|
+
|
|
662
|
+
// Sharp API
|
|
663
|
+
sharp: window.intools?.sharp,
|
|
664
|
+
getSharpVersion: () => window.intools?.getSharpVersion?.(),
|
|
665
|
+
|
|
666
|
+
// FFmpeg API
|
|
667
|
+
ffmpeg: window.intools?.ffmpeg,
|
|
668
|
+
}), [pluginId])
|
|
669
|
+
}
|
|
670
|
+
`;
|
|
671
|
+
}
|
|
672
|
+
function buildIntoolsTypes() {
|
|
673
|
+
return `// InTools API 类型定义
|
|
674
|
+
|
|
675
|
+
interface ClipboardFileInfo {
|
|
676
|
+
path: string
|
|
677
|
+
name: string
|
|
678
|
+
size: number
|
|
679
|
+
isDirectory: boolean
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
interface IntoolsClipboard {
|
|
683
|
+
readText(): Promise<string>
|
|
684
|
+
writeText(text: string): Promise<void>
|
|
685
|
+
readImage(): Promise<ArrayBuffer | null>
|
|
686
|
+
writeImage(image: string | ArrayBuffer): Promise<void>
|
|
687
|
+
readFiles(): Promise<ClipboardFileInfo[]>
|
|
688
|
+
writeFiles(files: string | string[]): Promise<boolean>
|
|
689
|
+
getFormat(): Promise<'text' | 'image' | 'files' | 'empty'>
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
interface IntoolsInput {
|
|
693
|
+
hideMainWindowPasteText(text: string): Promise<boolean>
|
|
694
|
+
hideMainWindowPasteImage(image: string | ArrayBuffer): Promise<boolean>
|
|
695
|
+
hideMainWindowPasteFile(filePaths: string | string[]): Promise<boolean>
|
|
696
|
+
hideMainWindowTypeString(text: string): Promise<boolean>
|
|
697
|
+
simulateKeyboardTap(key: string, ...modifiers: string[]): Promise<boolean>
|
|
698
|
+
simulateMouseMove(x: number, y: number): Promise<boolean>
|
|
699
|
+
simulateMouseClick(x: number, y: number): Promise<boolean>
|
|
700
|
+
simulateMouseDoubleClick(x: number, y: number): Promise<boolean>
|
|
701
|
+
simulateMouseRightClick(x: number, y: number): Promise<boolean>
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
interface IntoolsNotification {
|
|
705
|
+
show(message: string, type?: 'info' | 'success' | 'warning' | 'error'): void
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
interface BrowserWindowProxy {
|
|
709
|
+
id: number
|
|
710
|
+
show(): Promise<void>
|
|
711
|
+
hide(): Promise<void>
|
|
712
|
+
close(): Promise<void>
|
|
713
|
+
focus(): Promise<void>
|
|
714
|
+
setTitle(title: string): Promise<void>
|
|
715
|
+
setSize(width: number, height: number): Promise<void>
|
|
716
|
+
setPosition(x: number, y: number): Promise<void>
|
|
717
|
+
postMessage(channel: string, ...args: unknown[]): Promise<void>
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
interface IntoolsWindow {
|
|
721
|
+
hide(isRestorePreWindow?: boolean): void
|
|
722
|
+
show(): void
|
|
723
|
+
setSize(width: number, height: number): void
|
|
724
|
+
setExpendHeight(height: number): void
|
|
725
|
+
center(): void
|
|
726
|
+
create(url: string, options?: { width?: number; height?: number; title?: string }): Promise<BrowserWindowProxy | null>
|
|
727
|
+
close(): void
|
|
728
|
+
detach(): void
|
|
729
|
+
setAlwaysOnTop(flag: boolean): void
|
|
730
|
+
getMode(): Promise<'attached' | 'detached'>
|
|
731
|
+
getWindowType(): Promise<'main' | 'detach'>
|
|
732
|
+
minimize(): void
|
|
733
|
+
maximize(): void
|
|
734
|
+
getState(): Promise<{ isMaximized: boolean; isAlwaysOnTop: boolean }>
|
|
735
|
+
reload(): void
|
|
736
|
+
sendToParent(channel: string, ...args: unknown[]): void
|
|
737
|
+
onChildMessage(callback: (channel: string, ...args: unknown[]) => void): void
|
|
738
|
+
findInPage(text: string, options?: { forward?: boolean; findNext?: boolean; matchCase?: boolean }): Promise<number>
|
|
739
|
+
stopFindInPage(action?: 'clearSelection' | 'keepSelection' | 'activateSelection'): void
|
|
740
|
+
startDrag(filePath: string | string[]): void
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
interface IntoolsSubInput {
|
|
744
|
+
set(placeholder?: string, isFocus?: boolean): Promise<boolean>
|
|
745
|
+
remove(): Promise<boolean>
|
|
746
|
+
setValue(text: string): void
|
|
747
|
+
focus(): void
|
|
748
|
+
blur(): void
|
|
749
|
+
select(): void
|
|
750
|
+
onChange(callback: (data: { text: string }) => void): void
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
interface IntoolsTheme {
|
|
754
|
+
get(): Promise<{ mode: 'light' | 'dark' | 'system'; actual: 'light' | 'dark' }>
|
|
755
|
+
set(mode: 'light' | 'dark' | 'system'): Promise<{ mode: 'light' | 'dark' | 'system'; actual: 'light' | 'dark' }>
|
|
756
|
+
getActual(): Promise<'light' | 'dark'>
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
interface IntoolsPlugin {
|
|
760
|
+
getAll(): Promise<any[]>
|
|
761
|
+
search(query: string): Promise<any[]>
|
|
762
|
+
run(name: string, featureCode: string, input?: string): Promise<any>
|
|
763
|
+
install(filePath: string): Promise<any>
|
|
764
|
+
enable(name: string): Promise<any>
|
|
765
|
+
disable(name: string): Promise<any>
|
|
766
|
+
uninstall(name: string): Promise<any>
|
|
767
|
+
getReadme(name: string): Promise<string | null>
|
|
768
|
+
redirect(label: string | [string, string], payload?: unknown): Promise<boolean | { candidates: { name: string; displayName: string }[] }>
|
|
769
|
+
outPlugin(isKill?: boolean): Promise<boolean>
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
interface DisplayInfo {
|
|
773
|
+
id: number
|
|
774
|
+
label: string
|
|
775
|
+
bounds: { x: number; y: number; width: number; height: number }
|
|
776
|
+
workArea: { x: number; y: number; width: number; height: number }
|
|
777
|
+
scaleFactor: number
|
|
778
|
+
rotation: number
|
|
779
|
+
isPrimary: boolean
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
interface CaptureSource {
|
|
783
|
+
id: string
|
|
784
|
+
name: string
|
|
785
|
+
thumbnailDataUrl: string
|
|
786
|
+
displayId?: string
|
|
787
|
+
appIconDataUrl?: string
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
interface ColorPickResult {
|
|
791
|
+
hex: string
|
|
792
|
+
rgb: string
|
|
793
|
+
r: number
|
|
794
|
+
g: number
|
|
795
|
+
b: number
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
interface IntoolsScreen {
|
|
799
|
+
getAllDisplays(): Promise<DisplayInfo[]>
|
|
800
|
+
getPrimaryDisplay(): Promise<DisplayInfo>
|
|
801
|
+
getDisplayNearestPoint(point: { x: number; y: number }): Promise<DisplayInfo>
|
|
802
|
+
getDisplayMatching(rect: { x: number; y: number; width: number; height: number }): Promise<DisplayInfo>
|
|
803
|
+
getCursorScreenPoint(): Promise<{ x: number; y: number }>
|
|
804
|
+
getSources(options?: { types?: ('screen' | 'window')[]; thumbnailSize?: { width: number; height: number } }): Promise<CaptureSource[]>
|
|
805
|
+
capture(options?: { sourceId?: string; format?: 'png' | 'jpeg'; quality?: number }): Promise<ArrayBuffer>
|
|
806
|
+
captureRegion(region: { x: number; y: number; width: number; height: number }, options?: { format?: 'png' | 'jpeg'; quality?: number }): Promise<ArrayBuffer>
|
|
807
|
+
getMediaStreamConstraints(options: { sourceId: string; audio?: boolean; frameRate?: number }): Promise<object>
|
|
808
|
+
screenCapture(): Promise<string | null>
|
|
809
|
+
colorPick(): Promise<ColorPickResult | null>
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
interface IntoolsShell {
|
|
813
|
+
openPath(path: string): Promise<string>
|
|
814
|
+
openExternal(url: string): Promise<void>
|
|
815
|
+
showItemInFolder(path: string): Promise<void>
|
|
816
|
+
openFolder(path: string): Promise<string>
|
|
817
|
+
trashItem(path: string): Promise<void>
|
|
818
|
+
beep(): Promise<void>
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface IntoolsDialog {
|
|
822
|
+
showOpenDialog(options?: {
|
|
823
|
+
title?: string
|
|
824
|
+
defaultPath?: string
|
|
825
|
+
buttonLabel?: string
|
|
826
|
+
filters?: { name: string; extensions: string[] }[]
|
|
827
|
+
properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles')[]
|
|
828
|
+
}): Promise<string[]>
|
|
829
|
+
showSaveDialog(options?: {
|
|
830
|
+
title?: string
|
|
831
|
+
defaultPath?: string
|
|
832
|
+
buttonLabel?: string
|
|
833
|
+
filters?: { name: string; extensions: string[] }[]
|
|
834
|
+
}): Promise<string | null>
|
|
835
|
+
showMessageBox(options: {
|
|
836
|
+
type?: 'none' | 'info' | 'error' | 'question' | 'warning'
|
|
837
|
+
title?: string
|
|
838
|
+
message: string
|
|
839
|
+
detail?: string
|
|
840
|
+
buttons?: string[]
|
|
841
|
+
defaultId?: number
|
|
842
|
+
cancelId?: number
|
|
843
|
+
}): Promise<{ response: number; checkboxChecked: boolean }>
|
|
844
|
+
showErrorBox(title: string, content: string): Promise<void>
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
interface SystemInfo {
|
|
848
|
+
platform: string
|
|
849
|
+
arch: string
|
|
850
|
+
hostname: string
|
|
851
|
+
username: string
|
|
852
|
+
homedir: string
|
|
853
|
+
tmpdir: string
|
|
854
|
+
cpus: number
|
|
855
|
+
totalmem: number
|
|
856
|
+
freemem: number
|
|
857
|
+
uptime: number
|
|
858
|
+
osVersion: string
|
|
859
|
+
osRelease: string
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
interface AppInfo {
|
|
863
|
+
name: string
|
|
864
|
+
version: string
|
|
865
|
+
locale: string
|
|
866
|
+
isPackaged: boolean
|
|
867
|
+
userDataPath: string
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
interface IntoolsSystem {
|
|
871
|
+
getSystemInfo(): Promise<SystemInfo>
|
|
872
|
+
getAppInfo(): Promise<AppInfo>
|
|
873
|
+
getPath(name: 'home' | 'appData' | 'userData' | 'temp' | 'exe' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'logs'): Promise<string>
|
|
874
|
+
getEnv(name: string): Promise<string | undefined>
|
|
875
|
+
getIdleTime(): Promise<number>
|
|
876
|
+
getFileIcon(filePath: string): Promise<string>
|
|
877
|
+
getNativeId(): Promise<string>
|
|
878
|
+
isDev(): Promise<boolean>
|
|
879
|
+
isMacOS(): Promise<boolean>
|
|
880
|
+
isWindows(): Promise<boolean>
|
|
881
|
+
isLinux(): Promise<boolean>
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
interface IntoolsPermission {
|
|
885
|
+
getStatus(type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar'): Promise<'authorized' | 'granted' | 'denied' | 'not-determined' | 'restricted' | 'limited' | 'unknown'>
|
|
886
|
+
request(type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar'): Promise<'authorized' | 'granted' | 'denied' | 'not-determined' | 'restricted' | 'limited' | 'unknown'>
|
|
887
|
+
canRequest(type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar'): Promise<boolean>
|
|
888
|
+
openSystemSettings(type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar'): Promise<boolean>
|
|
889
|
+
isAccessibilityTrusted(): Promise<boolean>
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
interface IntoolsShortcut {
|
|
893
|
+
register(accelerator: string): Promise<boolean>
|
|
894
|
+
unregister(accelerator: string): Promise<void>
|
|
895
|
+
unregisterAll(): Promise<void>
|
|
896
|
+
isRegistered(accelerator: string): Promise<boolean>
|
|
897
|
+
onTriggered(callback: (accelerator: string) => void): void
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
interface IntoolsSecurity {
|
|
901
|
+
isEncryptionAvailable(): Promise<boolean>
|
|
902
|
+
encryptString(plainText: string): Promise<ArrayBuffer>
|
|
903
|
+
decryptString(encrypted: ArrayBuffer): Promise<string>
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
interface IntoolsMedia {
|
|
907
|
+
getAccessStatus(mediaType: 'microphone' | 'camera'): Promise<'not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'>
|
|
908
|
+
askForAccess(mediaType: 'microphone' | 'camera'): Promise<boolean>
|
|
909
|
+
hasCameraAccess(): Promise<boolean>
|
|
910
|
+
hasMicrophoneAccess(): Promise<boolean>
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
interface IntoolsPower {
|
|
914
|
+
getSystemIdleTime(): Promise<number>
|
|
915
|
+
getSystemIdleState(idleThreshold: number): Promise<'active' | 'idle' | 'locked' | 'unknown'>
|
|
916
|
+
isOnBatteryPower(): Promise<boolean>
|
|
917
|
+
getCurrentThermalState(): Promise<'unknown' | 'nominal' | 'fair' | 'serious' | 'critical'>
|
|
918
|
+
onSuspend(callback: () => void): void
|
|
919
|
+
onResume(callback: () => void): void
|
|
920
|
+
onAC(callback: () => void): void
|
|
921
|
+
onBattery(callback: () => void): void
|
|
922
|
+
onLockScreen(callback: () => void): void
|
|
923
|
+
onUnlockScreen(callback: () => void): void
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
interface IntoolsTray {
|
|
927
|
+
create(options: { icon: string; tooltip?: string; title?: string }): Promise<boolean>
|
|
928
|
+
destroy(): Promise<void>
|
|
929
|
+
setIcon(icon: string): Promise<void>
|
|
930
|
+
setTooltip(tooltip: string): Promise<void>
|
|
931
|
+
setTitle(title: string): Promise<void>
|
|
932
|
+
exists(): Promise<boolean>
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
interface IntoolsNetwork {
|
|
936
|
+
isOnline(): Promise<boolean>
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
interface IntoolsMenu {
|
|
940
|
+
showContextMenu(items: {
|
|
941
|
+
label: string
|
|
942
|
+
type?: 'normal' | 'separator' | 'checkbox' | 'radio'
|
|
943
|
+
checked?: boolean
|
|
944
|
+
enabled?: boolean
|
|
945
|
+
id?: string
|
|
946
|
+
submenu?: any[]
|
|
947
|
+
}[]): Promise<string | null>
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
interface IntoolsGeolocation {
|
|
951
|
+
getAccessStatus(): Promise<'not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'>
|
|
952
|
+
requestAccess(): Promise<'not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'>
|
|
953
|
+
canGetPosition(): Promise<boolean>
|
|
954
|
+
openSettings(): Promise<void>
|
|
955
|
+
getCurrentPosition(): Promise<{
|
|
956
|
+
latitude: number
|
|
957
|
+
longitude: number
|
|
958
|
+
accuracy: number
|
|
959
|
+
altitude?: number | null
|
|
960
|
+
altitudeAccuracy?: number | null
|
|
961
|
+
heading?: number | null
|
|
962
|
+
speed?: number | null
|
|
963
|
+
timestamp: number
|
|
964
|
+
}>
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
interface IntoolsTTS {
|
|
968
|
+
speak(text: string, options?: { lang?: string; rate?: number; pitch?: number; volume?: number }): Promise<void>
|
|
969
|
+
stop(): void
|
|
970
|
+
pause(): void
|
|
971
|
+
resume(): void
|
|
972
|
+
getVoices(): { name: string; lang: string; default: boolean; localService: boolean }[]
|
|
973
|
+
isSpeaking(): boolean
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
interface IntoolsStorage {
|
|
977
|
+
get(key: string, namespace?: string): Promise<unknown>
|
|
978
|
+
set(key: string, value: unknown, namespace?: string): Promise<void>
|
|
979
|
+
remove(key: string, namespace?: string): Promise<void>
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
interface HttpResponse {
|
|
983
|
+
status: number
|
|
984
|
+
statusText: string
|
|
985
|
+
headers: Record<string, string>
|
|
986
|
+
data: string
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
interface IntoolsHttp {
|
|
990
|
+
request(options: {
|
|
991
|
+
url: string
|
|
992
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD'
|
|
993
|
+
headers?: Record<string, string>
|
|
994
|
+
body?: unknown
|
|
995
|
+
timeout?: number
|
|
996
|
+
}): Promise<HttpResponse>
|
|
997
|
+
get(url: string, headers?: Record<string, string>): Promise<HttpResponse>
|
|
998
|
+
post(url: string, body?: unknown, headers?: Record<string, string>): Promise<HttpResponse>
|
|
999
|
+
put(url: string, body?: unknown, headers?: Record<string, string>): Promise<HttpResponse>
|
|
1000
|
+
delete(url: string, headers?: Record<string, string>): Promise<HttpResponse>
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
interface FileStat {
|
|
1004
|
+
name: string
|
|
1005
|
+
path: string
|
|
1006
|
+
size: number
|
|
1007
|
+
isFile: boolean
|
|
1008
|
+
isDirectory: boolean
|
|
1009
|
+
createdAt: number
|
|
1010
|
+
modifiedAt: number
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
interface IntoolsFilesystem {
|
|
1014
|
+
readFile(path: string, encoding?: 'utf-8' | 'base64'): Promise<string | ArrayBuffer>
|
|
1015
|
+
writeFile(path: string, data: string | ArrayBuffer, encoding?: 'utf-8' | 'base64'): Promise<void>
|
|
1016
|
+
exists(path: string): Promise<boolean>
|
|
1017
|
+
unlink(path: string): Promise<void>
|
|
1018
|
+
readdir(path: string): Promise<string[]>
|
|
1019
|
+
mkdir(path: string): Promise<void>
|
|
1020
|
+
stat(path: string): Promise<FileStat | null>
|
|
1021
|
+
copy(src: string, dest: string): Promise<void>
|
|
1022
|
+
move(src: string, dest: string): Promise<void>
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
interface IntoolsHost {
|
|
1026
|
+
invoke(pluginName: string, method: string, ...args: unknown[]): Promise<unknown>
|
|
1027
|
+
status(pluginName: string): Promise<{ ready: boolean; active: boolean }>
|
|
1028
|
+
restart(pluginName: string): Promise<boolean>
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
interface FFmpegRunProgress {
|
|
1032
|
+
bitrate: string
|
|
1033
|
+
fps: number
|
|
1034
|
+
frame: number
|
|
1035
|
+
percent?: number
|
|
1036
|
+
q: number | string
|
|
1037
|
+
size: string
|
|
1038
|
+
speed: string
|
|
1039
|
+
time: string
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
interface FFmpegDownloadProgress {
|
|
1043
|
+
phase: 'downloading' | 'extracting' | 'done'
|
|
1044
|
+
percent: number
|
|
1045
|
+
downloaded?: number
|
|
1046
|
+
total?: number
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
interface FFmpegTask {
|
|
1050
|
+
promise: Promise<void>
|
|
1051
|
+
kill(): void
|
|
1052
|
+
quit(): void
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
interface IntoolsFFmpeg {
|
|
1056
|
+
isAvailable(): Promise<boolean>
|
|
1057
|
+
getVersion(): Promise<string | null>
|
|
1058
|
+
getPath(): Promise<string | null>
|
|
1059
|
+
download(onProgress?: (progress: FFmpegDownloadProgress) => void): Promise<{ success: boolean; error?: string }>
|
|
1060
|
+
run(args: string[], onProgress?: (progress: FFmpegRunProgress) => void): FFmpegTask
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
interface PluginInitData {
|
|
1064
|
+
pluginName: string
|
|
1065
|
+
featureCode: string
|
|
1066
|
+
feature?: string
|
|
1067
|
+
input: string
|
|
1068
|
+
mode?: string
|
|
1069
|
+
route?: string
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
interface IntoolsAPI {
|
|
1073
|
+
clipboard: IntoolsClipboard
|
|
1074
|
+
input: IntoolsInput
|
|
1075
|
+
notification: IntoolsNotification
|
|
1076
|
+
window: IntoolsWindow
|
|
1077
|
+
subInput: IntoolsSubInput
|
|
1078
|
+
plugin: IntoolsPlugin
|
|
1079
|
+
theme?: IntoolsTheme
|
|
1080
|
+
screen: IntoolsScreen
|
|
1081
|
+
shell: IntoolsShell
|
|
1082
|
+
dialog: IntoolsDialog
|
|
1083
|
+
system: IntoolsSystem
|
|
1084
|
+
permission: IntoolsPermission
|
|
1085
|
+
shortcut: IntoolsShortcut
|
|
1086
|
+
security: IntoolsSecurity
|
|
1087
|
+
media: IntoolsMedia
|
|
1088
|
+
power: IntoolsPower
|
|
1089
|
+
tray: IntoolsTray
|
|
1090
|
+
network: IntoolsNetwork
|
|
1091
|
+
menu: IntoolsMenu
|
|
1092
|
+
geolocation: IntoolsGeolocation
|
|
1093
|
+
tts: IntoolsTTS
|
|
1094
|
+
storage: IntoolsStorage
|
|
1095
|
+
http: IntoolsHttp
|
|
1096
|
+
filesystem: IntoolsFilesystem
|
|
1097
|
+
host?: IntoolsHost
|
|
1098
|
+
onPluginInit(callback: (data: PluginInitData) => void): void
|
|
1099
|
+
onPluginAttach?(callback: (data: { pluginName: string; displayName: string; featureCode: string; input: string; uiPath: string; preloadPath: string }) => void): void
|
|
1100
|
+
onPluginDetached?(callback: () => void): void
|
|
1101
|
+
onThemeChange?(callback: (theme: 'light' | 'dark') => void): void
|
|
1102
|
+
onWindowStateChange?(callback: (state: { isMaximized: boolean }) => void): void
|
|
1103
|
+
inbrowser: {
|
|
1104
|
+
goto: (url: string, headers?: Record<string, string>, timeout?: number) => any
|
|
1105
|
+
useragent: (ua: string) => any
|
|
1106
|
+
device: (name: string) => any
|
|
1107
|
+
viewport: (width: number, height: number) => any
|
|
1108
|
+
show: () => any
|
|
1109
|
+
hide: () => any
|
|
1110
|
+
evaluate: (func: string | Function, ...params: any[]) => any
|
|
1111
|
+
wait: (msOrSelector: number | string) => any
|
|
1112
|
+
click: (selector: string) => any
|
|
1113
|
+
mousedown: (selector: string) => any
|
|
1114
|
+
mouseup: (selector: string) => any
|
|
1115
|
+
scroll: (selector: string | number, y?: number) => any
|
|
1116
|
+
devTools: (mode?: 'right' | 'bottom' | 'undocked' | 'detach') => any
|
|
1117
|
+
paste: (text: string) => any
|
|
1118
|
+
file: (selector: string, payload: string | string[]) => any
|
|
1119
|
+
end: () => any
|
|
1120
|
+
type: (selector: string, text: string) => any
|
|
1121
|
+
press: (key: string, modifiers?: string[]) => any
|
|
1122
|
+
check: (selector: string, checked: boolean) => any
|
|
1123
|
+
value: (selector: string, val: string) => any
|
|
1124
|
+
focus: (selector: string) => any
|
|
1125
|
+
when: (selector: string | Function, ...params: any[]) => any
|
|
1126
|
+
css: (css: string) => any
|
|
1127
|
+
pdf: (options?: any, savePath?: string) => any
|
|
1128
|
+
cookies: (nameOrFilter?: string | any) => any
|
|
1129
|
+
clearCookies: (url?: string) => any
|
|
1130
|
+
input: (selectorOrText: string, text?: string) => any
|
|
1131
|
+
dblclick: (selector: string) => any
|
|
1132
|
+
hover: (selector: string) => any
|
|
1133
|
+
screenshot: (target?: any, savePath?: string) => any
|
|
1134
|
+
drop: (selector: string, payload: any) => any
|
|
1135
|
+
download: (urlOrFunc: string | Function, savePath?: string, ...params: any[]) => any
|
|
1136
|
+
removeCookies: (name: string) => any
|
|
1137
|
+
setCookies: (nameOrCookies: any, value?: string) => any
|
|
1138
|
+
markdown: (selector?: string) => any
|
|
1139
|
+
getIdleInBrowsers: () => Promise<any[]>
|
|
1140
|
+
setInBrowserProxy: (config: any) => Promise<boolean>
|
|
1141
|
+
clearInBrowserCache: () => Promise<boolean>
|
|
1142
|
+
run: (idOrOptions?: number | any, options?: any) => Promise<any[]>
|
|
1143
|
+
}
|
|
1144
|
+
sharp: IntoolsSharpFunction
|
|
1145
|
+
getSharpVersion: () => Promise<{ sharp: Record<string, string>; format: Record<string, any> }>
|
|
1146
|
+
ffmpeg: IntoolsFFmpeg
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
interface IntoolsSharpProxy {
|
|
1150
|
+
resize(width?: number, height?: number, options?: object): IntoolsSharpProxy
|
|
1151
|
+
extend(options: object): IntoolsSharpProxy
|
|
1152
|
+
extract(options: { left: number; top: number; width: number; height: number }): IntoolsSharpProxy
|
|
1153
|
+
trim(options?: object): IntoolsSharpProxy
|
|
1154
|
+
rotate(angle?: number, options?: object): IntoolsSharpProxy
|
|
1155
|
+
flip(): IntoolsSharpProxy
|
|
1156
|
+
flop(): IntoolsSharpProxy
|
|
1157
|
+
blur(sigma?: number): IntoolsSharpProxy
|
|
1158
|
+
sharpen(options?: object): IntoolsSharpProxy
|
|
1159
|
+
flatten(options?: object): IntoolsSharpProxy
|
|
1160
|
+
gamma(gamma?: number): IntoolsSharpProxy
|
|
1161
|
+
negate(options?: object): IntoolsSharpProxy
|
|
1162
|
+
normalize(options?: object): IntoolsSharpProxy
|
|
1163
|
+
threshold(threshold?: number, options?: object): IntoolsSharpProxy
|
|
1164
|
+
modulate(options?: object): IntoolsSharpProxy
|
|
1165
|
+
tint(color: string | object): IntoolsSharpProxy
|
|
1166
|
+
greyscale(greyscale?: boolean): IntoolsSharpProxy
|
|
1167
|
+
grayscale(grayscale?: boolean): IntoolsSharpProxy
|
|
1168
|
+
composite(images: object[]): IntoolsSharpProxy
|
|
1169
|
+
png(options?: object): IntoolsSharpProxy
|
|
1170
|
+
jpeg(options?: object): IntoolsSharpProxy
|
|
1171
|
+
webp(options?: object): IntoolsSharpProxy
|
|
1172
|
+
gif(options?: object): IntoolsSharpProxy
|
|
1173
|
+
tiff(options?: object): IntoolsSharpProxy
|
|
1174
|
+
avif(options?: object): IntoolsSharpProxy
|
|
1175
|
+
withMetadata(options?: object): IntoolsSharpProxy
|
|
1176
|
+
clone(): IntoolsSharpProxy
|
|
1177
|
+
toBuffer(options?: object): Promise<ArrayBuffer>
|
|
1178
|
+
toFile(fileOut: string): Promise<{ format: string; width: number; height: number; channels: number; size: number }>
|
|
1179
|
+
metadata(): Promise<{ format?: string; width?: number; height?: number; channels?: number; space?: string; depth?: string; density?: number; hasAlpha?: boolean; orientation?: number }>
|
|
1180
|
+
stats(): Promise<object>
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
type IntoolsSharpFunction = (
|
|
1184
|
+
input?: string | ArrayBuffer | Uint8Array | object | any[],
|
|
1185
|
+
options?: object
|
|
1186
|
+
) => IntoolsSharpProxy
|
|
1187
|
+
|
|
1188
|
+
declare global {
|
|
1189
|
+
interface Window {
|
|
1190
|
+
intools: IntoolsAPI
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
export {}
|
|
1195
|
+
`;
|
|
1196
|
+
}
|