From f62161969bc348b38da5dd7c53a7a204bce9176c Mon Sep 17 00:00:00 2001 From: Michael Yong Date: Sat, 14 Sep 2024 19:17:30 -0700 Subject: [PATCH] Add standalone types --- plugin-api-standalone.d.ts | 2607 ++++++++++++++++++++++++++++++++++++ test-usage.sh | 45 +- 2 files changed, 2651 insertions(+), 1 deletion(-) create mode 100644 plugin-api-standalone.d.ts diff --git a/plugin-api-standalone.d.ts b/plugin-api-standalone.d.ts new file mode 100644 index 0000000..bf78775 --- /dev/null +++ b/plugin-api-standalone.d.ts @@ -0,0 +1,2607 @@ +/* plugin-typings are auto-generated. Do not update them directly. See plugin-docs/ for instructions. */ +/** + * NOTE: This file is useful if you want to import specific types eg. + * import type { SceneNode } from "@figma/plugin-typings/plugin-api-standalone" + */ +declare type ArgFreeEventType = + | 'selectionchange' + | 'currentpagechange' + | 'close' + | 'timerstart' + | 'timerstop' + | 'timerpause' + | 'timerresume' + | 'timeradjust' + | 'timerdone' +interface PluginAPI { + readonly apiVersion: '1.0.0' + readonly command: string + readonly editorType: 'figma' | 'figjam' | 'dev' + readonly mode: 'default' | 'textreview' | 'inspect' | 'codegen' | 'linkpreview' | 'auth' + readonly pluginId?: string + readonly widgetId?: string + readonly fileKey: string | undefined + skipInvisibleInstanceChildren: boolean + readonly timer?: TimerAPI + readonly viewport: ViewportAPI + readonly currentUser: User | null + readonly activeUsers: ActiveUser[] + readonly textreview?: TextReviewAPI + readonly codegen: CodegenAPI + readonly vscode?: VSCodeAPI + readonly devResources?: DevResourcesAPI + readonly payments?: PaymentsAPI + closePlugin(message?: string): void + notify(message: string, options?: NotificationOptions): NotificationHandler + commitUndo(): void + triggerUndo(): void + saveVersionHistoryAsync(title: string, description?: string): Promise + openExternal(url: string): void + showUI(html: string, options?: ShowUIOptions): void + readonly ui: UIAPI + readonly util: UtilAPI + readonly constants: ConstantsAPI + readonly clientStorage: ClientStorageAPI + readonly parameters: ParametersAPI + getNodeByIdAsync(id: string): Promise + getNodeById(id: string): BaseNode | null + getStyleByIdAsync(id: string): Promise + getStyleById(id: string): BaseStyle | null + readonly variables: VariablesAPI + readonly teamLibrary: TeamLibraryAPI + readonly root: DocumentNode + currentPage: PageNode + setCurrentPageAsync(page: PageNode): Promise + on(type: ArgFreeEventType, callback: () => void): void + on(type: 'run', callback: (event: RunEvent) => void): void + on(type: 'drop', callback: (event: DropEvent) => boolean): void + on(type: 'documentchange', callback: (event: DocumentChangeEvent) => void): void + on( + type: 'textreview', + callback: (event: TextReviewEvent) => Promise | TextReviewRange[], + ): void + on(type: 'stylechange', callback: (event: StyleChangeEvent) => void): void + once(type: ArgFreeEventType, callback: () => void): void + once(type: 'run', callback: (event: RunEvent) => void): void + once(type: 'drop', callback: (event: DropEvent) => boolean): void + once(type: 'documentchange', callback: (event: DocumentChangeEvent) => void): void + once( + type: 'textreview', + callback: (event: TextReviewEvent) => Promise | TextReviewRange[], + ): void + once(type: 'stylechange', callback: (event: StyleChangeEvent) => void): void + off(type: ArgFreeEventType, callback: () => void): void + off(type: 'run', callback: (event: RunEvent) => void): void + off(type: 'drop', callback: (event: DropEvent) => boolean): void + off(type: 'documentchange', callback: (event: DocumentChangeEvent) => void): void + off( + type: 'textreview', + callback: (event: TextReviewEvent) => Promise | TextReviewRange[], + ): void + off(type: 'stylechange', callback: (event: StyleChangeEvent) => void): void + readonly mixed: unique symbol + createRectangle(): RectangleNode + createLine(): LineNode + createEllipse(): EllipseNode + createPolygon(): PolygonNode + createStar(): StarNode + createVector(): VectorNode + createText(): TextNode + createFrame(): FrameNode + createComponent(): ComponentNode + createComponentFromNode(node: SceneNode): ComponentNode + createPage(): PageNode + createSlice(): SliceNode + createSticky(): StickyNode + createConnector(): ConnectorNode + createShapeWithText(): ShapeWithTextNode + createCodeBlock(): CodeBlockNode + createSection(): SectionNode + createTable(numRows?: number, numColumns?: number): TableNode + createNodeFromJSXAsync(jsx: any): Promise + createBooleanOperation(): BooleanOperationNode + createPaintStyle(): PaintStyle + createTextStyle(): TextStyle + createEffectStyle(): EffectStyle + createGridStyle(): GridStyle + getLocalPaintStylesAsync(): Promise + getLocalPaintStyles(): PaintStyle[] + getLocalTextStylesAsync(): Promise + getLocalTextStyles(): TextStyle[] + getLocalEffectStylesAsync(): Promise + getLocalEffectStyles(): EffectStyle[] + getLocalGridStylesAsync(): Promise + getLocalGridStyles(): GridStyle[] + getSelectionColors(): null | { + paints: Paint[] + styles: PaintStyle[] + } + moveLocalPaintStyleAfter(targetNode: PaintStyle, reference: PaintStyle | null): void + moveLocalTextStyleAfter(targetNode: TextStyle, reference: TextStyle | null): void + moveLocalEffectStyleAfter(targetNode: EffectStyle, reference: EffectStyle | null): void + moveLocalGridStyleAfter(targetNode: GridStyle, reference: GridStyle | null): void + moveLocalPaintFolderAfter(targetFolder: string, reference: string | null): void + moveLocalTextFolderAfter(targetFolder: string, reference: string | null): void + moveLocalEffectFolderAfter(targetFolder: string, reference: string | null): void + moveLocalGridFolderAfter(targetFolder: string, reference: string | null): void + importComponentByKeyAsync(key: string): Promise + importComponentSetByKeyAsync(key: string): Promise + importStyleByKeyAsync(key: string): Promise + listAvailableFontsAsync(): Promise + loadFontAsync(fontName: FontName): Promise + readonly hasMissingFont: boolean + createNodeFromSvg(svg: string): FrameNode + createImage(data: Uint8Array): Image + createImageAsync(src: string): Promise + getImageByHash(hash: string): Image | null + createVideoAsync(data: Uint8Array): Promise