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