@mastergo/plugin-typings 1.6.1 → 1.7.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 +188 -88
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -25,36 +25,6 @@ declare global {
25
25
  getBytesAsync(): Promise<Uint8Array>
26
26
  }
27
27
 
28
- enum LinkFlagEnum {
29
- CURRPAGE = 'currPage',
30
- OTHERPAGE = 'otherPage',
31
- PROTOTYPE = 'prototype',
32
- OUTFILE = 'outFile',
33
- OWNWEBSITE = 'ownWebsite',
34
- OTHERLINK = 'otherLink',
35
- }
36
-
37
- interface Superlink {
38
- start: number
39
- end: number
40
- superlink: {
41
- layerId?: string
42
- link: string
43
- linkFlag: LinkFlagEnum
44
- pageId: string
45
- }
46
- }
47
-
48
- interface Hyperlink {
49
- type: 'PAGE' | 'NODE' | 'URL',
50
- value: string
51
- }
52
- interface HyperlinkWithRange {
53
- start: number
54
- end: number
55
- hyperlink: Hyperlink
56
- }
57
-
58
28
  type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
59
29
  type ThemeColor = 'dark' | 'light'
60
30
 
@@ -133,6 +103,14 @@ declare global {
133
103
  createImage(imageData: Uint8Array): Promise<Image>
134
104
  getImageByHref(href: string): Image
135
105
 
106
+ /**
107
+ * 订阅团队库数据
108
+ */
109
+ teamLibrary: TeamLibrary,
110
+ importComponentByKeyAsync(ukey: string): Promise<ComponentNode>,
111
+ importComponentSetByKeyAsync(ukey: string): Promise<ComponentSetNode>,
112
+ importStyleByKeyAsync(ukey: string): Promise<BaseStyle>,
113
+
136
114
  hexToRGBA(hex: string): RGBA
137
115
  RGBAToHex(rgba: RGBA): string
138
116
  }
@@ -162,6 +140,8 @@ declare global {
162
140
  width?: number
163
141
  height?: number
164
142
  visible?: boolean
143
+ x?: number | string
144
+ y?: number | string
165
145
  }
166
146
 
