@mastergo/plugin-typings 1.20.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
@@ -226,8 +246,12 @@ declare global {
226
246
  onmessage: ((pluginMessage: any, origin: string) => void) | undefined
227
247
  }
228
248
  type PublishStatus = 'UNPUBLISHED' | 'CURRENT' | 'CHANGED'
249
+ interface DocumentationLink {
250
+ readonly uri: string
251
+ }
229
252
  interface PublishableMixin {
230
253
  description: string
254
+ documentationLinks: ReadonlyArray<DocumentationLink>
231
255
  /**
232
256
  * 是否为团队库组件/样式
233
257
  */
@@ -241,7 +265,7 @@ declare global {
241
265
 
242
266
  type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
243
267
 
244
- interface BaseStyle extends PublishableMixin {
268
+ interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks'> {
245
269
  readonly id: string
246
270
  readonly type: StyleType
247
271
  name: string
@@ -302,7 +326,7 @@ declare global {
302
326
  title: string
303
327
  subtitle: string
304
328
  }
305
-
329
+
306
330
  interface GridStyle extends BaseStyle {
307
331
  type: 'GRID'
308
332
  layoutGrids: ReadonlyArray<LayoutGrid>
@@ -397,22 +421,36 @@ declare global {
397
421
  | 'GRADIENT_DIAMOND'
398
422
  readonly transform: Transform
399
423
  readonly gradientStops: ReadonlyArray<ColorStop>
400
- readonly gradientHandlePositions?: [{ x: number, y: number}, { x: number, y: number}];
424
+ readonly gradientHandlePositions?: [{ x: number, y: number }, { x: number, y: number }];
401
425
  readonly isVisible?: boolean
402
426
  readonly alpha?: number
403
427
  readonly blendMode?: BlendMode
404
428
  readonly name?: string
405
429
  }
406
430
 
431
+ interface ImageFilters {
432
+ exposure?: number
433
+ contrast?: number
434
+ saturation?: number
435
+ temperature?: number
436
+ tint?: number
437
+ highlights?: number
438
+ shadows?: number
439
+ hue?: number
440
+ }
441
+
407
442
  interface ImagePaint {
408
443
  readonly type: 'IMAGE'
409
444
  readonly imageRef: string
410
445
  readonly scaleMode?: 'FILL' | 'TILE' | 'STRETCH' | 'FIT' | 'CROP'
446
+ readonly filters?: ImageFilters
411
447
 
412
448
  readonly isVisible?: boolean
413
449
  readonly alpha?: number
414
450
  readonly blendMode?: BlendMode
415
451
  readonly name?: string
452
+ readonly ratio?: number
453
+ readonly rotation?: number
416
454
  }
417
455
 
418
456
  type Paint = SolidPaint | GradientPaint | ImagePaint
@@ -444,11 +482,11 @@ declare global {
444
482
  }
445
483
 
446
484
  type LineHeight =
447
- | {
485
+ | {
448
486
  readonly value: number
449
487
  readonly unit: 'PIXELS' | 'PERCENT'
450
488
  }
451
- | {
489
+ | {
452
490
  readonly unit: 'AUTO'
453
491
  }
454
492
 
@@ -506,7 +544,7 @@ declare global {
506
544
  isVisible?: string,
507
545
  characters?: string,
508
546
  mainComponent?: string
509
- } | null
547
+ } | null
510
548
  }
511
549
 
512
550
  interface ChildrenMixin<ChildrenNode = SceneNode> {
@@ -566,7 +604,7 @@ declare global {
566
604
  isMask: boolean
567
605
  isMaskOutline: boolean
568
606
  isMaskVisible: boolean
569
- effects: ReadonlyArray<Effect>
607
+ effects: ReadonlyArray<Effect>
570
608
  effectStyleId: string
571
609
  }
572
610
 
@@ -580,14 +618,14 @@ declare global {
580
618
  interface ConnectorEndpointPosition {
581
619
  readonly position: { x: number; y: number }
582
620
  }
583
-
621
+
584
622
  interface ConnectorEndpointConnected {
585
623
  readonly position: { x: number; y: number }
586
624
  readonly endpointNodeId: string
587
625
  readonly magnet: 'TOP' | 'LEFT' | 'BOTTOM' | 'RIGHT'
588
626
  }
589
-
590
-
627
+
628
+
591
629
  type ConnectorEndpoint =
592
630
  | ConnectorEndpointPosition
593
631
  | ConnectorEndpointConnected
@@ -671,25 +709,25 @@ declare global {
671
709
  readonly count: number
672
710
  readonly sectionSize?: number | null
673
711
  readonly offset?: number
674
-
712
+
675
713
  readonly isVisible?: boolean
676
714
  readonly color?: RGBA
677
715
  readonly id?: string
678
716
  readonly name?: string
679
717
  }
680
-
718
+
681
719
  interface GridLayoutGrid {
682
720
  readonly gridType: "GRID"
683
721
 
684
722
  readonly sectionSize: number
685
-
723
+
686
724
  readonly isVisible?: boolean
687
725
  readonly color?: RGBA
688
726
  readonly id?: string
689
727
  readonly name?: string
690
728
  }
691
-
692
-
729
+
730
+
693
731
  type LayoutGrid = RowsColsLayoutGrid | GridLayoutGrid
694
732
 
695
733
  interface FrameContainerMixin extends AutoLayout {
@@ -758,7 +796,7 @@ declare global {
758
796
  currentPage: PageNode
759
797
 
760
798
  readonly children: ReadonlyArray<PageNode>
761
-
799
+
762
800
  findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
763
801
  findOne(callback: (node: SceneNode) => boolean): SceneNode | null
764
802
  findAllWithCriteria<T extends NodeType[]>(criteria: { types: T }): Array<{ type: T[number] } & SceneNode>
@@ -780,7 +818,7 @@ declare global {
780
818
  /**
781
819
  * 选中所有图层
782
820
  */
783
- selectAll() : void
821
+ selectAll(): void
784
822
  /**
785
823
  * 背景颜色
786
824
  */
@@ -792,7 +830,12 @@ declare global {
792
830
  /**
793
831
  * 标签,默认'NONE'
794
832
  */
795
- 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
796
839
  }
797
840
 
798
841
  interface FrameNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
@@ -873,11 +916,11 @@ declare global {
873
916
  }
874
917
 
875
918
 
876
- interface GroupNode
877
- extends DefaultShapeMixin,
878
- ContainerMixin,
879
- ChildrenMixin,
880
- CornerMixin {
919
+ interface GroupNode
920
+ extends DefaultShapeMixin,
921
+ ContainerMixin,
922
+ ChildrenMixin,
923
+ CornerMixin {
881
924
  readonly type: 'GROUP'
882
925
  clone(): GroupNode
883
926
  }
@@ -905,7 +948,7 @@ declare global {
905
948
  superlink: {
906
949
  layerId?: string
907
950
  link: string
908
- linkFlag: LinkFlagEnum
951
+ linkFlag: LinkFlagEnum
909
952
  pageId: string
910
953
  }
911
954
  }
@@ -979,12 +1022,6 @@ declare global {
979
1022
  value: string
980
1023
  }
981
1024
 
982
- /**
983
- * @deprecated
984
- *
985
- */
986
- type ComponentPropertyDefinitions = Array<VariantMixin>
987
-
988
1025
  interface ComponentPropertiesMixin {
989
1026
  readonly componentPropertyValues: ComponentPropertyValues
990
1027
  addComponentProperty(
@@ -1013,6 +1050,8 @@ declare global {
1013
1050
  id?: string
1014
1051
  variantOptions?: string[]
1015
1052
  preferredValues?: InstanceSwapPreferredValue[]
1053
+ alias?: string
1054
+ variantOptionsAlias?: string[]
1016
1055
  }
1017
1056
 
1018
1057
  type ComponentPropertyType = 'BOOLEAN' | 'TEXT' | 'INSTANCE_SWAP' | 'VARIANT'
@@ -1042,15 +1081,13 @@ declare global {
1042
1081
 
1043
1082
  interface ComponentSetNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin, ComponentPropertiesMixin {
1044
1083
  readonly type: 'COMPONENT_SET'
1045
- /**
1046
- * @deprecated
1047
- */
1048
- readonly componentPropertyDefinitions: ComponentPropertyDefinitions
1049
1084
  clone(): ComponentSetNode
1050
1085
  createVariantComponent(): void
1051
1086
  createVariantProperties(properties: Array<string>): void
1052
1087
  editVariantProperties(properties: Record<string, string>): void
1053
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
1054
1091
  deleteVariantProperty(property: string): void
1055
1092
  resizeToFit(): void
1056
1093
  }
@@ -1058,14 +1095,14 @@ declare global {
1058
1095
  interface InstanceNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
1059
1096
  readonly type: 'INSTANCE'
1060
1097
  readonly variantProperties: Array<VariantProperty> | undefined
1061
-
1098
+
1062
1099
  setVariantPropertyValues(property: Record<string, string>): void
1063
1100
 
1064
1101
  readonly componentProperties: Array<ComponentProperties>
1065
1102
  setProperties(properties: { [propertyId: string]: string | boolean }): void
1066
1103
  readonly exposedInstances: InstanceNode[]
1067
1104
  isExposedInstance: boolean
1068
-
1105
+
1069
1106
  resetOverrides(): void
1070
1107
 
1071
1108
  clone(): InstanceNode
@@ -1105,13 +1142,13 @@ declare global {
1105
1142
  readonly hyperlinks: Array<HyperlinkWithRange>
1106
1143
 
1107
1144
  readonly textStyles: ReadonlyArray<TextSegStyle>
1108
-
1145
+
1109
1146
  paragraphSpacing: number
1110
1147
 
1111
1148
  characters: string
1112
1149
  insertCharacters(start: number, characters: string): void
1113
1150
  deleteCharacters(start: number, end: number): void
1114
-
1151
+
1115
1152
  setRangeFontSize(start: number, end: number, fontSize: number): void
1116
1153
  setRangeTextDecoration(
1117
1154
  start: number,
@@ -1144,7 +1181,7 @@ declare global {
1144
1181
  id: string;
1145
1182
  description?: string;
1146
1183
  }
1147
-
1184
+
1148
1185
  interface FlowStartingPoint {
1149
1186
  name: string
1150
1187
  id: string
@@ -1164,22 +1201,22 @@ declare global {
1164
1201
  readonly scrollToXOffset?: number;
1165
1202
  readonly scrollToYOffset?: number;
1166
1203
  }
1167
-
1168
- type ActionType = 'BACK' | 'NODE'| 'URL'| 'CLOSE'| 'NONE';
1169
-
1170
- type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
1171
-
1204
+
1205
+ type ActionType = 'BACK' | 'NODE' | 'URL' | 'CLOSE' | 'NONE';
1206
+
1207
+ type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
1208
+
1172
1209
  interface Transition {
1173
1210
  readonly type: TransitionType;
1174
1211
  readonly duration: number;
1175
1212
  readonly direction: TransitionDirection;
1176
1213
  readonly easing: Easing;
1177
1214
  }
1178
-
1215
+
1179
1216
  type TransitionType = 'TANS_NONE' | 'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE' | 'MOVE_IN' | 'MOVE_OUT' | 'PUSH' | 'SLIDE_IN' | 'SLIDE_OUT' | 'DISPLACE'
1180
-
1217
+
1181
1218
  type TransitionDirection = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
1182
- interface Easing{
1219
+ interface Easing {
1183
1220
  readonly type: EasingType;
1184
1221
  readonly easingFunctionCubicBezier: {
1185
1222
  x1: number;
@@ -1188,19 +1225,19 @@ declare global {
1188
1225
  y2: number;
1189
1226
  };
1190
1227
  }
1191
-
1228
+
1192
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'
1193
- interface Trigger{
1230
+ interface Trigger {
1194
1231
  readonly type: TriggerType;
1195
1232
  readonly delay: number;
1196
1233
  }
1197
1234
  type TriggerType = 'ON_CLICK' | 'ON_DRAG' | 'ON_HOVER' | 'ON_PRESS' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_DOWN' | 'MOUSE_UP' | 'AFTER_DELAY'
1198
-
1235
+
1199
1236
  interface ArcData {
1200
1237
  /**
1201
1238
  * 起点弧度
1202
1239
  */
1203
- startingAngle: number
1240
+ startingAngle: number
1204
1241
  /**
1205
1242
  * 终点弧度
1206
1243
  */
@@ -1221,7 +1258,7 @@ declare global {
1221
1258
  x: number
1222
1259
  y: number
1223
1260
  absoluteX: number
1224
- absoluteY: number
1261
+ absoluteY: number
1225
1262
  dropMetadata?: any
1226
1263
  }
1227
1264
 
@@ -1274,6 +1311,7 @@ declare global {
1274
1311
  | BooleanOperationNode
1275
1312
  | SliceNode
1276
1313
  | ConnectorNode
1314
+ | SectionNode
1277
1315
 
1278
1316
  type NodeType =
1279
1317
  | 'DOCUMENT'
@@ -1293,6 +1331,7 @@ declare global {
1293
1331
  | 'BOOLEAN_OPERATION'
1294
1332
  | 'SLICE'
1295
1333
  | 'CONNECTOR'
1334
+ | 'SECTION'
1296
1335
  }
1297
1336
 
1298
1337
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "1.20.0",
3
+ "version": "2.0.0",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",