@mastergo/plugin-typings 1.7.0 → 1.7.2

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/README-en.md ADDED
@@ -0,0 +1,25 @@
1
+ **English** | [中文](./README.md)
2
+
3
+ # MasterGo Plugin Typings
4
+ This project is the ts declaration file of the MasterGo plugin API.
5
+
6
+ ## Install
7
+
8
+ 1. npm install
9
+ ```sh
10
+ npm i --save-dev @mastergo/plugin-typings
11
+ # or yarn
12
+ yarn add -D @mastergo/plugin-typings
13
+ ```
14
+
15
+ 2. configure `tsconfig.json`
16
+ ```js
17
+ {
18
+ "compilerOptions": {
19
+ "typeRoots": [
20
+ "./node_modules/@types",
21
+ "./node_modules/@mastergo"
22
+ ]
23
+ }
24
+ }
25
+ ```
package/dist/index.d.ts CHANGED
@@ -876,10 +876,10 @@ declare global {
876
876
  setRangeFills(start: number, end: number, paints: Paint[]): void
877
877
  /**
878
878
  * @deprecated
879
- * This function is deprecared, please use setRangeHyperLink instead.
879
+ * This function is deprecared, please use setRangeHyperlink instead.
880
880
  */
881
881
  setRangeSuperLink(start: number, end: number, link: string | null): void
882
- setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
882
+ setRangeHyperlink(start: number, end: number, hyperlink: Hyperlink | null): void
883
883
  setRangeTextCase(start: number, end: number, textCase: TextCase): void
884
884
  setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
885
885
  }
@@ -967,1140 +967,7 @@ declare global {
967
967
  ): void
968
968
  setRangeLineHeight(start: number, end: number, value: LineHeight): void
969
969
  setRangeFills(start: number, end: number, paints: Paint[]): void
