Skip to content

Commit

Permalink
Add types for Slides PluginAPI Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
kauffecup committed Sep 24, 2024
1 parent 2bd9d2d commit c8021c1
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 3 deletions.
84 changes: 82 additions & 2 deletions plugin-api-standalone.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ interface PluginAPI {
node: FrameNode | ComponentNode | ComponentSetNode | SectionNode | null,
): Promise<void>
loadAllPagesAsync(): Promise<void>
getSlideGrid(): Array<Array<SlideNode>>
setSlideGrid(slideGrid: Array<Array<SlideNode>>): void
}
interface VersionHistoryResult {
id: string
Expand Down Expand Up @@ -430,6 +432,7 @@ interface ViewportAPI {
zoom: number
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
readonly bounds: Rect
slidesMode: 'grid' | 'single-slide'
}
interface TextReviewAPI {
requestToBeEnabledAsync(): Promise<void>
Expand Down Expand Up @@ -1852,6 +1855,7 @@ interface Measurement {
side: MeasurementSide
}
offset: MeasurementOffset
freeText: string
}
declare type MeasurementSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT'
declare type MeasurementOffset =
Expand All @@ -1877,12 +1881,14 @@ interface MeasurementsMixin {
},
options?: {
offset?: MeasurementOffset
freeText?: string
},
): Measurement
editMeasurement(
id: string,
newValue: {
offset: MeasurementOffset
offset?: MeasurementOffset
freeText?: string
},
): Measurement
deleteMeasurement(id: string): void
Expand Down Expand Up @@ -2049,6 +2055,7 @@ interface PageNode
on(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
once(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
off(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
focusedSlide?: SlideNode | null
}
interface FrameNode extends DefaultFrameMixin {
readonly type: 'FRAME'
Expand Down Expand Up @@ -2475,6 +2482,79 @@ interface SectionNode extends ChildrenMixin, MinimalFillsMixin, OpaqueNodeMixin,
clone(): SectionNode
resizeWithoutConstraints(width: number, height: number): void
}
interface SlideNode
extends BaseNodeMixin,
BlendMixin,
ChildrenMixin,
ExportMixin,
GeometryMixin,
AutoLayoutMixin,
IndividualStrokesMixin,
AnnotationsMixin,
DimensionAndPositionMixin,
ContainerMixin,
ConstraintMixin {
readonly type: 'SLIDE'
clone(): SlideNode
getSlideTransition(): SlideTransition
setSlideTransition(transition: SlideTransition): void
layoutGrids: ReadonlyArray<LayoutGrid>
gridStyleId: string
setGridStyleIdAsync(styleId: string): Promise<void>
guides: ReadonlyArray<Guide>
inferredAutoLayout: InferredAutoLayoutResult | null
}
interface SlideRowNode extends BaseNodeMixin, ChildrenMixin {
readonly type: 'SLIDE_ROW'
clone(): SlideRowNode
}
interface SlideGridNode extends BaseNodeMixin, ChildrenMixin {
readonly type: 'SLIDE_GRID'
}
interface InteractiveSlideElementNode extends BaseNodeMixin {
readonly type: 'INTERACTIVE_SLIDE_ELEMENT'
readonly interactiveSlideElementType: 'POLL' | 'EMBED' | 'FACEPILE' | 'ALIGNMENT' | 'YOUTUBE'
}
interface SlideTransition {
readonly type:
| 'NONE'
| 'DISSOLVE'
| 'SLIDE_FROM_LEFT'
| 'SLIDE_FROM_RIGHT'
| 'SLIDE_FROM_BOTTOM'
| 'SLIDE_FROM_TOP'
| 'PUSH_FROM_LEFT'
| 'PUSH_FROM_RIGHT'
| 'PUSH_FROM_BOTTOM'
| 'PUSH_FROM_TOP'
| 'MOVE_FROM_LEFT'
| 'MOVE_FROM_RIGHT'
| 'MOVE_FROM_TOP'
| 'MOVE_FROM_BOTTOM'
| 'SLIDE_OUT_TO_LEFT'
| 'SLIDE_OUT_TO_RIGHT'
| 'SLIDE_OUT_TO_TOP'
| 'SLIDE_OUT_TO_BOTTOM'
| 'MOVE_OUT_TO_LEFT'
| 'MOVE_OUT_TO_RIGHT'
| 'MOVE_OUT_TO_TOP'
| 'MOVE_OUT_TO_BOTTOM'
| 'SMART_ANIMATE'
readonly duration: number
readonly easing:
| 'IN_CUBIC'
| 'OUT_CUBIC'
| 'INOUT_CUBIC'
| 'LINEAR'
| 'GENTLE_SPRING'
| 'SPRING_PRESET_ONE'
| 'SPRING_PRESET_TWO'
| 'SPRING_PRESET_THREE'
readonly trigger: {
readonly type: 'ON_CLICK' | 'AFTER_DELAY'
readonly delay?: number
}
}
declare type BaseNode = DocumentNode | PageNode | SceneNode
declare type SceneNode =
| SliceNode
Expand Down Expand Up @@ -2604,4 +2684,4 @@ interface FindAllCriteria<T extends NodeType[]> {
}

// prettier-ignore
export { ArgFreeEventType, PluginAPI, VersionHistoryResult, VariablesAPI, LibraryVariableCollection, LibraryVariable, TeamLibraryAPI, PaymentStatus, PaymentsAPI, ClientStorageAPI, NotificationOptions, NotifyDequeueReason, NotificationHandler, ShowUIOptions, UIPostMessageOptions, OnMessageProperties, MessageEventHandler, UIAPI, UtilAPI, ColorPalette, ColorPalettes, ConstantsAPI, CodegenEvent, CodegenPreferences, CodegenPreferencesEvent, CodegenResult, CodegenAPI, DevResource, DevResourceWithNodeId, LinkPreviewEvent, PlainTextElement, LinkPreviewResult, AuthEvent, DevResourceOpenEvent, AuthResult, VSCodeAPI, DevResourcesAPI, TimerAPI, ViewportAPI, TextReviewAPI, ParameterValues, SuggestionResults, ParameterInputEvent, ParametersAPI, RunParametersEvent, OpenDevResourcesEvent, RunEvent, DropEvent, DropItem, DropFile, DocumentChangeEvent, StyleChangeEvent, StyleChange, BaseDocumentChange, BaseNodeChange, RemovedNode, CreateChange, DeleteChange, PropertyChange, BaseStyleChange, StyleCreateChange, StyleDeleteChange, StylePropertyChange, DocumentChange, NodeChangeProperty, NodeChangeEvent, NodeChange, StyleChangeProperty, TextReviewEvent, TextReviewRange, Transform, Vector, Rect, RGB, RGBA, FontName, TextCase, TextDecoration, OpenTypeFeature, ArcData, DropShadowEffect, InnerShadowEffect, BlurEffect, Effect, ConstraintType, Constraints, ColorStop, ImageFilters, SolidPaint, GradientPaint, ImagePaint, VideoPaint, Paint, Guide, RowsColsLayoutGrid, GridLayoutGrid, LayoutGrid, ExportSettingsConstraints, ExportSettingsImage, ExportSettingsSVGBase, ExportSettingsSVG, ExportSettingsSVGString, ExportSettingsPDF, ExportSettingsREST, ExportSettings, WindingRule, VectorVertex, VectorSegment, VectorRegion, VectorNetwork, VectorPath, VectorPaths, LetterSpacing, LineHeight, LeadingTrim, HyperlinkTarget, TextListOptions, BlendMode, MaskType, Font, TextStyleOverrideType, StyledTextSegment, Reaction, VariableDataType, ExpressionFunction, Expression, VariableValueWithExpression, VariableData, ConditionalBlock, DevStatus, Action, SimpleTransition, DirectionalTransition, Transition, Trigger, Navigation, Easing, EasingFunctionBezier, EasingFunctionSpring, OverflowDirection, OverlayPositionType, OverlayBackground, OverlayBackgroundInteraction, PublishStatus, ConnectorEndpointPosition, ConnectorEndpointPositionAndEndpointNodeId, ConnectorEndpointEndpointNodeIdAndMagnet, ConnectorEndpoint, ConnectorStrokeCap, BaseNodeMixin, PluginDataMixin, DevResourcesMixin, DevStatusMixin, SceneNodeMixin, VariableBindableNodeField, VariableBindableTextField, VariableBindablePaintField, VariableBindablePaintStyleField, VariableBindableColorStopField, VariableBindableEffectField, VariableBindableEffectStyleField, VariableBindableLayoutGridField, VariableBindableGridStyleField, VariableBindableComponentPropertyField, StickableMixin, ChildrenMixin, ConstraintMixin, DimensionAndPositionMixin, LayoutMixin, BlendMixin, ContainerMixin, DeprecatedBackgroundMixin, StrokeCap, StrokeJoin, HandleMirroring, AutoLayoutMixin, AutoLayoutChildrenMixin, InferredAutoLayoutResult, DetachedInfo, MinimalStrokesMixin, IndividualStrokesMixin, MinimalFillsMixin, GeometryMixin, CornerMixin, RectangleCornerMixin, ExportMixin, FramePrototypingMixin, VectorLikeMixin, ReactionMixin, DocumentationLink, PublishableMixin, DefaultShapeMixin, BaseFrameMixin, DefaultFrameMixin, OpaqueNodeMixin, MinimalBlendMixin, Annotation, AnnotationProperty, AnnotationPropertyType, AnnotationsMixin, Measurement, MeasurementSide, MeasurementOffset, MeasurementsMixin, VariantMixin, ComponentPropertiesMixin, NonResizableTextMixin, TextSublayerNode, DocumentNode, ExplicitVariableModesMixin, PageNode, FrameNode, GroupNode, SliceNode, RectangleNode, LineNode, EllipseNode, PolygonNode, StarNode, VectorNode, TextNode, ComponentPropertyType, InstanceSwapPreferredValue, ComponentPropertyOptions, ComponentPropertyDefinitions, ComponentSetNode, ComponentNode, ComponentProperties, InstanceNode, BooleanOperationNode, StickyNode, StampNode, TableNode, TableCellNode, HighlightNode, WashiTapeNode, ShapeWithTextNode, CodeBlockNode, LabelSublayerNode, ConnectorNode, VariableResolvedDataType, VariableAlias, VariableValue, VariableScope, CodeSyntaxPlatform, Variable, VariableCollection, WidgetNode, EmbedData, EmbedNode, LinkUnfurlData, LinkUnfurlNode, MediaData, MediaNode, SectionNode, BaseNode, SceneNode, NodeType, StyleType, InheritedStyleField, StyleConsumers, BaseStyleMixin, PaintStyle, TextStyle, EffectStyle, GridStyle, BaseStyle, Image, Video, BaseUser, User, ActiveUser, FindAllCriteria }
export { ArgFreeEventType, PluginAPI, VersionHistoryResult, VariablesAPI, LibraryVariableCollection, LibraryVariable, TeamLibraryAPI, PaymentStatus, PaymentsAPI, ClientStorageAPI, NotificationOptions, NotifyDequeueReason, NotificationHandler, ShowUIOptions, UIPostMessageOptions, OnMessageProperties, MessageEventHandler, UIAPI, UtilAPI, ColorPalette, ColorPalettes, ConstantsAPI, CodegenEvent, CodegenPreferences, CodegenPreferencesEvent, CodegenResult, CodegenAPI, DevResource, DevResourceWithNodeId, LinkPreviewEvent, PlainTextElement, LinkPreviewResult, AuthEvent, DevResourceOpenEvent, AuthResult, VSCodeAPI, DevResourcesAPI, TimerAPI, ViewportAPI, TextReviewAPI, ParameterValues, SuggestionResults, ParameterInputEvent, ParametersAPI, RunParametersEvent, OpenDevResourcesEvent, RunEvent, DropEvent, DropItem, DropFile, DocumentChangeEvent, StyleChangeEvent, StyleChange, BaseDocumentChange, BaseNodeChange, RemovedNode, CreateChange, DeleteChange, PropertyChange, BaseStyleChange, StyleCreateChange, StyleDeleteChange, StylePropertyChange, DocumentChange, NodeChangeProperty, NodeChangeEvent, NodeChange, StyleChangeProperty, TextReviewEvent, TextReviewRange, Transform, Vector, Rect, RGB, RGBA, FontName, TextCase, TextDecoration, OpenTypeFeature, ArcData, DropShadowEffect, InnerShadowEffect, BlurEffect, Effect, ConstraintType, Constraints, ColorStop, ImageFilters, SolidPaint, GradientPaint, ImagePaint, VideoPaint, Paint, Guide, RowsColsLayoutGrid, GridLayoutGrid, LayoutGrid, ExportSettingsConstraints, ExportSettingsImage, ExportSettingsSVGBase, ExportSettingsSVG, ExportSettingsSVGString, ExportSettingsPDF, ExportSettingsREST, ExportSettings, WindingRule, VectorVertex, VectorSegment, VectorRegion, VectorNetwork, VectorPath, VectorPaths, LetterSpacing, LineHeight, LeadingTrim, HyperlinkTarget, TextListOptions, BlendMode, MaskType, Font, TextStyleOverrideType, StyledTextSegment, Reaction, VariableDataType, ExpressionFunction, Expression, VariableValueWithExpression, VariableData, ConditionalBlock, DevStatus, Action, SimpleTransition, DirectionalTransition, Transition, Trigger, Navigation, Easing, EasingFunctionBezier, EasingFunctionSpring, OverflowDirection, OverlayPositionType, OverlayBackground, OverlayBackgroundInteraction, PublishStatus, ConnectorEndpointPosition, ConnectorEndpointPositionAndEndpointNodeId, ConnectorEndpointEndpointNodeIdAndMagnet, ConnectorEndpoint, ConnectorStrokeCap, BaseNodeMixin, PluginDataMixin, DevResourcesMixin, DevStatusMixin, SceneNodeMixin, VariableBindableNodeField, VariableBindableTextField, VariableBindablePaintField, VariableBindablePaintStyleField, VariableBindableColorStopField, VariableBindableEffectField, VariableBindableEffectStyleField, VariableBindableLayoutGridField, VariableBindableGridStyleField, VariableBindableComponentPropertyField, StickableMixin, ChildrenMixin, ConstraintMixin, DimensionAndPositionMixin, LayoutMixin, BlendMixin, ContainerMixin, DeprecatedBackgroundMixin, StrokeCap, StrokeJoin, HandleMirroring, AutoLayoutMixin, AutoLayoutChildrenMixin, InferredAutoLayoutResult, DetachedInfo, MinimalStrokesMixin, IndividualStrokesMixin, MinimalFillsMixin, GeometryMixin, CornerMixin, RectangleCornerMixin, ExportMixin, FramePrototypingMixin, VectorLikeMixin, ReactionMixin, DocumentationLink, PublishableMixin, DefaultShapeMixin, BaseFrameMixin, DefaultFrameMixin, OpaqueNodeMixin, MinimalBlendMixin, Annotation, AnnotationProperty, AnnotationPropertyType, AnnotationsMixin, Measurement, MeasurementSide, MeasurementOffset, MeasurementsMixin, VariantMixin, ComponentPropertiesMixin, NonResizableTextMixin, TextSublayerNode, DocumentNode, ExplicitVariableModesMixin, PageNode, FrameNode, GroupNode, SliceNode, RectangleNode, LineNode, EllipseNode, PolygonNode, StarNode, VectorNode, TextNode, ComponentPropertyType, InstanceSwapPreferredValue, ComponentPropertyOptions, ComponentPropertyDefinitions, ComponentSetNode, ComponentNode, ComponentProperties, InstanceNode, BooleanOperationNode, StickyNode, StampNode, TableNode, TableCellNode, HighlightNode, WashiTapeNode, ShapeWithTextNode, CodeBlockNode, LabelSublayerNode, ConnectorNode, VariableResolvedDataType, VariableAlias, VariableValue, VariableScope, CodeSyntaxPlatform, Variable, VariableCollection, WidgetNode, EmbedData, EmbedNode, LinkUnfurlData, LinkUnfurlNode, MediaData, MediaNode, SectionNode, SlideNode, SlideRowNode, SlideGridNode, InteractiveSlideElementNode, SlideTransition, BaseNode, SceneNode, NodeType, StyleType, InheritedStyleField, StyleConsumers, BaseStyleMixin, PaintStyle, TextStyle, EffectStyle, GridStyle, BaseStyle, Image, Video, BaseUser, User, ActiveUser, FindAllCriteria }
82 changes: 81 additions & 1 deletion plugin-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ interface PluginAPI {
node: FrameNode | ComponentNode | ComponentSetNode | SectionNode | null,
): Promise<void>
loadAllPagesAsync(): Promise<void>
getSlideGrid(): Array<Array<SlideNode>>
setSlideGrid(slideGrid: Array<Array<SlideNode>>): void
}
interface VersionHistoryResult {
id: string
Expand Down Expand Up @@ -426,6 +428,7 @@ interface ViewportAPI {
zoom: number
scrollAndZoomIntoView(nodes: ReadonlyArray<BaseNode>): void
readonly bounds: Rect
slidesMode: 'grid' | 'single-slide'
}
interface TextReviewAPI {
requestToBeEnabledAsync(): Promise<void>
Expand Down Expand Up @@ -1848,6 +1851,7 @@ interface Measurement {
side: MeasurementSide
}
offset: MeasurementOffset
freeText: string
}
declare type MeasurementSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT'
declare type MeasurementOffset =
Expand All @@ -1873,12 +1877,14 @@ interface MeasurementsMixin {
},
options?: {
offset?: MeasurementOffset
freeText?: string
},
): Measurement
editMeasurement(
id: string,
newValue: {
offset: MeasurementOffset
offset?: MeasurementOffset
freeText?: string
},
): Measurement
deleteMeasurement(id: string): void
Expand Down Expand Up @@ -2045,6 +2051,7 @@ interface PageNode
on(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
once(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
off(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
focusedSlide?: SlideNode | null
}
interface FrameNode extends DefaultFrameMixin {
readonly type: 'FRAME'
Expand Down Expand Up @@ -2471,6 +2478,79 @@ interface SectionNode extends ChildrenMixin, MinimalFillsMixin, OpaqueNodeMixin,
clone(): SectionNode
resizeWithoutConstraints(width: number, height: number): void
}
interface SlideNode
extends BaseNodeMixin,
BlendMixin,
ChildrenMixin,
ExportMixin,
GeometryMixin,
AutoLayoutMixin,
IndividualStrokesMixin,
AnnotationsMixin,
DimensionAndPositionMixin,
ContainerMixin,
ConstraintMixin {
readonly type: 'SLIDE'
clone(): SlideNode
getSlideTransition(): SlideTransition
setSlideTransition(transition: SlideTransition): void
layoutGrids: ReadonlyArray<LayoutGrid>
gridStyleId: string
setGridStyleIdAsync(styleId: string): Promise<void>
guides: ReadonlyArray<Guide>
inferredAutoLayout: InferredAutoLayoutResult | null
}
interface SlideRowNode extends BaseNodeMixin, ChildrenMixin {
readonly type: 'SLIDE_ROW'
clone(): SlideRowNode
}
interface SlideGridNode extends BaseNodeMixin, ChildrenMixin {
readonly type: 'SLIDE_GRID'
}
interface InteractiveSlideElementNode extends BaseNodeMixin {
readonly type: 'INTERACTIVE_SLIDE_ELEMENT'
readonly interactiveSlideElementType: 'POLL' | 'EMBED' | 'FACEPILE' | 'ALIGNMENT' | 'YOUTUBE'
}
interface SlideTransition {
readonly type:
| 'NONE'
| 'DISSOLVE'
| 'SLIDE_FROM_LEFT'
| 'SLIDE_FROM_RIGHT'
| 'SLIDE_FROM_BOTTOM'
| 'SLIDE_FROM_TOP'
| 'PUSH_FROM_LEFT'
| 'PUSH_FROM_RIGHT'
| 'PUSH_FROM_BOTTOM'
| 'PUSH_FROM_TOP'
| 'MOVE_FROM_LEFT'
| 'MOVE_FROM_RIGHT'
| 'MOVE_FROM_TOP'
| 'MOVE_FROM_BOTTOM'
| 'SLIDE_OUT_TO_LEFT'
| 'SLIDE_OUT_TO_RIGHT'
| 'SLIDE_OUT_TO_TOP'
| 'SLIDE_OUT_TO_BOTTOM'
| 'MOVE_OUT_TO_LEFT'
| 'MOVE_OUT_TO_RIGHT'
| 'MOVE_OUT_TO_TOP'
| 'MOVE_OUT_TO_BOTTOM'
| 'SMART_ANIMATE'
readonly duration: number
readonly easing:
| 'IN_CUBIC'
| 'OUT_CUBIC'
| 'INOUT_CUBIC'
| 'LINEAR'
| 'GENTLE_SPRING'
| 'SPRING_PRESET_ONE'
| 'SPRING_PRESET_TWO'
| 'SPRING_PRESET_THREE'
readonly trigger: {
readonly type: 'ON_CLICK' | 'AFTER_DELAY'
readonly delay?: number
}
}
declare type BaseNode = DocumentNode | PageNode | SceneNode
declare type SceneNode =
| SliceNode
Expand Down

0 comments on commit c8021c1

Please sign in to comment.