diff --git a/libs/plugin-types/index.d.ts b/libs/plugin-types/index.d.ts index 75d2664..e515ed1 100644 --- a/libs/plugin-types/index.d.ts +++ b/libs/plugin-types/index.d.ts @@ -354,7 +354,7 @@ export interface Page extends PluginData { /** * Removes the `guide` from the current page. */ - removeRulerGuide(guide: RulerGuide); + removeRulerGuide(guide: RulerGuide): void; } /** @@ -1845,7 +1845,7 @@ export interface Board extends ShapeBase { /** * Removes the `guide` from the current page. */ - removeRulerGuide(guide: RulerGuide); + removeRulerGuide(guide: RulerGuide): void; } /** @@ -2312,18 +2312,18 @@ export interface Viewport { /** * Resets the zoom level. */ - zoomReset(); + zoomReset(): void; /** * Changes the viewport and zoom so can fit all the current shapes in the page. */ - zoomToFitAll(); + zoomToFitAll(): void; /** * Changes the viewport and zoom so all the `shapes` in the argument are * visible. */ - zoomToShapes(shapes: Shape[]); + zoomToShapes(shapes: Shape[]): void; } /** @@ -2341,7 +2341,7 @@ export interface Viewport { export type Shape = | Board | Group - | Bool + | Boolean | Rectangle | Path | Text @@ -3363,7 +3363,7 @@ export interface Context { * const booleanShape = context.createBoolean('union', [shape1, shape2]); * ``` */ - createBoolean(boolType: BooleanType, shapes: Shape[]): Bool | null; + createBoolean(boolType: BooleanType, shapes: Shape[]): Boolean | null; /** * Creates a Group from an SVG string. Requires `content:write` permission. * @param svgString The SVG string representing the shapes to be converted into a group. @@ -3861,7 +3861,7 @@ export interface ContextTypesUtils { * @param shape - The shape to check. * @return Returns true if the shape is a Bool, otherwise false. */ - isBool(shape: Shape): shape is Bool; + isBool(shape: Shape): shape is Boolean; /** * Checks if the given shape is a rectangle. diff --git a/libs/plugins-runtime/src/lib/create-plugin.spec.ts b/libs/plugins-runtime/src/lib/create-plugin.spec.ts index 02dc5d9..b94d411 100644 --- a/libs/plugins-runtime/src/lib/create-plugin.spec.ts +++ b/libs/plugins-runtime/src/lib/create-plugin.spec.ts @@ -2,7 +2,7 @@ import { describe, it, vi, expect, beforeEach, afterEach } from 'vitest'; import { createPlugin } from './create-plugin'; import { createPluginManager } from './plugin-manager.js'; import { createSandbox } from './create-sandbox.js'; -import type { PenpotContext } from '@penpot/plugin-types'; +import type { Context } from '@penpot/plugin-types'; import type { Manifest } from './models/manifest.model.js'; vi.mock('./plugin-manager.js', () => ({ @@ -14,7 +14,7 @@ vi.mock('./create-sandbox.js', () => ({ })); describe('createPlugin', () => { - let mockContext: PenpotContext; + let mockContext: Context; let manifest: Manifest; let onCloseCallback: ReturnType; let mockPluginManager: Awaited>; @@ -59,7 +59,7 @@ describe('createPlugin', () => { addListener: vi.fn(), removeListener: vi.fn(), getTheme: vi.fn().mockReturnValue('light'), - } as unknown as PenpotContext; + } as unknown as Context; onCloseCallback = vi.fn(); diff --git a/libs/plugins-runtime/src/lib/create-plugin.ts b/libs/plugins-runtime/src/lib/create-plugin.ts index 6b786d7..955a500 100644 --- a/libs/plugins-runtime/src/lib/create-plugin.ts +++ b/libs/plugins-runtime/src/lib/create-plugin.ts @@ -1,10 +1,10 @@ -import type { PenpotContext } from '@penpot/plugin-types'; +import type { Context } from '@penpot/plugin-types'; import type { Manifest } from './models/manifest.model.js'; import { createPluginManager } from './plugin-manager.js'; import { createSandbox } from './create-sandbox.js'; export async function createPlugin( - context: PenpotContext, + context: Context, manifest: Manifest, onCloseCallback: () => void ) { diff --git a/libs/plugins-runtime/src/lib/plugin-manager.spec.ts b/libs/plugins-runtime/src/lib/plugin-manager.spec.ts index 663fce9..06869f0 100644 --- a/libs/plugins-runtime/src/lib/plugin-manager.spec.ts +++ b/libs/plugins-runtime/src/lib/plugin-manager.spec.ts @@ -3,7 +3,7 @@ import { createPluginManager } from './plugin-manager'; import { loadManifestCode, getValidUrl } from './parse-manifest.js'; import { PluginModalElement } from './modal/plugin-modal.js'; import { openUIApi } from './api/openUI.api.js'; -import type { PenpotContext, PenpotTheme } from '@penpot/plugin-types'; +import type { Context, Theme } from '@penpot/plugin-types'; import type { Manifest } from './models/manifest.model.js'; vi.mock('./parse-manifest.js', () => ({ @@ -16,7 +16,7 @@ vi.mock('./api/openUI.api.js', () => ({ })); describe('createPluginManager', () => { - let mockContext: PenpotContext; + let mockContext: Context; let manifest: Manifest; let onCloseCallback: ReturnType; let onReloadModal: ReturnType; @@ -59,7 +59,7 @@ describe('createPluginManager', () => { addListener: vi.fn().mockReturnValue(Symbol()), removeListener: vi.fn(), getTheme: vi.fn().mockReturnValue('light'), - } as unknown as PenpotContext; + } as unknown as Context; onCloseCallback = vi.fn(); onReloadModal = vi.fn(); @@ -159,7 +159,7 @@ describe('createPluginManager', () => { throw new Error('Theme change callback not found'); } - themeChangeCallback('dark' as PenpotTheme); + themeChangeCallback('dark' as Theme); expect(mockModal.setTheme).toHaveBeenCalledWith('dark'); }); diff --git a/libs/plugins-runtime/src/lib/plugin-manager.ts b/libs/plugins-runtime/src/lib/plugin-manager.ts index 42a9611..fb42b0d 100644 --- a/libs/plugins-runtime/src/lib/plugin-manager.ts +++ b/libs/plugins-runtime/src/lib/plugin-manager.ts @@ -1,4 +1,4 @@ -import type { PenpotContext, PenpotTheme } from '@penpot/plugin-types'; +import type { Context, Theme } from '@penpot/plugin-types'; import { getValidUrl, loadManifestCode } from './parse-manifest.js'; import { Manifest } from './models/manifest.model.js'; @@ -8,7 +8,7 @@ import { OpenUIOptions } from './models/open-ui-options.model.js'; import { RegisterListener, DestroyListener } from './models/plugin.model.js'; export async function createPluginManager( - context: PenpotContext, + context: Context, manifest: Manifest, onCloseCallback: () => void, onReloadModal: (code: string) => void @@ -21,12 +21,9 @@ export async function createPluginManager( let uiMessagesCallbacks: ((message: unknown) => void)[] = []; const timeouts = new Set>(); - const themeChangeId = context.addListener( - 'themechange', - (theme: PenpotTheme) => { - modal?.setTheme(theme); - } - ); + const themeChangeId = context.addListener('themechange', (theme: Theme) => { + modal?.setTheme(theme); + }); const listenerId: symbol = context.addListener('finish', () => { closePlugin();