970
- setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
971
- setRangeTextCase(start: number, end: number, textCase: TextCase): void
972
- }
973
-
974
-
975
- interface CreateStyleConfig {
976
- name: string;
977
- /**
978
- * layerId
979
- */
980
- id: string;
981
- description?: string;
982
- }
983
-
984
- interface FlowStartingPoint {
985
- name: string
986
- id: string
987
- flowId: string
988
- description: string
989
- }
990
- interface Reaction {
991
- readonly trigger: Trigger;
992
- readonly action?: Action;
993
- }
994
- interface Action {
995
- readonly type: ActionType;
996
- readonly destinationId: string;
997
- readonly navigation: Navigation;
998
- readonly transition: Transition;
999
- readonly url: string;
1000
- readonly scrollToXOffset?: number;
1001
- readonly scrollToYOffset?: number;
1002
- }
1003
-
1004
- type ActionType = 'BACK' | 'NODE'| 'URL'| 'CLOSE'| 'NONE';
1005
-
1006
- type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
1007
-
1008
- interface Transition {
1009
- readonly type: TransitionType;
1010
- readonly duration: number;
1011
- readonly direction: TransitionDirection;
1012
- readonly easing: Easing;
1013
- }
1014
-
1015
- type TransitionType = 'TANS_NONE' | 'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE' | 'MOVE_IN' | 'MOVE_OUT' | 'PUSH' | 'SLIDE_IN' | 'SLIDE_OUT' | 'DISPLACE'
1016
-
1017
- type TransitionDirection = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
1018
- interface Easing{
1019
- readonly type: EasingType;
1020
- readonly easingFunctionCubicBezier: {
1021
- x1: number;
1022
- x2: number;
1023
- y1: number;
1024
- y2: number;
1025
- };
1026
- }
1027
-
1028
- type EasingType = 'LINEAR' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_AND_OUT' | 'EASE_IN_BACK' | 'EASE_OUT_BACK' | 'EASE_IN_AND_OUT_BACK' | 'CUSTOM_CUBIC_BEZIER'
1029
- interface Trigger{
1030
- readonly type: TriggerType;
1031
- readonly delay: number;
1032
- }
1033
- type TriggerType = 'ON_CLICK' | 'ON_DRAG' | 'ON_HOVER' | 'ON_PRESS' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_DOWN' | 'MOUSE_UP' | 'AFTER_DELAY'
1034
-
1035
- interface ArcData {
1036
- /**
1037
- * 起点弧度
1038
- */
1039
- startingAngle: number
1040
- /**
1041
- * 终点弧度
1042
- */
1043
- endingAngle?: number
1044
- /**
1045
- * 内径
1046
- */
1047
- innerRadius: number
1048
- }
1049
-
1050
- interface PluginDrop {
1051
- clientX: number
1052
- clientY: number
1053
- dropMetadata?: any
1054
- }
1055
-
1056
- interface DropEvent {
1057
- x: number
1058
- y: number
1059
- absoluteX: number
1060
- absoluteY: number
1061
- dropMetadata?: any
1062
- }
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
-
1092
- type BaseNode = DocumentNode | PageNode | SceneNode
1093
-
1094
- /**
1095
- * 画布节点
1096
- */
1097
- type SceneNode =
1098
- | GroupNode
1099
- | FrameNode
1100
- | PenNode
1101
- | StarNode
1102
- | LineNode
1103
- | EllipseNode
1104
- | PolygonNode
1105
- | RectangleNode
1106
- | TextNode
1107
- | ComponentNode
1108
- | ComponentSetNode
1109
- | InstanceNode
1110
- | BooleanOperationNode
1111
- | SliceNode
1112
- | ConnectorNode
1113
-
1114
- type NodeType =
1115
- | 'DOCUMENT'
1116
- | 'PAGE'
1117
- | 'GROUP'
1118
- | 'FRAME'
1119
- | 'RECTANGLE'
1120
- | 'TEXT'
1121
- | 'LINE'
1122
- | 'ELLIPSE'
1123
- | 'POLYGON'
1124
- | 'STAR'
1125
- | 'PEN'
1126
- | 'COMPONENT'
1127
- | 'COMPONENT_SET'
1128
- | 'INSTANCE'
1129
- | 'BOOLEAN_OPERATION'
1130
- | 'SLICE'
1131
- | 'CONNECTOR'
1132
- }
1133
-
1134
- declare global {
1135
- const mastergo: PluginAPI
1136
- const mg: PluginAPI
1137
- const console: Console
1138
- const __html__: string
1139
-
1140
- function setTimeout(callback: Function, timeout: number): number
1141
- function clearTimeout(timeoutID: number): void
1142
- function setInterval(callback: Function, timeout: number): number
1143
- function clearInterval(timeoutID: number): void
1144
- function requestAnimationFrame(cb: (ts: number) => void): number
1145
- function cancelAnimationFrame(requestID: number): void
1146
-
1147
- interface Console {
1148
- log(message?: any, ...optionalParams: any[]): void
1149
- error(message?: any, ...optionalParams: any[]): void
1150
- assert(condition?: boolean, message?: string, ...data: any[]): void
1151
- info(message?: any, ...optionalParams: any[]): void
1152
- warn(message?: any, ...optionalParams: any[]): void
1153
- clear(): void
1154
- }
1155
-
1156
- interface Image {
1157
- readonly href: string
1158
- getBytesAsync(): Promise<Uint8Array>
1159
- }
1160
-
1161
- type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
1162
- type ThemeColor = 'dark' | 'light'
1163
-
1164
- interface PluginAPI {
1165
- readonly document: DocumentNode
1166
-
1167
- readonly ui: UIAPI
1168
-
1169
- readonly themeColor: ThemeColor
1170
-
1171
- readonly apiVersion: string
1172
-
1173
- readonly documentId: number
1174
-
1175
- readonly command: string
1176
-
1177
- readonly clientStorage: ClientStorageAPI
1178
-
1179
- readonly viewport: ViewportAPI
1180
-
1181
- closePlugin(): void
1182
-
1183
- on(type: PluginEventType, callback: CallableFunction): void
1184
- once(type: PluginEventType, callback: CallableFunction): void
1185
- off(type?: PluginEventType, callback?: CallableFunction): void
1186
-
1187
- commitUndo(): void
1188
- triggerUndo(): void
1189
-
1190
- showUI(html: string, options?: ShowUIOptions): void
1191
-
1192
- getNodeById(id: string): SceneNode | null
1193
- createRectangle(): RectangleNode
1194
- createLine(): LineNode
1195
- createEllipse(): EllipseNode
1196
- createPolygon(): PolygonNode
1197
- createStar(): StarNode
1198
- createPen(): PenNode
1199
- createText(): TextNode
1200
- createFrame(): FrameNode
1201
- createComponent(): ComponentNode
1202
- createPage(): PageNode
1203
- createSlice(): SliceNode
1204
- createConnector(): ConnectorNode
1205
- createNodeFromSvgAsync(svg: string): Promise<FrameNode>
1206
-
1207
- getHoverLayer(): PageNode | SceneNode
1208
-
1209
- showGrid(show: boolean): void
1210
-
1211
- group(children: ReadonlyArray<SceneNode>): GroupNode
1212
- union(children: ReadonlyArray<SceneNode>): BooleanOperationNode
1213
- subtract(children: ReadonlyArray<SceneNode>): BooleanOperationNode
1214
- intersect(children: ReadonlyArray<SceneNode>): BooleanOperationNode
1215
- exclude(children: ReadonlyArray<SceneNode>): BooleanOperationNode
1216
-
1217
- saveVersionHistoryAsync(desc: string): Promise<void>
1218
-
1219
- notify(message: string, options?: NotifyOptions): void
1220
-
1221
- getStyleById(id: string): Style | null
1222
- getTitleByFontFamilyAndStyle(fontFamily: string, fontStyle: string) : FontAlias | null
1223
- createFillStyle(config: CreateStyleConfig): PaintStyle
1224
- createStrokeStyle(config: CreateStyleConfig): PaintStyle
1225
- createEffectStyle(config: CreateStyleConfig): EffectStyle
1226
- createTextStyle(config: CreateStyleConfig): TextStyle
1227
- createGridStyle(config: CreateStyleConfig): GridStyle
1228
-
1229
- getLocalPaintStyles(): PaintStyle[]
1230
- getLocalEffectStyles(): EffectStyle[]
1231
- getLocalTextStyles(): TextStyle[]
1232
- getLocalGridStyles(): GridStyle[]
1233
-
1234
- listAvailableFontsAsync(): Promise<Font[]>
1235
- loadFontAsync(fontName: FontName): Promise<boolean>
1236
- createImage(imageData: Uint8Array): Promise<Image>
1237
- getImageByHref(href: string): Image
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
-
1247
- hexToRGBA(hex: string): RGBA
1248
- RGBAToHex(rgba: RGBA): string
1249
- }
1250
-
1251
- interface Rect {
1252
- readonly x: number
1253
- readonly y: number
1254
- readonly width: number
1255
- readonly height: number
1256
- }
1257
-
1258
- interface ViewportAPI {
1259
- center: Vector
1260
- zoom: number
1261
- readonly bound: Rect
1262
- rulerVisible: boolean
1263
- layoutGridVisible: boolean
1264
- scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
1265
- }
1266
-
1267
- interface ClientStorageAPI {
1268
- getAsync(key: string): Promise<any | undefined>
1269
- setAsync(key: string, value: any): Promise<void>
1270
- }
1271
-
1272
- type ShowUIOptions = {
1273
- width?: number
1274
- height?: number
1275
- visible?: boolean
1276
- x?: number | string
1277
- y?: number | string
1278
- }
1279
-
1280
- interface ExportSettingsConstraints {
1281
- type: 'SCALE' | 'WIDTH' | 'HEIGHT'
1282
- value: number
1283
- }
1284
- type ExportFileFormat = 'PNG' | 'JPG' | 'SVG' | 'PDF' | 'WEBP'
1285
- type ExportSettings = {
1286
- format: ExportFileFormat
1287
- constraint?: ExportSettingsConstraints
1288
- isSuffix?: boolean
1289
- fileName?: string
1290
- readonly useAbsoluteBounds?: boolean
1291
- }
1292
-
1293
- interface ExportMixin {
1294
- exportSettings: ReadonlyArray<ExportSettings>
1295
- export(settings?: ExportSettings): Uint8Array | string // Defaults to PNG format
1296
- }
1297
-
1298
- interface NotifyOptions {
1299
- position?: 'top' | 'bottom'
1300
- type?: 'normal' | 'highlight' | 'error' | 'warning' | 'success'
1301
- }
1302
-
1303
- interface UIAPI {
1304
- show(): void
1305
- hide(): void
1306
- close(): void
1307
- resize(width: number, height: number): void
1308
-
1309
- postMessage(pluginMessage: any, origin?: string): void
1310
- onmessage: ((pluginMessage: any, origin: string) => void) | undefined
1311
- }
1312
- type PublishStatus = 'UNPUBLISHED' | 'CURRENT' | 'CHANGED'
1313
- interface PublishableMixin {
1314
- description: string
1315
- /**
1316
- * 是否为团队库组件/样式
1317
- */
1318
- readonly isExternal: boolean
1319
- readonly ukey: string
1320
- readonly publishStatus: PublishStatus
1321
- }
1322
-
1323
- /// /////////////////////////////////////////////////////////////////////////////
1324
- // Styles
1325
-
1326
- type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
1327
-
1328
- interface BaseStyle extends PublishableMixin {
1329
- readonly id: string
1330
- readonly type: StyleType
1331
- name: string
1332
- remove(): void
1333
- }
1334
-
1335
- interface PaintStyle extends BaseStyle {
1336
- type: 'PAINT'
1337
- paints: ReadonlyArray<Paint>
1338
- }
1339
-
1340
- interface NumValue {
1341
- value: number
1342
- unit: 'PIXELS' | 'PERCENT'
1343
- }
1344
-
1345
- interface TextSegStyle {
1346
- start: number
1347
- end: number
1348
- textStyleId: string
1349
- textStyle: {
1350
- fontName: FontName
1351
- fontSize: number
1352
- letterSpacing: LetterSpacing
1353
- lineHeight: LineHeight
1354
- textDecoration: TextDecoration
1355
- textCase: TextCase
1356
- }
1357
- fills: Paint[]
1358
- }
1359
-
1360
- interface ListStyle {
1361
- start: number
1362
- end: number
1363
- level: number
1364
- type: 'ORDERED' | 'BULLETED' | 'NONE'
1365
- }
1366
-
1367
- interface EffectStyle extends BaseStyle {
1368
- type: 'EFFECT'
1369
- effects: ReadonlyArray<Effect>
1370
- }
1371
-
1372
- interface TextStyle extends BaseStyle {
1373
- type: 'TEXT'
1374
- decoration: TextDecoration
1375
- fontSize: number
1376
- letterSpacing: number
1377
- letterSpacingUnit: NumValue['unit']
1378
- textCase: TextCase
1379
- lineHeight: LineHeight
1380
- }
1381
-
1382
- interface FontAlias {
1383
- title: string
1384
- subtitle: string
1385
- }
1386
-
1387
- interface GridStyle extends BaseStyle {
1388
- type: 'GRID'
1389
- layoutGrids: ReadonlyArray<LayoutGrid>
1390
- }
1391
-
1392
- type Style = PaintStyle | EffectStyle | TextStyle | GridStyle
1393
-
1394
- /// /////////////////////////////////////////////////////////////////////////////
1395
- // Datatypes
1396
-
1397
- type Transform = [[number, number, number], [number, number, number]]
1398
-
1399
- interface Vector {
1400
- readonly x: number
1401
- readonly y: number
1402
- }
1403
-
1404
- interface RGB {
1405
- readonly r: number
1406
- readonly g: number
1407
- readonly b: number
1408
- }
1409
-
1410
- interface RGBA {
1411
- readonly r: number
1412
- readonly g: number
1413
- readonly b: number
1414
- readonly a: number
1415
- }
1416
-
1417
- interface FontName {
1418
- readonly family: string
1419
- readonly style: string
1420
- }
1421
-
1422
- type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE';
1423
-
1424
- type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'
1425
-
1426
- interface ShadowEffect {
1427
- readonly type: 'DROP_SHADOW' | 'INNER_SHADOW'
1428
- readonly color: RGBA
1429
- // Effect的 x, y;
1430
- readonly offset: Vector
1431
- // spread和radius待确定
1432
- readonly spread: number
1433
- readonly radius: number
1434
- readonly isVisible: boolean
1435
- readonly blendMode: BlendMode
1436
- }
1437
-
1438
- interface BlurEffect {
1439
- readonly type: 'LAYER_BLUR' | 'BACKGROUND_BLUR'
1440
- readonly radius: number
1441
- readonly isVisible: boolean
1442
- readonly blendMode: BlendMode
1443
- }
1444
-
1445
- type Effect = ShadowEffect | BlurEffect
1446
-
1447
- // 待确认
1448
- type ConstraintType = 'START' | 'END' | 'STARTANDEND' | 'CENTER' | 'SCALE'
1449
-
1450
- interface Constraints {
1451
- readonly horizontal: ConstraintType
1452
- readonly vertical: ConstraintType
1453
- }
1454
-
1455
- interface ColorStop {
1456
- readonly position: number
1457
- readonly color: RGBA
1458
- }
1459
-
1460
- interface SolidPaint {
1461
- readonly type: 'SOLID'
1462
- readonly color: RGBA
1463
-
1464
- readonly isVisible?: boolean
1465
- /**
1466
- * It always be 1 when type is 'SOLID', please modify the alpha field in color instead.
1467
- * 纯色模式下alpha始终为1, 请设置color中的alpha.
1468
- */
1469
- readonly alpha?: number
1470
- readonly blendMode?: BlendMode
1471
- }
1472
-
1473
- interface GradientPaint {
1474
- readonly type:
1475
- | 'GRADIENT_LINEAR'
1476
- | 'GRADIENT_RADIAL'
1477
- | 'GRADIENT_ANGULAR'
1478
- | 'GRADIENT_DIAMOND'
1479
- readonly transform: Transform
1480
- readonly gradientStops: ReadonlyArray<ColorStop>
1481
- readonly gradientHandlePositions?: [{ x: number, y: number}, { x: number, y: number}];
1482
- readonly isVisible?: boolean
1483
- readonly alpha?: number
1484
- readonly blendMode?: BlendMode
1485
- }
1486
-
1487
- interface ImagePaint {
1488
- readonly type: 'IMAGE'
1489
- readonly imageRef: string
1490
- readonly scaleMode?: 'FILL' | 'TILE' | 'STRETCH' | 'FIT' | 'CROP'
1491
-
1492
- readonly isVisible?: boolean
1493
- readonly alpha?: number
1494
- readonly blendMode?: BlendMode
1495
- }
1496
-
1497
- type Paint = SolidPaint | GradientPaint | ImagePaint
1498
-
1499
- type WindingRule = 'Nonzero' | 'Evenodd'
1500
-
1501
- // 待确定
1502
- interface VectorVertex {
1503
- readonly id: number
1504
- readonly x: number
1505
- readonly y: number
1506
- readonly type: 'PATH_NODE' | 'CONTROL_NODE' // 0 路径端点 1 控制节点
1507
- readonly strokeCap?: StrokeCap
1508
- readonly strokeJoin?: StrokeJoin
1509
- readonly cornerRadius?: number
1510
- }
1511
-
1512
- // 待确定
1513
- interface VectorRegion {
1514
- readonly id: number
1515
- readonly windingRule: WindingRule
1516
- readonly pathIds?: ReadonlyArray<number>
1517
- }
1518
-
1519
- interface VectorCtrl {
1520
- x: number
1521
- y: number
1522
- }
1523
-
1524
- type LetterSpacing = {
1525
- readonly value: number
1526
- readonly unit: 'PIXELS' | 'PERCENT'
1527
- }
1528
-
1529
- type LineHeight = {
1530
- readonly value: number
1531
- readonly unit: 'PIXELS'
1532
- }
1533
-
1534
- type BlendMode =
1535
- | 'NORMAL'
1536
- | 'DARKEN'
1537
- | 'MULTIPLY'
1538
- | 'COLOR_BURN'
1539
- | 'LIGHTEN'
1540
- | 'SCREEN'
1541
- | 'COLOR_DODGE'
1542
- | 'OVERLAY'
1543
- | 'SOFT_LIGHT'
1544
- | 'HARD_LIGHT'
1545
- | 'DIFFERENCE'
1546
- | 'EXCLUSION'
1547
- | 'HUE'
1548
- | 'SATURATION'
1549
- | 'COLOR'
1550
- | 'LUMINOSITY'
1551
- | 'PLUS_DARKER'
1552
- | 'PLUS_LIGHTER'
1553
- | 'PASS_THROUGH'
1554
-
1555
- interface Font {
1556
- fontName: FontName
1557
- }
1558
-
1559
- /// /////////////////////////////////////////////////////////////////////////////
1560
- // Mixins
1561
-
1562
- interface BaseNodeMixin {
1563
- readonly id: string
1564
- readonly parent: (BaseNode & ChildrenMixin) | void
1565
- name: string
1566
- removed: boolean
1567
- remove(): void
1568
- getPluginData(key: string): string
1569
- setPluginData(key: string, value: string): void
1570
- getPluginDataKeys(): string[]
1571
- removePluginData(key: string): void
1572
- clearPluginData(): void
1573
- getSharedPluginData(namespace: string, key: string): string
1574
- setSharedPluginData(namespace: string, key: string, value: string): void
1575
- getSharedPluginDataKeys(namespace: string): void
1576
- removeSharedPluginData(namespace: string, key: string): void
1577
- clearSharedPluginData(namespace: string): void
1578
- }
1579
-
1580
- interface SceneNodeMixin {
1581
- isVisible: boolean
1582
- isLocked: boolean
1583
- }
1584
-
1585
- interface ChildrenMixin<ChildrenNode = SceneNode> {
1586
- readonly children: ReadonlyArray<ChildrenNode>
1587
- appendChild(child: SceneNode): void
1588
- insertChild(index: number, child: SceneNode): void
1589
-
1590
- findChildren(
1591
- callback?: (node: SceneNode) => boolean
1592
- ): ReadonlyArray<SceneNode>
1593
- findChild(callback: (node: SceneNode) => boolean): SceneNode | null
1594
-
1595
- findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
1596
- findOne(callback: (node: SceneNode) => boolean): SceneNode | null
1597
- }
1598
-
1599
- interface ConstraintMixin {
1600
- constraints: Constraints
1601
- }
1602
-
1603
- interface Bound {
1604
- x: number
1605
- y: number
1606
- width: number
1607
- height: number
1608
- }
1609
-
1610
- interface LayoutMixin {
1611
- absoluteTransform: Transform
1612
- relativeTransform: Transform
1613
- bound: Bound
1614
- x: number
1615
- y: number
1616
- width: number
1617
- height: number
1618
- rotation: number // In degrees
1619
- constrainProportions: boolean
1620
- layoutPositioning: 'AUTO' | 'ABSOLUTE' // applicable only inside auto-layout frames
1621
- alignSelf: 'STRETCH' | 'INHERIT' // applicable only inside auto-layout frames
1622
- flexGrow: 0 | 1 // applicable only inside auto-layout frames
1623
- }
1624
-
1625
- interface BlendMixin {
1626
- opacity: number
1627
- blendMode: BlendMode
1628
- isMask: boolean
1629
- effects: ReadonlyArray<Effect>
1630
- effectStyleId: string
1631
- }
1632
-
1633
- type StrokeCap = 'NONE' | 'ROUND' | 'SQUARE' | 'LINE_ARROW' | 'TRIANGLE_ARROW' | 'ROUND_ARROW' | 'RING' | 'DIAMOND' | 'LINE'
1634
- type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'
1635
- type StrokeAlign = 'CENTER' | 'INSIDE' | 'OUTSIDE'
1636
- type DashCap = 'NONE' | 'ROUND' | 'SQUARE'
1637
- type StrokeStyle = 'SOLID' | 'DASH' | 'CUSTOM'
1638
- type ConnectorStrokeCap = StrokeCap
1639
-
1640
- interface ConnectorEndpointPosition {
1641
- readonly position: { x: number; y: number }
1642
- }
1643
-
1644
- interface ConnectorEndpointConnected {
1645
- readonly position: { x: number; y: number }
1646
- readonly endpointNodeId: string
1647
- readonly magnet: 'TOP' | 'LEFT' | 'BOTTOM' | 'RIGHT'
1648
- }
1649
-
1650
-
1651
- type ConnectorEndpoint =
1652
- | ConnectorEndpointPosition
1653
- | ConnectorEndpointConnected
1654
-
1655
- interface GeometryMixin {
1656
- fills: ReadonlyArray<Paint>
1657
- strokes: ReadonlyArray<Paint>
1658
- strokeWeight: number
1659
- strokeAlign: StrokeAlign
1660
- strokeCap: StrokeCap
1661
- strokeJoin: StrokeJoin
1662
- strokeStyle: StrokeStyle
1663
- dashCap: DashCap
1664
- strokeDashes: ReadonlyArray<number>
1665
- fillStyleId: string
1666
- strokeStyleId: string
1667
- /**
1668
- * You have to ensure the layer has stroke before invoking this method.
1669
- * 在调用接口之前需要确保layer有描边.
1670
- */
1671
- outlineStroke(): SceneNode | null
1672
- }
1673
-
1674
- interface RectangleStrokeWeightMixin {
1675
- strokeTopWeight: number
1676
- strokeLeftWeight: number
1677
- strokeBottomWeight: number
1678
- strokeRightWeight: number
1679
- }
1680
-
1681
- interface CornerMixin {
1682
- // 待确认
1683
- cornerSmooth: number
1684
- cornerRadius: number | symbol
1685
- }
1686
-
1687
- interface DefaultShapeMixin
1688
- extends BaseNodeMixin,
1689
- SceneNodeMixin,
1690
- BlendMixin,
1691
- GeometryMixin,
1692
- LayoutMixin,
1693
- ReactionMixin,
1694
- ExportMixin { }
1695
-
1696
- interface DefaultContainerMixin
1697
- extends BaseNodeMixin,
1698
- ReactionMixin,
1699
- SceneNodeMixin,
1700
- ChildrenMixin,
1701
- RectangleCornerMixin,
1702
- BlendMixin,
1703
- CornerMixin,
1704
- ConstraintMixin,
1705
- LayoutMixin,
1706
- ExportMixin { }
1707
-
1708
- interface AutoLayout {
1709
- flexMode: 'NONE' | 'HORIZONTAL' | 'VERTICAL'
1710
- itemSpacing: number
1711
- mainAxisAlignItems: 'FLEX_START' | 'FLEX_END' | 'CENTER' | 'SPACING_BETWEEN'
1712
- crossAxisAlignItems: 'FLEX_START' | 'FLEX_END' | 'CENTER'
1713
- mainAxisSizingMode: 'FIXED' | 'AUTO'
1714
- crossAxisSizingMode: 'FIXED' | 'AUTO'
1715
- strokesIncludedInLayout: boolean
1716
- itemReverseZIndex: boolean
1717
- paddingTop: number
1718
- paddingRight: number
1719
- paddingBottom: number
1720
- paddingLeft: number
1721
- }
1722
-
1723
- interface RowsColsLayoutGrid {
1724
- readonly gridType: "ROWS" | "COLUMNS"
1725
-
1726
- readonly alignment: "LEFT" | "RIGHT" | "STRETCH" | "CENTER"
1727
- readonly gutterSize: number
1728
- readonly count: number
1729
- readonly sectionSize?: number | null
1730
- readonly offset?: number
1731
-
1732
- readonly isVisible?: boolean
1733
- readonly color?: RGBA
1734
- readonly id?: string
1735
- readonly name?: string
1736
- }
1737
-
1738
- interface GridLayoutGrid {
1739
- readonly gridType: "GRID"
1740
-
1741
- readonly sectionSize: number
1742
-
1743
- readonly isVisible?: boolean
1744
- readonly color?: RGBA
1745
- readonly id?: string
1746
- readonly name?: string
1747
- }
1748
-
1749
-
1750
- type LayoutGrid = RowsColsLayoutGrid | GridLayoutGrid
1751
-
1752
- interface FrameContainerMixin extends AutoLayout {
1753
- clipsContent: boolean
1754
- layoutGrids: ReadonlyArray<LayoutGrid>
1755
- gridStyleId: string
1756
- overflowDirection: OverflowDirection
1757
- }
1758
-
1759
- type OverflowDirection = "NONE" | "HORIZONTAL" | "VERTICAL" | "BOTH"
1760
-
1761
- interface RectangleCornerMixin {
1762
- topLeftRadius: number
1763
- topRightRadius: number
1764
- bottomLeftRadius: number
1765
- bottomRightRadius: number
1766
- }
1767
-
1768
- interface ReactionMixin {
1769
- reactions: ReadonlyArray<Reaction>
1770
- }
1771
-
1772
- interface OpaqueNodeMixin extends BaseNodeMixin, SceneNodeMixin, ExportMixin {
1773
- readonly absoluteTransform: Transform
1774
- relativeTransform: Transform
1775
- x: number
1776
- y: number
1777
- readonly width: number
1778
- readonly height: number
1779
- readonly bound: Bound
1780
- }
1781
-
1782
- interface MinimalBlendMixin {
1783
- opacity: number
1784
- blendMode: BlendMode
1785
- }
1786
-
1787
- interface MinimalStrokesMixin {
1788
- strokes: ReadonlyArray<Paint>
1789
- strokeStyleId: string
1790
- strokeWeight: number
1791
- strokeJoin: StrokeJoin
1792
- strokeAlign: StrokeAlign
1793
- strokeStyle: StrokeStyle
1794
- strokeCap: StrokeCap
1795
- strokeDashes: ReadonlyArray<number>
1796
- dashCap: DashCap
1797
- }
1798
-
1799
- interface MinimalFillsMixin {
1800
- fills: ReadonlyArray<Paint>
1801
- fillStyleId: string
1802
- }
1803
-
1804
- /// /////////////////////////////////////////////////////////////////////////////
1805
- // Nodes
1806
-
1807
- interface DocumentNode {
1808
- readonly type: 'DOCUMENT'
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
1817
- }
1818
-
1819
- interface PageNode
1820
- extends
1821
- ChildrenMixin<SceneNode> {
1822
- readonly type: 'PAGE'
1823
-
1824
- readonly id: string
1825
- readonly parent: DocumentNode
1826
- name: string
1827
- removed: boolean
1828
- remove(): void
1829
-
1830
- selection: ReadonlyArray<SceneNode>
1831
- clone(): PageNode
1832
- /**
1833
- * 选中所有图层
1834
- */
1835
- selectAll() : void
1836
- /**
1837
- * 背景颜色
1838
- */
1839
- bgColor: RGBA
1840
- /**
1841
- * 原型所有的flow
1842
- */
1843
- readonly flowStartingPoints: FlowStartingPoint[]
1844
- /**
1845
- * 标签,默认'NONE'
1846
- */
1847
- label:'NONE' | 'BLUE' | 'GREEN' | 'RED' | 'YELLOW' | 'PURPLE' | 'GRAY'
1848
- }
1849
-
1850
- interface FrameNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
1851
- readonly type: 'FRAME'
1852
- clone(): FrameNode
1853
- resizeToFit(): void
1854
- }
1855
-
1856
- interface GroupNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin {
1857
- readonly type: 'GROUP'
1858
- clone(): GroupNode
1859
- }
1860
-
1861
- interface RectangleNode
1862
- extends DefaultShapeMixin,
1863
- ConstraintMixin,
1864
- CornerMixin,
1865
- RectangleStrokeWeightMixin,
1866
- RectangleCornerMixin {
1867
- readonly type: 'RECTANGLE'
1868
- clone(): RectangleNode
1869
- }
1870
-
1871
- interface LineNode extends DefaultShapeMixin, ConstraintMixin {
1872
- readonly type: 'LINE'
1873
- clone(): LineNode
1874
- readonly height: number
1875
- leftStrokeCap: StrokeCap
1876
- rightStrokeCap: StrokeCap
1877
- }
1878
-
1879
- interface EllipseNode extends DefaultShapeMixin, ConstraintMixin {
1880
- readonly type: 'ELLIPSE'
1881
- clone(): EllipseNode
1882
- arcData: ArcData
1883
- }
1884
-
1885
- interface PolygonNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
1886
- readonly type: 'POLYGON'
1887
- pointCount: number
1888
- clone(): PolygonNode
1889
- }
1890
-
1891
- interface StarNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
1892
- readonly type: 'STAR'
1893
- pointCount: number
1894
- innerRadius: number
1895
- clone(): StarNode
1896
- }
1897
-
1898
- // interface VectorPath {
1899
- // readonly id: number
1900
- // readonly nodeIds: ReadonlyArray<number>
1901
- // }
1902
- type VectorPath = number[]
1903
-
1904
- type VectorPaths = ReadonlyArray<VectorPath>
1905
-
1906
- interface PenNetwork {
1907
- paths: ReadonlyArray<VectorPaths>
1908
- nodes: ReadonlyArray<VectorVertex>
1909
- regions: ReadonlyArray<VectorRegion> | []
1910
- ctrlNodes: ReadonlyArray<VectorCtrl>
1911
- }
1912
-
1913
- interface PenPaths {
1914
- windingRule: WindingRule
1915
- data: string
1916
- }
1917
-
1918
- interface PenNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
1919
- readonly type: 'PEN'
1920
- penNetwork: PenNetwork
1921
- set penPaths(paths: Array<PenPaths>)
1922
- //@ts-ignore
1923
- get penPaths(): PenPaths
1924
- clone(): PenNode
1925
- }
1926
-
1927
- interface BooleanOperationNode
1928
- extends DefaultShapeMixin,
1929
- FrameContainerMixin,
1930
- ChildrenMixin,
1931
- CornerMixin {
1932
- readonly type: 'BOOLEAN_OPERATION'
1933
- booleanOperation: 'UNION' | 'INTERSECT' | 'SUBTRACT' | 'EXCLUDE'
1934
- clone(): BooleanOperationNode
1935
- }
1936
-
1937
- interface TextRangeStyle {
1938
- fontName: FontName
1939
- fontSize: number
1940
- lineHeight: LineHeight
1941
- textDecoration: TextDecoration
1942
- letterSpacing: LetterSpacing
1943
- }
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
-
1975
- interface TextNode extends DefaultShapeMixin, ConstraintMixin {
1976
- readonly type: 'TEXT'
1977
- characters: string
1978
- readonly hasMissingFont: boolean
1979
- /**
1980
- * @deprecated
1981
- * This attribute is deprecared, please use hyperlinks instead.
1982
- */
1983
- readonly superlinks: Array<Superlink>
1984
- readonly hyperlinks: Array<HyperlinkWithRange>
1985
- textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'
1986
- textAlignVertical: 'TOP' | 'CENTER' | 'BOTTOM'
1987
- textAutoResize: 'NONE' | 'WIDTH_AND_HEIGHT' | 'HEIGHT'
1988
- paragraphSpacing: number
1989
- readonly textStyles: ReadonlyArray<TextSegStyle>
1990
- readonly listStyles: ReadonlyArray<ListStyle>
1991
- clone(): TextNode
1992
-
1993
- insertCharacters(start: number, characters: string): void
1994
- deleteCharacters(start: number, end: number): void
1995
-
1996
- setRangeFontSize(start: number, end: number, fontSize: number): void
1997
- setRangeTextDecoration(
1998
- start: number,
1999
- end: number,
2000
- decoration: TextDecoration
2001
- ): void
2002
- setRangeFontName(start: number, end: number, fontName: FontName): void
2003
- setRangeLetterSpacing(
2004
- start: number,
2005
- end: number,
2006
- value: LetterSpacing
2007
- ): void
2008
- setRangeLineHeight(start: number, end: number, value: LineHeight): void
2009
- setRangeFills(start: number, end: number, paints: Paint[]): void
2010
- /**
2011
- * @deprecated
2012
- * This function is deprecared, please use setRangeHyperLink instead.
2013
- */
2014
- setRangeSuperLink(start: number, end: number, link: string | null): void
2015
- setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
2016
- setRangeTextCase(start: number, end: number, textCase: TextCase): void
2017
- setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
2018
- }
2019
-
2020
- interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
2021
- readonly type: 'COMPONENT'
2022
- readonly variantProperties: Array<Record<string, string>>
2023
- setVariantPropertyValues(property: Record<string, string>): void
2024
- clone(): ComponentNode
2025
- createInstance(): InstanceNode
2026
- resizeToFit(): void
2027
- }
2028
-
2029
- interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
2030
- readonly type: 'COMPONENT_SET'
2031
- readonly componentPropertyDefinitions: Array<Record<string, Array<string> | string>>
2032
- clone(): ComponentSetNode
2033
- createVariantComponent(): void
2034
- createVariantProperties(properties: Array<string>): void
2035
- editVariantProperties(properties: Record<string, string>): void
2036
- editVariantPropertyValues(properties: Record<string, { oldValue: string, newValue: string }>): void
2037
- deleteVariantProperty(property: string): void
2038
- resizeToFit(): void
2039
- }
2040
-
2041
- interface InstanceNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
2042
- readonly type: 'INSTANCE'
2043
- readonly variantProperties: Array<Record<string, string>>
2044
- setVariantPropertyValues(property: Record<string, string>): void
2045
- clone(): InstanceNode
2046
- /**
2047
- * this is an async func
2048
- */
2049
- swapComponent(): void
2050
- detachInstance(): InstanceNode
2051
- mainComponent: ComponentNode | null
2052
- }
2053
-
2054
- interface SliceNode extends BaseNodeMixin, LayoutMixin, ConstraintMixin, SceneNodeMixin, ExportMixin {
2055
- readonly type: 'SLICE'
2056
- clone(): SliceNode
2057
- isPreserveRatio: boolean
2058
- }
2059
-
2060
- interface ConnectorNode extends OpaqueNodeMixin, Pick<MinimalBlendMixin, 'opacity'>, Omit<MinimalStrokesMixin, 'strokeAlign'> {
2061
- readonly type: 'CONNECTOR'
2062
- createText(): TextSublayerNode
2063
- readonly text: TextSublayerNode | null
2064
- cornerRadius?: number
2065
- connectorStart: ConnectorEndpoint
2066
- connectorEnd: ConnectorEndpoint
2067
- connectorStartStrokeCap: ConnectorStrokeCap
2068
- connectorEndStrokeCap: ConnectorStrokeCap
2069
- readonly strokeAlign: 'CENTER'
2070
- clone(): ConnectorNode
2071
- }
2072
-
2073
- interface TextSublayerNode extends MinimalFillsMixin {
2074
- readonly id: string
2075
- readonly hasMissingFont: boolean
2076
- readonly textAlignHorizontal: 'CENTER'
2077
- readonly textAlignVertical: 'CENTER'
2078
- readonly textAutoResize: 'WIDTH_AND_HEIGHT'
2079
- readonly hyperlinks: Array<HyperlinkWithRange>
2080
-
2081
- readonly textStyles: ReadonlyArray<TextSegStyle>
2082
-
2083
- paragraphSpacing: number
2084
-
2085
- characters: string
2086
- insertCharacters(start: number, characters: string): void
2087
- deleteCharacters(start: number, end: number): void
2088
-
2089
- setRangeFontSize(start: number, end: number, fontSize: number): void
2090
- setRangeTextDecoration(
2091
- start: number,
2092
- end: number,
2093
- decoration: TextDecoration
2094
- ): void
2095
- setRangeFontName(start: number, end: number, fontName: FontName): void
2096
- setRangeLetterSpacing(
2097
- start: number,
2098
- end: number,
2099
- value: LetterSpacing
2100
- ): void
2101
- setRangeLineHeight(start: number, end: number, value: LineHeight): void
2102
- setRangeFills(start: number, end: number, paints: Paint[]): void
2103
- setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
970
+ setRangeHyperlink(start: number, end: number, hyperlink: Hyperlink | null): void
2104
971
  setRangeTextCase(start: number, end: number, textCase: TextCase): void
2105
972
  }
2106
973
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/plugin-typings",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "MasterGo插件API声明文件",
5
5
  "main": "",
6
6
  "types": "dist/index.d.ts",
@@ -8,14 +8,16 @@
8
8
  "prepare": "husky install",
9
9
  "dev": "node scripts/dev.js",
10
10
  "build": "node scripts/build.js",
11
- "postbuild": "node scripts/concat-typings.js",
11
+ "postbuild": "node scripts/concat-typings",
12
12
  "release": "node scripts/release.js",
13
13
  "publish-to-npm": "node scripts/publish.js",
14
14
  "verify-commit": "node scripts/verify-commit.js",
15
15
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
16
16
  },
17
17
  "files": [
18
- "dist"
18
+ "dist",
19
+ "README-en.md",
20
+ "README.md"
19
21
  ],
20
22
  "keywords": [
21
23
  "mastergo",