@mastergo/plugin-typings 2.7.0 → 2.8.0-beta.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/dist/index.d.ts +159 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -999,7 +999,11 @@ declare global {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
declare global {
|
|
1002
|
+
/**
|
|
1003
|
+
* @deprecated please use mg instead
|
|
1004
|
+
*/
|
|
1002
1005
|
const mastergo: PluginAPI
|
|
1006
|
+
|
|
1003
1007
|
const mg: PluginAPI
|
|
1004
1008
|
const console: Console
|
|
1005
1009
|
const __html__: string
|
|
@@ -1020,12 +1024,31 @@ declare global {
|
|
|
1020
1024
|
clear(): void
|
|
1021
1025
|
}
|
|
1022
1026
|
|
|
1027
|
+
interface ConfirmAction {
|
|
1028
|
+
label: string
|
|
1029
|
+
type: 'primary' | 'text'
|
|
1030
|
+
action: () => void
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
interface PromptAction {
|
|
1034
|
+
label: string
|
|
1035
|
+
type: 'primary' | 'text'
|
|
1036
|
+
action: (value: string) => void
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1023
1039
|
interface Image {
|
|
1024
1040
|
readonly href: string
|
|
1025
1041
|
getBytesAsync(): Promise<Uint8Array>
|
|
1026
1042
|
}
|
|
1027
1043
|
|
|
1028
|
-
type
|
|
1044
|
+
type GuardEventType = 'beforeReadyForDev'
|
|
1045
|
+
|
|
1046
|
+
type PluginEventType =
|
|
1047
|
+
'selectionchange' | 'layoutchange' |
|
|
1048
|
+
'currentpagechange' | 'close' |
|
|
1049
|
+
'themechange' | 'drop' |
|
|
1050
|
+
'run' | 'readyForDev' | GuardEventType
|
|
1051
|
+
|
|
1029
1052
|
type ThemeColor = 'dark' | 'light'
|
|
1030
1053
|
|
|
1031
1054
|
interface PluginAPI {
|
|
@@ -1051,7 +1074,9 @@ declare global {
|
|
|
1051
1074
|
|
|
1052
1075
|
readonly viewport: ViewportAPI
|
|
1053
1076
|
|
|
1054
|
-
|
|
1077
|
+
/**
|
|
1078
|
+
* @note only available in devMode
|
|
1079
|
+
*/
|
|
1055
1080
|
readonly codegen?: CodegenAPI
|
|
1056
1081
|
|
|
1057
1082
|
closePlugin(): void
|
|
@@ -1105,16 +1130,64 @@ declare global {
|
|
|
1105
1130
|
|
|
1106
1131
|
getStyleById(id: string): Style | null
|
|
1107
1132
|
getTitleByFontFamilyAndStyle(fontFamily: string, fontStyle: string): FontAlias | null
|
|
1133
|
+
|
|
1108
1134
|
createFillStyle(config: CreateStyleConfig): PaintStyle
|
|
1109
|
-
createStrokeStyle(config: CreateStyleConfig): PaintStyle
|
|
1110
1135
|
createEffectStyle(config: CreateStyleConfig): EffectStyle
|
|
1111
1136
|
createTextStyle(config: CreateStyleConfig): TextStyle
|
|
1112
1137
|
createGridStyle(config: CreateStyleConfig): GridStyle
|
|
1138
|
+
createCornerRadiusStyle(config: CreateStyleConfig): CornerRadiusStyle
|
|
1139
|
+
createPaddingStyle(config: CreateStyleConfig): PaddingStyle
|
|
1140
|
+
createSpacingStyle(config: CreateStyleConfig): SpacingStyle
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* @deprecated please use createStrokeFillStyle instead
|
|
1144
|
+
*/
|
|
1145
|
+
createStrokeStyle(config: CreateStyleConfig): PaintStyle
|
|
1146
|
+
createStrokeFillStyle(config: CreateStyleConfig): PaintStyle
|
|
1147
|
+
createStrokeWidthStyle(config: CreateStyleConfig): StrokeWidthStyle
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* createFillStyle/createStrokeFillStyle 这些函数的聚合函数,传入不同的 type,返回对应的 style
|
|
1151
|
+
* @param layerId
|
|
1152
|
+
* @param type NodeStyleType
|
|
1153
|
+
* @param styleName
|
|
1154
|
+
* @param description optional
|
|
1155
|
+
*/
|
|
1156
|
+
createStyleByLayer<T extends NodeStyleType>(layerId: string, type: T, styleName: string, description?: string): NodeStyleReturnType<T>
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* 创建一个新的默认样式,不依赖某一个图层中的样式,
|
|
1160
|
+
* eg: createStyle('PAINT', 'New Style', 'This is a new style')
|
|
1161
|
+
* @param type styleType
|
|
1162
|
+
* @param styleName
|
|
1163
|
+
* @param description optional
|
|
1164
|
+
*/
|
|
1165
|
+
createStyle<T extends StyleType>(type: T, styleName: string, description?: string): StyleReturnType<T>
|
|
1166
|
+
/**
|
|
1167
|
+
* 创建某一个样式的副本
|
|
1168
|
+
* @param sourceStyleId 副本的源样式id
|
|
1169
|
+
* @param type
|
|
1170
|
+
* @param styleName
|
|
1171
|
+
* @param description
|
|
1172
|
+
*/
|
|
1173
|
+
createStyleCopy<T extends StyleType = StyleType>(sourceStyleId: string, type: T, styleName?: string, description?: string): StyleReturnType<T>
|
|
1174
|
+
/**
|
|
1175
|
+
* 创建某一个样式引用
|
|
1176
|
+
* @param sourceStyleId 引用源样式id
|
|
1177
|
+
* @param type
|
|
1178
|
+
* @param styleName
|
|
1179
|
+
* @param description
|
|
1180
|
+
*/
|
|
1181
|
+
createStyleRef<T extends StyleType = StyleType>(sourceStyleId: string, type: T, styleName?: string, description?: string): StyleReturnType<T>
|
|
1113
1182
|
|
|
1114
1183
|
getLocalPaintStyles(): PaintStyle[]
|
|
1115
1184
|
getLocalEffectStyles(): EffectStyle[]
|
|
1116
1185
|
getLocalTextStyles(): TextStyle[]
|
|
1117
1186
|
getLocalGridStyles(): GridStyle[]
|
|
1187
|
+
getLocalStrokeWidthStyles(): StrokeWidthStyle[]
|
|
1188
|
+
getLocalCornerRadiusStyles(): CornerRadiusStyle[]
|
|
1189
|
+
getLocalPaddingStyles(): PaddingStyle[]
|
|
1190
|
+
getLocalSpacingStyles(): SpacingStyle[]
|
|
1118
1191
|
|
|
1119
1192
|
listAvailableFontsAsync(): Promise<Font[]>
|
|
1120
1193
|
loadFontAsync(fontName: FontName): Promise<boolean>
|
|
@@ -1135,6 +1208,9 @@ declare global {
|
|
|
1135
1208
|
|
|
1136
1209
|
hexToRGBA(hex: string): RGBA
|
|
1137
1210
|
RGBAToHex(rgba: RGBA): string
|
|
1211
|
+
|
|
1212
|
+
confirm: (message: string, options: [ConfirmAction, ...ConfirmAction[]]) => void
|
|
1213
|
+
prompt: (message: string, defaultValue: string, options: [PromptAction, ...PromptAction[]]) => void
|
|
1138
1214
|
}
|
|
1139
1215
|
|
|
1140
1216
|
interface User {
|
|
@@ -1256,19 +1332,23 @@ declare global {
|
|
|
1256
1332
|
description: string
|
|
1257
1333
|
documentationLinks: ReadonlyArray<DocumentationLink>
|
|
1258
1334
|
/**
|
|
1259
|
-
*
|
|
1260
|
-
|
|
1335
|
+
* @description 组件或者组件集的别名
|
|
1336
|
+
*/
|
|
1337
|
+
alias: string
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* @description 是否为团队库组件/样式
|
|
1341
|
+
*/
|
|
1261
1342
|
readonly isExternal: boolean
|
|
1262
1343
|
readonly ukey: string
|
|
1263
1344
|
readonly publishStatus: PublishStatus
|
|
1264
1345
|
}
|
|
1265
1346
|
|
|
1266
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
1267
1347
|
// Styles
|
|
1348
|
+
type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID' | 'STROKE_WIDTH' | 'CORNER_RADIUS' | 'PADDING' | 'SPACING'
|
|
1349
|
+
type NodeStyleType = 'fill' | 'strokeFill' | 'strokeWidth' | 'cornerRadius' | 'padding' | 'spacing'
|
|
1268
1350
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks'> {
|
|
1351
|
+
interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks' | 'alias'> {
|
|
1272
1352
|
readonly id: string
|
|
1273
1353
|
readonly type: StyleType
|
|
1274
1354
|
name: string
|
|
@@ -1280,6 +1360,26 @@ declare global {
|
|
|
1280
1360
|
paints: ReadonlyArray<Paint>
|
|
1281
1361
|
}
|
|
1282
1362
|
|
|
1363
|
+
interface StrokeWidthStyle extends BaseStyle {
|
|
1364
|
+
type: 'STROKE_WIDTH'
|
|
1365
|
+
value: StrokeWidth
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
interface CornerRadiusStyle extends BaseStyle {
|
|
1369
|
+
type: 'CORNER_RADIUS'
|
|
1370
|
+
value: CornerRadius
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
interface PaddingStyle extends BaseStyle {
|
|
1374
|
+
type: 'PADDING'
|
|
1375
|
+
value: Padding
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
interface SpacingStyle extends BaseStyle {
|
|
1379
|
+
type: 'SPACING'
|
|
1380
|
+
value: Spacing
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1283
1383
|
interface NumValue {
|
|
1284
1384
|
value: number
|
|
1285
1385
|
unit: 'PIXELS' | 'PERCENT'
|
|
@@ -1463,6 +1563,24 @@ declare global {
|
|
|
1463
1563
|
|
|
1464
1564
|
type Paint = SolidPaint | GradientPaint | ImagePaint
|
|
1465
1565
|
|
|
1566
|
+
type CSSWidthSetter = number | [number, number] | [number, number, number] | [number, number, number, number]
|
|
1567
|
+
|
|
1568
|
+
interface StrokeWidth {
|
|
1569
|
+
width: CSSWidthSetter,
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
interface Padding {
|
|
1573
|
+
padding: CSSWidthSetter,
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
interface Spacing {
|
|
1577
|
+
spacing: CSSWidthSetter,
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
interface CornerRadius {
|
|
1581
|
+
cornerRadius: CSSWidthSetter,
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1466
1584
|
type WindingRule = 'Nonzero' | 'Evenodd'
|
|
1467
1585
|
|
|
1468
1586
|
// 待确定
|
|
@@ -1658,7 +1776,17 @@ declare global {
|
|
|
1658
1776
|
dashCap: DashCap
|
|
1659
1777
|
strokeDashes: ReadonlyArray<number>
|
|
1660
1778
|
fillStyleId: string
|
|
1779
|
+
/**
|
|
1780
|
+
* @deprecated please use strokePaintStyleId instead
|
|
1781
|
+
*/
|
|
1661
1782
|
strokeStyleId: string
|
|
1783
|
+
strokeFillStyleId: string
|
|
1784
|
+
strokeWidthStyleId: string
|
|
1785
|
+
borderStyleId: string
|
|
1786
|
+
paddingStyleId: string
|
|
1787
|
+
spacingStyleId: string
|
|
1788
|
+
cornerRadiusStyleId: string
|
|
1789
|
+
|
|
1662
1790
|
/**
|
|
1663
1791
|
* You have to ensure the layer has stroke before invoking this method.
|
|
1664
1792
|
* 在调用接口之前需要确保layer有描边.
|
|
@@ -2310,6 +2438,10 @@ declare global {
|
|
|
2310
2438
|
effects: ReadonlyArray<TeamLibraryStyle>
|
|
2311
2439
|
texts: ReadonlyArray<TeamLibraryStyle>
|
|
2312
2440
|
grids: ReadonlyArray<TeamLibraryStyle>
|
|
2441
|
+
strokeWidths: ReadonlyArray<TeamLibraryStyle>
|
|
2442
|
+
cornerRadiuses: ReadonlyArray<TeamLibraryStyle>
|
|
2443
|
+
paddings: ReadonlyArray<TeamLibraryStyle>
|
|
2444
|
+
spacings: ReadonlyArray<TeamLibraryStyle>
|
|
2313
2445
|
}
|
|
2314
2446
|
}>
|
|
2315
2447
|
|
|
@@ -2423,4 +2555,22 @@ declare global {
|
|
|
2423
2555
|
*/
|
|
2424
2556
|
getCodeByDSL(data: MGDSL.MGDSLData, type: MGDSL.Framework): Promise<CodeFile | null>;
|
|
2425
2557
|
}
|
|
2558
|
+
|
|
2559
|
+
type StyleReturnType<T extends StyleType> =
|
|
2560
|
+
T extends 'PAINT' ? PaintStyle :
|
|
2561
|
+
T extends 'TEXT' ? TextStyle :
|
|
2562
|
+
T extends 'EFFECT' ? EffectStyle :
|
|
2563
|
+
T extends 'GRID' ? GridStyle :
|
|
2564
|
+
T extends 'STROKE_WIDTH' ? StrokeWidthStyle :
|
|
2565
|
+
T extends 'CORNER_RADIUS' ? CornerRadiusStyle :
|
|
2566
|
+
T extends 'PADDING' ? PaddingStyle :
|
|
2567
|
+
T extends 'SPACING' ? SpacingStyle : never
|
|
2568
|
+
|
|
2569
|
+
type NodeStyleReturnType<T extends NodeStyleType> =
|
|
2570
|
+
T extends 'fill' ? PaintStyle :
|
|
2571
|
+
T extends 'strokeFill' ? PaintStyle :
|
|
2572
|
+
T extends 'strokeWidth' ? StrokeWidthStyle :
|
|
2573
|
+
T extends 'cornerRadius' ? CornerRadiusStyle :
|
|
2574
|
+
T extends 'padding' ? PaddingStyle :
|
|
2575
|
+
T extends 'spacing' ? SpacingStyle : never
|
|
2426
2576
|
}
|