@mastergo/plugin-typings 2.16.1 → 2.17.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 +346 -2
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1095,6 +1095,231 @@ declare global {
|
|
|
1095
1095
|
|
|
1096
1096
|
type PluginEventType = keyof MGEventCallbackMap
|
|
1097
1097
|
|
|
1098
|
+
interface VariableAPI {
|
|
1099
|
+
// --- Collection ---
|
|
1100
|
+
createCollection(name?: string): Promise<Collection | null>
|
|
1101
|
+
getCollections(includeExternal?: boolean): Collection[]
|
|
1102
|
+
getCollectionById(id?: string): Collection | null
|
|
1103
|
+
deleteCollection(collectionId: string): void
|
|
1104
|
+
renameCollection(collectionId: string, name: string): void
|
|
1105
|
+
moveCollection(
|
|
1106
|
+
collectionId: string,
|
|
1107
|
+
options?: { afterId?: string; index?: number }
|
|
1108
|
+
): void
|
|
1109
|
+
|
|
1110
|
+
// --- Mode ---
|
|
1111
|
+
getModes(collectionId?: string): CollectionMode[]
|
|
1112
|
+
getModeById(
|
|
1113
|
+
collectionId?: string,
|
|
1114
|
+
modeId?: string
|
|
1115
|
+
): CollectionMode | null
|
|
1116
|
+
addMode(
|
|
1117
|
+
collectionId: string,
|
|
1118
|
+
name?: string
|
|
1119
|
+
): Promise<CollectionMode | null>
|
|
1120
|
+
renameMode(collectionId: string, modeId: string, name: string): void
|
|
1121
|
+
deleteMode(collectionId: string, modeId: string): void
|
|
1122
|
+
setVariableMode(collectionId: string, modeId: string): void
|
|
1123
|
+
setPageVariableMode(
|
|
1124
|
+
collectionId: string,
|
|
1125
|
+
modeId: string,
|
|
1126
|
+
pageId?: string
|
|
1127
|
+
): void
|
|
1128
|
+
|
|
1129
|
+
// --- Group ---
|
|
1130
|
+
getGroupList(collectionId?: string): VariableGroupNode[]
|
|
1131
|
+
createGroup(
|
|
1132
|
+
collectionId: string,
|
|
1133
|
+
variableIds: string[],
|
|
1134
|
+
groupName?: string
|
|
1135
|
+
): void
|
|
1136
|
+
addVariablesToGroup(
|
|
1137
|
+
collectionId: string,
|
|
1138
|
+
groupPath: string,
|
|
1139
|
+
variableIds: string[]
|
|
1140
|
+
): void
|
|
1141
|
+
removeVariablesFromGroup(
|
|
1142
|
+
collectionId: string,
|
|
1143
|
+
groupPath: string,
|
|
1144
|
+
variableIds: string[]
|
|
1145
|
+
): void
|
|
1146
|
+
disbandGroup(
|
|
1147
|
+
collectionId: string,
|
|
1148
|
+
groupPath?: string,
|
|
1149
|
+
variableIds?: string[]
|
|
1150
|
+
): void
|
|
1151
|
+
renameGroup(
|
|
1152
|
+
collectionId: string,
|
|
1153
|
+
newName: string,
|
|
1154
|
+
groupPath?: string,
|
|
1155
|
+
variableIds?: string[]
|
|
1156
|
+
): void
|
|
1157
|
+
deleteGroup(
|
|
1158
|
+
collectionId: string,
|
|
1159
|
+
groupPath?: string,
|
|
1160
|
+
variableIds?: string[]
|
|
1161
|
+
): void
|
|
1162
|
+
|
|
1163
|
+
// --- Variable ---
|
|
1164
|
+
createVariable(options: {
|
|
1165
|
+
name: string
|
|
1166
|
+
type: VariableType
|
|
1167
|
+
value?: any
|
|
1168
|
+
description?: string
|
|
1169
|
+
collectionId?: string
|
|
1170
|
+
}): Promise<Variable | null>
|
|
1171
|
+
getVariableById(id: string): Variable | null
|
|
1172
|
+
getVariables(options?: {
|
|
1173
|
+
collectionId?: string
|
|
1174
|
+
groupPath?: string
|
|
1175
|
+
type?: VariableType
|
|
1176
|
+
scopeType?: string
|
|
1177
|
+
}): Variable[]
|
|
1178
|
+
setVariableReference(options: {
|
|
1179
|
+
id: string
|
|
1180
|
+
reference: string | object
|
|
1181
|
+
modeId?: string
|
|
1182
|
+
index?: string
|
|
1183
|
+
textProperty?: string
|
|
1184
|
+
strokeProperty?: string
|
|
1185
|
+
radiusProperty?: string
|
|
1186
|
+
paddingProperty?: string
|
|
1187
|
+
gridProperty?: string
|
|
1188
|
+
effectProperty?: string
|
|
1189
|
+
}): void
|
|
1190
|
+
unlinkVariable(options: {
|
|
1191
|
+
id: string
|
|
1192
|
+
modeId?: string
|
|
1193
|
+
}): Promise<void>
|
|
1194
|
+
renameVariable(variableId: string, name: string): void
|
|
1195
|
+
setVariableValue(options: {
|
|
1196
|
+
id: string
|
|
1197
|
+
value: any
|
|
1198
|
+
modeId: string
|
|
1199
|
+
}): Variable | null
|
|
1200
|
+
addVariableValue(options: {
|
|
1201
|
+
id: string
|
|
1202
|
+
value?: any
|
|
1203
|
+
modeId: string
|
|
1204
|
+
}): Variable | null
|
|
1205
|
+
deleteVariableValue(options: {
|
|
1206
|
+
id: string
|
|
1207
|
+
index: string | string[]
|
|
1208
|
+
modeId: string
|
|
1209
|
+
}): Variable | null
|
|
1210
|
+
deleteVariable(variableId: string): void
|
|
1211
|
+
moveVariable(
|
|
1212
|
+
variableId: string,
|
|
1213
|
+
options?: { afterId?: string; index?: number }
|
|
1214
|
+
): Promise<void>
|
|
1215
|
+
|
|
1216
|
+
// --- Variable Description / Alias ---
|
|
1217
|
+
getVariableDescription(variableId: string): string | null
|
|
1218
|
+
setVariableDescription(
|
|
1219
|
+
variableId: string,
|
|
1220
|
+
value: string
|
|
1221
|
+
): Promise<Variable | null>
|
|
1222
|
+
resetVariableDescription(
|
|
1223
|
+
variableId: string
|
|
1224
|
+
): Promise<Variable | null>
|
|
1225
|
+
getVariableAlias(variableId: string): string | null
|
|
1226
|
+
setVariableAlias(
|
|
1227
|
+
variableId: string,
|
|
1228
|
+
value: string
|
|
1229
|
+
): Promise<Variable | null>
|
|
1230
|
+
resetVariableAlias(variableId: string): Promise<Variable | null>
|
|
1231
|
+
|
|
1232
|
+
// --- Component Property Variable ---
|
|
1233
|
+
setVariableInComponent(options: {
|
|
1234
|
+
id: string
|
|
1235
|
+
propertyId: string
|
|
1236
|
+
type: 'BOOLEAN' | 'CONTENT'
|
|
1237
|
+
}): void
|
|
1238
|
+
unlinkVariableInComponent(options: {
|
|
1239
|
+
propertyId: string
|
|
1240
|
+
type: 'BOOLEAN' | 'CONTENT'
|
|
1241
|
+
}): void
|
|
1242
|
+
createVariableInComponent(options: {
|
|
1243
|
+
name: string
|
|
1244
|
+
description?: string
|
|
1245
|
+
collectionId?: string
|
|
1246
|
+
layerId: string
|
|
1247
|
+
type: 'BOOLEAN' | 'CONTENT'
|
|
1248
|
+
value?: any
|
|
1249
|
+
}): Promise<string | null>
|
|
1250
|
+
|
|
1251
|
+
// --- Layer Property Variable ---
|
|
1252
|
+
createVariableInLayer(options: {
|
|
1253
|
+
name: string
|
|
1254
|
+
description?: string
|
|
1255
|
+
collectionId?: string
|
|
1256
|
+
layerId: string
|
|
1257
|
+
value?: any
|
|
1258
|
+
strokeProperty?: string
|
|
1259
|
+
radiusProperty?: string
|
|
1260
|
+
paddingProperty?: string
|
|
1261
|
+
dimensionProperty?: string
|
|
1262
|
+
baseProperty?: string
|
|
1263
|
+
effectProperty?: string
|
|
1264
|
+
gridProperty?: string
|
|
1265
|
+
textProperty?: string
|
|
1266
|
+
index?: number
|
|
1267
|
+
}): Promise<Variable | null>
|
|
1268
|
+
setVariableReferenceInLayer(options: {
|
|
1269
|
+
id: string
|
|
1270
|
+
layerId: string
|
|
1271
|
+
strokeProperty?: string
|
|
1272
|
+
radiusProperty?: string
|
|
1273
|
+
paddingProperty?: string
|
|
1274
|
+
dimensionProperty?: string
|
|
1275
|
+
baseProperty?: string
|
|
1276
|
+
effectProperty?: string
|
|
1277
|
+
gridProperty?: string
|
|
1278
|
+
textProperty?: string
|
|
1279
|
+
index?: number
|
|
1280
|
+
}): Promise<void>
|
|
1281
|
+
unlinkVariableReferenceInLayer(options: {
|
|
1282
|
+
layerId: string
|
|
1283
|
+
strokeProperty?: string
|
|
1284
|
+
radiusProperty?: string
|
|
1285
|
+
paddingProperty?: string
|
|
1286
|
+
dimensionProperty?: string
|
|
1287
|
+
baseProperty?: string
|
|
1288
|
+
effectProperty?: string
|
|
1289
|
+
gridProperty?: string
|
|
1290
|
+
textProperty?: string
|
|
1291
|
+
index?: number
|
|
1292
|
+
}): Promise<void>
|
|
1293
|
+
|
|
1294
|
+
// --- Variable Code Syntax ---
|
|
1295
|
+
getCodeSyntax(variableId: string): VariableCodeSyntax | null
|
|
1296
|
+
setCodeSyntax(
|
|
1297
|
+
variableId: string,
|
|
1298
|
+
codeSyntax: { web?: string; android?: string; ios?: string }
|
|
1299
|
+
): Promise<Variable | null>
|
|
1300
|
+
resetCodeSyntax(
|
|
1301
|
+
variableId: string,
|
|
1302
|
+
platform?: string
|
|
1303
|
+
): Promise<Variable | null>
|
|
1304
|
+
|
|
1305
|
+
// --- Variable Scopes ---
|
|
1306
|
+
getVariableScopes(variableId: string): ScopeName[]
|
|
1307
|
+
setVariableScopes(
|
|
1308
|
+
variableId: string,
|
|
1309
|
+
scopes: ScopeName[]
|
|
1310
|
+
): Promise<Variable | null>
|
|
1311
|
+
|
|
1312
|
+
// --- Variable Indexes ---
|
|
1313
|
+
getVariableIndexes(
|
|
1314
|
+
variableId: string,
|
|
1315
|
+
modeId?: string
|
|
1316
|
+
): string[]
|
|
1317
|
+
|
|
1318
|
+
// --- Font ---
|
|
1319
|
+
getFontFamilies(): FontFamilyInfo[]
|
|
1320
|
+
getFontWeights(fontFamily: string): FontWeightInfo[]
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1098
1323
|
interface PluginAPI {
|
|
1099
1324
|
readonly document: DocumentNode
|
|
1100
1325
|
|
|
@@ -1225,12 +1450,14 @@ declare global {
|
|
|
1225
1450
|
* @param type NodeStyleType
|
|
1226
1451
|
* @param styleName
|
|
1227
1452
|
* @param description optional
|
|
1453
|
+
* @param collectionId optional
|
|
1228
1454
|
*/
|
|
1229
1455
|
createStyleByLayer<T extends NodeStyleType>(
|
|
1230
1456
|
layerId: string,
|
|
1231
1457
|
type: T,
|
|
1232
1458
|
styleName: string,
|
|
1233
|
-
description?: string
|
|
1459
|
+
description?: string,
|
|
1460
|
+
collectionId?: string
|
|
1234
1461
|
): NodeStyleReturnType<T>
|
|
1235
1462
|
|
|
1236
1463
|
/**
|
|
@@ -1239,11 +1466,13 @@ declare global {
|
|
|
1239
1466
|
* @param type styleType
|
|
1240
1467
|
* @param styleName
|
|
1241
1468
|
* @param description optional
|
|
1469
|
+
* @param collectionId optional
|
|
1242
1470
|
*/
|
|
1243
1471
|
createStyle<T extends StyleType>(
|
|
1244
1472
|
type: T,
|
|
1245
1473
|
styleName: string,
|
|
1246
|
-
description?: string
|
|
1474
|
+
description?: string,
|
|
1475
|
+
collectionId?: string
|
|
1247
1476
|
): StyleReturnType<T>
|
|
1248
1477
|
/**
|
|
1249
1478
|
* 创建某一个样式的副本
|
|
@@ -1267,6 +1496,8 @@ declare global {
|
|
|
1267
1496
|
getLocalPaddingStyles(): PaddingStyle[]
|
|
1268
1497
|
getLocalSpacingStyles(): SpacingStyle[]
|
|
1269
1498
|
|
|
1499
|
+
readonly variables: VariableAPI
|
|
1500
|
+
|
|
1270
1501
|
listAvailableFontsAsync(): Promise<Font[]>
|
|
1271
1502
|
loadFontAsync(fontName: FontName): Promise<boolean>
|
|
1272
1503
|
createImage(imageData: Uint8Array, isSync?: boolean): Promise<Image>
|
|
@@ -1508,6 +1739,106 @@ declare global {
|
|
|
1508
1739
|
| 'cornerRadius'
|
|
1509
1740
|
| 'padding'
|
|
1510
1741
|
| 'spacing'
|
|
1742
|
+
| 'effect'
|
|
1743
|
+
| 'text'
|
|
1744
|
+
| 'grid'
|
|
1745
|
+
|
|
1746
|
+
// #region Variable / Collection / Mode / Group types
|
|
1747
|
+
|
|
1748
|
+
type VariableType =
|
|
1749
|
+
| 'STRING'
|
|
1750
|
+
| 'BOOLEAN'
|
|
1751
|
+
| 'COLOR'
|
|
1752
|
+
| 'NUMBER'
|
|
1753
|
+
| 'PAINT'
|
|
1754
|
+
| 'TEXT'
|
|
1755
|
+
| 'EFFECT'
|
|
1756
|
+
| 'GRID'
|
|
1757
|
+
| 'STROKE_WIDTH'
|
|
1758
|
+
| 'CORNER_RADIUS'
|
|
1759
|
+
| 'PADDING'
|
|
1760
|
+
| 'SPACING'
|
|
1761
|
+
|
|
1762
|
+
type ScopeName =
|
|
1763
|
+
| 'all'
|
|
1764
|
+
| 'fill'
|
|
1765
|
+
| 'fillAll'
|
|
1766
|
+
| 'shapeFill'
|
|
1767
|
+
| 'textFill'
|
|
1768
|
+
| 'stroke'
|
|
1769
|
+
| 'effect'
|
|
1770
|
+
| 'grid'
|
|
1771
|
+
| 'widthHeight'
|
|
1772
|
+
| 'cornerRadius'
|
|
1773
|
+
| 'opacity'
|
|
1774
|
+
| 'layoutSpacing'
|
|
1775
|
+
| 'layoutPadding'
|
|
1776
|
+
| 'fontSize'
|
|
1777
|
+
| 'fontWeight'
|
|
1778
|
+
| 'textLineHeight'
|
|
1779
|
+
| 'textLetterSpacing'
|
|
1780
|
+
| 'textParagraphSpacing'
|
|
1781
|
+
| 'fontFamily'
|
|
1782
|
+
| 'textContent'
|
|
1783
|
+
|
|
1784
|
+
interface VariableCodeSyntax {
|
|
1785
|
+
readonly web?: string
|
|
1786
|
+
readonly android?: string
|
|
1787
|
+
readonly ios?: string
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
interface Variable {
|
|
1791
|
+
readonly id: string
|
|
1792
|
+
readonly name: string
|
|
1793
|
+
readonly description: string
|
|
1794
|
+
readonly alias: string
|
|
1795
|
+
readonly type: VariableType
|
|
1796
|
+
readonly collectionId: string
|
|
1797
|
+
readonly isExternal: boolean
|
|
1798
|
+
readonly supportScope: boolean
|
|
1799
|
+
readonly codeSyntax?: VariableCodeSyntax
|
|
1800
|
+
readonly scopes?: ReadonlyArray<ScopeName>
|
|
1801
|
+
readonly modes: Record<string, ReadonlyArray<any>>
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
interface Collection {
|
|
1805
|
+
readonly id: string
|
|
1806
|
+
readonly name: string
|
|
1807
|
+
readonly isExternal: boolean
|
|
1808
|
+
readonly modes: ReadonlyArray<CollectionMode>
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
interface CollectionMode {
|
|
1812
|
+
readonly id: string
|
|
1813
|
+
readonly name: string
|
|
1814
|
+
readonly collectionId: string
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
interface VariableGroupNode {
|
|
1818
|
+
readonly id: string
|
|
1819
|
+
readonly name: string
|
|
1820
|
+
readonly currentPath?: string
|
|
1821
|
+
readonly level: number
|
|
1822
|
+
readonly isLeaf: boolean
|
|
1823
|
+
readonly children?: ReadonlyArray<VariableGroupNode>
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
interface FontFamilyInfo {
|
|
1827
|
+
readonly family: string
|
|
1828
|
+
readonly label: string
|
|
1829
|
+
readonly lang: string
|
|
1830
|
+
readonly isVariable: boolean
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
interface FontWeightInfo {
|
|
1834
|
+
readonly postscriptName: string
|
|
1835
|
+
readonly label: string
|
|
1836
|
+
readonly style: string
|
|
1837
|
+
readonly weight: number
|
|
1838
|
+
readonly slant: number
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
// #endregion
|
|
1511
1842
|
|
|
1512
1843
|
interface BaseStyle extends Omit<PublishableMixin, 'documentationLinks'> {
|
|
1513
1844
|
readonly id: string
|
|
@@ -1608,6 +1939,7 @@ declare global {
|
|
|
1608
1939
|
| CornerRadiusStyle
|
|
1609
1940
|
| PaddingStyle
|
|
1610
1941
|
| SpacingStyle
|
|
1942
|
+
| Variable
|
|
1611
1943
|
|
|
1612
1944
|
/// /////////////////////////////////////////////////////////////////////////////
|
|
1613
1945
|
// Datatypes
|
|
@@ -1692,6 +2024,7 @@ declare global {
|
|
|
1692
2024
|
}
|
|
1693
2025
|
|
|
1694
2026
|
interface MotionBlurEffect {
|
|
2027
|
+
readonly type: 'MOTION_BLUR'
|
|
1695
2028
|
readonly isVisible: boolean
|
|
1696
2029
|
readonly radius: number
|
|
1697
2030
|
readonly angle: number
|
|
@@ -2621,6 +2954,7 @@ declare global {
|
|
|
2621
2954
|
*/
|
|
2622
2955
|
id: string
|
|
2623
2956
|
description?: string
|
|
2957
|
+
collectionId?: string
|
|
2624
2958
|
}
|
|
2625
2959
|
|
|
2626
2960
|
interface FlowStartingPoint {
|
|
@@ -2764,6 +3098,10 @@ declare global {
|
|
|
2764
3098
|
cornerRadiuses: ReadonlyArray<TeamLibraryStyle>
|
|
2765
3099
|
paddings: ReadonlyArray<TeamLibraryStyle>
|
|
2766
3100
|
spacings: ReadonlyArray<TeamLibraryStyle>
|
|
3101
|
+
numbers: ReadonlyArray<TeamLibraryStyle>
|
|
3102
|
+
strings: ReadonlyArray<TeamLibraryStyle>
|
|
3103
|
+
bools: ReadonlyArray<TeamLibraryStyle>
|
|
3104
|
+
colors: ReadonlyArray<TeamLibraryStyle>
|
|
2767
3105
|
}
|
|
2768
3106
|
}>
|
|
2769
3107
|
|
|
@@ -2970,5 +3308,11 @@ declare global {
|
|
|
2970
3308
|
? PaddingStyle
|
|
2971
3309
|
: T extends 'spacing'
|
|
2972
3310
|
? SpacingStyle
|
|
3311
|
+
: T extends 'effect'
|
|
3312
|
+
? EffectStyle
|
|
3313
|
+
: T extends 'text'
|
|
3314
|
+
? TextStyle
|
|
3315
|
+
: T extends 'grid'
|
|
3316
|
+
? GridStyle
|
|
2973
3317
|
: never
|
|
2974
3318
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastergo/plugin-typings",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "MasterGo插件API声明文件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "",
|
|
@@ -68,5 +68,6 @@
|
|
|
68
68
|
"commitizen": {
|
|
69
69
|
"path": "cz-conventional-changelog"
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
72
73
|
}
|