### Complete Window Plugin Setup
Source: https://developer.eagle.cool/plugin-api/get-started/plugin-types/window
This example demonstrates a complete setup for a Window-based plugin, including the manifest.json file with essential metadata, the index.html for the plugin's user interface, and plugin.js for handling plugin lifecycle events and interacting with the UI.
```json
{
"id": "LBCZE8V6LPCKD",
"version": "1.0.0",
"name": "Window Plugin",
"logo": "/logo.png",
"keywords": [],
"main":
{
"url": "index.html",
"width": 640,
"height": 480
}
}
```
```html
```
```javascript
eagle.onPluginCreate((plugin) => {
console.log('eagle.onPluginCreate');
console.log(plugin);
document.querySelector('#message').innerHTML = `
- id: ${plugin.manifest.id}
- version: ${plugin.manifest.version}
- name: ${plugin.manifest.name}
- logo: ${plugin.manifest.logo}
- path: ${plugin.path}
`;
});
eagle.onPluginShow(() => {
console.log('eagle.onPluginShow');
});
eagle.onPluginHide(() => {
console.log('eagle.onPluginHide');
});
eagle.onPluginBeforeExit((event) => {
console.log('eagle.onPluginBeforeExit');
});
```
--------------------------------
### Use FFmpeg Functions in a Plugin (Thumbnail Plugin)
Source: https://developer.eagle.cool/plugin-api/extra-module/ffmpeg
Demonstrates how to access FFmpeg functions through the `extraModule` parameter within a plugin's function. It checks for FFmpeg installation, retrieves FFmpeg binary paths, and uses `child_process.spawn` to run FFmpeg commands to extract media information. The example handles potential errors during the process.
```javascript
module.exports = async ({ src, dest, item, plugin, extraModule }) => {
return new Promise(async (resolve, reject) => {
try {
const ffmpegModule = extraModule.ffmpeg;
// Check if the FFmpeg dependency plugin is installed
if (!ffmpegModule.isInstalled) {
return reject(new Error(`ffmpeg is not installed.`));
}
// Get the location of the FFmpeg binary file
const { ffmpeg, ffprobe } = ffmpegModule.paths;
// Use the spwan command to perform related operations
const spawn = require('child_process').spawn;
const ffprobe = spawn(ffprobePath, [
'-v', 'error',
'-print_format', 'json',
'-show_format',
'-show_streams',
"C:\\your_file.mp4"
]);
return resolve(item);
}
catch (err) {
return reject(err);
}
});
}
```
--------------------------------
### Make GET Request using https in Node.js
Source: https://developer.eagle.cool/plugin-api/tutorial/network-request
When browser restrictions limit fetch, Node.js's native https module can be used for greater flexibility. This example shows how to send an HTTP GET request and handle the response stream and potential errors.
```javascript
const https = require('https');
https.get('https://www.example.com', (res) => {
console.log(`Got response: ${res.statusCode}`);
res.on('data', (d) => {
// Process response data
});
}).on('error', (e) => {
console.error(`Got error: ${e.message}`);
});
```
--------------------------------
### Use FFmpeg Functions in a Plugin (Window Plugin)
Source: https://developer.eagle.cool/plugin-api/extra-module/ffmpeg
Illustrates the use of `eagle.extraModule.ffmpeg` to interact with FFmpeg within a plugin. It covers checking if FFmpeg is installed, installing it if necessary, and obtaining the paths to FFmpeg binaries. It then demonstrates using the `child_process.spawn` function to execute FFmpeg commands.
```javascript
eagle.onPluginCreate(async (plugin) => {
// Check if the FFmpeg dependency plugin is installed
const isFFemptInstalled = await eagle.extraModule.ffmpeg.isInstalled();
// Open the plugin center and pop up the FFmpeg dependency plugin installation page.
if (!isFFemptInstalled) {
await eagle.extraModule.ffmpeg.install();
return;
}
// Get the location of the FFmpeg binary file
const ffmpegPaths= await eagle.extraModule.ffmpeg.getPaths();
const ffmpegBinaryPath = ffmpegPaths.ffmpeg;
const ffprobeBinaryPath = ffmpegPaths.ffprobe;
// Use the spwan command to perform related operations
const spawn = require('child_process').spawn;
const ffprobe = spawn(ffprobePath, [
'-v', 'error',
'-print_format', 'json',
'-show_format',
'-show_streams',
"C:\\your_file.mp4"
]);
});
```
--------------------------------
### Make GET Request using fetch in JavaScript
Source: https://developer.eagle.cool/plugin-api/tutorial/network-request
The fetch function is a tool for accessing network resources, allowing you to send HTTP requests and handle response processing. It supports various request types and custom formats. This example demonstrates a GET request and JSON response parsing.
```javascript
fetch('https://example.com/api/endpoint')
.then(response => response.json())
.then(data => {
// Process the response here
});
```
--------------------------------
### os.hostname() - Get Hostname
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the hostname of the operating system.
```APIDOC
## os.hostname()
### Description
Returns the hostname of the operating system.
### Method
GET
### Endpoint
/os/hostname
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **hostname** (string) - The hostname of the operating system.
### Response Example
```json
{
"hostname": "My_Windows"
}
```
```
--------------------------------
### Get All Displays
Source: https://developer.eagle.cool/plugin-api/api/screen
Retrieves an array containing information for all currently available displays.
```APIDOC
## GET /screen/all-displays
### Description
Retrieves an array containing information for all currently available displays.
### Method
GET
### Endpoint
/screen/all-displays
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **displays** (Display[]) - An array of display objects, each containing information about a connected screen.
- Refer to [Electron Display Structure](https://www.electronjs.org/docs/latest/api/structures/display) for details.
#### Response Example
```json
{
"displays": [
{
"id": 0,
"bounds": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
},
"workArea": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1040
},
"size": {
"width": 1920,
"height": 1080
},
"scaleFactor": 1,
"isPrimary": true,
"isBuiltin": true,
"rotation": 0,
"colorDepth": 24,
"depthPerComponent": 8,
"வுகளில்": false
},
{
"id": 1,
"bounds": {
"x": 1920,
"y": 0,
"width": 1680,
"height": 1050
},
"workArea": {
"x": 1920,
"y": 0,
"width": 1680,
"height": 1010
},
"size": {
"width": 1680,
"height": 1050
},
"scaleFactor": 1,
"isPrimary": false,
"isBuiltin": false,
"rotation": 0,
"colorDepth": 24,
"depthPerComponent": 8,
"வுகளில்": false
}
]
}
```
```
--------------------------------
### os.arch() - Get CPU Architecture
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the CPU architecture of the operating system.
```APIDOC
## os.arch()
### Description
Returns the CPU architecture of the operating system.
### Method
GET
### Endpoint
/os/arch
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **arch** (string) - The current CPU architecture. Possible values: `x64`, `arm64`, `x86`.
### Response Example
```json
{
"arch": "x64"
}
```
```
--------------------------------
### os.release() - Get OS Release
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the release version string of the operating system.
```APIDOC
## os.release()
### Description
Returns the release version of the operating system.
### Method
GET
### Endpoint
/os/release
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **release** (string) - The release version of the operating system.
### Response Example
```json
{
"release": "10.0.22621"
}
```
```
--------------------------------
### Get Folders by IDs or Selection - JavaScript
Source: https://developer.eagle.cool/plugin-api/api/folder
Shows how to retrieve folders based on specific criteria using the eagle.folder.get() method. Examples include fetching folders by an array of IDs or by their selection status within the application.
```javascript
// Get the folder corresponding to the specified id
let folders = await eagle.folder.get({
ids: ['folder_id1', 'folder_id2']
});
// Get currently selected folders in the application
let folders = await eagle.folder.get({
isSelected: true
});
```
--------------------------------
### Add Bookmark with Basic Options - JavaScript
Source: https://developer.eagle.cool/plugin-api/api/item
Demonstrates how to add a simple bookmark to Eagle using the `addBookmark` function. This example includes the URL, name, tags, folders, and annotation for the bookmark. It requires the `eagle` object to be available in the scope.
```javascript
const bookmarkURL = 'https://www.google.com/';
const itemId = await eagle.item.addBookmark(bookmarkURL, {
name: 'Eagle',
tags: ["Eagle", "Site"],
folders: [],
annotation: 'bookmark form api',
});
```
--------------------------------
### Install is.js Module via npm
Source: https://developer.eagle.cool/plugin-api/tutorial/3rd-modules
This command installs the 'is.js' library, a data type checking utility for JavaScript, as a dependency for your Node.js project. The '--save' flag ensures it's added to your project's dependencies.
```bash
npm install is_js --save
```
--------------------------------
### os.homedir() - Get Home Directory
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the home directory of the current user.
```APIDOC
## os.homedir()
### Description
Returns the home directory of the current user.
### Method
GET
### Endpoint
/os/homedir
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **homedir** (string) - The home directory of the current user.
### Response Example
```json
{
"homedir": "C:\\Users\\User"
}
```
```
--------------------------------
### Window Management: Show, Hide, Minimize, Maximize, Fullscreen (JavaScript)
Source: https://developer.eagle.cool/plugin-api/api/window
Provides common examples for controlling the plugin window's visibility, state (minimized, maximized), and fullscreen mode using asynchronous JavaScript operations.
```javascript
await eagle.window.show(); // Show plugin window
await eagle.window.hide(); // Hide plugin window
await eagle.window.minimize(); // Minimize window
await eagle.window.restore(); // Restore minimized
await eagle.window.maximize(); // Maximize window
await eagle.window.unmaximize(); // Restore maximized
await eagle.window.setFullScreen(true); // Set to fullscreen
await eagle.window.setFullScreen(false); // Exit fullscreen
```
--------------------------------
### os.version() - Get OS Version
Source: https://developer.eagle.cool/plugin-api/api/os
Retrieves the kernel version string of the operating system.
```APIDOC
## os.version()
### Description
Get the string of the operating system kernel version.
### Method
GET
### Endpoint
/os/version
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **version** (string) - The string of the operating system kernel version.
### Response Example
```json
{
"version": "Windows 10 Home"
}
```
```
--------------------------------
### Get Primary Display
Source: https://developer.eagle.cool/plugin-api/api/screen
Returns information about the primary display connected to the system.
```APIDOC
## GET /screen/primary-display
### Description
Returns information about the primary display connected to the system.
### Method
GET
### Endpoint
/screen/primary-display
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **display** (Display) - An object containing information about the primary display.
- Refer to [Electron Display Structure](https://www.electronjs.org/docs/latest/api/structures/display) for details.
#### Response Example
```json
{
"display": {
"id": 0,
"bounds": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
},
"workArea": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1040
},
"size": {
"width": 1920,
"height": 1080
},
"scaleFactor": 1,
"isPrimary": true,
"isBuiltin": true,
"rotation": 0,
"colorDepth": 24,
"depthPerComponent": 8,
"வுகளில்": false
}
}
```
```
--------------------------------
### Get OS Hostname
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the hostname of the operating system. This is the unique name assigned to the computer on a network. The output is a string.
```javascript
eagle.os.hostname(); // 'My_Windows'
```
--------------------------------
### Get All Displays Information (JavaScript)
Source: https://developer.eagle.cool/plugin-api/api/screen
Retrieves an array containing information for all currently available screens. The method returns a Promise that resolves to an array of Display objects. Each `Display` object conforms to the Electron.js Display structure.
```javascript
let displays = await eagle.screen.getAllDisplays();
```
--------------------------------
### os.tmpdir() - Get Temporary Directory
Source: https://developer.eagle.cool/plugin-api/api/os
Retrieves the default temporary file path for the operating system.
```APIDOC
## os.tmpdir()
### Description
Get the default temporary file path of the operating system.
### Method
GET
### Endpoint
/os/tmpdir
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **path** (string) - The default temporary file path of the operating system.
### Response Example
```json
{
"path": "C:\\Users\\User\\AppData\\Local\\Temp"
}
```
```
--------------------------------
### Configure Window Plugin Manifest
Source: https://developer.eagle.cool/plugin-api/get-started/plugin-types/window
This snippet shows how to configure the 'main' field in the manifest.json file to define the default URL, width, and height of the plugin window. This setup is crucial for the initial display and dimensions of the plugin when it's opened.
```json
{
"main": {
"url": "index.html",
"width": 640,
"height": 480
}
}
```
--------------------------------
### Use Predefined Folder Icon Colors
Source: https://developer.eagle.cool/plugin-api/api/folder
Provides examples of using the `eagle.folder.IconColor` static object to set folder icon colors. This method is recommended over using raw string values for better type safety and code completion. It also shows how to batch update multiple folders.
```javascript
// Available color constants
// eagle.folder.IconColor.Red // 'red'
// eagle.folder.IconColor.Orange // 'orange'
// eagle.folder.IconColor.Yellow // 'yellow'
// eagle.folder.IconColor.Green // 'green'
// eagle.folder.IconColor.Aqua // 'aqua'
// eagle.folder.IconColor.Blue // 'blue'
// eagle.folder.IconColor.Purple // 'purple'
// eagle.folder.IconColor.Pink // 'pink'
let folder = await eagle.folder.getById('folder_id');
// Use color constants to set folder color
folder.iconColor = eagle.folder.IconColor.Blue;
await folder.save();
// Batch set multiple folder colors
let folders = await eagle.folder.getAll();
for (let i = 0; i < folders.length; i++) {
if (i % 2 === 0) {
folders[i].iconColor = eagle.folder.IconColor.Green;
} else {
folders[i].iconColor = eagle.folder.IconColor.Purple;
}
await folders[i].save();
}
```
--------------------------------
### os.type() - Get OS Type
Source: https://developer.eagle.cool/plugin-api/api/os
Returns the name of the operating system (e.g., 'Darwin' on macOS, 'Windows_NT' on Windows).
```APIDOC
## os.type()
### Description
Returns the name of the operating system.
For example: returns `Darwin` on macOS, and `Windows_NT` on Windows.
### Method
GET
### Endpoint
/os/type
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **type** (string) - The name of the operating system.
### Response Example
```json
{
"type": "Windows_NT"
}
```
```
--------------------------------
### Get User Home Directory
Source: https://developer.eagle.cool/plugin-api/api/os
Retrieves the path to the home directory of the current user. This is typically where user-specific configurations and data are stored. It returns a string representing the directory path.
```javascript
eagle.os.homedir(); // 'C:\Users\User'
```
--------------------------------
### Start File Drag Operation with drag.startDrag
Source: https://developer.eagle.cool/plugin-api/api/drag
Initiates a file drag operation by displaying a notification window. It accepts an array of file paths as input and returns a Promise. This method is analogous to Electron's webContents.startDrag API.
```javascript
await eagle.drag.startDrag([
"C:\\Users\\User\\Pictures\\drag1.jpg",
"C:\\Users\\User\\Pictures\\drag2.jpg",
]);
```
--------------------------------
### Get Repository Information - JavaScript
Source: https://developer.eagle.cool/plugin-api/api/library
Retrieves detailed information about the current repository, including folders, smart folders, and tag groups. This method returns a Promise that resolves to an object containing various repository properties.
```javascript
console.log(await eagle.library.info());
```
--------------------------------
### Get Primary Display Information (JavaScript)
Source: https://developer.eagle.cool/plugin-api/api/screen
Fetches information about the primary display connected to the system. It returns a Promise that resolves to a Display object, which contains details about the screen. The `Display` object structure is documented by Electron.js.
```javascript
let display = await eagle.screen.getPrimaryDisplay();
```
--------------------------------
### Declare AI SDK Dependency in manifest.json
Source: https://developer.eagle.cool/plugin-api/extra-module/ai-sdk
This JSON snippet shows how to declare the 'ai-sdk' as a dependency in the plugin's manifest.json file. This ensures that the Eagle system recognizes the plugin's need for AI extension functions and automatically handles the installation of the AI SDK Dependency Plugin.
```json
{
"id": "LBCZE8V6LPCKD",
"version": "1.0.0",
"platform": "all",
"arch": "all",
"name": "Window Plugin",
"logo": "/logo.png",
"keywords": [],
"dependencies": ["ai-sdk"],
"devTools": false,
"main":
{
"url": "index.html",
"width": 640,
"height": 480
}
}
```
--------------------------------
### Basic Text Generation with AI SDK
Source: https://developer.eagle.cool/plugin-api/extra-module/ai-sdk
This JavaScript code demonstrates how to use the AI SDK to generate text. It retrieves AI providers and the generateText function from the ai module. The example shows a basic text generation call using OpenAI's GPT-5 model, prompting it to write an introduction about digital art. The generated text is then logged to the console.
```javascript
eagle.onPluginCreate(async (plugin) => {
// Get AI module and Provider
const ai = eagle.extraModule.ai;
const { openai, anthropic, gemini, deepseek, qwen, ollama, lmstudio } = await ai.getProviders();
const { generateText } = ai;
// Basic text generation
const result = await generateText({
model: openai("gpt-5"),
prompt: "Please help me write a creative introduction about digital art",
});
console.log(result.text);
});
```
--------------------------------
### Get OS Type
Source: https://developer.eagle.cool/plugin-api/api/os
Determines and returns the name of the operating system. Examples include 'Darwin' for macOS and 'Windows_NT' for Windows. This provides a general classification of the OS.
```javascript
eagle.os.type(); // 'Windows_NT', 'Darwin'
```
--------------------------------
### Modify Folder Properties (JavaScript)
Source: https://developer.eagle.cool/plugin-api/tutorial/modify-eagle-data
This example shows how to get the currently selected folder in the Eagle app, update its name and description, and save these modifications. It utilizes the `eagle.folder.getSelected()` and `folder.save()` methods.
```javascript
let folder = (await eagle.folder.getSelected())[0];
// Modify properties
folder.name = 'New Folder Name';
folder.description = 'New description...';
// Save changes
await folder.save();
```
--------------------------------
### Show Plugin Window (JavaScript)
Source: https://developer.eagle.cool/plugin-api/api/window
Demonstrates how to display and bring the plugin window to the forefront using the `show()` method. This operation is asynchronous and returns a Promise.
```javascript
await eagle.window.show();
```
--------------------------------
### Retrieve All Items in Eagle
Source: https://developer.eagle.cool/plugin-api/api/item
Demonstrates how to fetch all files within the Eagle application using the `eagle.item.getAll()` method. A best practice warning is included to avoid using this method without restrictions on libraries with a large number of files to prevent performance degradation.
```javascript
let items = await eagle.item.getAll();
console.log(items);
```
--------------------------------
### Inspector Plugin HTML Structure and Script
Source: https://developer.eagle.cool/plugin-api/get-started/plugin-types/inspector
Provides an example of an index.html file for an inspector plugin. It includes basic HTML structure, styling for different themes, and JavaScript to listen for plugin creation and theme changes, interacting with the Eagle API to get selected items and themes.
```html
Inspector Plugin Example
Inspector Plugin Example
```
--------------------------------
### Add Bookmark with Base64 Thumbnail - JavaScript
Source: https://developer.eagle.cool/plugin-api/api/item
Illustrates adding a bookmark to Eagle with a custom thumbnail provided in base64 format. This example utilizes the `base64` option within the `addBookmark` function, alongside other bookmark details like name, tags, folders, and annotation. Ensure the base64 string is correctly formatted.
```javascript
const bookmarkURL = 'https://www.google.com/';
const base64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAnCAYAAACIVoEIAAAAAXNSR0IArs4c6QAACUFJREFUWAmlWFlzVMcV/u42Gi0w2pEE1miFIIGRkMoowRCbRErKlUqeU5Uqv+UhD6n4yW8pJ1V5i/9AquynuPLisCUEHNtsdkJYBAGMkWWJAhGMomAWIzSjmbvkO31vX90ZCSMlPdW3u8/e55w+t+8A/2cLAHNZf+MNU4tdhluJPoQZmieeaMBaxt/OuD++b1k/c/MuEElKV9nG/KXLF998e+C137zpvpWzrO7AJb680Vo/gnEKJ2X76zzvd68/Z79jd/ziRG3RMUaNIKiIqcoFlK0LnofNm9Y7M/ng1/dtbDICG4ZItoDqB3kceusPzQ9/Or1QaVqv5opir10mAQiEnk0GmYu7m4oBqfGOXTC8n5t25leBu6iECuGzmhlYaO7dhEeGDT/nwoi8VJm2cX3/u5i363utlrbX53M+DD/yh9BEhmj5asmHjAEN56hcagcwGwKvAGVURC1ET4ur5wVo3VCDup4GzC+60Mlj2BaKMzdx7vQ4XvzJqwiq0wiKrlKoZCWFci5L3ZTXCPAjILdKRkZOuzMm1JOy0WSctgxnsWAyJJ6PgBqFt5rw8388gNquPnQM9WGh4C1tTO8wUprUpUDyYPd9X1GaQRBQ3Op+ruuho6sR6U1NcF0aJLL4sBwbjy6PY+KzOxj5wSjydopwyiROaMQD0mWtxtCGEC/waO3TFk7B8DFUGiqQsqbwhInZ6QoLXTs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gpeV25/cBA2v3iUt0Sh7gmlGqeN0KMYpnqCR/Tww4F/5/CWa/Kx6s5KGVSk0bnv+/j3jRksTP4T8oUTChJh7HwPGolevtY4gQu9vAECFmQ2w75z/pTdMLiHO5TUErtX1+S6ka60kM724dbJ99BT20AZq+cv1xKwID+YuMid8YX8+F/T/3DT68ZM23H+F6EBt7jgWpi7flm+XMt1rWFt+LlbUx+RwRX3VFZsGW63U04K4c1hDYJYVAsF0qd4+VsTWykx/cO/Ib35a2dvE/H4v9IJhWmtCpMiAAAAAElFTkSuQmCC';
const itemId = await eagle.item.addBookmark(bookmarkURL, {
name: 'Eagle',
base64: base64,
tags: ["Eagle", "Site"],
folders: [],
annotation: 'bookmark form api',
});
```
--------------------------------
### Basic manifest.json Configuration for Window Plugin
Source: https://developer.eagle.cool/plugin-api/get-started/anatomy-of-an-extension
This JSON configuration defines the essential properties for a 'window plugin', including its ID, version, name, logo, keywords for searching, and the main entry point for its window. It specifies the entry HTML file, dimensions, and whether developer tools should be enabled.
```json
{
"id": "LB5UL2P0Q9FFF",
"version": "1.0.0",
"name": "Hello World",
"logo": "/logo.png",
"keywords": ["keywrod1", "keywrod2"],
"main":
{
"devTools": true,
"url": "index.html",
"width": 640,
"height": 480
}
}
```
--------------------------------
### GET /api/tags/recent
Source: https://developer.eagle.cool/plugin-api/api/tag
Retrieves the most recently used tags.
```APIDOC
## GET /api/tags/recent
### Description
Retrieves the most recently used tags.
### Method
GET
### Endpoint
/api/tags/recent
### Parameters
None
### Request Example
(No request body or parameters)
### Response
#### Success Response (200)
- **tags** (Object[]) - The query result for tags.
#### Response Example
```json
{
"tags": [
{
"name": "recent-tag-1",
"count": 5,
"color": "#00FF00",
"groups": [],
"pinyin": "zuijin"
}
]
}
```
```
--------------------------------
### Show File Open Dialog for Files and Directories
Source: https://developer.eagle.cool/plugin-api/api/dialog
Opens a dialog allowing the user to select both files and directories. This is configured using the `properties` option within the `showOpenDialog` method, specifying both 'openFile' and 'openDirectory'. The return value contains the user's selection.
```javascript
let result = await eagle.dialog.showOpenDialog({
properties: ['openFile', 'openDirectory']
});
```
--------------------------------
### Folder Creation API
Source: https://developer.eagle.cool/plugin-api/api/folder
Provides methods to create new folders, including subfolders, with specified names and descriptions.
```APIDOC
## POST /api/folders/create
### Description
Creates a new folder with the given options.
### Method
POST
### Endpoint
/api/folders/create
### Parameters
#### Request Body
- **name** (string) - Required - The name of the folder.
- **description** (string) - Optional - The description of the folder.
- **parent** (string) - Optional - The ID of the parent folder. If provided, this is equivalent to `createSubfolder`.
### Request Example
```json
{
"name": "New Folder",
"description": "Folder's description."
}
```
### Response
#### Success Response (200)
- **folder** (object) - The newly created folder object.
- **id** (string) - The unique identifier of the folder.
- **name** (string) - The name of the folder.
- **description** (string) - The description of the folder.
#### Response Example
```json
{
"id": "folder_123",
"name": "New Folder",
"description": "Folder's description."
}
```
## POST /api/folders/createSubfolder
### Description
Creates a new subfolder within a specified parent folder.
### Method
POST
### Endpoint
/api/folders/createSubfolder
### Parameters
#### Request Body
- **parentId** (string) - Required - The ID of the parent folder.
- **options** (object) - Required - An object containing folder properties.
- **name** (string) - Required - The name of the subfolder.
- **description** (string) - Optional - The description of the subfolder.
### Request Example
```json
{
"parentId": "parent_folder_id",
"options": {
"name": "Subfolder",
"description": "Subfolder description."
}
}
```
### Response
#### Success Response (200)
- **folder** (object) - The newly created subfolder object.
- **id** (string) - The unique identifier of the subfolder.
- **name** (string) - The name of the subfolder.
- **description** (string) - The description of the subfolder.
#### Response Example
```json
{
"id": "subfolder_456",
"name": "Subfolder",
"description": "Subfolder description."
}
```
```
--------------------------------
### GET /api/tags
Source: https://developer.eagle.cool/plugin-api/api/tag
Retrieves a list of tags. This endpoint supports filtering by tag name.
```APIDOC
## GET /api/tags
### Description
Retrieves tags with optional filtering.
### Method
GET
### Endpoint
/api/tags
### Parameters
#### Query Parameters
- **name** (string) - Optional - Filter tags by name with fuzzy search, case-insensitive. Requires Eagle 4.0 build12 or higher.
### Request Example
```json
{
"name": "design"
}
```
### Response
#### Success Response (200)
- **tags** (Object[]) - The query result for tags.
#### Response Example
```json
{
"tags": [
{
"name": "design",
"count": 10,
"color": "#FF0000",
"groups": ["UI/UX"],
"pinyin": "sheji"
}
]
}
```
```
--------------------------------
### Search and Retrieve Items with Eagle Plugin API
Source: https://developer.eagle.cool/plugin-api/api/item
Provides examples of using the `eagle.item.get()` method to retrieve files based on various criteria such as IDs, selection status, tags, keywords, file extensions, ratings, and more. It also shows how to specify fields to return for improved performance.
```javascript
let items = await eagle.item.get({
ids: [],
isSelected: true,
isUnfiled: true,
isUntagged: true,
keywords: [""],
ext: "",
tags: [],
folders: [],
shape: "square",
rating: 5,
annotation: "",
url: ""
});
let selected = await eagle.item.get({
isSelected: true
});
let jpgs = await eagle.item.get({
ext: "jpg"
});
// Get only specific fields to improve performance
let itemsWithFields = await eagle.item.get({
tags: ["Design"],
fields: ["id", "name", "tags", "modifiedAt"]
});
```
--------------------------------
### Create New Folder - JavaScript
Source: https://developer.eagle.cool/plugin-api/api/folder
Demonstrates how to create a new folder with a specified name and description using the eagle.folder.create() method. This method returns a Promise that resolves with the newly created folder object.
```javascript
let newFolder = await eagle.folder.create({
name: 'New Folder',
description: 'Folder\'s description.',
});
```
--------------------------------
### getFileIcon(path, options)
Source: https://developer.eagle.cool/plugin-api/api/app
Gets the icon associated with a file at the specified path, with optional size constraints.
```APIDOC
## getFileIcon(path, options)
### Description
Retrieves the icon for a file at a given path.
### Method
`await eagle.app.getFileIcon(path: string, options?: { size: 'small' | 'normal' | 'large' })`
### Parameters
#### Path Parameters
- **path** (string) - Required - The file path for which to get the icon.
#### Query Parameters
- **options** (Object) - Optional - Configuration for the icon size.
- **size** (string) - Optional - The desired icon size. Supported values: 'small' (16x16), 'normal' (32x32), 'large' (32x32 on Windows, not supported on macOS).
### Returns
- `Promise` - A promise that resolves with a NativeImage object representing the file icon.
### Request Example
```javascript
const icon = await eagle.app.getFileIcon('path/to/your/file.txt', { size: 'small' });
const dataUrl = icon.toDataURL();
const size = icon.getSize();
console.log(dataUrl, size);
```
```
--------------------------------
### Open File or Directory Path with JavaScript
Source: https://developer.eagle.cool/plugin-api/api/shell
The `openPath(path)` function opens a specified file or directory using the system's default application. It accepts a string representing the path and returns a Promise. This is useful for directly accessing local resources from the application.
```javascript
await eagle.shell.openPath('path_to_file');
```
--------------------------------
### Get Display Nearest Point
Source: https://developer.eagle.cool/plugin-api/api/screen
Identifies and returns information about the display that is nearest to the specified point (x, y).
```APIDOC
## GET /screen/display-nearest-point
### Description
Identifies and returns information about the display that is nearest to the specified point (x, y).
### Method
GET
### Endpoint
/screen/display-nearest-point
### Parameters
#### Query Parameters
- **x** (Integer) - Required - The x-coordinate of the point.
- **y** (Integer) - Required - The y-coordinate of the point.
### Request Example
```
GET /screen/display-nearest-point?x=100&y=100
```
### Response
#### Success Response (200)
- **display** (Display) - An object containing information about the nearest display.
- Refer to [Electron Display Structure](https://www.electronjs.org/docs/latest/api/structures/display) for details.
#### Response Example
```json
{
"display": {
"id": 0,
"bounds": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
},
"workArea": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1040
},
"size": {
"width": 1920,
"height": 1080
},
"scaleFactor": 1,
"isPrimary": true,
"isBuiltin": true,
"rotation": 0,
"colorDepth": 24,
"depthPerComponent": 8,
"வுகளில்": false
}
}
```
```
--------------------------------
### Get Cursor Screen Point
Source: https://developer.eagle.cool/plugin-api/api/screen
Retrieves the absolute screen coordinates (x, y) of the current mouse cursor.
```APIDOC
## GET /screen/cursor/point
### Description
Retrieves the absolute screen coordinates (x, y) of the current mouse cursor.
### Method
GET
### Endpoint
/screen/cursor/point
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **point** (Object) - An object containing the cursor's screen coordinates.
- **point.x** (Integer) - The x-coordinate of the cursor.
- **point.y** (Integer) - The y-coordinate of the cursor.
#### Response Example
```json
{
"point": {
"x": 123,
"y": 456
}
}
```
```
--------------------------------
### GET /api/tags/starred
Source: https://developer.eagle.cool/plugin-api/api/tag
Retrieves the user's starred (favorite) tags. Requires Eagle 4.0 build18 or higher.
```APIDOC
## GET /api/tags/starred
### Description
Retrieves starred tags (user's favorite tags). Requires Eagle 4.0 build18 or higher.
### Method
GET
### Endpoint
/api/tags/starred
### Parameters
None
### Request Example
(No request body or parameters)
### Response
#### Success Response (200)
- **tags** (Object[]) - The query result for tags.
#### Response Example
```json
{
"tags": [
{
"name": "favorite-tag",
"count": 15,
"color": "#FFFF00",
"groups": ["Favorites"],
"pinyin": "shoucang"
}
]
}
```
```