Skip to content

Commit

Permalink
Merge pull request #257 from figma/rohit/plugin-typings-update
Browse files Browse the repository at this point in the history
Add prototyping and constants types
  • Loading branch information
rohitchouhan8 authored Sep 14, 2023
2 parents 2f26217 + 1694429 commit b17d377
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions plugin-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,12 @@ interface UtilAPI {
rgba(color: string | RGB | RGBA): RGBA
solidPaint(color: string | RGB | RGBA, overrides?: Partial<SolidPaint>): SolidPaint
}
interface ColorPalette {
[key: string]: string
}
interface ConstantsAPI {
colors: {
[key: string]: ColorPalette
}
figJamBase: ColorPalette
figJamBaseLight: ColorPalette
}
declare type CodegenEvent = {
node: SceneNode
Expand Down Expand Up @@ -668,9 +670,6 @@ interface RGB {
readonly g: number
readonly b: number
}
interface ColorPalette {
[key: string]: string
}
interface RGBA {
readonly r: number
readonly g: number
Expand Down Expand Up @@ -1165,9 +1164,45 @@ interface StyledTextSegment {
}
}
declare type Reaction = {
action: Action | null
action?: Action
actions?: Action[]
trigger: Trigger | null
}
declare type VariableDataType =
| 'BOOLEAN'
| 'FLOAT'
| 'STRING'
| 'VARIABLE_ALIAS'
| 'COLOR'
| 'EXPRESSION'
declare type ExpressionFunction =
| 'ADDITION'
| 'SUBTRACTION'
| 'MULTIPLICATION'
| 'DIVISION'
| 'EQUALS'
| 'NOT_EQUAL'
| 'LESS_THAN'
| 'LESS_THAN_OR_EQUAL'
| 'GREATER_THAN'
| 'GREATER_THAN_OR_EQUAL'
| 'AND'
| 'OR'
| 'VAR_MODE_LOOKUP'
interface Expression {
expressionFunction: ExpressionFunction
expressionArguments: VariableData[]
}
declare type VariableValueWithExpression = VariableValue | Expression
interface VariableData {
type?: VariableDataType
resolvedType?: VariableResolvedDataType
value?: VariableValueWithExpression
}
declare type ConditionalBlock = {
condition?: VariableData
actions: Action[]
}
declare type Action =
| {
readonly type: 'BACK' | 'CLOSE'
Expand Down Expand Up @@ -1199,6 +1234,15 @@ declare type Action =
readonly mediaAction: 'SKIP_TO'
readonly newTimestamp: number
}
| {
readonly type: 'SET_VARIABLE'
readonly variableId: string | null
readonly variableValue?: VariableData
}
| {
readonly type: 'CONDITIONAL'
readonly conditionalBlocks: ConditionalBlock[]
}
| {
readonly type: 'NODE'
readonly destinationId: string | null
Expand Down

0 comments on commit b17d377

Please sign in to comment.