diff --git a/penpot-plugin/src/TaskHandler.ts b/penpot-plugin/src/TaskHandler.ts index 4c576c6..950c19c 100644 --- a/penpot-plugin/src/TaskHandler.ts +++ b/penpot-plugin/src/TaskHandler.ts @@ -9,7 +9,11 @@ export class Task { * @param taskType The type of the task to execute * @param params Task parameters/arguments */ - constructor(public requestId: string, public taskType: string, public params: TParams) {} + constructor( + public requestId: string, + public taskType: string, + public params: TParams + ) {} /** * Sends a task response back to the MCP server. @@ -70,4 +74,4 @@ export abstract class TaskHandler { * @param task - The task to be handled */ abstract handle(task: Task): void; -} \ No newline at end of file +} diff --git a/penpot-plugin/src/plugin.ts b/penpot-plugin/src/plugin.ts index 56ab7c2..3fd0ca2 100644 --- a/penpot-plugin/src/plugin.ts +++ b/penpot-plugin/src/plugin.ts @@ -1,14 +1,11 @@ -import {PrintTextTaskHandler} from "./task-handlers/PrintTextTaskHandler"; -import {ExecuteCodeTaskHandler} from "./task-handlers/ExecuteCodeTaskHandler"; -import {Task, TaskHandler} from "./TaskHandler"; +import { PrintTextTaskHandler } from "./task-handlers/PrintTextTaskHandler"; +import { ExecuteCodeTaskHandler } from "./task-handlers/ExecuteCodeTaskHandler"; +import { Task, TaskHandler } from "./TaskHandler"; /** * Registry of all available task handlers. */ -const taskHandlers: TaskHandler[] = [ - new PrintTextTaskHandler(), - new ExecuteCodeTaskHandler(), -]; +const taskHandlers: TaskHandler[] = [new PrintTextTaskHandler(), new ExecuteCodeTaskHandler()]; penpot.ui.open("Penpot MCP Plugin", `?theme=${penpot.theme}`); @@ -45,7 +42,7 @@ function handlePluginTaskRequest(request: { id: string; task: string; params: an const task = new Task(request.id, request.task, request.params); // Find the appropriate handler - const handler = taskHandlers.find(h => h.isApplicableTo(task)); + const handler = taskHandlers.find((h) => h.isApplicableTo(task)); if (handler) { try { @@ -71,7 +68,6 @@ function handlePluginTaskRequest(request: { id: string; task: string; params: an } } - // Update the theme in the iframe penpot.on("themechange", (theme) => { penpot.ui.sendMessage({ diff --git a/penpot-plugin/src/task-handlers/ExecuteCodeTaskHandler.ts b/penpot-plugin/src/task-handlers/ExecuteCodeTaskHandler.ts index f97a2db..94a79cb 100644 --- a/penpot-plugin/src/task-handlers/ExecuteCodeTaskHandler.ts +++ b/penpot-plugin/src/task-handlers/ExecuteCodeTaskHandler.ts @@ -1,14 +1,14 @@ -import {Task, TaskHandler} from "../TaskHandler"; -import {ExecuteCodeTaskParams} from "../../../common/src"; +import { Task, TaskHandler } from "../TaskHandler"; +import { ExecuteCodeTaskParams } from "../../../common/src"; /** * Task handler for executing JavaScript code in the plugin context. - * + * * Maintains a persistent context object that preserves state between code executions. */ export class ExecuteCodeTaskHandler extends TaskHandler { readonly taskType = "executeCode"; - + /** * Persistent context object that maintains state between code executions. * Contains the penpot API and any variables defined in executed code. @@ -21,7 +21,7 @@ export class ExecuteCodeTaskHandler extends TaskHandler { // initialize context, making penpot object available this.context = { penpot: penpot, - storage: {} + storage: {}, }; } diff --git a/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts b/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts index 3052571..b6d32d5 100644 --- a/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts +++ b/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts @@ -1,5 +1,5 @@ -import {Task, TaskHandler} from "../TaskHandler"; -import {PrintTextTaskParams} from "../../../common/src"; +import { Task, TaskHandler } from "../TaskHandler"; +import { PrintTextTaskParams } from "../../../common/src"; /** * Task handler for printing text to Penpot. @@ -28,4 +28,4 @@ export class PrintTextTaskHandler extends TaskHandler { throw new Error("Failed to create text element"); } } -} \ No newline at end of file +}