TypeScript type definitions for JadeView v2 Frontend API, providing type safety and IntelliSense for front-end developers working with JadeView WebView.
npm install --save-dev jadeview-ipc-typesThe type definitions will be automatically recognized by TypeScript when you install the package. You can then use the jade or window.jade object with full type safety and IntelliSense.
Call backend API and get return result.
// Basic invoke
const result = await jade.invoke('message', { data: 'test' });
// With timeout
const result = await jade.invoke('slowCommand', { key: 'value' }, { timeout: 5000 });
// With generic type
const version: string = await jade.invoke<string>('get_version');Batch invoke multiple commands, wait for all to complete. Results are returned in the same order as the input commands. If any command fails, the entire batch fails.
const [path, version] = await jade.invokeBatch([
{ command: 'get_init_path' },
{ command: 'get_version' },
]);
// With payload and options
const results = await jade.invokeBatch([
{ command: 'get_init_path' },
{ command: 'open_module', payload: { name: 'settings' } },
{ command: 'slow_cmd', options: { timeout: 10000 } },
]);Subscribe to backend events. Returns an unsubscribe function.
// Subscribe to event
const unsubscribe = jade.on('window-state-changed', (payload) => {
console.log('Window state changed:', payload);
});
// Unsubscribe when done
unsubscribe();Dialog API for showing native dialogs.
const result = await jade.dialog.showOpenDialog({
title: '选择文件',
properties: ['openFile', 'multiSelections'],
filters: [
{ name: 'Images', extensions: ['jpg', 'png'] },
{ name: 'All Files', extensions: ['*'] }
]
});
if (!result.canceled) {
console.log('Selected files:', result.filePaths);
}const result = await jade.dialog.showSaveDialog({
title: '保存文件',
defaultPath: 'document.txt',
filters: [
{ name: 'Text', extensions: ['txt'] }
]
});
if (!result.canceled) {
console.log('Save path:', result.filePath);
}const result = await jade.dialog.showMessageBox({
title: '确认操作',
message: '确定要删除吗?',
buttons: ['确定', '取消'],
defaultId: 1,
cancelId: 1,
type: 'warning'
});
if (result.response === 0) {
console.log('User confirmed');
}await jade.dialog.showErrorBox('错误', '操作失败');import type {
JadeAPI,
InvokeOptions,
InvokeBatchItem,
DialogAPI,
OpenDialogOptions,
SaveDialogOptions,
MessageBoxOptions,
OpenDialogResult,
SaveDialogResult,
MessageBoxResult,
FileFilter,
DialogProperty,
MessageBoxType,
} from 'jadeview-ipc-types';| Property | Type | Required | Description |
|---|---|---|---|
| timeout | number |
No | Timeout in milliseconds |
| Property | Type | Required | Description |
|---|---|---|---|
| command | string |
Yes | Command name |
| payload | unknown |
No | Data to pass to backend |
| options | InvokeOptions |
No | Invoke options |
| Property | Type | Required | Description |
|---|---|---|---|
| title | string |
No | Dialog title |
| defaultPath | string |
No | Default path |
| buttonLabel | string |
No | Custom button label |
| filters | FileFilter[] |
No | File filters |
| properties | DialogProperty[] |
No | Dialog properties |
| blocking | boolean |
No | Block process, default true |
| Property | Type | Required | Description |
|---|---|---|---|
| title | string |
No | Dialog title |
| defaultPath | string |
No | Default save path |
| buttonLabel | string |
No | Custom button label |
| filters | FileFilter[] |
No | File filters |
| blocking | boolean |
No | Block process, default true |
| Property | Type | Required | Description |
|---|---|---|---|
| title | string |
No | Message box title |
| message | string |
No | Message content |
| detail | string |
No | Detail text |
| buttons | string[] |
No | Button labels |
| defaultId | number |
No | Default button index |
| cancelId | number |
No | Cancel button index |
| type | MessageBoxType |
No | Icon type |
| blocking | boolean |
No | Block process, default true |
| Value | Description |
|---|---|
openFile |
Allow selecting files |
openDirectory |
Allow selecting directories |
multiSelections |
Allow multiple selections |
showHiddenFiles |
Show hidden files |
promptToCreate |
Prompt to create files |
Also accepts custom strings for future extensions.
| Value | Description |
|---|---|
none |
No icon |
info |
Info icon |
error |
Error icon |
warning |
Warning icon |
question |
Question icon |
- This package only provides type definitions, not the actual implementation
- The implementation is provided by the JadeView WebView runtime
jade/window.jadeis always available in JadeView WebView environmentinvokeBatchinternally calls invoke sequentially; if any command fails, the entire batch fails
MIT