From c8021c1cefdc9ad08d2b759086df003fad041b43 Mon Sep 17 00:00:00 2001 From: Jonathan Kaufman Date: Tue, 24 Sep 2024 15:35:43 -0400 Subject: [PATCH] Add types for Slides PluginAPI Beta --- plugin-api-standalone.d.ts | 84 +++++++++++++++++++++++++++++++++++++- plugin-api.d.ts | 82 ++++++++++++++++++++++++++++++++++++- 2 files changed, 163 insertions(+), 3 deletions(-) diff --git a/plugin-api-standalone.d.ts b/plugin-api-standalone.d.ts index 576400f..8715651 100644 --- a/plugin-api-standalone.d.ts +++ b/plugin-api-standalone.d.ts @@ -179,6 +179,8 @@ interface PluginAPI { node: FrameNode | ComponentNode | ComponentSetNode | SectionNode | null, ): Promise loadAllPagesAsync(): Promise + getSlideGrid(): Array> + setSlideGrid(slideGrid: Array>): void } interface VersionHistoryResult { id: string @@ -430,6 +432,7 @@ interface ViewportAPI { zoom: number scrollAndZoomIntoView(nodes: ReadonlyArray): void readonly bounds: Rect + slidesMode: 'grid' | 'single-slide' } interface TextReviewAPI { requestToBeEnabledAsync(): Promise @@ -1852,6 +1855,7 @@ interface Measurement { side: MeasurementSide } offset: MeasurementOffset + freeText: string } declare type MeasurementSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT' declare type MeasurementOffset = @@ -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 @@ -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' @@ -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 + gridStyleId: string + setGridStyleIdAsync(styleId: string): Promise + guides: ReadonlyArray + 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 @@ -2604,4 +2684,4 @@ interface FindAllCriteria { } // 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 } diff --git a/plugin-api.d.ts b/plugin-api.d.ts index a012f35..9b0153c 100644 --- a/plugin-api.d.ts +++ b/plugin-api.d.ts @@ -175,6 +175,8 @@ interface PluginAPI { node: FrameNode | ComponentNode | ComponentSetNode | SectionNode | null, ): Promise loadAllPagesAsync(): Promise + getSlideGrid(): Array> + setSlideGrid(slideGrid: Array>): void } interface VersionHistoryResult { id: string @@ -426,6 +428,7 @@ interface ViewportAPI { zoom: number scrollAndZoomIntoView(nodes: ReadonlyArray): void readonly bounds: Rect + slidesMode: 'grid' | 'single-slide' } interface TextReviewAPI { requestToBeEnabledAsync(): Promise @@ -1848,6 +1851,7 @@ interface Measurement { side: MeasurementSide } offset: MeasurementOffset + freeText: string } declare type MeasurementSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT' declare type MeasurementOffset = @@ -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 @@ -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' @@ -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 + gridStyleId: string + setGridStyleIdAsync(styleId: string): Promise + guides: ReadonlyArray + 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