@mastergo/plugin-typings 1.11.0 → 1.13.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,38 @@
1
+ # [1.13.0](https://github.com/mastergo-design/plugin-typings/compare/v1.12.0...v1.13.0) (2023-01-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 修复组件图层clone方法返回值类型错误问题 ([3558202](https://github.com/mastergo-design/plugin-typings/commit/35582022c3f5d201559efbbeb1e452d5838eef15))
7
+ * 修改错误componentPropertyReferences类型 ([dcdb0b8](https://github.com/mastergo-design/plugin-typings/commit/dcdb0b8a1fc22785c8bbf9add75b1a7b46215178))
8
+
9
+
10
+ ### Features
11
+
12
+ * 补充组件属性类型 ([a58b2da](https://github.com/mastergo-design/plugin-typings/commit/a58b2da55d45c202ab4a593aa0aeb6d7e7feb844))
13
+ * 导出设置增加useRenderBounds, 增加不同类型区分导出数据 ([852044d](https://github.com/mastergo-design/plugin-typings/commit/852044dfd9047cec5f9e2414b0bf2455728b439f))
14
+ * 更改componentPropertyReferences类型 ([3e67ca1](https://github.com/mastergo-design/plugin-typings/commit/3e67ca1214cfee6838ab7188d40729d1154dbc46))
15
+ * 更换子组件props命名 ([76a1b75](https://github.com/mastergo-design/plugin-typings/commit/76a1b75469cb769fe86638f7d412442f23423849))
16
+ * 合并webp为image ([e4d1c13](https://github.com/mastergo-design/plugin-typings/commit/e4d1c133c566a2481799802cfb6991481e639cfa))
17
+ * 合并webp为image ([627bfa0](https://github.com/mastergo-design/plugin-typings/commit/627bfa04da410b661936c115b210a6431528cd77))
18
+ * 添加absoluteRenderBounds和absoluteBoundingBox接口 ([924b83a](https://github.com/mastergo-design/plugin-typings/commit/924b83a0d84896c05046bc83386570c039e502cc))
19
+ * 文字样式增加fontName ([8d72a18](https://github.com/mastergo-design/plugin-typings/commit/8d72a1849ef6666622a6efb403f4648ccaaa8c2a))
20
+ * 新增组件属性相关types ([a7f4e67](https://github.com/mastergo-design/plugin-typings/commit/a7f4e676f04f504d172402d74ccc8d5111867142))
21
+ * 修改absoluteRenderBounds和absoluteBoundingBox返回类型 ([b90dd96](https://github.com/mastergo-design/plugin-typings/commit/b90dd96c99e392ba9bbdb54260c13573dd02ba28))
22
+ * absoluteBoundingBox去除null返回值 ([7e903ef](https://github.com/mastergo-design/plugin-typings/commit/7e903ef72d059d0822ac6f1a6ad035e84392327d))
23
+
24
+
25
+
26
+ # [1.12.0](https://github.com/mastergo-design/plugin-typings/compare/v1.11.0...v1.12.0) (2022-12-20)
27
+
28
+
29
+ ### Features
30
+
31
+ * 类型优化,添加ui.viewport和ui.moveTo ([8fc66ea](https://github.com/mastergo-design/plugin-typings/commit/8fc66eaa0da1992256b90cc8ce9ad93f5fe53766))
32
+ * 修改ui可视属性字段名 ([6cd233d](https://github.com/mastergo-design/plugin-typings/commit/6cd233dc6fb3e8b310bfd4cfb3bdfee5a0c1142c))
33
+
34
+
35
+
1
36
  # [1.11.0](https://github.com/mastergo-design/plugin-typings/compare/v1.10.2...v1.11.0) (2022-12-15)
2
37
 
3
38
 
package/dist/index.d.ts CHANGED
@@ -127,12 +127,7 @@ declare global {
127
127
  RGBAToHex(rgba: RGBA): string
128
128
  }
129
129
 
130
- interface Rect {
131
- readonly x: number
132
- readonly y: number
133
- readonly width: number
134
- readonly height: number
135
- }
130
+ interface Rect extends Readonly<Bound> {}
136
131
 
137
132
  interface ViewportAPI {
138
133
  center: Vector
@@ -162,14 +157,31 @@ declare global {
162
157
  type: 'SCALE' | 'WIDTH' | 'HEIGHT'
163
158
  value: number
164
159
  }
165
- type ExportFileFormat = 'PNG' | 'JPG' | 'SVG' | 'PDF' | 'WEBP'
166
- type ExportSettings = {
167
- format: ExportFileFormat
168
- constraint?: ExportSettingsConstraints
169
- isSuffix?: boolean
170
- fileName?: string
171
- readonly useAbsoluteBounds?: boolean
160
+
161
+ interface ExportSettingsImage {
162
+ readonly format: 'JPG' | 'PNG' | 'WEBP'
163
+ readonly isSuffix?: boolean
164
+ readonly fileName?: string
165
+ readonly constraint?: ExportSettingsConstraints
166
+ readonly useAbsoluteBounds?: boolean // defaults to false
167
+ readonly useRenderBounds?: boolean // default to true
168
+ }
169
+ interface ExportSettingsSVG {
170
+ readonly format: 'SVG'
171
+ readonly isSuffix?: boolean
172
+ readonly fileName?: string
173
+ }
174
+
175
+ interface ExportSettingsPDF {
176
+ readonly format: 'PDF'
177
+ readonly isSuffix?: string
178
+ readonly fileName?: string
179
+ readonly useAbsoluteBounds?: boolean // defaults to false
180
+ readonly useRenderBounds?: boolean // default to true
172
181
  }
182
+
183
+ type ExportSettings = ExportSettingsImage | ExportSettingsSVG | ExportSettingsPDF
184
+
173
185
 
174
186
  interface ExportMixin {
175
187
  exportSettings: ReadonlyArray<ExportSettings>
@@ -181,12 +193,18 @@ declare global {
181
193
  type?: 'normal' | 'highlight' | 'error' | 'warning' | 'success'
182
194
  }
183
195
 
196
+ interface UIViewport extends Bound {
197
+ headerHeight: number
198
+ visible: boolean
199
+ }
200
+
184
201
  interface UIAPI {
185
202
  show(): void
186
203
  hide(): void
187
204
  close(): void
188
205
  resize(width: number, height: number): void
189
-
206
+ moveTo(x: number, y: number): void
207
+ viewport: UIViewport
190
208
  postMessage(pluginMessage: any, origin?: string): void
191
209
  onmessage: ((pluginMessage: any, origin: string) => void) | undefined
192
210
  }
@@ -260,6 +278,7 @@ declare global {
260
278
  letterSpacingUnit: NumValue['unit']
261
279
  textCase: TextCase
262
280
  lineHeight: LineHeight
281
+ fontName: FontName
263
282
  }
264
283
 
265
284
  interface FontAlias {
@@ -466,6 +485,11 @@ declare global {
466
485
  interface SceneNodeMixin {
467
486
  isVisible: boolean
468
487
  isLocked: boolean
488
+ componentPropertyReferences: {
489
+ isVisible?: string,
490
+ characters?: string,
491
+ mainComponent?: string
492
+ } | null
469
493
  }
470
494
 
471
495
  interface ChildrenMixin<ChildrenNode = SceneNode> {
@@ -503,6 +527,8 @@ declare global {
503
527
  interface LayoutMixin {
504
528
  absoluteTransform: Transform
505
529
  relativeTransform: Transform
530
+ readonly absoluteRenderBounds: Bound | null
531
+ readonly absoluteBoundingBox: Bound
506
532
  bound: Bound
507
533
  x: number
508
534
  y: number
@@ -667,6 +693,8 @@ declare global {
667
693
  interface OpaqueNodeMixin extends BaseNodeMixin, SceneNodeMixin, ExportMixin {
668
694
  readonly absoluteTransform: Transform
669
695
  relativeTransform: Transform
696
+ readonly absoluteRenderBounds: Bound | null
697
+ readonly absoluteBoundingBox: Bound
670
698
  x: number
671
699
  y: number
672
700
  readonly width: number
@@ -916,16 +944,6 @@ declare global {
916
944
  setRangeTextStyleId(start: number, end: number, textStyleId: string): void
917
945
  }
918
946
 
919
- interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
920
- readonly type: 'COMPONENT'
921
- readonly variantProperties: Array<VariantProperty> | undefined
922
- setVariantPropertyValues(property: Record<string, string>): void
923
- clone(): ComponentNode
924
- createInstance(): InstanceNode
925
- resizeToFit(): void
926
- }
927
-
928
-
929
947
  type VariantMixin = {
930
948
  property: string
931
949
  type: 'variant'
@@ -937,10 +955,62 @@ declare global {
937
955
  value: string
938
956
  }
939
957
 
958
+ /**
959
+ * @deprecated
960
+ *
961
+ */
940
962
  type ComponentPropertyDefinitions = Array<VariantMixin>
941
963
 
942
- interface ComponentSetNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
964
+ interface ComponentPropertiesMixin {
965
+ readonly componentPropertyValues: ComponentPropertyValues
966
+ addComponentProperty(
967
+ propertyName: string,
968
+ type: Exclude<ComponentPropertyType, 'VARIANT'>,
969
+ defaultValue: string | boolean,
970
+ ): string
971
+ editComponentProperty(
972
+ propertyId: string,
973
+ newValue: {
974
+ name?: string
975
+ defaultValue?: string | boolean
976
+ },
977
+ ): string
978
+ deleteComponentProperty(propertyId: string): void
979
+ }
980
+
981
+ type ComponentPropertyValues = Array<ComponentPropertyValue>
982
+
983
+ type ComponentPropertyValue = {
984
+ name: string
985
+ type: ComponentPropertyType
986
+ defaultValue: string | boolean
987
+ id?: string
988
+ variantOptions?: string[]
989
+ }
990
+
991
+ type ComponentPropertyType = 'BOOLEAN' | 'TEXT' | 'INSTANCE_SWAP' | 'VARIANT'
992
+
993
+ type ComponentProperties = {
994
+ name: string
995
+ id?: string
996
+ type: ComponentPropertyType
997
+ value: boolean | string
998
+ }
999
+
1000
+ interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin, ComponentPropertiesMixin {
1001
+ readonly type: 'COMPONENT'
1002
+ readonly variantProperties: Array<VariantProperty> | undefined
1003
+ setVariantPropertyValues(property: Record<string, string>): void
1004
+ clone(): InstanceNode
1005
+ createInstance(): InstanceNode
1006
+ resizeToFit(): void
1007
+ }
1008
+
1009
+ interface ComponentSetNode extends Omit<DefaultContainerMixin, 'appendChild' | 'insertChild'>, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin, ComponentPropertiesMixin {
943
1010
  readonly type: 'COMPONENT_SET'
1011
+ /**
1012
+ * @deprecated
1013
+ */
944
1014
  readonly componentPropertyDefinitions: ComponentPropertyDefinitions
945
1015
  clone(): ComponentSetNode
946
1016
  createVariantComponent(): void
@@ -955,6 +1025,10 @@ declare global {
955
1025
  readonly type: 'INSTANCE'
956
1026
  readonly variantProperties: Array<VariantProperty> | undefined
957
1027
  setVariantPropertyValues(property: Record<string, string>): void
1028
+
1029
+ readonly componentProperties: Array<ComponentProperties>
1030
+ setProperties(properties: { [propertyId: string]: string | boolean }): void
1031
+
958
1032
  clone(): InstanceNode
959
1033
  /**
960
1034
  * this is an async func
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",