### Install and Build Extension Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/README.md Installs project dependencies and builds the extension package for distribution. Ensure Node.js and npm are installed. ```bash npm install npm run build ``` -------------------------------- ### Install Dependencies Source: https://github.com/easyeda/pro-api-sdk/blob/master/README.en.md Install the necessary dependencies for the development environment using npm. This command should be run after cloning the repository. ```shell npm install ``` -------------------------------- ### Project Structure Example Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md Illustrates the recommended directory and file layout for an EasyEDA Pro extension project. ```tree my-extension/ ├── src/ │ ├── index.ts // Entry point │ ├── utils/ │ │ └── helpers.ts // Utility functions │ └── modules/ │ └── calculator.ts // Feature modules ├── locales/ │ ├── en.json // English translations │ ├── zh-Hans.json // Chinese translations │ └── extensionJson/ │ ├── en.json │ └── zh-Hans.json ├── images/ │ └── logo.png // Extension logo ├── extension.json // Extension manifest ├── package.json // NPM configuration ├── tsconfig.json // TypeScript configuration ├── eslint.config.mjs // Linting rules ├── config/ │ ├── esbuild.common.ts // Shared build config │ └── esbuild.prod.ts // Production build ├── build/ │ └── packaged.ts // Packaging script ├── dist/ // Compiled output (generated) └── README.md // Project documentation ``` -------------------------------- ### Get All Schematics Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Lists all schematic documents within the current project. ```typescript getAllSchematicsInfo(): Promise> ``` -------------------------------- ### Getting Current Context Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Retrieve information about the current project, schematic page, PCB, or active document. ```APIDOC ## Getting Current Context ### Description Allows retrieval of the current state of the design environment, including project, schematic, PCB, and document information. ### Methods - `await eda.dmt_Project.getCurrentProjectInfo()`: Retrieves information about the currently active project. - `await eda.dmt_Schematic.getCurrentSchematicPageInfo()`: Retrieves information about the current schematic page. - `await eda.dmt_Pcb.getCurrentPcbInfo()`: Retrieves information about the current PCB. - `await eda.dmt_SelectControl.getCurrentDocumentInfo()`: Retrieves information about the currently active document. ``` -------------------------------- ### get Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves the properties of a specific footprint. ```APIDOC ## get ### Description Retrieves all footprint properties. ### Method GET ### Endpoint /libraries/{libraryUuid}/footprints/{footprintUuid} ### Parameters #### Path Parameters - **footprintUuid** (string) - Required - The UUID of the footprint to retrieve. - **libraryUuid** (string) - Optional - The UUID of the library the footprint belongs to. ``` -------------------------------- ### Get All Workspace Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Lists all accessible workspaces. Use this to retrieve a list of available workspaces. ```typescript getAllWorkspacesInfo(): Promise> ``` -------------------------------- ### get Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves all module properties, including associated boards, using the module UUID and an optional library UUID. ```APIDOC ## get ### Description Retrieves all module properties including boards. ### Method Signature ```typescript get(cbbUuid: string, libraryUuid?: string): Promise ``` ### Parameters #### Path Parameters - **cbbUuid** (string) - Required - Module UUID - **libraryUuid** (string) - Optional - Library UUID ### Returns `Promise` — Module properties with board array or `undefined` on failure ``` -------------------------------- ### Complete Extension Manifest Example Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md This JSON object defines all necessary metadata and UI integration points for an extension. It includes details like name, version, publisher, activation events, and menu configurations for different editor scopes. ```json { "name": "my-tool-extension", "uuid": "550e8400-e29b-41d4-a716-446655440000", "displayName": "My Circuit Tool", "description": "A powerful tool for circuit design", "version": "1.2.0", "publisher": "Your Company", "engines": { "eda": "^3.0.0" }, "license": "Apache-2.0", "repository": { "type": "extension-store", "url": "https://github.com/yourcompany/my-tool" }, "categories": "Utilities", "keywords": ["tool", "circuit", "automation"], "images": { "logo": "./images/logo.png" }, "homepage": "https://yourcompany.com/my-tool", "bugs": "https://github.com/yourcompany/my-tool/issues", "activationEvents": {}, "entry": "./dist/index", "dependentExtensions": {}, "headerMenus": { "home": [ { "id": "myToolMenu", "title": "My Tool", "menuItems": [ { "id": "openTool", "title": "Open Tool", "registerFn": "openToolDialog" }, { "id": "settings", "title": "Settings", "registerFn": "openSettings" } ] } ], "sch": [ { "id": "schematicTools", "title": "Schematic Tools", "menuItems": [ { "id": "schCheck", "title": "Check Schematic", "registerFn": "checkSchematic" } ] } ], "pcb": [ { "id": "pcbTools", "title": "PCB Tools", "menuItems": [ { "id": "generateLayout", "title": "Auto Layout", "registerFn": "autoLayout" } ] } ] } } ``` -------------------------------- ### Get All Boards Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Lists all boards within the current project. This function returns an array of board information objects. ```typescript getAllBoardsInfo(): Promise> ``` -------------------------------- ### Example Menu Item Configuration Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md This JSON object demonstrates the structure for a single menu item within the `headerMenus` configuration. It specifies the item's ID, display title, the exported function to register, and optional icon and keyboard shortcut. ```json { "id": "runCheck", "title": "Run Electrical Check", "registerFn": "runElectricalCheck", "icon": "./icons/check.svg", "shortcut": "Ctrl+E" } ``` -------------------------------- ### get Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves all properties of a specific symbol using its UUID. The library UUID is optional and defaults to the system library if not provided. ```APIDOC ## get ### Description Retrieves all symbol properties. ### Method Signature ```typescript get(symbolUuid: string, libraryUuid?: string): Promise ``` ### Parameters #### Path Parameters - **symbolUuid** (string) - Required - Symbol UUID - **libraryUuid** (string) - Optional - Library UUID (system if omitted) ### Returns `Promise` — Symbol properties or `undefined` on failure ``` -------------------------------- ### List All Panel Information Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves an array containing information objects for all panels within the current project. This is useful for getting an overview of available panels. ```typescript getAllPanelsInfo(): Promise> ``` -------------------------------- ### Get Schematic Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves detailed information about a schematic, including all its pages, using its UUID. ```typescript getSchematicInfo(schematicUuid: string): Promise ``` -------------------------------- ### Get Current Schematic Page Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves information for the schematic page currently active in the editor. ```typescript getCurrentSchematicPageInfo(): Promise ``` -------------------------------- ### Get Project Information by UUID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves basic properties of a project using its UUID. This method does not fetch the full document tree, making it efficient for quick checks. ```typescript eda.dmt_Project.getProjectInfo(projectUuid: string): Promise ``` -------------------------------- ### Get Current Project Information Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves detailed information about the currently active project, including all its documents. Returns undefined if no project is active or an error occurs. ```typescript const projectInfo = await eda.dmt_Project.getCurrentProjectInfo(); if (projectInfo) { console.log('Project name:', projectInfo.friendlyName); console.log('Documents:', projectInfo.data.length); } ``` -------------------------------- ### Get Current Board Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves information about the currently active board, including its associated schematic and PCB. This function does not require any parameters. ```typescript getCurrentBoardInfo(): Promise ``` -------------------------------- ### Get Symbol Render Image Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Captures a preview of a symbol render as a PNG image blob. Optionally specify a sub-part name. ```typescript getRenderImage(source: { symbolUuid: string; libraryUuid: string; subPartName?: string; }): Promise ``` -------------------------------- ### Unit Test Helper Functions Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md Example of how to test helper functions using a testing framework like Jest. Ensure helper functions are imported correctly and use assertions to verify their behavior. ```typescript // src/__tests__/helpers.test.ts import * as helpers from '../utils/helpers'; describe('Helper Functions', () => { test('converts units correctly', () => { const result = helpers.convertMilToMm(1000); expect(result).toBeCloseTo(25.4, 2); }); }); ``` -------------------------------- ### Get Current Project Context Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Retrieve information about the current project, schematic page, PCB, or active document. These functions are essential for context-aware operations within the IDE. ```typescript // Current project const project = await eda.dmt_Project.getCurrentProjectInfo(); // Current schematic page const page = await eda.dmt_Schematic.getCurrentSchematicPageInfo(); // Current PCB const pcb = await eda.dmt_Pcb.getCurrentPcbInfo(); // Currently active document const doc = await eda.dmt_SelectControl.getCurrentDocumentInfo(); ``` -------------------------------- ### Get information for the active PCB editor Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves the information for the PCB currently active in the editor. Returns undefined if no PCB is active. ```typescript const currentPcb = await eda.dmt_Pcb.getCurrentPcbInfo(); ``` -------------------------------- ### Asynchronous Operations: Multiple Results Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/README.md Shows how to handle asynchronous API calls that return multiple results. The example iterates over a list of UUIDs obtained from `getAllProjectsUuid`. ```typescript // Multiple results const projects = await eda.dmt_Project.getAllProjectsUuid(teamUuid); projects.forEach(uuid => console.log(uuid)); ``` -------------------------------- ### Get Footprint Render Image Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Captures a preview image of a footprint render. Requires the footprint and library UUIDs within a source object. Returns a Blob or undefined. ```typescript getRenderImage(source: { footprintUuid: string; libraryUuid: string; }): Promise ``` -------------------------------- ### Work with Libraries Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Perform operations related to libraries, including getting system library UUIDs, searching for components, and opening library items in the editor. Requires library UUIDs for most operations. ```typescript // Get system library UUID const sysLibId = await eda.lib_LibrariesList.getSystemLibraryUuid(); // Search components const results = await eda.lib_Device.search('resistor', sysLibId); // Open in editor const tabId = await eda.lib_Symbol.openInEditor(symbolUuid, libUuid); ``` -------------------------------- ### Get All Team Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves properties of all directly accessible teams. Use this to get a list of teams and their details. ```typescript const teams = await eda.dmt_Team.getAllTeamsInfo(); teams.forEach(team => { console.log(`Team: ${team.name} (UUID: ${team.uuid})`); }); ``` -------------------------------- ### Create and Configure a New Project Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/README.md Creates a new project in the current team and opens it. Handles errors if no team is selected or project creation fails. ```typescript export async function createNewProject() { // Get current team const teamInfo = await eda.dmt_Team.getCurrentTeamInfo(); if (!teamInfo) { eda.sys_Dialog.showErrorMessage('No team selected', 'Error'); return; } // Create project const projectUuid = await eda.dmt_Project.createProject( 'My New Project', 'my-new-project', teamInfo.uuid, undefined, 'A sample project' ); if (!projectUuid) { eda.sys_Dialog.showErrorMessage('Failed to create project', 'Error'); return; } // Open project const opened = await eda.dmt_Project.openProject(projectUuid); if (opened) { eda.sys_Dialog.showInformationMessage('Project created', 'Success'); } } ``` -------------------------------- ### createProject Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Creates a new project with specified properties. ```APIDOC ## createProject ### Description Creates a new project with specified properties. ### Method createProject ### Parameters #### Path Parameters - **projectFriendlyName** (string) - Required - Display name for the project - **projectName** (string) - Optional - Link name; supports only `a-zA-Z`, `0-9`, `-` - **teamUuid** (string) - Optional - Team UUID for project ownership - **folderUuid** (string) - Optional - Target folder UUID - **description** (string) - Optional - Project description - **collaborationMode** (EDMT_ProjectCollaborationMode) - Optional - Collaboration mode (STRICT=3, FREE=1) ### Response #### Success Response (string | undefined) - **projectUuid** (string) - New project UUID or `undefined` on failure ### Request Example ```typescript const projectUuid = await eda.dmt_Project.createProject( 'My Circuit Design', 'my-circuit-design', 'team-uuid-123', undefined, 'A sample circuit design project' ); ``` ``` -------------------------------- ### Get Current Schematic Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves information for the schematic associated with the currently active editor. ```typescript getCurrentSchematicInfo(): Promise ``` -------------------------------- ### Get Schematic Page Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves specific properties of a schematic page using its UUID. ```typescript getSchematicPageInfo(schematicPageUuid: string): Promise ``` -------------------------------- ### create Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Creates a new footprint in a specified library. ```APIDOC ## create ### Description Creates a new footprint. ### Method POST ### Endpoint /libraries/{libraryUuid}/footprints ### Parameters #### Path Parameters - **libraryUuid** (string) - Required - The UUID of the library to create the footprint in. #### Request Body - **footprintName** (string) - Required - The name of the new footprint. - **classification** (ILIB_ClassificationIndex | Array) - Optional - The classification for the footprint. - **description** (string) - Optional - A description for the footprint. ``` -------------------------------- ### Extension Entry Point (src/index.ts) Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md TypeScript code for the extension's entry point, including activation and exported functions for menu actions. The 'activate' function is called on extension load, and other exported functions can be registered as menu actions. ```typescript /** * Activation hook called on extension load * @param status - Activation trigger type * @param arg - Additional context */ export function activate(status?: 'onStartupFinished', arg?: string): void { // Initialize extension } /** * Menu action example * These exported functions are called when user clicks the menu item */ export function about(): void { eda.sys_Dialog.showInformationMessage( 'Extension Version 1.0.0', 'About' ); } export async function doWork(): Promise { // Perform extension operations using eda global } ``` -------------------------------- ### Extension Activation and Core Functions Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md This TypeScript code demonstrates the entry point for an extension, including the activation hook and exported functions for interacting with the EasyEDA Pro API. Use these functions to implement features like opening dialogs, checking schematics, and auto-layout. ```typescript import * as extensionConfig from '../extension.json'; /** * Extension activation hook * Called when extension is loaded */ export function activate(status?: 'onStartupFinished', arg?: string): void { console.log('Extension activated'); // Initialization code here } /** * Exported functions are called when user clicks menu items * Must match registerFn values in extension.json */ export async function openToolDialog(): Promise { try { const projectInfo = await eda.dmt_Project.getCurrentProjectInfo(); if (!projectInfo) { eda.sys_Dialog.showWarningMessage( 'Please open a project first', 'No Project' ); return; } // Perform tool operations const schematicInfo = await eda.dmt_Schematic.getCurrentSchematicInfo(); if (schematicInfo) { eda.sys_Dialog.showInformationMessage( `Working with: ${schematicInfo.name}`, 'Tool Active' ); } } catch (error) { eda.sys_Dialog.showErrorMessage( `Error: ${error instanceof Error ? error.message : 'Unknown error'}`, 'Error' ); } } export async function checkSchematic(): Promise { // Menu item action for schematic editor } export async function autoLayout(): Promise { // Menu item action for PCB editor } export function openSettings(): Promise { // Settings dialog } ``` -------------------------------- ### getAllPcbsInfo Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Lists all PCB documents within the current project. ```APIDOC ## getAllPcbsInfo ### Description Lists all PCBs in the current project. ### Method ```typescript getAllPcbsInfo(): Promise> ``` ### Returns `Promise>` — Array of PCB information objects ``` -------------------------------- ### Get Current Workspace Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves current workspace information. Returns undefined if no workspace is active. ```typescript const currentWorkspace = await eda.dmt_Workspace.getCurrentWorkspaceInfo(); if (currentWorkspace) { console.log(`Current workspace: ${currentWorkspace.name}`); } ``` -------------------------------- ### getAllPanelsInfo Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Lists all panels available in the current project. Returns an array of panel information objects. ```APIDOC ## getAllPanelsInfo ### Description Lists all panels in the current project. ### Method getAllPanelsInfo ### Returns `Promise>` — Array of panel information objects ``` -------------------------------- ### create Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Creates a new reusable module. It takes library UUID, module name, optional classification, and an optional description. ```APIDOC ## create ### Description Creates a new reusable module. ### Method Signature ```typescript create( libraryUuid: string, cbbName: string, classification?: ILIB_ClassificationIndex | Array, description?: string ): Promise ``` ### Parameters #### Path Parameters - **libraryUuid** (string) - Required - Library UUID - **cbbName** (string) - Required - Module name - **classification** (object | array) - Optional - Category classification - **description** (string) - Optional - Module description ### Returns `Promise` — New module UUID or `undefined` on failure ``` -------------------------------- ### Get Footprint Details Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves all properties of a specific footprint. Requires the footprint UUID and optionally the library UUID. ```typescript get(footprintUuid: string, libraryUuid?: string): Promise ``` -------------------------------- ### LIB_Device.create Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Creates a new device component in the library, linking symbols, footprints, and other associations. ```APIDOC ## LIB_Device.create ### Description Creates a new device component. ### Method Signature ```typescript create( libraryUuid: string, deviceName: string, classification?: ILIB_ClassificationIndex | Array, association?: { symbolType?: ELIB_SymbolType; symbolUuid?: string; symbol?: { uuid: string; libraryUuid: string }; footprintUuid?: string; footprint?: { uuid: string; libraryUuid: string }; model3D?: { uuid: string; libraryUuid: string }; imageData?: File | Blob; }, description?: string, property?: ILIB_DeviceExtendPropertyItem ): Promise ``` ### Parameters #### Path Parameters - **libraryUuid** (string) - Required - Library UUID - **deviceName** (string) - Required - Device name #### Optional Parameters - **classification** (object | array) - Optional - Category classification - **association** (object) - Optional - Symbol, footprint, 3D model, image associations - `symbolType` (ELIB_SymbolType) - Create new symbol of this type - `symbolUuid` (string) - Associate existing symbol - `symbol` ({ uuid: string; libraryUuid: string }) - Associate existing symbol - `footprintUuid` (string) - Associate existing footprint - `footprint` ({ uuid: string; libraryUuid: string }) - Associate existing footprint - `model3D` ({ uuid: string; libraryUuid: string }) - Associate existing 3D model - `imageData` (File | Blob) - Attach product image - **description** (string) - Optional - Device description - **property** (object) - Optional - Extended properties (designator, BOM settings, etc.) ### Returns `Promise` - New device UUID or `undefined` on failure ``` -------------------------------- ### Clone Pro API SDK Repository (Gitee) Source: https://github.com/easyeda/pro-api-sdk/blob/master/README.md Use this command to clone the pro-api-sdk project from Gitee. ```shell git clone --depth=1 https://gitee.com/jlceda/pro-api-sdk.git ``` -------------------------------- ### Get Device Component Properties Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves all properties for a specific device component. An optional library UUID can be provided. ```typescript get(deviceUuid: string, libraryUuid?: string): Promise ``` -------------------------------- ### Project Build Commands Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md Provides essential commands for compiling TypeScript to JavaScript using esbuild, linting code, fixing style issues, and performing a full build. ```bash `npm run compile` | TypeScript → JavaScript (esbuild) ``` ```bash `npm run lint` | Check code style ``` ```bash `npm run fix` | Auto-fix code style issues ``` ```bash `npm run build` | Full build: compile + package ``` -------------------------------- ### Clone Pro-API-SDK Repository Source: https://github.com/easyeda/pro-api-sdk/blob/master/README.en.md Clone the pro-api-sdk project repository to your local machine. This command fetches the entire repository history. ```shell git clone --depth=1 https://github.com/easyeda/pro-api-sdk.git ``` -------------------------------- ### Get All Libraries UUIDs Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Lists all accessible library unique identifiers. Returns a promise that resolves to an array of UUID strings. ```typescript getAllLibrariesUuid(): Promise> ``` -------------------------------- ### Create a new PCB document Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Creates a new PCB document. Provide an optional board name; otherwise, it's a standalone PCB. ```typescript const pcbUuid = await eda.dmt_Pcb.createPcb('Board-1'); console.log(`Created PCB: ${pcbUuid}`); ``` -------------------------------- ### LIB_Device.copy Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Copies an existing device to another library. ```APIDOC ## LIB_Device.copy ### Description Copies a device to another library. ### Method Signature ```typescript copy( deviceUuid: string, libraryUuid: string, targetLibraryUuid: string, targetClassification?: ILIB_ClassificationIndex | Array, newDeviceName?: string ): Promise ``` ### Parameters #### Path Parameters - **deviceUuid** (string) - Required - UUID of the device to copy - **libraryUuid** (string) - Required - UUID of the source library - **targetLibraryUuid** (string) - Required - UUID of the target library #### Optional Parameters - **targetClassification** (object | array) - Optional - Classification for the new device in the target library - **newDeviceName** (string) - Optional - Name for the new device in the target library ### Returns `Promise` - UUID of the newly copied device or `undefined` on failure ``` -------------------------------- ### Get Current Active Panel Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves information for the panel that is currently active in the editor. Returns undefined if no panel is active. ```typescript getCurrentPanelInfo(): Promise ``` -------------------------------- ### LIB_Device.get Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves all properties of a specific device component. ```APIDOC ## LIB_Device.get ### Description Retrieves all device properties. ### Method Signature ```typescript get(deviceUuid: string, libraryUuid?: string): Promise ``` ### Parameters #### Path Parameters - **deviceUuid** (string) - Required - Device UUID #### Query Parameters - **libraryUuid** (string) - Optional - Library UUID ### Returns `Promise` - Device properties or `undefined` on failure ``` -------------------------------- ### openDocument Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-editor.md Opens a project document in the editor. It can target a specific split screen if provided. ```APIDOC ## openDocument ### Description Opens a project document in the editor. ### Method openDocument(documentUuid: string, splitScreenId?: string): Promise ### Parameters #### Path Parameters - **documentUuid** (string) - Required - UUID of schematic, schematic page, PCB, or panel document - **splitScreenId** (string) - Optional - Target split screen ID (last focused if omitted) ### Response #### Success Response - **string | undefined** - Tab ID of opened document or `undefined` on failure ### Request Example ```typescript const tabId = await eda.dmt_EditorControl.openDocument('schematic-page-uuid'); if (tabId) { console.log(`Document opened in tab: ${tabId}`); } ``` ``` -------------------------------- ### Extension Manifest Configuration (extension.json) Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Defines the metadata, UI integration points, and dependencies for an EasyEDA Pro extension. Ensure all required fields are correctly populated. ```json { "name": "your-extension-name", "uuid": "extension-uuid", "displayName": "Extension Display Name", "description": "What this extension does", "version": "1.0.0", "publisher": "Publisher Name", "engines": { "eda": "^3.0.0" }, "license": "Apache-2.0", "repository": { "type": "extension-store", "url": "https://..." }, "categories": "Other", "keywords": ["Tool"], "images": { "logo": "./images/logo.png" }, "homepage": "https://...", "bugs": "https://...", "activationEvents": {}, "entry": "./dist/index", "dependentExtensions": {}, "headerMenus": { "home": [{ "id": "menuId", "title": "Extension Menu", "menuItems": [{ "id": "actionId", "title": "Action Title", "registerFn": "exportedFunctionName" }] }] } } ``` -------------------------------- ### Get System Library UUID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves the unique identifier for the system library. Returns a promise that resolves to the UUID string or undefined if the operation fails. ```typescript getSystemLibraryUuid(): Promise ``` -------------------------------- ### Get All Classification Tree Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves the complete hierarchy of classification categories for a given library. Returns a promise that resolves to a tree structure representing all categories and their children. ```typescript getAllClassificationTree( libraryUuid: string, libraryType: ELIB_LibraryType ): Promise; }>> ``` -------------------------------- ### createSplitScreen Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-editor.md Creates a new split screen and moves a specified tab into it. Requires the source screen to have at least two tabs. ```APIDOC ## createSplitScreen ### Description Creates a new split screen, moving one tab from the source screen. ### Method createSplitScreen(splitScreenType: EDMT_EditorSplitScreenDirection, tabId: string): Promise<{ sourceSplitScreenId: string; newSplitScreenId: string; } | undefined> ### Parameters #### Path Parameters - **splitScreenType** (enum) - Required - HORIZONTAL or VERTICAL - **tabId** (string) - Required - Tab to move to new screen (source must have 2+ tabs) ### Response #### Success Response - **object | undefined** - Object with source and new screen IDs or `undefined` on failure ``` -------------------------------- ### Get Library Info by UUID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves metadata for a specific library using its UUID. Returns a promise that resolves to library information or undefined if the library is not found. ```typescript getLibraryInfoByUuid(libraryUuid: string): Promise ``` -------------------------------- ### Create New Project Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Creates a new project with a display name and optional parameters like project name, team, folder, description, and collaboration mode. The project name must only contain alphanumeric characters and hyphens. Returns the UUID of the newly created project. ```typescript const projectUuid = await eda.dmt_Project.createProject( 'My Circuit Design', 'my-circuit-design', 'team-uuid-123', undefined, 'A sample circuit design project' ); ``` -------------------------------- ### Get Folder Information Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves the properties of a specific folder using its UUID and the team UUID. This function returns folder details or undefined if the folder is not found. ```typescript getFolderInfo(teamUuid: string, folderUuid: string): Promise ``` -------------------------------- ### Get Current Team Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves team information for the team containing the currently active document. Returns undefined if no document is active or the team cannot be determined. ```typescript getCurrentTeamInfo(): Promise ``` -------------------------------- ### Build Extension Package Source: https://github.com/easyeda/pro-api-sdk/blob/master/README.en.md Compile the extension package. The generated package will be located in the ./build/dist/ directory. ```shell npm run build ``` -------------------------------- ### create Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Creates a new symbol within a specified library. You can provide details like name, classification, type, and description. ```APIDOC ## create ### Description Creates a new symbol. ### Method Signature ```typescript create( libraryUuid: string, symbolName: string, classification?: ILIB_ClassificationIndex | Array, symbolType?: ELIB_SymbolType, description?: string ): Promise ``` ### Parameters #### Path Parameters - **libraryUuid** (string) - Required - Library UUID - **symbolName** (string) - Required - Symbol name - **classification** (object | array) - Optional - Category index or path array - **symbolType** (enum) - Optional - Symbol type (default: COMPONENT) - **description** (string) - Optional - Symbol description ### Returns `Promise` — New symbol UUID or `undefined` on failure ### Symbol Types - `COMPONENT` - Component symbol - `NET_FLAG` - Net label - `NET_PORT` - Net port - `DRAWING` - Drawing/graphic - `NON_ELECTRICAL` - Non-electrical - `SHORT_CIRCUIT_FLAG` - Short circuit label - `OFF_PAGE_CONNECTOR` - Off-page connector - `DIFFERENTIAL_PAIRS_FLAG` - Differential pair label - `CBB_SYMBOL` - Reusable module symbol ``` -------------------------------- ### List all PCBs in the current project Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves an array of information objects for all PCBs within the current project. ```typescript const allPcbs = await eda.dmt_Pcb.getAllPcbsInfo(); ``` -------------------------------- ### Create Translation Files Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Define translations for different languages in JSON files within the 'locales/' directory. These files map keys to their localized string values. ```json { "menuTitle": "My Extension", "actionLabel": "Run Tool", "success": "Operation completed" } ``` ```json { "menuTitle": "我的扩展", "actionLabel": "运行工具", "success": "操作已完成" } ``` -------------------------------- ### LIB_Device.searchByProperties Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Performs an exact-match search for devices based on their properties. ```APIDOC ## LIB_Device.searchByProperties ### Description Performs exact-match search by device properties. ### Method Signature ```typescript searchByProperties( properties: { name?: string; value?: string; symbolName?: string; footprintName?: string; supplierFootprint?: string; supplierId?: string; partNumber?: string; partCode?: string; }, libraryUuid?: string, classification?: Array, symbolType?: ELIB_SymbolType, itemsOfPage?: number, page?: number ): Promise> ``` ### Parameters #### Path Parameters - **properties** (object) - Required - Object containing device properties to search by - `name` (string) - Optional - Device name - `value` (string) - Optional - Device value - `symbolName` (string) - Optional - Symbol name - `footprintName` (string) - Optional - Footprint name - `supplierFootprint` (string) - Optional - Supplier footprint name - `supplierId` (string) - Optional - Supplier ID - `partNumber` (string) - Optional - Part number - `partCode` (string) - Optional - Part code #### Query Parameters - **libraryUuid** (string) - Optional - Library UUID - **classification** (array) - Optional - Filter by classification - **symbolType** (ELIB_SymbolType) - Optional - Filter by symbol type - **itemsOfPage** (number) - Optional - Number of items per page - **page** (number) - Optional - Page number ### Returns `Promise>` - Matching devices ``` -------------------------------- ### Get Personal Library UUID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves the unique identifier for the user's personal library. Returns a promise that resolves to the UUID string or undefined if the operation fails. ```typescript getPersonalLibraryUuid(): Promise ``` -------------------------------- ### getAllSchematicsInfo Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Lists all available schematic documents within the current project. ```APIDOC ## getAllSchematicsInfo ### Description Lists all schematics in the current project. ### Method getAllSchematicsInfo ### Returns `Promise>` — Array of schematic information objects ``` -------------------------------- ### Get Frontend Data Unit Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Retrieves the current unit system used in the EDA frontend. Returns a unit compatible with both schematic and PCB editors, or undefined on failure. ```typescript getFrontendDataUnit(): Promise ``` -------------------------------- ### Get Tabs by Split Screen ID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-editor.md Lists all document tabs currently present within a specified split screen. Returns an array of tab information objects. ```typescript getTabsBySplitScreenId(splitScreenId: string): Promise> ``` -------------------------------- ### getProjectInfo Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves basic project properties without full document tree. ```APIDOC ## getProjectInfo ### Description Retrieves basic project properties without full document tree. ### Method getProjectInfo ### Parameters #### Path Parameters - **projectUuid** (string) - Required - Project UUID ### Response #### Success Response (IDMT_BriefProjectItem | undefined) - **projectInfo** (IDMT_BriefProjectItem) - Brief project information ``` -------------------------------- ### Get Split Screen ID by Tab ID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-editor.md Finds the split screen ID that contains a given document tab. Returns undefined if the tab ID is not found. ```typescript getSplitScreenIdByTabId(tabId: string): Promise ``` -------------------------------- ### Get 3D Model Properties Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves all properties of a specific 3D model using its UUID and an optional library UUID. Returns the model properties or undefined if not found. ```typescript get(modelUuid: string, libraryUuid?: string): Promise ``` -------------------------------- ### Project Dependencies and Scripts in package.json Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/configuration.md Defines project metadata, dependencies, and scripts for compilation, linting, and building. Ensure Node.js version is compatible. ```json { "name": "my-tool-extension", "version": "1.2.0", "description": "My circuit design tool", "author": "Your Company", "license": "Apache-2.0", "engines": { "node": ">=20.17.0" }, "scripts": { "compile": "rimraf ./dist/ && ts-node ./config/esbuild.prod.ts", "lint": "eslint", "fix": "eslint --fix", "build": "npm run compile && ts-node ./build/packaged.ts" }, "devDependencies": { "@antfu/eslint-config": "^5.4.1", "@jlceda/pro-api-types": "^0.2.62", "@types/fs-extra": "^11.0.4", "esbuild": "^0.24.2", "eslint": "^9.37.0", "fs-extra": "^11.3.0", "ignore": "^7.0.3", "jszip": "^3.10.1", "lint-staged": "^16.2.3", "rimraf": "^6.0.1", "simple-git-hooks": "^2.13.1", "ts-node": "^10.9.2", "typescript": "^5.7.3" }, "simple-git-hooks": { "pre-commit": "npx lint-staged" }, "lint-staged": { "*": "eslint --fix" } } ``` -------------------------------- ### Create Schematic Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Creates a new schematic document. Optionally associate it with a board name; otherwise, it's standalone. ```typescript createSchematic(boardName?: string): Promise ``` -------------------------------- ### openProject Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Opens a project in the EDA frontend. This will discard unsaved changes in previously open projects. ```APIDOC ## openProject ### Description Opens a project in the EDA frontend. This will discard unsaved changes in previously open projects. ### Method openProject ### Parameters #### Path Parameters - **projectUuid** (string) - Required - UUID of the project to open ### Response #### Success Response (boolean) - **success** (boolean) - Success status of the open operation ### Request Example ```typescript const success = await eda.dmt_Project.openProject('project-uuid-123'); if (success) { console.log('Project opened successfully'); } ``` ``` -------------------------------- ### Asynchronous Operations: Single Result Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/README.md Demonstrates how to call an asynchronous API method that returns a single result. Use `await` to get the result and check if it's defined before using it. ```typescript // Single result const projectInfo = await eda.dmt_Project.getCurrentProjectInfo(); if (projectInfo) { // Use projectInfo } ``` -------------------------------- ### openProjectInEditor Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Opens the reusable module as a project in the editor. Requires module UUID and library UUID. ```APIDOC ## openProjectInEditor ### Description Opens the reusable module as a project in the editor. ### Method Signature ```typescript openProjectInEditor(cbbUuid: string, libraryUuid: string): Promise ``` ### Parameters #### Path Parameters - **cbbUuid** (string) - Required - Module UUID - **libraryUuid** (string) - Required - Library UUID ### Returns `Promise` — Success status **Warning:** Unsaved changes in previously open projects will be lost. ``` -------------------------------- ### Get Classification Name by UUID Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves category names based on their UUIDs. Accepts primary and optionally secondary classification UUIDs. Returns an object with category names or undefined if not found. ```typescript getNameByUuid( libraryUuid: string, libraryType: ELIB_LibraryType, primaryClassificationUuid: string, secondaryClassificationUuid?: string ): Promise<{ primaryClassificationName: string; secondaryClassificationName?: string } | undefined> ``` -------------------------------- ### Get All Project UUIDs Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Lists all project UUIDs that match the specified filtering criteria, such as team, folder, or workspace. This is useful for batch operations or listing projects within a specific context. ```typescript const projectIds = await eda.dmt_Project.getAllProjectsUuid('team-uuid-123'); console.log(`Found ${projectIds.length} projects`); ``` -------------------------------- ### Get Symbol Properties Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves all properties for a given symbol using its UUID. The library UUID is optional; if omitted, the system library is used. Returns the symbol's properties or undefined if not found. ```typescript get(symbolUuid: string, libraryUuid?: string): Promise ``` -------------------------------- ### Get Current Document Info Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Retrieves information about the currently active document with input focus. Use this to access details like document type and UUID. Returns undefined if retrieval fails. ```typescript getCurrentDocumentInfo(): Promise ``` ```typescript const currentDoc = await eda.dmt_SelectControl.getCurrentDocumentInfo(); if (currentDoc) { console.log('Document Type:', currentDoc.documentType); console.log('Document UUID:', currentDoc.uuid); } ``` -------------------------------- ### Working with Libraries Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/sys-utilities.md Interact with the library system, including searching for components and opening library items in the editor. ```APIDOC ## Working with Libraries ### Description Provides functionality to interact with the component library, such as obtaining system library identifiers, searching for components, and opening library symbols in the editor. ### Methods - `await eda.lib_LibrariesList.getSystemLibraryUuid()`: Retrieves the UUID of the system library. - `await eda.lib_Device.search(query: string, libraryId: string)`: Searches for components within a specified library. - `await eda.lib_Symbol.openInEditor(symbolUuid: string, libraryId: string)`: Opens a library symbol in the editor. ``` -------------------------------- ### Create Footprint Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Creates a new footprint in a specified library. Requires the library UUID and footprint name. Optionally accepts classification and description. ```typescript create( libraryUuid: string, footprintName: string, classification?: ILIB_ClassificationIndex | Array, description?: string ): Promise ``` -------------------------------- ### Batch Get Devices by LCSC IDs Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves multiple devices using their JLC component numbers. Optionally allows for multi-match results per ID. Ensure the correct LCSC IDs are provided. ```typescript const devices = await eda.lib_Device.getByLcscIds( ['C001234', 'C005678'], undefined, true ); devices.forEach(d => { console.log(`${d.name}: ${d.symbol.name}, ${d.footprint?.name || 'N/A'}`); }); ``` -------------------------------- ### createPcb Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Creates a new PCB document. If a board name is provided, it's associated with that board; otherwise, it's a standalone PCB. ```APIDOC ## createPcb ### Description Creates a new PCB document. ### Method ```typescript createPcb(boardName?: string): Promise ``` ### Parameters #### Query Parameters - **boardName** (string) - Optional - Associated board name (standalone PCB if omitted) ### Returns `Promise` — New PCB UUID or `undefined` on failure ### Request Example ```typescript const pcbUuid = await eda.dmt_Pcb.createPcb('Board-1'); console.log(`Created PCB: ${pcbUuid}`); ``` ``` -------------------------------- ### Get Classification Index by Name Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-core.md Retrieves a classification index using category names. Supports querying by primary category name and optionally by secondary category name. Returns the classification index or undefined if not found. ```typescript getIndexByName( libraryUuid: string, libraryType: ELIB_LibraryType, primaryClassificationName: string, secondaryClassificationName?: string ): Promise ``` -------------------------------- ### Get Device(s) by LCSC IDs Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/lib-advanced.md Retrieves device(s) using their JLC component number (LCSC ID). Supports returning a single match or all matches based on the `allowMultiMatch` flag. Note: Unavailable in private deployments. ```typescript getByLcscIds( lcscIds: string, libraryUuid?: string, allowMultiMatch?: false ): Promise ``` ```typescript getByLcscIds( lcscIds: string, libraryUuid?: string, allowMultiMatch?: true ): Promise> ``` -------------------------------- ### Open Project in EDA Frontend Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-core.md Opens a specified project in the EasyEDA frontend. This action will discard any unsaved changes in the currently open project. Use this when you need to switch to a different project context. ```typescript const success = await eda.dmt_Project.openProject('project-uuid-123'); if (success) { console.log('Project opened successfully'); } ``` -------------------------------- ### getCurrentPcbInfo Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-documents.md Retrieves information for the PCB document currently active in the editor. ```APIDOC ## getCurrentPcbInfo ### Description Retrieves PCB information for the currently active PCB editor. ### Method ```typescript getCurrentPcbInfo(): Promise ``` ### Returns `Promise` — Current PCB information or `undefined` if no PCB is active ``` -------------------------------- ### Get Split Screen Layout Tree Source: https://github.com/easyeda/pro-api-sdk/blob/master/_autodocs/api-reference/dmt-editor.md Retrieves the entire hierarchy of the editor's split screen layout. This is useful for understanding the current arrangement of tabs and screens. The function returns a nested structure representing the layout. ```typescript const tree = await eda.dmt_EditorControl.getSplitScreenTree(); if (tree) { console.log(`Root screen ID: ${tree.id}`); if (tree.tabs) { console.log(`Tabs in this screen: ${tree.tabs.length}`); } if (tree.children) { console.log(`Child screens: ${tree.children.length}`); } } ```