Skip to content

Commit deeec5a

Browse files
Merge pull request #362 from figma/brandonchung/plugin-typings-june-16
Update plugin typings
2 parents c33f1e3 + 3433a62 commit deeec5a

2 files changed

Lines changed: 22 additions & 58 deletions

File tree

plugin-api-standalone.d.ts

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,32 +1078,6 @@ interface PluginAPI {
10781078
* ```
10791079
*/
10801080
createFrame(): FrameNode
1081-
/**
1082-
* Note: This API is only available via `use_figma` in the MCP server
1083-
*
1084-
* Creates a new frame with auto layout already enabled. Both axes default to hug content
1085-
* (`primaryAxisSizingMode = "AUTO"`, `counterAxisSizingMode = "AUTO"`), so children can
1086-
* immediately use `layoutSizingHorizontal/Vertical = "FILL"` after being appended.
1087-
*
1088-
* @remarks
1089-
*
1090-
* Prefer this over `createFrame()` whenever you need an auto-layout parent. Since `layoutMode` is
1091-
* already set, children can use `FILL` sizing immediately after being appended.
1092-
*
1093-
* The default direction is `"HORIZONTAL"`. Pass `"VERTICAL"` for a column layout.
1094-
*
1095-
* ```ts title="Create an auto-layout frame"
1096-
* const row = figma.createAutoLayout()
1097-
* const column = figma.createAutoLayout("VERTICAL")
1098-
*
1099-
* row.itemSpacing = 16
1100-
* row.paddingTop = 24
1101-
* row.paddingBottom = 24
1102-
* row.paddingLeft = 24
1103-
* row.paddingRight = 24
1104-
* ```
1105-
*/
1106-
createAutoLayout(direction?: 'HORIZONTAL' | 'VERTICAL'): FrameNode
11071081
/**
11081082
* Note: This API is only available in Figma Design
11091083
*
@@ -1139,15 +1113,13 @@ interface PluginAPI {
11391113
*/
11401114
createComponentFromNode(node: SceneNode): ComponentNode
11411115
/**
1142-
* Note: This API is only available in Figma Design
1143-
*
11441116
* Creates a new page, appended to the document's list of children.
11451117
*
11461118
* @remarks
11471119
*
11481120
* A page node can be the parent of all types of nodes except for the document node and other page nodes.
11491121
*
1150-
* Files in a Starter team are limited to three pages. When a plugin tries to create more than three pages in a Starter team file, it triggers the following error:
1122+
* Files in a Starter team are limited to three pages in Figma Design files and one page in FigJam files. When a plugin tries to exceed this limit, it triggers the following error:
11511123
*
11521124
* ```text title="Page limit error"
11531125
* The Starter plan only comes with 3 pages. Upgrade to
@@ -5731,6 +5703,11 @@ interface SceneNodeMixin extends ExplicitVariableModesMixin {
57315703
| null
57325704
/**
57335705
* The variables bound to a particular field on this node. Please see the [Working with Variables](https://developers.figma.com/docs/plugins/working-with-variables) guide for how to get and set variable bindings.
5706+
*
5707+
* @remarks
5708+
*
5709+
* On nodes with independent corner radii (e.g. rectangles, frames), a `cornerRadius` binding sets all four corners and appears in `boundVariables` as `topLeftRadius`/`topRightRadius`/`bottomLeftRadius`/`bottomRightRadius` rather than `cornerRadius`; elsewhere it appears as `cornerRadius`.
5710+
*
57345711
*/
57355712
readonly boundVariables?: {
57365713
readonly [field in VariableBindableNodeField]?: VariableAlias
@@ -5843,6 +5820,7 @@ type VariableBindableNodeField =
58435820
| 'paddingTop'
58445821
| 'paddingBottom'
58455822
| 'visible'
5823+
| 'cornerRadius'
58465824
| 'topLeftRadius'
58475825
| 'topRightRadius'
58485826
| 'bottomLeftRadius'
@@ -5906,6 +5884,9 @@ interface ChildrenMixin {
59065884
*
59075885
* As such, this property cannot be assigned to, and the array cannot be modified directly (it wouldn't do anything). Instead, use {@link ChildrenMixin.appendChild}, {@link ChildrenMixin.insertChild} or {@link BaseNodeMixin.remove}.
59085886
*
5887+
* Do not recursively walk the entire document tree by repeatedly reading `children` (for example, a manual DFS/BFS over `node.children`). That pattern is often much slower in large files.
5888+
* Prefer {@link ChildrenMixin.findAllWithCriteria} when you know the target node types, and use {@link ChildrenMixin.findAll} when you need callback-based logic.
5889+
*
59095890
* Note: If you are curious, the reason why inserting children has to be done via API calls is because our internal representation for the layer tree uses [fractional indexing](https://www.figma.com/blog/multiplayer-editing-in-figma/) and {@link ChildrenMixin.insertChild} performs that conversion.
59105891
*/
59115892
readonly children: ReadonlyArray<SceneNode>
@@ -10145,6 +10126,7 @@ interface SlotNode extends DefaultFrameMixin {
1014510126
* - `'BELOW_MIN'`: the slot has fewer children than its configured `minChildren`.
1014610127
* - `'ABOVE_MAX'`: the slot has more children than its configured `maxChildren`.
1014710128
* - `'HAS_NON_PREFERRED'`: the slot contains a child that is not in the property's preferred values, while `allowPreferredValuesOnly` is `true`.
10129+
*
1014810130
*/
1014910131
readonly limitViolations: Array<'BELOW_MIN' | 'ABOVE_MAX' | 'HAS_NON_PREFERRED'>
1015010132
}

plugin-api.d.ts

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,32 +1078,6 @@ interface PluginAPI {
10781078
* ```
10791079
*/
10801080
createFrame(): FrameNode
1081-
/**
1082-
* Note: This API is only available via `use_figma` in the MCP server
1083-
*
1084-
* Creates a new frame with auto layout already enabled. Both axes default to hug content
1085-
* (`primaryAxisSizingMode = "AUTO"`, `counterAxisSizingMode = "AUTO"`), so children can
1086-
* immediately use `layoutSizingHorizontal/Vertical = "FILL"` after being appended.
1087-
*
1088-
* @remarks
1089-
*
1090-
* Prefer this over `createFrame()` whenever you need an auto-layout parent. Since `layoutMode` is
1091-
* already set, children can use `FILL` sizing immediately after being appended.
1092-
*
1093-
* The default direction is `"HORIZONTAL"`. Pass `"VERTICAL"` for a column layout.
1094-
*
1095-
* ```ts title="Create an auto-layout frame"
1096-
* const row = figma.createAutoLayout()
1097-
* const column = figma.createAutoLayout("VERTICAL")
1098-
*
1099-
* row.itemSpacing = 16
1100-
* row.paddingTop = 24
1101-
* row.paddingBottom = 24
1102-
* row.paddingLeft = 24
1103-
* row.paddingRight = 24
1104-
* ```
1105-
*/
1106-
createAutoLayout(direction?: 'HORIZONTAL' | 'VERTICAL'): FrameNode
11071081
/**
11081082
* Note: This API is only available in Figma Design
11091083
*
@@ -1139,15 +1113,13 @@ interface PluginAPI {
11391113
*/
11401114
createComponentFromNode(node: SceneNode): ComponentNode
11411115
/**
1142-
* Note: This API is only available in Figma Design
1143-
*
11441116
* Creates a new page, appended to the document's list of children.
11451117
*
11461118
* @remarks
11471119
*
11481120
* A page node can be the parent of all types of nodes except for the document node and other page nodes.
11491121
*
1150-
* Files in a Starter team are limited to three pages. When a plugin tries to create more than three pages in a Starter team file, it triggers the following error:
1122+
* Files in a Starter team are limited to three pages in Figma Design files and one page in FigJam files. When a plugin tries to exceed this limit, it triggers the following error:
11511123
*
11521124
* ```text title="Page limit error"
11531125
* The Starter plan only comes with 3 pages. Upgrade to
@@ -5731,6 +5703,11 @@ interface SceneNodeMixin extends ExplicitVariableModesMixin {
57315703
| null
57325704
/**
57335705
* The variables bound to a particular field on this node. Please see the [Working with Variables](https://developers.figma.com/docs/plugins/working-with-variables) guide for how to get and set variable bindings.
5706+
*
5707+
* @remarks
5708+
*
5709+
* On nodes with independent corner radii (e.g. rectangles, frames), a `cornerRadius` binding sets all four corners and appears in `boundVariables` as `topLeftRadius`/`topRightRadius`/`bottomLeftRadius`/`bottomRightRadius` rather than `cornerRadius`; elsewhere it appears as `cornerRadius`.
5710+
*
57345711
*/
57355712
readonly boundVariables?: {
57365713
readonly [field in VariableBindableNodeField]?: VariableAlias
@@ -5843,6 +5820,7 @@ type VariableBindableNodeField =
58435820
| 'paddingTop'
58445821
| 'paddingBottom'
58455822
| 'visible'
5823+
| 'cornerRadius'
58465824
| 'topLeftRadius'
58475825
| 'topRightRadius'
58485826
| 'bottomLeftRadius'
@@ -5906,6 +5884,9 @@ interface ChildrenMixin {
59065884
*
59075885
* As such, this property cannot be assigned to, and the array cannot be modified directly (it wouldn't do anything). Instead, use {@link ChildrenMixin.appendChild}, {@link ChildrenMixin.insertChild} or {@link BaseNodeMixin.remove}.
59085886
*
5887+
* Do not recursively walk the entire document tree by repeatedly reading `children` (for example, a manual DFS/BFS over `node.children`). That pattern is often much slower in large files.
5888+
* Prefer {@link ChildrenMixin.findAllWithCriteria} when you know the target node types, and use {@link ChildrenMixin.findAll} when you need callback-based logic.
5889+
*
59095890
* Note: If you are curious, the reason why inserting children has to be done via API calls is because our internal representation for the layer tree uses [fractional indexing](https://www.figma.com/blog/multiplayer-editing-in-figma/) and {@link ChildrenMixin.insertChild} performs that conversion.
59105891
*/
59115892
readonly children: ReadonlyArray<SceneNode>
@@ -10145,6 +10126,7 @@ interface SlotNode extends DefaultFrameMixin {
1014510126
* - `'BELOW_MIN'`: the slot has fewer children than its configured `minChildren`.
1014610127
* - `'ABOVE_MAX'`: the slot has more children than its configured `maxChildren`.
1014710128
* - `'HAS_NON_PREFERRED'`: the slot contains a child that is not in the property's preferred values, while `allowPreferredValuesOnly` is `true`.
10129+
*
1014810130
*/
1014910131
readonly limitViolations: Array<'BELOW_MIN' | 'ABOVE_MAX' | 'HAS_NON_PREFERRED'>
1015010132
}

0 commit comments

Comments
 (0)