@mastergo/plugin-typings 1.21.0 → 2.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ # [2.0.0](https://github.com/mastergo-design/plugin-typings/compare/v1.21.0...v2.0.0) (2023-09-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 修改接口 ([50c9d6f](https://github.com/mastergo-design/plugin-typings/commit/50c9d6f1ad1f7290f62009f7c4f672b8f7f1ad81))
7
+
8
+
9
+ ### Features
10
+
11
+ * 插件API支持SECTION类型 ([ae02af9](https://github.com/mastergo-design/plugin-typings/commit/ae02af932b90ca770e343a5f1bad7abb48fe90df))
12
+ * 全局增加createSection的接口 ([da713b1](https://github.com/mastergo-design/plugin-typings/commit/da713b18c1994ecbe576c75a19e67ba7edda6e46))
13
+ * 新增组件集属性别名相关方法/画布在整个窗口中的位置 ([5b212c9](https://github.com/mastergo-design/plugin-typings/commit/5b212c943c7d0c2afb92fcad1433e70733fa43d2))
14
+
15
+
16
+
17
+ # [1.21.0](https://github.com/mastergo-design/plugin-typings/compare/v1.19.0...v1.21.0) (2023-07-06)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * 补充paint的name字段 ([217c68e](https://github.com/mastergo-design/plugin-typings/commit/217c68efdcd1a3e6d0d0d07c3fd024794563751b))
23
+ * opaque图层禁止修改相对矩阵 ([fb634b1](https://github.com/mastergo-design/plugin-typings/commit/fb634b1eb77d7df2f5d1eeb98bd53888586b0daa))
24
+
25
+
26
+ ### Features
27
+
28
+ * 添加轮廓蒙层和是否可视属性,文本支持省略 ([89414ad](https://github.com/mastergo-design/plugin-typings/commit/89414ad67f398dd44055172b1d0f9ff47693b1d6))
29
+ * 增加pluginId ([321db49](https://github.com/mastergo-design/plugin-typings/commit/321db497ff6da8f2802bab2f5ea1c5e3f3a1fc76))
30
+ * document增加id ([d2bfdff](https://github.com/mastergo-design/plugin-typings/commit/d2bfdff8451eea4c09a757b6d01fec0c37f73e6f))
31
+
32
+
33
+
1
34
  # [1.20.0](https://github.com/mastergo-design/plugin-typings/compare/v1.19.0...v1.20.0) (2023-04-27)
2
35
 
3
36
 
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ declare global {
25
25
  getBytesAsync(): Promise<Uint8Array>
26
26
  }
27
27
 
28
- type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
28
+ type PluginEventType = 'selectionchange' | 'layoutchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
29
29
  type ThemeColor = 'dark' | 'light'
30
30
 
31
31
  interface PluginAPI {
@@ -63,7 +63,7 @@ declare global {
63
63
  showUI(html: string, options?: ShowUIOptions): void
64
64
 
65
65
  getNodeById(id: string): SceneNode | null
66
- getNodeByPosition(position: {x: number, y: number}): SceneNode | null
66
+ getNodeByPosition(position: { x: number, y: number }): SceneNode | null
67
67
  createRectangle(): RectangleNode
68
68
  createLine(): LineNode
69
69
  createEllipse(): EllipseNode
@@ -73,6 +73,7 @@ declare global {
73
73
  createText(): TextNode
74
74
  createFrame(children?: SceneNode[]): FrameNode
75
75
  createComponent(children?: SceneNode[]): ComponentNode
76
+ createSection(): SectionNode
76
77
  createPage(): PageNode
77
78
  createSlice(): SliceNode
78
79
  createConnector(): ConnectorNode
@@ -100,7 +101,7 @@ declare global {
100
101
  notify(message: string, options?: NotifyOptions): NotificationHandler
101
102
 
102
103
  getStyleById(id: string): Style | null
103
- getTitleByFontFamilyAndStyle(fontFamily: string, fontStyle: string) : FontAlias | null
104
+ getTitleByFontFamilyAndStyle(fontFamily: string, fontStyle: string): FontAlias | null
104
105
  createFillStyle(config: CreateStyleConfig): PaintStyle
105
106
  createStrokeStyle(config: CreateStyleConfig): PaintStyle
106
107
  createEffectStyle(config: CreateStyleConfig): EffectStyle
@@ -139,14 +140,33 @@ declare global {
139
140
  photoUrl: string | null
140
141
  }
141
142
 
142
- interface Rect extends Readonly<Bound> {}
143
+ interface Rect extends Readonly<Bound> { }
143
144
  interface NotificationHandler {
144
145
  cancel: () => void
145
146
  }
147
+ interface Layout {
148
+ canvas: number
149
+ leftbar: number
150
+ rightbar: number
151
+ window: number
152
+ }
153
+
154
+ interface PositionOnDom {
155
+ width: number
156
+ height: number
157
+ x: number
158
+ y: number
159
+ }
160
+
146
161
  interface ViewportAPI {
147
162
  center: Vector
148
163
  zoom: number
149
164
  readonly bound: Rect
165
+ /**
166
+ * @deprecated
167
+ */
168
+ readonly layout: Layout
169
+ readonly positionOnDom: PositionOnDom
150
170
  rulerVisible: boolean
151
171
  layoutGridVisible: boolean
152
172
  scrollAndZoomIntoView(nodes: SceneNode[]): void
@@ -185,7 +205,7 @@ declare global {
185
205
  readonly isSuffix?: boolean
186
206
  readonly fileName?: string
187
207
  }
188
-
208
+
189
209
  interface ExportSettingsPDF {
190
210
  readonly format: 'PDF'
191
211
  readonly isSuffix?: string
@@ -193,7 +213,7 @@ declare global {
193
213
  readonly useAbsoluteBounds?: boolean // defaults to true
194
214
  readonly useRenderBounds?: boolean // default to true
195
215
  }
196
-
216
+
197
217
  type ExportSettings = ExportSettingsImage | ExportSettingsSVG | ExportSettingsPDF
198
218
 
199
219
 
@@ -214,7 +234,7 @@ declare global {
214
234
  readonly headerHeight: number
215
235
  readonly visible: boolean
216
236
  }
217
-
237
+
218
238
  interface UIAPI {
219
239
  show(): void
220
240
  hide(): void
@@ -245,7 +265,7 @@ declare global {
245
265
 
246
266
  type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
247
267
 
248
- interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks'> {
268
+ interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks'> {
249
269
  readonly id: string
250
270
  readonly type: StyleType
251
271
  name: string
@@ -306,7 +326,7 @@ declare global {
306
326
  title: string
307
327
  subtitle: string
308
328
  }
309
-
329
+
310
330
  interface GridStyle extends BaseStyle {
311
331
  type: 'GRID'
312
332
  layoutGrids: ReadonlyArray<LayoutGrid>
@@ -401,7 +421,7 @@ declare global {
401
421
  | 'GRADIENT_DIAMOND'
402
422
  readonly transform: Transform
403
423
  readonly gradientStops: ReadonlyArray<ColorStop>
404
- readonly gradientHandlePositions?: [{ x: number, y: number}, { x: number, y: number}];
424
+ readonly gradientHandlePositions?: [{ x: number, y: number }, { x: number, y: number }];
405
425
  readonly isVisible?: boolean
406
426
  readonly alpha?: number
407
427
  readonly blendMode?: BlendMode
@@ -462,11 +482,11 @@ declare global {
462
482
  }
463
483
 
464
484
  type LineHeight =
465
- | {
485
+ | {
466
486
  readonly value: number
467
487
  readonly unit: 'PIXELS' | 'PERCENT'
468
488
  }
469
- | {
489
+ | {
470
490
  readonly unit: 'AUTO'
471
491
  }
472
492
 
@@ -524,7 +544,7 @@ declare global {
524
544
  isVisible?: string,
525
545
  characters?: string,
526
546
  mainComponent?: string
527
- } | null
547
+ } | null
528
548
  }
529
549
 
530
550
  interface ChildrenMixin<ChildrenNode = SceneNode> {
@@ -584,7 +604,7 @@ declare global {
584
604
  isMask: boolean
585
605
  isMaskOutline: boolean
586
606
  isMaskVisible: boolean
587
- effects: ReadonlyArray<Effect>
607
+ effects: ReadonlyArray<Effect>
588
608
  effectStyleId: string
589
609
  }
590
610
 
@@ -598,14 +618,14 @@ declare global {
598
618
  interface ConnectorEndpointPosition {
599
619
  readonly position: { x: number; y: number }
600
620
  }
601
-
621
+
602
622
  interface ConnectorEndpointConnected {
603
623
  readonly position: { x: number; y: number }
604
624
  readonly endpointNodeId: string
605
625
  readonly magnet: 'TOP' | 'LEFT' | 'BOTTOM' | 'RIGHT'
606
626
  }
607
-
608
-
627
+
628
+
609
629
  type ConnectorEndpoint =
610
630
  | ConnectorEndpointPosition
611
631
  | ConnectorEndpointConnected
@@ -689,25 +709,25 @@ declare global {
689
709
  readonly count: number
690
710
  readonly sectionSize?: number | null
691
711
  readonly offset?: number
692
-
712
+
693
713
  readonly isVisible?: boolean
694
714
  readonly color?: RGBA
695
715
  readonly id?: string
696
716
  readonly name?: string
697
717
  }
698
-
718
+
699
719
  interface GridLayoutGrid {
700
720
  readonly gridType: "GRID"
701
721
 
702
722
  readonly sectionSize: number
703
-
723
+
704
724
  readonly isVisible?: boolean
705
725
  readonly color?: RGBA
706
726
  readonly id?: string
707
727
  readonly name?: string
708
728
  }
709
-
710
-
729
+
730
+
711
731
  type LayoutGrid = RowsColsLayoutGrid | GridLayoutGrid
712
732
 
713
733
  interface FrameContainerMixin extends AutoLayout {
@@ -776,7 +796,7 @@ declare global {
776
796
  currentPage: PageNode
777
797
 
778
798
  readonly children: ReadonlyArray<PageNode>
779
-
799
+
780
800
  findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
781
801
  findOne(callback: (node: SceneNode) => boolean): SceneNode | null
782
802
  findAllWithCriteria<T extends NodeType[]>(criteria: { types: T }): Array<{ type: T[number] } & SceneNode>
@@ -798,7 +818,7 @@ declare global {
798
818
  /**
799
819
  * 选中所有图层
800
820
  */
801
- selectAll() : void
821
+ selectAll(): void
802
822
  /**
803
823
  * 背景颜色
804
824
  */
@@ -810,7 +830,12 @@ declare global {
810
830
  /**
811
831
  * 标签,默认'NONE'
812
832
  */
813
- label:'NONE' | 'BLUE' | 'GREEN' | 'RED' | 'YELLOW' | 'PURPLE' | 'GRAY'
833
+ label: 'NONE' | 'BLUE' | 'GREEN' | 'RED' | 'YELLOW' | 'PURPLE' | 'GRAY'
834
+ }
835
+
836
+ interface SectionNode extends Omit<DefaultContainerMixin, 'opacity' | 'blendMode' | 'isMask' | 'isMaskOutline' | 'isMaskVisible' | 'effects' | 'effectStyleId'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
837
+ readonly type: 'SECTION'
838
+ clone(): SectionNode
814
839
  }
815
840
 
816
841
  interface FrameNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
@@ -891,11 +916,11 @@ declare global {
891
916
  }
892
917
 
893
918
 
894
- interface GroupNode
895
- extends DefaultShapeMixin,
896
- ContainerMixin,
897
- ChildrenMixin,
898
- CornerMixin {
919
+ interface GroupNode
920
+ extends DefaultShapeMixin,
921
+ ContainerMixin,
922
+ ChildrenMixin,
923
+ CornerMixin {
899
924
  readonly type: 'GROUP'
900
925
  clone(): GroupNode
901
926
  }
@@ -923,7 +948,7 @@ declare global {
923
948
  superlink: {
924
949
  layerId?: string
925
950
  link: string
926
- linkFlag: LinkFlagEnum
951
+ linkFlag: LinkFlagEnum
927
952
  pageId: string
928
953
  }
929
954
  }
@@ -997,12 +1022,6 @@ declare global {
997
1022
  value: string
998
1023
  }
999
1024
 
1000
- /**
1001
- * @deprecated
1002
- *
1003
- */
1004
- type ComponentPropertyDefinitions = Array<VariantMixin>
1005
-
1006
1025
  interface ComponentPropertiesMixin {
1007
1026
  readonly componentPropertyValues: ComponentPropertyValues
1008
1027
  addComponentProperty(
@@ -1031,6 +1050,8 @@ declare global {
1031
1050
  id?: string
1032
1051
  variantOptions?: string[]
1033
1052
  preferredValues?: InstanceSwapPreferredValue[]
1053
+ alias?: string
1054
+ variantOptionsAlias?: string[]
1034
1055
  }
1035
1056
 
1036
1057
  type ComponentPropertyType = 'BOOLEAN' | 'TEXT' | 'INSTANCE_SWAP' | 'VARIANT'
@@ -1060,15 +1081,13 @@ declare global {
1060
1081
 
1061
1082
  interface ComponentSetNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin, ComponentPropertiesMixin {
1062
1083
  readonly type: 'COMPONENT_SET'
1063
- /**
1064
- * @deprecated
1065
- */
1066
- readonly componentPropertyDefinitions: ComponentPropertyDefinitions
1067
1084
  clone(): ComponentSetNode
1068
1085
  createVariantComponent(): void
1069
1086
  createVariantProperties(properties: Array<string>): void
1070
1087
  editVariantProperties(properties: Record<string, string>): void
1071
1088
  editVariantPropertyValues(properties: Record<string, { oldValue: string, newValue: string }>): void
1089
+ editVariantPropertiesAlias(properties: Record<string, string>): void
1090
+ editVariantPropertyValuesAlias(properties: Record<string, { name: string, alias: string }>): void
1072
1091
  deleteVariantProperty(property: string): void
1073
1092
  resizeToFit(): void
1074
1093
  }
@@ -1076,14 +1095,14 @@ declare global {
1076
1095
  interface InstanceNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
1077
1096
  readonly type: 'INSTANCE'
1078
1097
  readonly variantProperties: Array<VariantProperty> | undefined
1079
-
1098
+
1080
1099
  setVariantPropertyValues(property: Record<string, string>): void
1081
1100
 
1082
1101
  readonly componentProperties: Array<ComponentProperties>
1083
1102
  setProperties(properties: { [propertyId: string]: string | boolean }): void
1084
1103
  readonly exposedInstances: InstanceNode[]
1085
1104
  isExposedInstance: boolean
1086
-
1105
+
1087
1106
  resetOverrides(): void
1088
1107
 
1089
1108
  clone(): InstanceNode
@@ -1123,13 +1142,13 @@ declare global {
1123
1142
  readonly hyperlinks: Array<HyperlinkWithRange>
1124
1143
 
1125
1144
  readonly textStyles: ReadonlyArray<TextSegStyle>
1126
-
1145
+
1127
1146
  paragraphSpacing: number
1128
1147
 
1129
1148
  characters: string
1130
1149
  insertCharacters(start: number, characters: string): void
1131
1150
  deleteCharacters(start: number, end: number): void
1132
-
1151
+
1133
1152
  setRangeFontSize(start: number, end: number, fontSize: number): void
1134
1153
  setRangeTextDecoration(
1135
1154
  start: number,
@@ -1162,7 +1181,7 @@ declare global {
1162
1181
  id: string;
1163
1182
  description?: string;
1164
1183
  }
1165
-
1184
+
1166
1185
  interface FlowStartingPoint {
1167
1186
  name: string
1168
1187
  id: string
@@ -1182,22 +1201,22 @@ declare global {
1182
1201
  readonly scrollToXOffset?: number;
1183
1202
  readonly scrollToYOffset?: number;
1184
1203
  }
1185
-
1186
- type ActionType = 'BACK' | 'NODE'| 'URL'| 'CLOSE'| 'NONE';
1187
-
1188
- type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
1189
-
1204
+
1205
+ type ActionType = 'BACK' | 'NODE' | 'URL' | 'CLOSE' | 'NONE';
1206
+
1207
+ type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
1208
+
1190
1209
  interface Transition {
1191
1210
  readonly type: TransitionType;
1192
1211
  readonly duration: number;
1193
1212
  readonly direction: TransitionDirection;
1194
1213
  readonly easing: Easing;
1195
1214
  }
1196
-
1215
+
1197
1216
  type TransitionType = 'TANS_NONE' | 'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE' | 'MOVE_IN' | 'MOVE_OUT' | 'PUSH' | 'SLIDE_IN' | 'SLIDE_OUT' | 'DISPLACE'
1198
-
1217
+
1199
1218
  type TransitionDirection = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
1200
- interface Easing{
1219
+ interface Easing {
1201
1220
  readonly type: EasingType;
1202
1221
  readonly easingFunctionCubicBezier: {
1203
1222
  x1: number;
@@ -1206,19 +1225,19 @@ declare global {
1206
1225
  y2: number;
1207
1226
  };
1208
1227
  }
1209
-
1228
+
1210
1229
  type EasingType = 'LINEAR' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_AND_OUT' | 'EASE_IN_BACK' | 'EASE_OUT_BACK' | 'EASE_IN_AND_OUT_BACK' | 'CUSTOM_CUBIC_BEZIER'
1211
- interface Trigger{
1230
+ interface Trigger {
1212
1231
  readonly type: TriggerType;
1213
1232
  readonly delay: number;
1214
1233
  }
1215
1234
  type TriggerType = 'ON_CLICK' | 'ON_DRAG' | 'ON_HOVER' | 'ON_PRESS' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_DOWN' | 'MOUSE_UP' | 'AFTER_DELAY'
1216
-
1235
+
1217
1236
  interface ArcData {
1218
1237
  /**
1219
1238
  * 起点弧度
1220
1239
  */
1221
- startingAngle: number
1240
+ startingAngle: number
1222
1241
  /**
1223
1242
  * 终点弧度
1224
1243
  */
@@ -1239,7 +1258,7 @@ declare global {
1239
1258
  x: number
1240
1259
  y: number
1241
1260
  absoluteX: number
1242
- absoluteY: number
1261
+ absoluteY: number
1243
1262
  dropMetadata?: any
1244
1263
  }
1245
1264
 
@@ -1292,6 +1311,7 @@ declare global {
1292
1311
  | BooleanOperationNode
1293
1312
  | SliceNode
1294
1313
  | ConnectorNode
1314
+ | SectionNode
1295
1315
 
1296
1316
  type NodeType =
1297
1317
  | 'DOCUMENT'
@@ -1311,6 +1331,7 @@ declare global {
1311
1331
  | 'BOOLEAN_OPERATION'
1312
1332
  | 'SLICE'
1313
1333
  | 'CONNECTOR'
1334
+ | 'SECTION'
1314
1335
  }
1315
1336
 
1316
1337
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "1.21.0",
3
+ "version": "2.0.0",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",