@mastergo/plugin-typings 2.8.2 → 2.8.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +24 -1
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1113,6 +1113,8 @@ declare global {
1113
1113
  */
1114
1114
  readonly codegen?: CodegenAPI
1115
1115
 
1116
+ readonly snippetgent?: SnippetgenAPI
1117
+
1116
1118
  readonly mode?: "inspect" | "design" | "codegen" | "snippetgen"
1117
1119
 
1118
1120
  closePlugin(): void
@@ -1126,7 +1128,7 @@ declare global {
1126
1128
 
1127
1129
  showUI(html: string, options?: ShowUIOptions): void
1128
1130
 
1129
- getNodeById(id: string): SceneNode | null
1131
+ getNodeById<T extends SceneNode>(id: string): T | null
1130
1132
  getNodeByPosition(position: { x: number, y: number }): SceneNode | null
1131
1133
  createRectangle(): RectangleNode
1132
1134
  createLine(): LineNode
@@ -2581,6 +2583,27 @@ declare global {
2581
2583
  getCodeByDSL(data: MGDSL.MGDSLData, type: MGDSL.Framework): Promise<CodeFile | null>;
2582
2584
  }
2583
2585
 
2586
+ interface SnippetgenData {
2587
+ language: string;
2588
+ layerId: string;
2589
+ preferences: Record<string, string>;
2590
+ unit: Record<string, string>;
2591
+ }
2592
+
2593
+ interface SnippetGenResult {
2594
+ language: string;
2595
+ code: string;
2596
+ title: string;
2597
+ }
2598
+
2599
+ interface SnippetgenAPI {
2600
+ on(type: 'generate', event: (data: SnippetgenData, callback: (modifiedData: SnippetGenResult[]) => void) => void): void
2601
+ off(type: 'generate', event: (data: SnippetgenData, callback: (modifiedData: SnippetGenResult[]) => void) => void): void
2602
+
2603
+ on(type: 'action', event: (value: string) => void): void
2604
+ off(type: 'action', event: (value: string) => void): void
2605
+ }
2606
+
2584
2607
  type StyleReturnType<T extends StyleType> =
2585
2608
  T extends 'PAINT' ? PaintStyle :
2586
2609
  T extends 'TEXT' ? TextStyle :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "2.8.2",
3
+ "version": "2.8.3-beta.0",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",