mirror of
https://github.com/penpot/penpot.git
synced 2026-07-28 17:06:21 +00:00
⬆️ Upgrade plugin-types and plugin-styles to v1.5.0 in MCP plugin (#10830)
The upgrade allows ts-ignore annotations and manually declared type information to be removed.
This commit is contained in:
parent
2f8d71e143
commit
a749763fb1
@ -12,8 +12,8 @@
|
||||
"clean": "rm -rf dist/"
|
||||
},
|
||||
"dependencies": {
|
||||
"@penpot/plugin-styles": "1.4.2",
|
||||
"@penpot/plugin-types": "1.4.2"
|
||||
"@penpot/plugin-styles": "1.5.0",
|
||||
"@penpot/plugin-types": "1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^10.1.0",
|
||||
|
||||
@ -214,8 +214,6 @@ export class PenpotUtils {
|
||||
public static getBounds(shape: Shape): Bounds {
|
||||
if (shape.type === "text") {
|
||||
const text = shape as Text;
|
||||
// TODO: Remove ts-ignore once type definitions are updated
|
||||
// @ts-ignore
|
||||
return text.textBounds;
|
||||
} else {
|
||||
return shape.bounds;
|
||||
@ -473,7 +471,6 @@ export class PenpotUtils {
|
||||
*/
|
||||
public static findTokensByName(name: string): any[] {
|
||||
const tokens: any[] = [];
|
||||
// @ts-ignore
|
||||
const tokenCatalog = penpot.library.local.tokens;
|
||||
|
||||
for (const set of tokenCatalog.sets) {
|
||||
@ -494,7 +491,6 @@ export class PenpotUtils {
|
||||
* @returns The first matching token, or null if not found
|
||||
*/
|
||||
public static findTokenByName(name: string): any | null {
|
||||
// @ts-ignore
|
||||
const tokenCatalog = penpot.library.local.tokens;
|
||||
|
||||
for (const set of tokenCatalog.sets) {
|
||||
@ -515,7 +511,6 @@ export class PenpotUtils {
|
||||
* @returns The TokenSet containing this token, or null if not found
|
||||
*/
|
||||
public static getTokenSet(token: any): any | null {
|
||||
// @ts-ignore
|
||||
const tokenCatalog = penpot.library.local.tokens;
|
||||
|
||||
for (const set of tokenCatalog.sets) {
|
||||
@ -571,7 +566,6 @@ export class PenpotUtils {
|
||||
}
|
||||
|
||||
// 1. Create the variant container
|
||||
// @ts-ignore — createVariantFromComponents was added after plugin-types@1.4.1
|
||||
const container: VariantContainer = (penpot as any).createVariantFromComponents(components.map((c) => c.shape));
|
||||
const variants = container.variants;
|
||||
if (!variants) {
|
||||
@ -617,7 +611,6 @@ export class PenpotUtils {
|
||||
*/
|
||||
public static tokenOverview(): Record<string, Record<string, string[]>> {
|
||||
const overview: Record<string, Record<string, string[]>> = {};
|
||||
// @ts-ignore
|
||||
const tokenCatalog = penpot.library.local.tokens;
|
||||
|
||||
for (const set of tokenCatalog.sets) {
|
||||
|
||||
@ -38,8 +38,6 @@ export class Task<TParams = any> {
|
||||
|
||||
// Send to main.ts which will forward to MCP server via WebSocket
|
||||
try {
|
||||
// TODO: Remove ts-ignore once Penpot types have been updated
|
||||
// @ts-ignore
|
||||
penpot.ui.sendMessage(response, true);
|
||||
} catch (sendError) {
|
||||
console.error("Failed to transfer task response for transmission to MCP server", sendError);
|
||||
|
||||
9
mcp/packages/plugin/src/index.d.ts
vendored
9
mcp/packages/plugin/src/index.d.ts
vendored
@ -1,12 +1,3 @@
|
||||
import "@penpot/plugin-types";
|
||||
|
||||
declare module "@penpot/plugin-types" {
|
||||
interface Penpot {
|
||||
/** The Penpot application version string. */
|
||||
version: string;
|
||||
}
|
||||
}
|
||||
|
||||
interface McpOptions {
|
||||
getToken(): string;
|
||||
getServerUrl(): string;
|
||||
|
||||
@ -196,20 +196,13 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
||||
const code = task.params.code;
|
||||
|
||||
// set the flags naturalChildOrdering and throwValidationErrors to true during code execution.
|
||||
// TODO: Remove all ts-ignore once Penpot types have been updated
|
||||
let originalNaturalChildOrdering: any, originalThrowValidationErrors: any;
|
||||
// @ts-ignore
|
||||
if (penpot.flags) {
|
||||
// @ts-ignore
|
||||
originalNaturalChildOrdering = penpot.flags.naturalChildOrdering;
|
||||
// @ts-ignore
|
||||
penpot.flags.naturalChildOrdering = true;
|
||||
// @ts-ignore
|
||||
originalThrowValidationErrors = penpot.flags.throwValidationErrors;
|
||||
// @ts-ignore
|
||||
penpot.flags.throwValidationErrors = true;
|
||||
} else {
|
||||
// TODO: This can be removed once `flags` has been merged to PROD
|
||||
throw new Error(
|
||||
"You are using a version of the Penpot MCP server which is incompatible " +
|
||||
"with the connected Penpot version. " +
|
||||
@ -228,9 +221,7 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
||||
})(context);
|
||||
} finally {
|
||||
// restore the original value of the flags
|
||||
// @ts-ignore
|
||||
penpot.flags.naturalChildOrdering = originalNaturalChildOrdering;
|
||||
// @ts-ignore
|
||||
penpot.flags.throwValidationErrors = originalThrowValidationErrors;
|
||||
}
|
||||
|
||||
|
||||
20
mcp/pnpm-lock.yaml
generated
20
mcp/pnpm-lock.yaml
generated
@ -24,11 +24,11 @@ importers:
|
||||
packages/plugin:
|
||||
dependencies:
|
||||
'@penpot/plugin-styles':
|
||||
specifier: 1.4.2
|
||||
version: 1.4.2
|
||||
specifier: 1.5.0
|
||||
version: 1.5.0
|
||||
'@penpot/plugin-types':
|
||||
specifier: 1.4.2
|
||||
version: 1.4.2
|
||||
specifier: 1.5.0
|
||||
version: 1.5.0
|
||||
devDependencies:
|
||||
cross-env:
|
||||
specifier: ^10.1.0
|
||||
@ -496,11 +496,11 @@ packages:
|
||||
'@oxc-project/types@0.137.0':
|
||||
resolution: {integrity: sha512-WT+Gb24i8hmvo85AIv2oEYouEXkRlKAlT9WaCa3TfLgNCN+GhrJOGZuIlMouAh38Qe4QOx26eUOVsq70qXrywA==}
|
||||
|
||||
'@penpot/plugin-styles@1.4.2':
|
||||
resolution: {integrity: sha512-/Rn6xy80W+mxAi6j5/SOiNY8P0qHMB1WW+j+nyZajecFSnVGPzSWOiMcIDH+Jtsz7Xpmd5AICpgVM0xjechQig==}
|
||||
'@penpot/plugin-styles@1.5.0':
|
||||
resolution: {integrity: sha512-rwXFBRPd0IZs3ens+eRT8oA5WqkQgF6xlW6fCfH7U1NHRjej9HH7vTGXmfjoIVml6Xx1sbyYHZVxkQC8Ub8+zA==}
|
||||
|
||||
'@penpot/plugin-types@1.4.2':
|
||||
resolution: {integrity: sha512-O8wU6RSYE8bIVU7g8cSTYi32ppxs3R13dq7X3Nn9tmDaJjBOKOBpVLuoRPIp3fJC65fv8/7om0sdrtFoL5v19g==}
|
||||
'@penpot/plugin-types@1.5.0':
|
||||
resolution: {integrity: sha512-hFk4Rx66rLaSUWoN6bhxXkDI2ymwKg9xokdslvZvXM5MSmEmfhsJKUMwtuzgYWljbbfaQhK+DjK8g8yVbbavtA==}
|
||||
|
||||
'@pinojs/redact@0.4.0':
|
||||
resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==}
|
||||
@ -1762,9 +1762,9 @@ snapshots:
|
||||
|
||||
'@oxc-project/types@0.137.0': {}
|
||||
|
||||
'@penpot/plugin-styles@1.4.2': {}
|
||||
'@penpot/plugin-styles@1.5.0': {}
|
||||
|
||||
'@penpot/plugin-types@1.4.2': {}
|
||||
'@penpot/plugin-types@1.5.0': {}
|
||||
|
||||
'@pinojs/redact@0.4.0': {}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user