@mastergo/plugin-typings 1.6.1 → 1.7.1
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 +557 -0
- package/README-en.md +25 -0
- package/dist/index.d.ts +97 -1132
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -25,1119 +25,6 @@ declare global {
|
|
|
25
25
|
getBytesAsync(): Promise<Uint8Array>
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
enum LinkFlagEnum {
|
|
29
|
-
CURRPAGE = 'currPage',
|
|
30
|
-
OTHERPAGE = 'otherPage',
|
|
31
|
-
PROTOTYPE = 'prototype',
|
|
32
|
-
OUTFILE = 'outFile',
|
|
33
|
-
OWNWEBSITE = 'ownWebsite',
|
|
34
|
-
OTHERLINK = 'otherLink',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface Superlink {
|
|
38
|
-
start: number
|
|
39
|
-
end: number
|
|
40
|
-
superlink: {
|
|
41
|
-
layerId?: string
|
|
42
|
-
link: string
|
|
43
|
-
linkFlag: LinkFlagEnum
|
|
44
|
-
pageId: string
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface Hyperlink {
|
|
49
|
-
type: 'PAGE' | 'NODE' | 'URL',
|
|
50
|
-
value: string
|
|
51
|
-
}
|
|
52
|
-
interface HyperlinkWithRange {
|
|
53
|
-
start: number
|
|
54
|
-
end: number
|
|
55
|
-
hyperlink: Hyperlink
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
|
|
59
|
-
type ThemeColor = 'dark' | 'light'
|
|
60
|
-
|
|
61
|
-
interface PluginAPI {
|
|
62
|
-
readonly document: DocumentNode
|
|
63
|
-
|
|
64
|
-
readonly ui: UIAPI
|
|
65
|
-
|
|
66
|
-
readonly themeColor: ThemeColor
|
|
67
|
-
|
|
68
|
-
readonly apiVersion: string
|
|
69
|
-
|
|
70
|
-
readonly documentId: number
|
|
71
|
-
|
|
72
|
-
readonly command: string
|
|
73
|
-
|
|
74
|
-
readonly clientStorage: ClientStorageAPI
|
|
75
|
-
|
|
76
|
-
readonly viewport: ViewportAPI
|
|
77
|
-
|
|
78
|
-
closePlugin(): void
|
|
79
|
-
|
|
80
|
-
on(type: PluginEventType, callback: CallableFunction): void
|
|
81
|
-
once(type: PluginEventType, callback: CallableFunction): void
|
|
82
|
-
off(type?: PluginEventType, callback?: CallableFunction): void
|
|
83
|
-
|
|
84
|
-
commitUndo(): void
|
|
85
|
-
triggerUndo(): void
|
|
86
|
-
|
|
87
|
-
showUI(html: string, options?: ShowUIOptions): void
|
|
88
|
-
|
|
89
|
-
getNodeById(id: string): SceneNode | null
|
|
90
|
-
createRectangle(): RectangleNode
|
|
91
|
-
createLine(): LineNode
|
|
92
|
-
createEllipse(): EllipseNode
|
|
93
|
-
createPolygon(): PolygonNode
|
|
94
|
-
createStar(): StarNode
|
|
95
|
-
createPen(): PenNode
|
|
96
|
-
createText(): TextNode
|
|
97
|
-
createFrame(): FrameNode
|
|
98
|
-
createComponent(): ComponentNode
|
|
99
|
-
createPage(): PageNode
|
|
100
|
-
createSlice(): SliceNode
|
|
101
|
-
createConnector(): ConnectorNode
|
|
102
|
-
createNodeFromSvgAsync(svg: string): Promise<FrameNode>
|
|
103
|
-
|
|
104
|
-
getHoverLayer(): PageNode | SceneNode
|
|
105
|
-
|
|
106
|
-
showGrid(show: boolean): void
|
|
107
|
-
|
|
108
|
-
group(children: ReadonlyArray<SceneNode>): GroupNode
|
|
109
|
-
union(children: ReadonlyArray<SceneNode>): BooleanOperationNode
|
|
110
|
-
subtract(children: ReadonlyArray<SceneNode>): BooleanOperationNode
|
|
111
|
-
intersect(children: ReadonlyArray<SceneNode>): BooleanOperationNode
|
|
112
|
-
exclude(children: ReadonlyArray<SceneNode>): BooleanOperationNode
|
|
113
|
-
|
|
114
|
-
saveVersionHistoryAsync(desc: string): Promise<void>
|
|
115
|
-
|
|
116
|
-
notify(message: string, options?: NotifyOptions): void
|
|
117
|
-
|
|
118
|
-
getStyleById(id: string): Style | null
|
|
119
|
-
getTitleByFontFamilyAndStyle(fontFamily: string, fontStyle: string) : FontAlias | null
|
|
120
|
-
createFillStyle(config: CreateStyleConfig): PaintStyle
|
|
121
|
-
createStrokeStyle(config: CreateStyleConfig): PaintStyle
|
|
122
|
-
createEffectStyle(config: CreateStyleConfig): EffectStyle
|
|
123
|
-
createTextStyle(config: CreateStyleConfig): TextStyle
|
|
124
|
-
createGridStyle(config: CreateStyleConfig): GridStyle
|
|
125
|
-
|
|
126
|
-
getLocalPaintStyles(): PaintStyle[]
|
|
127
|
-
getLocalEffectStyles(): EffectStyle[]
|
|
128
|
-
getLocalTextStyles(): TextStyle[]
|
|
129
|
-
getLocalGridStyles(): GridStyle[]
|
|
130
|
-
|
|
131
|
-
listAvailableFontsAsync(): Promise<Font[]>
|
|
132
|
-
loadFontAsync(fontName: FontName): Promise<boolean>
|
|
133
|
-
createImage(imageData: Uint8Array): Promise<Image>
|
|
134
|
-
getImageByHref(href: string): Image
|
|
135
|
-
|
|
136
|
-
hexToRGBA(hex: string): RGBA
|
|
137
|
-
RGBAToHex(rgba: RGBA): string
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface Rect {
|
|
141
|
-
readonly x: number
|
|
142
|
-
readonly y: number
|
|
143
|
-
readonly width: number
|
|
144
|
-
readonly height: number
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface ViewportAPI {
|
|
148
|
-
center: Vector
|
|
149
|
-
zoom: number
|
|
150
|
-
readonly bound: Rect
|
|
151
|
-
rulerVisible: boolean
|
|
152
|
-
layoutGridVisible: boolean
|
|
153
|
-
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
interface ClientStorageAPI {
|
|
157
|
-
getAsync(key: string): Promise<any | undefined>
|
|
158
|
-
setAsync(key: string, value: any): Promise<void>
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
type ShowUIOptions = {
|
|
162
|
-
width?: number
|
|
163
|
-
height?: number
|
|
164
|
-
visible?: boolean
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
interface ExportSettingsConstraints {
|
|
168
|
-
type: 'SCALE' | 'WIDTH' | 'HEIGHT'
|
|
169
|
-
value: number
|
|
170
|
-
}
|
|
171
|
-
type ExportFileFormat = 'PNG' | 'JPG' | 'SVG' | 'PDF' | 'WEBP'
|
|
172
|
-
type ExportSettings = {
|
|
173
|
-
format: ExportFileFormat
|
|
174
|
-
constraint?: ExportSettingsConstraints
|
|
175
|
-
isSuffix?: boolean
|
|
176
|
-
fileName?: string
|
|
177
|
-
readonly useAbsoluteBounds?: boolean
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
interface ExportMixin {
|
|
181
|
-
exportSettings: ReadonlyArray<ExportSettings>
|
|
182
|
-
export(settings?: ExportSettings): Promise<Uint8Array | string> // Defaults to PNG format
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
interface NotifyOptions {
|
|
186
|
-
position?: 'top' | 'bottom'
|
|
187
|
-
type?: 'normal' | 'highlight' | 'error' | 'warning' | 'success'
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
interface UIAPI {
|
|
191
|
-
show(): void
|
|
192
|
-
hide(): void
|
|
193
|
-
close(): void
|
|
194
|
-
resize(width: number, height: number): void
|
|
195
|
-
|
|
196
|
-
postMessage(pluginMessage: any, origin?: string): void
|
|
197
|
-
onmessage: ((pluginMessage: any, origin: string) => void) | undefined
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
201
|
-
// Styles
|
|
202
|
-
interface PublishableMixin {
|
|
203
|
-
description: string
|
|
204
|
-
/**
|
|
205
|
-
* 是否为团队库样式
|
|
206
|
-
*/
|
|
207
|
-
readonly isExternal: boolean
|
|
208
|
-
readonly ukey: string
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
|
|
212
|
-
|
|
213
|
-
interface BaseStyle extends PublishableMixin {
|
|
214
|
-
readonly id: string
|
|
215
|
-
readonly type: StyleType
|
|
216
|
-
name: string
|
|
217
|
-
remove(): void
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
interface PaintStyle extends BaseStyle {
|
|
221
|
-
type: 'PAINT'
|
|
222
|
-
paints: ReadonlyArray<Paint>
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
interface NumValue {
|
|
226
|
-
value: number
|
|
227
|
-
unit: 'PIXELS' | 'PERCENT'
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
interface TextSegStyle {
|
|
231
|
-
start: number
|
|
232
|
-
end: number
|
|
233
|
-
textStyleId: string
|
|
234
|
-
textStyle: {
|
|
235
|
-
fontName: FontName
|
|
236
|
-
fontSize: number
|
|
237
|
-
letterSpacing: LetterSpacing
|
|
238
|
-
lineHeight: LineHeight
|
|
239
|
-
textDecoration: TextDecoration
|
|
240
|
-
textCase: TextCase
|
|
241
|
-
}
|
|
242
|
-
fills: Paint[]
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
interface ListStyle {
|
|
246
|
-
start: number
|
|
247
|
-
end: number
|
|
248
|
-
level: number
|
|
249
|
-
type: 'ORDERED' | 'BULLETED' | 'NONE'
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
interface EffectStyle extends BaseStyle {
|
|
253
|
-
type: 'EFFECT'
|
|
254
|
-
effects: ReadonlyArray<Effect>
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
interface TextStyle extends BaseStyle {
|
|
258
|
-
type: 'TEXT'
|
|
259
|
-
decoration: TextDecoration
|
|
260
|
-
description: string
|
|
261
|
-
fontSize: number
|
|
262
|
-
isExternal: boolean
|
|
263
|
-
letterSpacing: number
|
|
264
|
-
letterSpacingUnit: NumValue['unit']
|
|
265
|
-
textCase: TextCase
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface FontAlias {
|
|
269
|
-
title: string
|
|
270
|
-
subtitle: string
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
interface GridStyle extends BaseStyle {
|
|
274
|
-
type: 'GRID'
|
|
275
|
-
layoutGrids: ReadonlyArray<LayoutGrid>
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
type Style = PaintStyle | EffectStyle | TextStyle | GridStyle
|
|
279
|
-
|
|
280
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
281
|
-
// Datatypes
|
|
282
|
-
|
|
283
|
-
type Transform = [[number, number, number], [number, number, number]]
|
|
284
|
-
|
|
285
|
-
interface Vector {
|
|
286
|
-
readonly x: number
|
|
287
|
-
readonly y: number
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
interface RGB {
|
|
291
|
-
readonly r: number
|
|
292
|
-
readonly g: number
|
|
293
|
-
readonly b: number
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
interface RGBA {
|
|
297
|
-
readonly r: number
|
|
298
|
-
readonly g: number
|
|
299
|
-
readonly b: number
|
|
300
|
-
readonly a: number
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
interface FontName {
|
|
304
|
-
readonly family: string
|
|
305
|
-
readonly style: string
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE';
|
|
309
|
-
|
|
310
|
-
type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'
|
|
311
|
-
|
|
312
|
-
interface ShadowEffect {
|
|
313
|
-
readonly type: 'DROP_SHADOW' | 'INNER_SHADOW'
|
|
314
|
-
readonly color: RGBA
|
|
315
|
-
// Effect的 x, y;
|
|
316
|
-
readonly offset: Vector
|
|
317
|
-
// spread和radius待确定
|
|
318
|
-
readonly spread: number
|
|
319
|
-
readonly radius: number
|
|
320
|
-
readonly isVisible: boolean
|
|
321
|
-
readonly blendMode: BlendMode
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
interface BlurEffect {
|
|
325
|
-
readonly type: 'LAYER_BLUR' | 'BACKGROUND_BLUR'
|
|
326
|
-
readonly radius: number
|
|
327
|
-
readonly isVisible: boolean
|
|
328
|
-
readonly blendMode: BlendMode
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
type Effect = ShadowEffect | BlurEffect
|
|
332
|
-
|
|
333
|
-
// 待确认
|
|
334
|
-
type ConstraintType = 'START' | 'END' | 'STARTANDEND' | 'CENTER' | 'SCALE'
|
|
335
|
-
|
|
336
|
-
interface Constraints {
|
|
337
|
-
readonly horizontal: ConstraintType
|
|
338
|
-
readonly vertical: ConstraintType
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
interface ColorStop {
|
|
342
|
-
readonly position: number
|
|
343
|
-
readonly color: RGBA
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
interface SolidPaint {
|
|
347
|
-
readonly type: 'SOLID'
|
|
348
|
-
readonly color: RGBA
|
|
349
|
-
|
|
350
|
-
readonly isVisible?: boolean
|
|
351
|
-
/**
|
|
352
|
-
* It always be 1 when type is 'SOLID', please modify the alpha field in color instead.
|
|
353
|
-
* 纯色模式下alpha始终为1, 请设置color中的alpha.
|
|
354
|
-
*/
|
|
355
|
-
readonly alpha?: number
|
|
356
|
-
readonly blendMode?: BlendMode
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
interface GradientPaint {
|
|
360
|
-
readonly type:
|
|
361
|
-
| 'GRADIENT_LINEAR'
|
|
362
|
-
| 'GRADIENT_RADIAL'
|
|
363
|
-
| 'GRADIENT_ANGULAR'
|
|
364
|
-
| 'GRADIENT_DIAMOND'
|
|
365
|
-
readonly transform: Transform
|
|
366
|
-
readonly gradientStops: ReadonlyArray<ColorStop>
|
|
367
|
-
readonly gradientHandlePositions?: [{ x: number, y: number}, { x: number, y: number}];
|
|
368
|
-
readonly isVisible?: boolean
|
|
369
|
-
readonly alpha?: number
|
|
370
|
-
readonly blendMode?: BlendMode
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
interface ImagePaint {
|
|
374
|
-
readonly type: 'IMAGE'
|
|
375
|
-
readonly imageRef: string
|
|
376
|
-
readonly scaleMode?: 'FILL' | 'TILE' | 'STRETCH' | 'FIT' | 'CROP'
|
|
377
|
-
|
|
378
|
-
readonly isVisible?: boolean
|
|
379
|
-
readonly alpha?: number
|
|
380
|
-
readonly blendMode?: BlendMode
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
type Paint = SolidPaint | GradientPaint | ImagePaint
|
|
384
|
-
|
|
385
|
-
type WindingRule = 'Nonzero' | 'Evenodd'
|
|
386
|
-
|
|
387
|
-
// 待确定
|
|
388
|
-
interface VectorVertex {
|
|
389
|
-
readonly id: number
|
|
390
|
-
readonly x: number
|
|
391
|
-
readonly y: number
|
|
392
|
-
readonly type: 'PATH_NODE' | 'CONTROL_NODE' // 0 路径端点 1 控制节点
|
|
393
|
-
readonly strokeCap?: StrokeCap
|
|
394
|
-
readonly strokeJoin?: StrokeJoin
|
|
395
|
-
readonly cornerRadius?: number
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// 待确定
|
|
399
|
-
interface VectorRegion {
|
|
400
|
-
readonly id: number
|
|
401
|
-
readonly windingRule: WindingRule
|
|
402
|
-
readonly pathIds?: ReadonlyArray<number>
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
interface VectorCtrl {
|
|
406
|
-
x: number
|
|
407
|
-
y: number
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
type LetterSpacing = {
|
|
411
|
-
readonly value: number
|
|
412
|
-
readonly unit: 'PIXELS' | 'PERCENT'
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
type LineHeight = {
|
|
416
|
-
readonly value: number
|
|
417
|
-
readonly unit: 'PIXELS'
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
type BlendMode =
|
|
421
|
-
| 'NORMAL'
|
|
422
|
-
| 'DARKEN'
|
|
423
|
-
| 'MULTIPLY'
|
|
424
|
-
| 'COLOR_BURN'
|
|
425
|
-
| 'LIGHTEN'
|
|
426
|
-
| 'SCREEN'
|
|
427
|
-
| 'COLOR_DODGE'
|
|
428
|
-
| 'OVERLAY'
|
|
429
|
-
| 'SOFT_LIGHT'
|
|
430
|
-
| 'HARD_LIGHT'
|
|
431
|
-
| 'DIFFERENCE'
|
|
432
|
-
| 'EXCLUSION'
|
|
433
|
-
| 'HUE'
|
|
434
|
-
| 'SATURATION'
|
|
435
|
-
| 'COLOR'
|
|
436
|
-
| 'LUMINOSITY'
|
|
437
|
-
| 'PLUS_DARKER'
|
|
438
|
-
| 'PLUS_LIGHTER'
|
|
439
|
-
| 'PASS_THROUGH'
|
|
440
|
-
|
|
441
|
-
interface Font {
|
|
442
|
-
fontName: FontName
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
446
|
-
// Mixins
|
|
447
|
-
|
|
448
|
-
interface BaseNodeMixin {
|
|
449
|
-
readonly id: string
|
|
450
|
-
readonly parent: (BaseNode & ChildrenMixin) | void
|
|
451
|
-
name: string // Note: setting this also sets \`autoRename\` to false on TextNodes
|
|
452
|
-
removed: boolean
|
|
453
|
-
remove(): void
|
|
454
|
-
getPluginData(key: string): string
|
|
455
|
-
setPluginData(key: string, value: string): void
|
|
456
|
-
getPluginDataKeys(): string[]
|
|
457
|
-
removePluginData(key: string): void
|
|
458
|
-
clearPluginData(): void
|
|
459
|
-
getSharedPluginData(namespace: string, key: string): string
|
|
460
|
-
setSharedPluginData(namespace: string, key: string, value: string): void
|
|
461
|
-
getSharedPluginDataKeys(namespace: string): void
|
|
462
|
-
removeSharedPluginData(namespace: string, key: string): void
|
|
463
|
-
clearSharedPluginData(namespace: string): void
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
interface SceneNodeMixin {
|
|
467
|
-
isVisible: boolean
|
|
468
|
-
isLocked: boolean
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
interface ChildrenMixin<ChildrenNode = SceneNode> {
|
|
472
|
-
readonly children: ReadonlyArray<ChildrenNode>
|
|
473
|
-
appendChild(child: SceneNode): void
|
|
474
|
-
insertChild(index: number, child: SceneNode): void
|
|
475
|
-
|
|
476
|
-
findChildren(
|
|
477
|
-
callback?: (node: SceneNode) => boolean
|
|
478
|
-
): ReadonlyArray<SceneNode>
|
|
479
|
-
findChild(callback: (node: SceneNode) => boolean): SceneNode | null
|
|
480
|
-
|
|
481
|
-
findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
|
|
482
|
-
findOne(callback: (node: SceneNode) => boolean): SceneNode | null
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
interface ConstraintMixin {
|
|
486
|
-
constraints: Constraints
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
interface Bound {
|
|
490
|
-
x: number
|
|
491
|
-
y: number
|
|
492
|
-
width: number
|
|
493
|
-
height: number
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
interface LayoutMixin {
|
|
497
|
-
absoluteTransform: Transform
|
|
498
|
-
relativeTransform: Transform
|
|
499
|
-
bound: Bound
|
|
500
|
-
x: number
|
|
501
|
-
y: number
|
|
502
|
-
width: number
|
|
503
|
-
height: number
|
|
504
|
-
rotation: number // In degrees
|
|
505
|
-
constrainProportions: boolean
|
|
506
|
-
layoutPositioning: 'AUTO' | 'ABSOLUTE' // applicable only inside auto-layout frames
|
|
507
|
-
alignSelf: 'STRETCH' | 'INHERIT' // applicable only inside auto-layout frames
|
|
508
|
-
flexGrow: 0 | 1 // applicable only inside auto-layout frames
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
interface BlendMixin {
|
|
512
|
-
opacity: number
|
|
513
|
-
blendMode: BlendMode
|
|
514
|
-
isMask: boolean
|
|
515
|
-
effects: ReadonlyArray<Effect>
|
|
516
|
-
effectStyleId: string
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
type StrokeCap = 'NONE' | 'ROUND' | 'SQUARE' | 'LINE_ARROW' | 'TRIANGLE_ARROW' | 'ROUND_ARROW' | 'RING' | 'DIAMOND' | 'LINE'
|
|
520
|
-
type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'
|
|
521
|
-
type StrokeAlign = 'CENTER' | 'INSIDE' | 'OUTSIDE'
|
|
522
|
-
type DashCap = 'NONE' | 'ROUND' | 'SQUARE'
|
|
523
|
-
type StrokeStyle = 'SOLID' | 'DASH' | 'CUSTOM'
|
|
524
|
-
type ConnectorStrokeCap = StrokeCap
|
|
525
|
-
|
|
526
|
-
interface ConnectorEndpointPosition {
|
|
527
|
-
readonly position: { x: number; y: number }
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
interface ConnectorEndpointConnected {
|
|
531
|
-
readonly position: { x: number; y: number }
|
|
532
|
-
readonly endpointNodeId: string
|
|
533
|
-
readonly magnet: 'TOP' | 'LEFT' | 'BOTTOM' | 'RIGHT'
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
type ConnectorEndpoint =
|
|
538
|
-
| ConnectorEndpointPosition
|
|
539
|
-
| ConnectorEndpointConnected
|
|
540
|
-
|
|
541
|
-
interface GeometryMixin {
|
|
542
|
-
fills: ReadonlyArray<Paint>
|
|
543
|
-
strokes: ReadonlyArray<Paint>
|
|
544
|
-
strokeWeight: number
|
|
545
|
-
strokeAlign: StrokeAlign
|
|
546
|
-
strokeCap: StrokeCap
|
|
547
|
-
strokeJoin: StrokeJoin
|
|
548
|
-
strokeStyle: StrokeStyle
|
|
549
|
-
dashCap: DashCap
|
|
550
|
-
strokeDashes: ReadonlyArray<number>
|
|
551
|
-
fillStyleId: string
|
|
552
|
-
strokeStyleId: string
|
|
553
|
-
/**
|
|
554
|
-
* You have to ensure the layer has stroke before invoking this method.
|
|
555
|
-
* 在调用接口之前需要确保layer有描边.
|
|
556
|
-
*/
|
|
557
|
-
outlineStroke(): SceneNode | null
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
interface RectangleStrokeWeightMixin {
|
|
561
|
-
strokeTopWeight: number
|
|
562
|
-
strokeLeftWeight: number
|
|
563
|
-
strokeBottomWeight: number
|
|
564
|
-
strokeRightWeight: number
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
interface CornerMixin {
|
|
568
|
-
// 待确认
|
|
569
|
-
cornerSmooth: number
|
|
570
|
-
cornerRadius: number | symbol
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
interface DefaultShapeMixin
|
|
574
|
-
extends BaseNodeMixin,
|
|
575
|
-
SceneNodeMixin,
|
|
576
|
-
BlendMixin,
|
|
577
|
-
GeometryMixin,
|
|
578
|
-
LayoutMixin,
|
|
579
|
-
ReactionMixin,
|
|
580
|
-
ExportMixin { }
|
|
581
|
-
|
|
582
|
-
interface DefaultContainerMixin
|
|
583
|
-
extends BaseNodeMixin,
|
|
584
|
-
ReactionMixin,
|
|
585
|
-
SceneNodeMixin,
|
|
586
|
-
ChildrenMixin,
|
|
587
|
-
RectangleCornerMixin,
|
|
588
|
-
BlendMixin,
|
|
589
|
-
CornerMixin,
|
|
590
|
-
ConstraintMixin,
|
|
591
|
-
LayoutMixin,
|
|
592
|
-
ExportMixin { }
|
|
593
|
-
|
|
594
|
-
interface AutoLayout {
|
|
595
|
-
flexMode: 'NONE' | 'HORIZONTAL' | 'VERTICAL'
|
|
596
|
-
itemSpacing: number
|
|
597
|
-
mainAxisAlignItems: 'FLEX_START' | 'FLEX_END' | 'CENTER' | 'SPACING_BETWEEN'
|
|
598
|
-
crossAxisAlignItems: 'FLEX_START' | 'FLEX_END' | 'CENTER'
|
|
599
|
-
mainAxisSizingMode: 'FIXED' | 'AUTO'
|
|
600
|
-
crossAxisSizingMode: 'FIXED' | 'AUTO'
|
|
601
|
-
strokesIncludedInLayout: boolean
|
|
602
|
-
itemReverseZIndex: boolean
|
|
603
|
-
paddingTop: number
|
|
604
|
-
paddingRight: number
|
|
605
|
-
paddingBottom: number
|
|
606
|
-
paddingLeft: number
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
interface RowsColsLayoutGrid {
|
|
610
|
-
readonly gridType: "ROWS" | "COLUMNS"
|
|
611
|
-
|
|
612
|
-
readonly alignment: "LEFT" | "RIGHT" | "STRETCH" | "CENTER"
|
|
613
|
-
readonly gutterSize: number
|
|
614
|
-
readonly count: number
|
|
615
|
-
readonly sectionSize?: number | null
|
|
616
|
-
readonly offset?: number
|
|
617
|
-
|
|
618
|
-
readonly isVisible?: boolean
|
|
619
|
-
readonly color?: RGBA
|
|
620
|
-
readonly id?: string
|
|
621
|
-
readonly name?: string
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
interface GridLayoutGrid {
|
|
625
|
-
readonly gridType: "GRID"
|
|
626
|
-
|
|
627
|
-
readonly sectionSize: number
|
|
628
|
-
|
|
629
|
-
readonly isVisible?: boolean
|
|
630
|
-
readonly color?: RGBA
|
|
631
|
-
readonly id?: string
|
|
632
|
-
readonly name?: string
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
type LayoutGrid = RowsColsLayoutGrid | GridLayoutGrid
|
|
637
|
-
|
|
638
|
-
interface FrameContainerMixin extends AutoLayout {
|
|
639
|
-
clipsContent: boolean
|
|
640
|
-
layoutGrids: ReadonlyArray<LayoutGrid>
|
|
641
|
-
gridStyleId: string
|
|
642
|
-
overflowDirection: OverflowDirection
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
type OverflowDirection = "NONE" | "HORIZONTAL" | "VERTICAL" | "BOTH"
|
|
646
|
-
|
|
647
|
-
interface RectangleCornerMixin {
|
|
648
|
-
topLeftRadius: number
|
|
649
|
-
topRightRadius: number
|
|
650
|
-
bottomLeftRadius: number
|
|
651
|
-
bottomRightRadius: number
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
interface ReactionMixin {
|
|
655
|
-
reactions: ReadonlyArray<Reaction>
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
interface OpaqueNodeMixin extends BaseNodeMixin, SceneNodeMixin, ExportMixin {
|
|
659
|
-
readonly absoluteTransform: Transform
|
|
660
|
-
relativeTransform: Transform
|
|
661
|
-
x: number
|
|
662
|
-
y: number
|
|
663
|
-
readonly width: number
|
|
664
|
-
readonly height: number
|
|
665
|
-
readonly bound: Bound
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
interface MinimalBlendMixin {
|
|
669
|
-
opacity: number
|
|
670
|
-
blendMode: BlendMode
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
interface MinimalStrokesMixin {
|
|
674
|
-
strokes: ReadonlyArray<Paint>
|
|
675
|
-
strokeStyleId: string
|
|
676
|
-
strokeWeight: number
|
|
677
|
-
strokeJoin: StrokeJoin
|
|
678
|
-
strokeAlign: StrokeAlign
|
|
679
|
-
strokeStyle: StrokeStyle
|
|
680
|
-
strokeCap: StrokeCap
|
|
681
|
-
strokeDashes: ReadonlyArray<number>
|
|
682
|
-
dashCap: DashCap
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
interface MinimalFillsMixin {
|
|
686
|
-
fills: ReadonlyArray<Paint>
|
|
687
|
-
fillStyleId: string
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
691
|
-
// Nodes
|
|
692
|
-
|
|
693
|
-
interface DocumentNode extends ChildrenMixin<PageNode> {
|
|
694
|
-
readonly type: 'DOCUMENT'
|
|
695
|
-
currentPage: PageNode
|
|
696
|
-
name: string
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
interface PageNode
|
|
700
|
-
extends BaseNodeMixin,
|
|
701
|
-
ChildrenMixin<SceneNode> {
|
|
702
|
-
readonly type: 'PAGE'
|
|
703
|
-
|
|
704
|
-
selection: ReadonlyArray<SceneNode>
|
|
705
|
-
clone(): PageNode
|
|
706
|
-
/**
|
|
707
|
-
* 选中所有图层
|
|
708
|
-
*/
|
|
709
|
-
selectAll() : void
|
|
710
|
-
/**
|
|
711
|
-
* 背景颜色
|
|
712
|
-
*/
|
|
713
|
-
bgColor: RGBA
|
|
714
|
-
/**
|
|
715
|
-
* 原型所有的flow
|
|
716
|
-
*/
|
|
717
|
-
readonly flowStartingPoints: FlowStartingPoint[]
|
|
718
|
-
/**
|
|
719
|
-
* 标签,默认'NONE'
|
|
720
|
-
*/
|
|
721
|
-
label:'NONE' | 'BLUE' | 'GREEN' | 'RED' | 'YELLOW' | 'PURPLE' | 'GRAY'
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
interface FrameNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
725
|
-
readonly type: 'FRAME'
|
|
726
|
-
clone(): FrameNode
|
|
727
|
-
resizeToFit(): void
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
interface GroupNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin {
|
|
731
|
-
readonly type: 'GROUP'
|
|
732
|
-
clone(): GroupNode
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
interface RectangleNode
|
|
736
|
-
extends DefaultShapeMixin,
|
|
737
|
-
ConstraintMixin,
|
|
738
|
-
CornerMixin,
|
|
739
|
-
RectangleStrokeWeightMixin,
|
|
740
|
-
RectangleCornerMixin {
|
|
741
|
-
readonly type: 'RECTANGLE'
|
|
742
|
-
clone(): RectangleNode
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
interface LineNode extends DefaultShapeMixin, ConstraintMixin {
|
|
746
|
-
readonly type: 'LINE'
|
|
747
|
-
clone(): LineNode
|
|
748
|
-
readonly height: number
|
|
749
|
-
leftStrokeCap: StrokeCap
|
|
750
|
-
rightStrokeCap: StrokeCap
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
interface EllipseNode extends DefaultShapeMixin, ConstraintMixin {
|
|
754
|
-
readonly type: 'ELLIPSE'
|
|
755
|
-
clone(): EllipseNode
|
|
756
|
-
arcData: ArcData
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
interface PolygonNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
|
|
760
|
-
readonly type: 'POLYGON'
|
|
761
|
-
pointCount: number
|
|
762
|
-
clone(): PolygonNode
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
interface StarNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
|
|
766
|
-
readonly type: 'STAR'
|
|
767
|
-
pointCount: number
|
|
768
|
-
innerRadius: number
|
|
769
|
-
clone(): StarNode
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// interface VectorPath {
|
|
773
|
-
// readonly id: number
|
|
774
|
-
// readonly nodeIds: ReadonlyArray<number>
|
|
775
|
-
// }
|
|
776
|
-
type VectorPath = number[]
|
|
777
|
-
|
|
778
|
-
type VectorPaths = ReadonlyArray<VectorPath>
|
|
779
|
-
|
|
780
|
-
interface PenNetwork {
|
|
781
|
-
paths: ReadonlyArray<VectorPaths>
|
|
782
|
-
nodes: ReadonlyArray<VectorVertex>
|
|
783
|
-
regions: ReadonlyArray<VectorRegion> | []
|
|
784
|
-
ctrlNodes: ReadonlyArray<VectorCtrl>
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
interface PenPaths {
|
|
788
|
-
windingRule: WindingRule
|
|
789
|
-
data: string
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
interface PenNode extends DefaultShapeMixin, ConstraintMixin, CornerMixin {
|
|
793
|
-
readonly type: 'PEN'
|
|
794
|
-
penNetwork: PenNetwork
|
|
795
|
-
set penPaths(paths: Array<PenPaths>)
|
|
796
|
-
//@ts-ignore
|
|
797
|
-
get penPaths(): PenPaths
|
|
798
|
-
clone(): PenNode
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
interface BooleanOperationNode
|
|
802
|
-
extends DefaultShapeMixin,
|
|
803
|
-
FrameContainerMixin,
|
|
804
|
-
ChildrenMixin,
|
|
805
|
-
CornerMixin {
|
|
806
|
-
readonly type: 'BOOLEAN_OPERATION'
|
|
807
|
-
booleanOperation: 'UNION' | 'INTERSECT' | 'SUBTRACT' | 'EXCLUDE'
|
|
808
|
-
clone(): BooleanOperationNode
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
interface TextRangeStyle {
|
|
812
|
-
fontName: FontName
|
|
813
|
-
fontSize: number
|
|
814
|
-
lineHeight: LineHeight
|
|
815
|
-
textDecoration: TextDecoration
|
|
816
|
-
letterSpacing: LetterSpacing
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
interface TextNode extends DefaultShapeMixin, ConstraintMixin {
|
|
820
|
-
readonly type: 'TEXT'
|
|
821
|
-
characters: string
|
|
822
|
-
readonly hasMissingFont: boolean
|
|
823
|
-
/**
|
|
824
|
-
* @deprecated
|
|
825
|
-
* This attribute is deprecared, please use hyperlinks instead.
|
|
826
|
-
*/
|
|
827
|
-
readonly superlinks: Array<Superlink>
|
|
828
|
-
readonly hyperlinks: Array<HyperlinkWithRange>
|
|
829
|
-
textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'
|
|
830
|
-
textAlignVertical: 'TOP' | 'CENTER' | 'BOTTOM'
|
|
831
|
-
textAutoResize: 'NONE' | 'WIDTH_AND_HEIGHT' | 'HEIGHT'
|
|
832
|
-
paragraphSpacing: number
|
|
833
|
-
readonly textStyles: ReadonlyArray<TextSegStyle>
|
|
834
|
-
readonly listStyles: ReadonlyArray<ListStyle>
|
|
835
|
-
clone(): TextNode
|
|
836
|
-
|
|
837
|
-
insertCharacters(start: number, characters: string): void
|
|
838
|
-
deleteCharacters(start: number, end: number): void
|
|
839
|
-
|
|
840
|
-
setRangeFontSize(start: number, end: number, fontSize: number): void
|
|
841
|
-
setRangeTextDecoration(
|
|
842
|
-
start: number,
|
|
843
|
-
end: number,
|
|
844
|
-
decoration: TextDecoration
|
|
845
|
-
): void
|
|
846
|
-
setRangeFontName(start: number, end: number, fontName: FontName): void
|
|
847
|
-
setRangeLetterSpacing(
|
|
848
|
-
start: number,
|
|
849
|
-
end: number,
|
|
850
|
-
value: LetterSpacing
|
|
851
|
-
): void
|
|
852
|
-
setRangeLineHeight(start: number, end: number, value: LineHeight): void
|
|
853
|
-
setRangeFills(start: number, end: number, paints: Paint[]): void
|
|
854
|
-
/**
|
|
855
|
-
* @deprecated
|
|
856
|
-
* This function is deprecared, please use setRangeHyperLink instead.
|
|
857
|
-
*/
|
|
858
|
-
setRangeSuperLink(start: number, end: number, link: string | null): void
|
|
859
|
-
setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
|
|
860
|
-
setRangeTextCase(start: number, end: number, textCase: TextCase): void
|
|
861
|
-
setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
865
|
-
readonly type: 'COMPONENT'
|
|
866
|
-
readonly variantProperties: Array<Record<string, string>>
|
|
867
|
-
description: string
|
|
868
|
-
setVariantPropertyValues(property: Record<string, string>): void
|
|
869
|
-
clone(): ComponentNode
|
|
870
|
-
createInstance(): InstanceNode
|
|
871
|
-
resizeToFit(): void
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
875
|
-
readonly type: 'COMPONENT_SET'
|
|
876
|
-
readonly componentPropertyDefinitions: Array<Record<string, Array<string> | string>>
|
|
877
|
-
clone(): ComponentSetNode
|
|
878
|
-
createVariantComponent(): void
|
|
879
|
-
createVariantProperties(properties: Array<string>): void
|
|
880
|
-
editVariantProperties(properties: Record<string, string>): void
|
|
881
|
-
editVariantPropertyValues(properties: Record<string, { oldValue: string, newValue: string }>): void
|
|
882
|
-
deleteVariantProperty(property: string): void
|
|
883
|
-
resizeToFit(): void
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
interface InstanceNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
887
|
-
readonly type: 'INSTANCE'
|
|
888
|
-
readonly variantProperties: Array<Record<string, string>>
|
|
889
|
-
setVariantPropertyValues(property: Record<string, string>): void
|
|
890
|
-
clone(): InstanceNode
|
|
891
|
-
/**
|
|
892
|
-
* this is an async func
|
|
893
|
-
*/
|
|
894
|
-
swapComponent(): void
|
|
895
|
-
detachInstance(): InstanceNode
|
|
896
|
-
mainComponent: ComponentNode | null
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
interface SliceNode extends BaseNodeMixin, LayoutMixin, ConstraintMixin, SceneNodeMixin, ExportMixin {
|
|
900
|
-
readonly type: 'SLICE'
|
|
901
|
-
clone(): SliceNode
|
|
902
|
-
isPreserveRatio: boolean
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
interface ConnectorNode extends OpaqueNodeMixin, Pick<MinimalBlendMixin, 'opacity'>, Omit<MinimalStrokesMixin, 'strokeAlign'> {
|
|
906
|
-
readonly type: 'CONNECTOR'
|
|
907
|
-
createText(): TextSublayerNode
|
|
908
|
-
readonly text: TextSublayerNode | null
|
|
909
|
-
cornerRadius?: number
|
|
910
|
-
connectorStart: ConnectorEndpoint
|
|
911
|
-
connectorEnd: ConnectorEndpoint
|
|
912
|
-
connectorStartStrokeCap: ConnectorStrokeCap
|
|
913
|
-
connectorEndStrokeCap: ConnectorStrokeCap
|
|
914
|
-
readonly strokeAlign: 'CENTER'
|
|
915
|
-
clone(): ConnectorNode
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
interface TextSublayerNode extends MinimalFillsMixin {
|
|
919
|
-
readonly id: string
|
|
920
|
-
readonly hasMissingFont: boolean
|
|
921
|
-
readonly textAlignHorizontal: 'CENTER'
|
|
922
|
-
readonly textAlignVertical: 'CENTER'
|
|
923
|
-
readonly textAutoResize: 'WIDTH_AND_HEIGHT'
|
|
924
|
-
readonly hyperlinks: Array<HyperlinkWithRange>
|
|
925
|
-
|
|
926
|
-
readonly textStyles: ReadonlyArray<TextSegStyle>
|
|
927
|
-
|
|
928
|
-
paragraphSpacing: number
|
|
929
|
-
|
|
930
|
-
characters: string
|
|
931
|
-
insertCharacters(start: number, characters: string): void
|
|
932
|
-
deleteCharacters(start: number, end: number): void
|
|
933
|
-
|
|
934
|
-
setRangeFontSize(start: number, end: number, fontSize: number): void
|
|
935
|
-
setRangeTextDecoration(
|
|
936
|
-
start: number,
|
|
937
|
-
end: number,
|
|
938
|
-
decoration: TextDecoration
|
|
939
|
-
): void
|
|
940
|
-
setRangeFontName(start: number, end: number, fontName: FontName): void
|
|
941
|
-
setRangeLetterSpacing(
|
|
942
|
-
start: number,
|
|
943
|
-
end: number,
|
|
944
|
-
value: LetterSpacing
|
|
945
|
-
): void
|
|
946
|
-
setRangeLineHeight(start: number, end: number, value: LineHeight): void
|
|
947
|
-
setRangeFills(start: number, end: number, paints: Paint[]): void
|
|
948
|
-
setRangeHyperLink(start: number, end: number, hyperlink: Hyperlink | null): void
|
|
949
|
-
setRangeTextCase(start: number, end: number, textCase: TextCase): void
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
interface CreateStyleConfig {
|
|
954
|
-
name: string;
|
|
955
|
-
/**
|
|
956
|
-
* layerId
|
|
957
|
-
*/
|
|
958
|
-
id: string;
|
|
959
|
-
description?: string;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
interface FlowStartingPoint {
|
|
963
|
-
name: string
|
|
964
|
-
id: string
|
|
965
|
-
flowId: string
|
|
966
|
-
description: string
|
|
967
|
-
}
|
|
968
|
-
interface Reaction {
|
|
969
|
-
readonly trigger: Trigger;
|
|
970
|
-
readonly action?: Action;
|
|
971
|
-
}
|
|
972
|
-
interface Action {
|
|
973
|
-
readonly type: ActionType;
|
|
974
|
-
readonly destinationId: string;
|
|
975
|
-
readonly navigation: Navigation;
|
|
976
|
-
readonly transition: Transition;
|
|
977
|
-
readonly url: string;
|
|
978
|
-
readonly scrollToXOffset?: number;
|
|
979
|
-
readonly scrollToYOffset?: number;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
type ActionType = 'BACK' | 'NODE'| 'URL'| 'CLOSE'| 'NONE';
|
|
983
|
-
|
|
984
|
-
type Navigation = 'NAVIGATE' | 'OVERLAY' | 'SWAP_OVERLAY' | 'SCROLL_TO';
|
|
985
|
-
|
|
986
|
-
interface Transition {
|
|
987
|
-
readonly type: TransitionType;
|
|
988
|
-
readonly duration: number;
|
|
989
|
-
readonly direction: TransitionDirection;
|
|
990
|
-
readonly easing: Easing;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
type TransitionType = 'TANS_NONE' | 'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE' | 'MOVE_IN' | 'MOVE_OUT' | 'PUSH' | 'SLIDE_IN' | 'SLIDE_OUT' | 'DISPLACE'
|
|
994
|
-
|
|
995
|
-
type TransitionDirection = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
|
|
996
|
-
interface Easing{
|
|
997
|
-
readonly type: EasingType;
|
|
998
|
-
readonly easingFunctionCubicBezier: {
|
|
999
|
-
x1: number;
|
|
1000
|
-
x2: number;
|
|
1001
|
-
y1: number;
|
|
1002
|
-
y2: number;
|
|
1003
|
-
};
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
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'
|
|
1007
|
-
interface Trigger{
|
|
1008
|
-
readonly type: TriggerType;
|
|
1009
|
-
readonly delay: number;
|
|
1010
|
-
}
|
|
1011
|
-
type TriggerType = 'ON_CLICK' | 'ON_DRAG' | 'ON_HOVER' | 'ON_PRESS' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_DOWN' | 'MOUSE_UP' | 'AFTER_DELAY'
|
|
1012
|
-
|
|
1013
|
-
interface ArcData {
|
|
1014
|
-
/**
|
|
1015
|
-
* 起点弧度
|
|
1016
|
-
*/
|
|
1017
|
-
startingAngle: number
|
|
1018
|
-
/**
|
|
1019
|
-
* 终点弧度
|
|
1020
|
-
*/
|
|
1021
|
-
endingAngle?: number
|
|
1022
|
-
/**
|
|
1023
|
-
* 内径
|
|
1024
|
-
*/
|
|
1025
|
-
innerRadius: number
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
interface PluginDrop {
|
|
1029
|
-
clientX: number
|
|
1030
|
-
clientY: number
|
|
1031
|
-
dropMetadata?: any
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
interface DropEvent {
|
|
1035
|
-
x: number
|
|
1036
|
-
y: number
|
|
1037
|
-
absoluteX: number
|
|
1038
|
-
absoluteY: number
|
|
1039
|
-
dropMetadata?: any
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
type BaseNode = DocumentNode | PageNode | SceneNode
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* 画布节点
|
|
1046
|
-
*/
|
|
1047
|
-
type SceneNode =
|
|
1048
|
-
| GroupNode
|
|
1049
|
-
| FrameNode
|
|
1050
|
-
| PenNode
|
|
1051
|
-
| StarNode
|
|
1052
|
-
| LineNode
|
|
1053
|
-
| EllipseNode
|
|
1054
|
-
| PolygonNode
|
|
1055
|
-
| RectangleNode
|
|
1056
|
-
| TextNode
|
|
1057
|
-
| ComponentNode
|
|
1058
|
-
| ComponentSetNode
|
|
1059
|
-
| InstanceNode
|
|
1060
|
-
| BooleanOperationNode
|
|
1061
|
-
| SliceNode
|
|
1062
|
-
| ConnectorNode
|
|
1063
|
-
|
|
1064
|
-
type NodeType =
|
|
1065
|
-
| 'DOCUMENT'
|
|
1066
|
-
| 'PAGE'
|
|
1067
|
-
| 'GROUP'
|
|
1068
|
-
| 'FRAME'
|
|
1069
|
-
| 'RECTANGLE'
|
|
1070
|
-
| 'TEXT'
|
|
1071
|
-
| 'LINE'
|
|
1072
|
-
| 'ELLIPSE'
|
|
1073
|
-
| 'POLYGON'
|
|
1074
|
-
| 'STAR'
|
|
1075
|
-
| 'PEN'
|
|
1076
|
-
| 'COMPONENT'
|
|
1077
|
-
| 'COMPONENT_SET'
|
|
1078
|
-
| 'INSTANCE'
|
|
1079
|
-
| 'BOOLEAN_OPERATION'
|
|
1080
|
-
| 'SLICE'
|
|
1081
|
-
| 'CONNECTOR'
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
declare global {
|
|
1085
|
-
const mastergo: PluginAPI
|
|
1086
|
-
const mg: PluginAPI
|
|
1087
|
-
const console: Console
|
|
1088
|
-
const __html__: string
|
|
1089
|
-
|
|
1090
|
-
function setTimeout(callback: Function, timeout: number): number
|
|
1091
|
-
function clearTimeout(timeoutID: number): void
|
|
1092
|
-
function setInterval(callback: Function, timeout: number): number
|
|
1093
|
-
function clearInterval(timeoutID: number): void
|
|
1094
|
-
function requestAnimationFrame(cb: (ts: number) => void): number
|
|
1095
|
-
function cancelAnimationFrame(requestID: number): void
|
|
1096
|
-
|
|
1097
|
-
interface Console {
|
|
1098
|
-
log(message?: any, ...optionalParams: any[]): void
|
|
1099
|
-
error(message?: any, ...optionalParams: any[]): void
|
|
1100
|
-
assert(condition?: boolean, message?: string, ...data: any[]): void
|
|
1101
|
-
info(message?: any, ...optionalParams: any[]): void
|
|
1102
|
-
warn(message?: any, ...optionalParams: any[]): void
|
|
1103
|
-
clear(): void
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
interface Image {
|
|
1107
|
-
readonly href: string
|
|
1108
|
-
getBytesAsync(): Promise<Uint8Array>
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
enum LinkFlagEnum {
|
|
1112
|
-
CURRPAGE = 'currPage',
|
|
1113
|
-
OTHERPAGE = 'otherPage',
|
|
1114
|
-
PROTOTYPE = 'prototype',
|
|
1115
|
-
OUTFILE = 'outFile',
|
|
1116
|
-
OWNWEBSITE = 'ownWebsite',
|
|
1117
|
-
OTHERLINK = 'otherLink',
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
interface Superlink {
|
|
1121
|
-
start: number
|
|
1122
|
-
end: number
|
|
1123
|
-
superlink: {
|
|
1124
|
-
layerId?: string
|
|
1125
|
-
link: string
|
|
1126
|
-
linkFlag: LinkFlagEnum
|
|
1127
|
-
pageId: string
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
interface Hyperlink {
|
|
1132
|
-
type: 'PAGE' | 'NODE' | 'URL',
|
|
1133
|
-
value: string
|
|
1134
|
-
}
|
|
1135
|
-
interface HyperlinkWithRange {
|
|
1136
|
-
start: number
|
|
1137
|
-
end: number
|
|
1138
|
-
hyperlink: Hyperlink
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
28
|
type PluginEventType = 'selectionchange' | 'currentpagechange' | 'close' | 'themechange' | 'drop' | 'run'
|
|
1142
29
|
type ThemeColor = 'dark' | 'light'
|
|
1143
30
|
|
|
@@ -1216,6 +103,14 @@ declare global {
|
|
|
1216
103
|
createImage(imageData: Uint8Array): Promise<Image>
|
|
1217
104
|
getImageByHref(href: string): Image
|
|
1218
105
|
|
|
106
|
+
/**
|
|
107
|
+
* 订阅团队库数据
|
|
108
|
+
*/
|
|
109
|
+
teamLibrary: TeamLibrary,
|
|
110
|
+
importComponentByKeyAsync(ukey: string): Promise<ComponentNode>,
|
|
111
|
+
importComponentSetByKeyAsync(ukey: string): Promise<ComponentSetNode>,
|
|
112
|
+
importStyleByKeyAsync(ukey: string): Promise<BaseStyle>,
|
|
113
|
+
|
|
1219
114
|
hexToRGBA(hex: string): RGBA
|
|
1220
115
|
RGBAToHex(rgba: RGBA): string
|
|
1221
116
|
}
|
|
@@ -1245,6 +140,8 @@ declare global {
|
|
|
1245
140
|
width?: number
|
|
1246
141
|
height?: number
|
|
1247
142
|
visible?: boolean
|
|
143
|
+
x?: number | string
|
|
144
|
+
y?: number | string
|
|
1248
145
|
}
|
|
1249
146
|
|
|
1250
147
|
interface ExportSettingsConstraints {
|
|
@@ -1262,7 +159,7 @@ declare global {
|
|
|
1262
159
|
|
|
1263
160
|
interface ExportMixin {
|
|
1264
161
|
exportSettings: ReadonlyArray<ExportSettings>
|
|
1265
|
-
export(settings?: ExportSettings):
|
|
162
|
+
export(settings?: ExportSettings): Uint8Array | string // Defaults to PNG format
|
|
1266
163
|
}
|
|
1267
164
|
|
|
1268
165
|
interface NotifyOptions {
|
|
@@ -1279,18 +176,20 @@ declare global {
|
|
|
1279
176
|
postMessage(pluginMessage: any, origin?: string): void
|
|
1280
177
|
onmessage: ((pluginMessage: any, origin: string) => void) | undefined
|
|
1281
178
|
}
|
|
1282
|
-
|
|
1283
|
-
/// /////////////////////////////////////////////////////////////////////////////
|
|
1284
|
-
// Styles
|
|
179
|
+
type PublishStatus = 'UNPUBLISHED' | 'CURRENT' | 'CHANGED'
|
|
1285
180
|
interface PublishableMixin {
|
|
1286
181
|
description: string
|
|
1287
182
|
/**
|
|
1288
|
-
*
|
|
183
|
+
* 是否为团队库组件/样式
|
|
1289
184
|
*/
|
|
1290
185
|
readonly isExternal: boolean
|
|
1291
186
|
readonly ukey: string
|
|
187
|
+
readonly publishStatus: PublishStatus
|
|
1292
188
|
}
|
|
1293
189
|
|
|
190
|
+
/// /////////////////////////////////////////////////////////////////////////////
|
|
191
|
+
// Styles
|
|
192
|
+
|
|
1294
193
|
type StyleType = 'PAINT' | 'TEXT' | 'EFFECT' | 'GRID'
|
|
1295
194
|
|
|
1296
195
|
interface BaseStyle extends PublishableMixin {
|
|
@@ -1340,12 +239,11 @@ declare global {
|
|
|
1340
239
|
interface TextStyle extends BaseStyle {
|
|
1341
240
|
type: 'TEXT'
|
|
1342
241
|
decoration: TextDecoration
|
|
1343
|
-
description: string
|
|
1344
242
|
fontSize: number
|
|
1345
|
-
isExternal: boolean
|
|
1346
243
|
letterSpacing: number
|
|
1347
244
|
letterSpacingUnit: NumValue['unit']
|
|
1348
245
|
textCase: TextCase
|
|
246
|
+
lineHeight: LineHeight
|
|
1349
247
|
}
|
|
1350
248
|
|
|
1351
249
|
interface FontAlias {
|
|
@@ -1531,7 +429,7 @@ declare global {
|
|
|
1531
429
|
interface BaseNodeMixin {
|
|
1532
430
|
readonly id: string
|
|
1533
431
|
readonly parent: (BaseNode & ChildrenMixin) | void
|
|
1534
|
-
name: string
|
|
432
|
+
name: string
|
|
1535
433
|
removed: boolean
|
|
1536
434
|
remove(): void
|
|
1537
435
|
getPluginData(key: string): string
|
|
@@ -1773,17 +671,29 @@ declare global {
|
|
|
1773
671
|
/// /////////////////////////////////////////////////////////////////////////////
|
|
1774
672
|
// Nodes
|
|
1775
673
|
|
|
1776
|
-
interface DocumentNode
|
|
674
|
+
interface DocumentNode {
|
|
1777
675
|
readonly type: 'DOCUMENT'
|
|
1778
|
-
currentPage: PageNode
|
|
1779
676
|
name: string
|
|
677
|
+
|
|
678
|
+
currentPage: PageNode
|
|
679
|
+
|
|
680
|
+
readonly children: ReadonlyArray<PageNode>
|
|
681
|
+
|
|
682
|
+
findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray<SceneNode>
|
|
683
|
+
findOne(callback: (node: SceneNode) => boolean): SceneNode | null
|
|
1780
684
|
}
|
|
1781
685
|
|
|
1782
686
|
interface PageNode
|
|
1783
|
-
extends
|
|
687
|
+
extends
|
|
1784
688
|
ChildrenMixin<SceneNode> {
|
|
1785
689
|
readonly type: 'PAGE'
|
|
1786
690
|
|
|
691
|
+
readonly id: string
|
|
692
|
+
readonly parent: DocumentNode
|
|
693
|
+
name: string
|
|
694
|
+
removed: boolean
|
|
695
|
+
remove(): void
|
|
696
|
+
|
|
1787
697
|
selection: ReadonlyArray<SceneNode>
|
|
1788
698
|
clone(): PageNode
|
|
1789
699
|
/**
|
|
@@ -1899,6 +809,36 @@ declare global {
|
|
|
1899
809
|
letterSpacing: LetterSpacing
|
|
1900
810
|
}
|
|
1901
811
|
|
|
812
|
+
enum LinkFlagEnum {
|
|
813
|
+
CURRPAGE = 'currPage',
|
|
814
|
+
OTHERPAGE = 'otherPage',
|
|
815
|
+
PROTOTYPE = 'prototype',
|
|
816
|
+
OUTFILE = 'outFile',
|
|
817
|
+
OWNWEBSITE = 'ownWebsite',
|
|
818
|
+
OTHERLINK = 'otherLink',
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface Superlink {
|
|
822
|
+
start: number
|
|
823
|
+
end: number
|
|
824
|
+
superlink: {
|
|
825
|
+
layerId?: string
|
|
826
|
+
link: string
|
|
827
|
+
linkFlag: LinkFlagEnum
|
|
828
|
+
pageId: string
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
interface Hyperlink {
|
|
833
|
+
type: 'PAGE' | 'NODE' | 'URL',
|
|
834
|
+
value: string
|
|
835
|
+
}
|
|
836
|
+
interface HyperlinkWithRange {
|
|
837
|
+
start: number
|
|
838
|
+
end: number
|
|
839
|
+
hyperlink: Hyperlink
|
|
840
|
+
}
|
|
841
|
+
|
|
1902
842
|
interface TextNode extends DefaultShapeMixin, ConstraintMixin {
|
|
1903
843
|
readonly type: 'TEXT'
|
|
1904
844
|
characters: string
|
|
@@ -1936,25 +876,24 @@ declare global {
|
|
|
1936
876
|
setRangeFills(start: number, end: number, paints: Paint[]): void
|
|
1937
877
|
/**
|
|
1938
878
|
* @deprecated
|
|
1939
|
-
* This function is deprecared, please use
|
|
879
|
+
* This function is deprecared, please use setRangeHyperlink instead.
|
|
1940
880
|
*/
|
|
1941
881
|
setRangeSuperLink(start: number, end: number, link: string | null): void
|
|
1942
|
-
|
|
882
|
+
setRangeHyperlink(start: number, end: number, hyperlink: Hyperlink | null): void
|
|
1943
883
|
setRangeTextCase(start: number, end: number, textCase: TextCase): void
|
|
1944
884
|
setRangeListStyle(start: number, end: number, type: 'ORDERED' | 'BULLETED' | 'NONE'): void
|
|
1945
885
|
}
|
|
1946
886
|
|
|
1947
|
-
interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
887
|
+
interface ComponentNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
|
|
1948
888
|
readonly type: 'COMPONENT'
|
|
1949
889
|
readonly variantProperties: Array<Record<string, string>>
|
|
1950
|
-
description: string
|
|
1951
890
|
setVariantPropertyValues(property: Record<string, string>): void
|
|
1952
891
|
clone(): ComponentNode
|
|
1953
892
|
createInstance(): InstanceNode
|
|
1954
893
|
resizeToFit(): void
|
|
1955
894
|
}
|
|
1956
895
|
|
|
1957
|
-
interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin {
|
|
896
|
+
interface ComponentSetNode extends DefaultContainerMixin, GeometryMixin, FrameContainerMixin, RectangleStrokeWeightMixin, PublishableMixin {
|
|
1958
897
|
readonly type: 'COMPONENT_SET'
|
|
1959
898
|
readonly componentPropertyDefinitions: Array<Record<string, Array<string> | string>>
|
|
1960
899
|
clone(): ComponentSetNode
|
|
@@ -2028,7 +967,7 @@ declare global {
|
|
|
2028
967
|
): void
|
|
2029
968
|
setRangeLineHeight(start: number, end: number, value: LineHeight): void
|
|
2030
969
|
setRangeFills(start: number, end: number, paints: Paint[]): void
|
|
2031
|
-
|
|
970
|
+
setRangeHyperlink(start: number, end: number, hyperlink: Hyperlink | null): void
|
|
2032
971
|
setRangeTextCase(start: number, end: number, textCase: TextCase): void
|
|
2033
972
|
}
|
|
2034
973
|
|
|
@@ -2122,6 +1061,34 @@ declare global {
|
|
|
2122
1061
|
dropMetadata?: any
|
|
2123
1062
|
}
|
|
2124
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
|
+
|
|
2125
1092
|
type BaseNode = DocumentNode | PageNode | SceneNode
|
|
2126
1093
|
|
|
2127
1094
|
/**
|
|
@@ -2163,5 +1130,3 @@ declare global {
|
|
|
2163
1130
|
| 'SLICE'
|
|
2164
1131
|
| 'CONNECTOR'
|
|
2165
1132
|
}
|
|
2166
|
-
|
|
2167
|
-
export { }
|