167
147
  interface ExportSettingsConstraints {
@@ -179,7 +159,7 @@ declare global {
179
159
 
180
160
  interface ExportMixin {
181
161
  exportSettings: ReadonlyArray<ExportSettings>
182
- export(settings?: ExportSettings): Promise<Uint8Array | string> // Defaults to PNG format
162
+ export(settings?: ExportSettings): Uint8Array | string // Defaults to PNG format
183
163
  }
184
164
 
185
165
  interface NotifyOptions {
@@ -196,18 +176,20 @@ declare global {
196
176
  postMessage(pluginMessage: any, origin?: string): void
197
177
  onmessage: ((pluginMessage: any, origin: string) => void) | undefined
198
178
  }
199
-
200
- /// /////////////////////////////////////////////////////////////////////////////
201
- // Styles
179
+ type PublishStatus = 'UNPUBLISHED' | 'CURRENT' | 'CHANGED'
202
180
  interface PublishableMixin {
203
181
  description: string
204
182
  /**
205
- * 是否为团队库样式
183
+ * 是否为团队库组件/样式
206
184
  */
207
185
  readonly isExternal: boolean
208
186
  readonly ukey: string
187
+ readonly publishStatus: PublishStatus
209
188
  }
210
189
 
190
+ /// /////////////////////////////////////////////////////////////////////////////
191
+ // Styles
192
+
211
193
  type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
212
194
 
213
195
  interface BaseStyle extends PublishableMixin {
@@ -257,12 +239,11 @@ declare global {
257
239
  interface TextStyle extends BaseStyle {
258
240
  type: 'TEXT'
259
241
  decoration: TextDecoration
260
- description: string
261
242
  fontSize: number
262
- isExternal: boolean
263
243
  letterSpacing: number
264
244
  letterSpacingUnit: NumValue['unit']
265
245
  textCase: TextCase
246
+ lineHeight: LineHeight
266
247
  }
267
248
 
268
249
  interface FontAlias {
@@ -448,7 +429,7 @@ declare global {
448
429
  interface BaseNodeMixin {
449
430
  readonly id: string
450
431
  readonly parent: (BaseNode & ChildrenMixin) | void
451
- name: string // Note: setting this also sets \`autoRename\` to false on TextNodes
432
+ name: string
452
433
  removed: boolean
453
434
  remove(): void
454
435
  getPluginData(key: string): string
@@ -690,17 +671,29 @@ declare global {
690
671
  /// /////////////////////////////////////////////////////////////////////////////
691
672
  // Nodes
692
673
 
693
- interface DocumentNode extends ChildrenMixin<PageNode> {
674
+ interface DocumentNode {
694
675
  readonly type: 'DOCUMENT'
695
- currentPage: PageNode
696
676
  name: string
677
+
678
+ currentPage: PageNode
679
+
680
+ readonly children: ReadonlyArray<PageNode>
681
+
682
+ findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
683
+ findOne(callback: (node: SceneNode) => boolean): SceneNode | null
697
684
  }
698
685
 
699
686
  interface PageNode
700
- extends BaseNodeMixin,
687
+ extends
701
688
  ChildrenMixin<SceneNode> {
702
689
  readonly type: 'PAGE'
703
690
 
691
+ readonly id: string
692
+ readonly parent: DocumentNode
693
+ name: string
694
+ removed: boolean
695
+ remove(): void
696
+
704
697
  selection: ReadonlyArray<SceneNode>
705
698
  clone(): PageNode
706
699
  /**
@@ -816,6 +809,36 @@ declare global {
816
809
  letterSpacing: LetterSpacing
817
810
  }
818
811
 
812
+ enum LinkFlagEnum {
813
+ CURRPAGE = 'currPage',
814
+ OTHERPAGE = 'otherPage',
815
+ PROTOTYPE = 'prototype',
816
+ OUTFILE = 'outFile',
817
+ OWNWEBSITE = 'ownWebsite',
818
+ OTHERLINK = 'otherLink',
819
+ }
820
+
821
+ interface Superlink {
822
+ start: number
823
+ end: number
824
+ superlink: {
825
+ layerId?: string
826
+ link: string
827
+ linkFlag: LinkFlagEnum
828
+ pageId: string
829
+ }
830
+ }
831
+
832
+ interface Hyperlink {
833
+ type: 'PAGE' | 'NODE' | 'URL',
834
+ value: string
835
+ }
836
+ interface HyperlinkWithRange {
837
+ start: number
838
+ end: number
839
+ hyperlink: Hyperlink
840
+ }
841
+
819
842
  interface TextNode extends DefaultShapeMixin, ConstraintMixin {
820
843
  readonly type: 'TEXT'
821
844
  characters: string
@@ -861,17 +884,16 @@ declare global {
861
884
  setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
862
885
  }
863
886
 
864
- interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
887
+ interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
865
888
  readonly type: 'COMPONENT'
866
889
  readonly variantProperties: Array<Record<string, string>>
867
- description: string
868
890
  setVariantPropertyValues(property: Record<string, string>): void
869
891
  clone(): ComponentNode
870
892
  createInstance(): InstanceNode
871
893
  resizeToFit(): void
872
894
  }
873
895
 
874
- interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
896
+ interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
875
897
  readonly type: 'COMPONENT_SET'
876
898
  readonly componentPropertyDefinitions: Array<Record<string, Array<string> | string>>
877
899
  clone(): ComponentSetNode
@@ -1039,6 +1061,34 @@ declare global {
1039
1061
  dropMetadata?: any
1040
1062
  }
1041
1063
 
1064
+ interface TeamLibraryComponent {
1065
+ readonly id: string;
1066
+ readonly name: string;
1067
+ readonly ukey: string;
1068
+ readonly description: string;
1069
+ readonly type: "COMPONENT" | 'COMPONENT_SET'
1070
+ }
1071
+
1072
+ interface TeamLibraryStyle {
1073
+ readonly id: string;
1074
+ readonly name: string;
1075
+ readonly ukey: string;
1076
+ readonly description: string;
1077
+ readonly type: StyleType;
1078
+ }
1079
+
1080
+ type TeamLibrary = ReadonlyArray<{
1081
+ readonly name: string;
1082
+ readonly id: string;
1083
+ readonly componentList: TeamLibraryComponent[]
1084
+ readonly style: {
1085
+ paints: ReadonlyArray<TeamLibraryStyle>
1086
+ effects: ReadonlyArray<TeamLibraryStyle>
1087
+ texts: ReadonlyArray<TeamLibraryStyle>
1088
+ grids: ReadonlyArray<TeamLibraryStyle>
1089
+ }
1090
+ }>
1091
+
1042
1092
  type BaseNode = DocumentNode | PageNode | SceneNode
1043
1093
 
1044
1094
  /**
@@ -1108,36 +1158,6 @@ declare global {
1108
1158
  getBytesAsync(): Promise<Uint8Array>
1109
1159
  }
1110
1160
 
1111
- enum LinkFlagEnum {
1112
- CURRPAGE = 'currPage',
1113
- OTHERPAGE = 'otherPage',
1114
- PROTOTYPE = 'prototype',
1115
- OUTFILE = 'outFile',
1116
- OWNWEBSITE = 'ownWebsite',
1117
- OTHERLINK = 'otherLink',
1118
- }
1119
-
1120
- interface Superlink {
1121
- start: number
1122
- end: number
1123
- superlink: {
1124
- layerId?: string
1125
- link: string
1126
- linkFlag: LinkFlagEnum
1127
- pageId: string
1128
- }
1129
- }
1130
-
1131
- interface Hyperlink {
1132
- type: 'PAGE' | 'NODE' | 'URL',
1133
- value: string
1134
- }
1135
- interface HyperlinkWithRange {
1136
- start: number
1137
- end: number
1138
- hyperlink: Hyperlink
1139
- }
1140
-
1141
1161
  type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
1142
1162
  type ThemeColor = 'dark' | 'light'
1143
1163
 
@@ -1216,6 +1236,14 @@ declare global {
1216
1236
  createImage(imageData: Uint8Array): Promise<Image>
1217
1237
  getImageByHref(href: string): Image
1218
1238
 
1239
+ /**
1240
+ * 订阅团队库数据
1241
+ */
1242
+ teamLibrary: TeamLibrary,
1243
+ importComponentByKeyAsync(ukey: string): Promise<ComponentNode>,
1244
+ importComponentSetByKeyAsync(ukey: string): Promise<ComponentSetNode>,
1245
+ importStyleByKeyAsync(ukey: string): Promise<BaseStyle>,
1246
+
1219
1247
  hexToRGBA(hex: string): RGBA
1220
1248
  RGBAToHex(rgba: RGBA): string
1221
1249
  }
@@ -1245,6 +1273,8 @@ declare global {
1245
1273
  width?: number
1246
1274
  height?: number
1247
1275
  visible?: boolean
1276
+ x?: number | string
1277
+ y?: number | string
1248
1278
  }
1249
1279
 
1250
1280
  interface ExportSettingsConstraints {
@@ -1262,7 +1292,7 @@ declare global {
1262
1292
 
1263
1293
  interface ExportMixin {
1264
1294
  exportSettings: ReadonlyArray<ExportSettings>
1265
- export(settings?: ExportSettings): Promise<Uint8Array | string> // Defaults to PNG format
1295
+ export(settings?: ExportSettings): Uint8Array | string // Defaults to PNG format
1266
1296
  }
1267
1297
 
1268
1298
  interface NotifyOptions {
@@ -1279,18 +1309,20 @@ declare global {
1279
1309
  postMessage(pluginMessage: any, origin?: string): void
1280
1310
  onmessage: ((pluginMessage: any, origin: string) => void) | undefined
1281
1311
  }
1282
-
1283
- /// /////////////////////////////////////////////////////////////////////////////
1284
- // Styles
1312
+ type PublishStatus = 'UNPUBLISHED' | 'CURRENT' | 'CHANGED'
1285
1313
  interface PublishableMixin {
1286
1314
  description: string
1287
1315
  /**
1288
- * 是否为团队库样式
1316
+ * 是否为团队库组件/样式
1289
1317
  */
1290
1318
  readonly isExternal: boolean
1291
1319
  readonly ukey: string
1320
+ readonly publishStatus: PublishStatus
1292
1321
  }
1293
1322
 
1323
+ /// /////////////////////////////////////////////////////////////////////////////
1324
+ // Styles
1325
+
1294
1326
  type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
1295
1327
 
1296
1328
  interface BaseStyle extends PublishableMixin {
@@ -1340,12 +1372,11 @@ declare global {
1340
1372
  interface TextStyle extends BaseStyle {
1341
1373
  type: 'TEXT'
1342
1374
  decoration: TextDecoration
1343
- description: string
1344
1375
  fontSize: number
1345
- isExternal: boolean
1346
1376
  letterSpacing: number
1347
1377
  letterSpacingUnit: NumValue['unit']
1348
1378
  textCase: TextCase
1379
+ lineHeight: LineHeight
1349
1380
  }
1350
1381
 
1351
1382
  interface FontAlias {
@@ -1531,7 +1562,7 @@ declare global {
1531
1562
  interface BaseNodeMixin {
1532
1563
  readonly id: string
1533
1564
  readonly parent: (BaseNode & ChildrenMixin) | void
1534
- name: string // Note: setting this also sets \`autoRename\` to false on TextNodes
1565
+ name: string
1535
1566
  removed: boolean
1536
1567
  remove(): void
1537
1568
  getPluginData(key: string): string
@@ -1773,17 +1804,29 @@ declare global {
1773
1804
  /// /////////////////////////////////////////////////////////////////////////////
1774
1805
  // Nodes
1775
1806
 
1776
- interface DocumentNode extends ChildrenMixin<PageNode> {
1807
+ interface DocumentNode {
1777
1808
  readonly type: 'DOCUMENT'
1778
- currentPage: PageNode
1779
1809
  name: string
1810
+
1811
+ currentPage: PageNode
1812
+
1813
+ readonly children: ReadonlyArray<PageNode>
1814
+
1815
+ findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
1816
+ findOne(callback: (node: SceneNode) => boolean): SceneNode | null
1780
1817
  }
1781
1818
 
1782
1819
  interface PageNode
1783
- extends BaseNodeMixin,
1820
+ extends
1784
1821
  ChildrenMixin<SceneNode> {
1785
1822
  readonly type: 'PAGE'
1786
1823
 
1824
+ readonly id: string
1825
+ readonly parent: DocumentNode
1826
+ name: string
1827
+ removed: boolean
1828
+ remove(): void
1829
+
1787
1830
  selection: ReadonlyArray<SceneNode>
1788
1831
  clone(): PageNode
1789
1832
  /**
@@ -1899,6 +1942,36 @@ declare global {
1899
1942
  letterSpacing: LetterSpacing
1900
1943
  }
1901
1944
 
1945
+ enum LinkFlagEnum {
1946
+ CURRPAGE = 'currPage',
1947
+ OTHERPAGE = 'otherPage',
1948
+ PROTOTYPE = 'prototype',
1949
+ OUTFILE = 'outFile',
1950
+ OWNWEBSITE = 'ownWebsite',
1951
+ OTHERLINK = 'otherLink',
1952
+ }
1953
+
1954
+ interface Superlink {
1955
+ start: number
1956
+ end: number
1957
+ superlink: {
1958
+ layerId?: string
1959
+ link: string
1960
+ linkFlag: LinkFlagEnum
1961
+ pageId: string
1962
+ }
1963
+ }
1964
+
1965
+ interface Hyperlink {
1966
+ type: 'PAGE' | 'NODE' | 'URL',
1967
+ value: string
1968
+ }
1969
+ interface HyperlinkWithRange {
1970
+ start: number
1971
+ end: number
1972
+ hyperlink: Hyperlink
1973
+ }
1974
+
1902
1975
  interface TextNode extends DefaultShapeMixin, ConstraintMixin {
1903
1976
  readonly type: 'TEXT'
1904
1977
  characters: string
@@ -1944,17 +2017,16 @@ declare global {
1944
2017
  setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
1945
2018
  }
1946
2019
 
1947
- interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
2020
+ interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
1948
2021
  readonly type: 'COMPONENT'
1949
2022
  readonly variantProperties: Array<Record<string, string>>
1950
- description: string
1951
2023
  setVariantPropertyValues(property: Record<string, string>): void
1952
2024
  clone(): ComponentNode
1953
2025
  createInstance(): InstanceNode
1954
2026
  resizeToFit(): void
1955
2027
  }
1956
2028
 
1957
- interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
2029
+ interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
1958
2030
  readonly type: 'COMPONENT_SET'
1959
2031
  readonly componentPropertyDefinitions: Array<Record<string, Array<string> | string>>
1960
2032
  clone(): ComponentSetNode
@@ -2122,6 +2194,34 @@ declare global {
2122
2194
  dropMetadata?: any
2123
2195
  }
2124
2196
 
2197
+ interface TeamLibraryComponent {
2198
+ readonly id: string;
2199
+ readonly name: string;
2200
+ readonly ukey: string;
2201
+ readonly description: string;
2202
+ readonly type: "COMPONENT" | 'COMPONENT_SET'
2203
+ }
2204
+
2205
+ interface TeamLibraryStyle {
2206
+ readonly id: string;
2207
+ readonly name: string;
2208
+ readonly ukey: string;
2209
+ readonly description: string;
2210
+ readonly type: StyleType;
2211
+ }
2212
+
2213
+ type TeamLibrary = ReadonlyArray<{
2214
+ readonly name: string;
2215
+ readonly id: string;
2216
+ readonly componentList: TeamLibraryComponent[]
2217
+ readonly style: {
2218
+ paints: ReadonlyArray<TeamLibraryStyle>
2219
+ effects: ReadonlyArray<TeamLibraryStyle>
2220
+ texts: ReadonlyArray<TeamLibraryStyle>
2221
+ grids: ReadonlyArray<TeamLibraryStyle>
2222
+ }
2223
+ }>
2224
+
2125
2225
  type BaseNode = DocumentNode | PageNode | SceneNode
2126
2226
 
2127
2227
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",