diff --git a/plugin-api-standalone.d.ts b/plugin-api-standalone.d.ts index 86c80b9..42fea49 100644 --- a/plugin-api-standalone.d.ts +++ b/plugin-api-standalone.d.ts @@ -2015,9 +2015,9 @@ interface VariablesAPI { * * @deprecated Use `createVariable(string, VariableCollection, VariableResolvedDataType)` instead. This function will throw an exception if the plugin manifest contains `"documentAccess": "dynamic-page"`. * - * @param name - the name of the newly created variable - * @param collectionId - the ID of a collection object - * @param resolvedType - the resolved type of this variable + * @param name - The name of the newly created variable + * @param collectionId - The ID of a collection object + * @param resolvedType - The resolved type of this variable */ createVariable( name: string, @@ -2027,9 +2027,9 @@ interface VariablesAPI { /** * Creates a variable with a given name and resolved type inside a collection. * - * @param name - the name of the newly created variable + * @param name - The name of the newly created variable * @param collection - A variable collection. Make sure to pass a collection object here; passing a collection ID is deprecated. - * @param resolvedType - the resolved type of this variable + * @param resolvedType - The resolved type of this variable */ createVariable( name: string, @@ -2038,9 +2038,22 @@ interface VariablesAPI { ): Variable /** * Creates a new variable collection with the given name. - * @param name - the name of the newly created variable collection. + * @param name - The name of the newly created variable collection. */ createVariableCollection(name: string): VariableCollection + /** + * Creates a new extended variable collection from a library or local variable collection with the given name. + * @param collectionKey - The key of the library or local variable collection to extend. + * @param name - The name of the newly created variable collection. + * + * Note: This API is limited to the Enterprise plan. + * If limited by the current pricing tier, this method will throw an error with the message + * `in extend: Cannot create extended collections outside of enterprise plan.` + */ + extendLibraryCollectionByKeyAsync( + collectionKey: string, + name: string, + ): Promise /** * Helper function to create a variable alias. * @@ -10086,7 +10099,7 @@ interface Variable extends PluginDataMixin { resolvedType: VariableResolvedDataType } /** - * Sets the value of this variable for the provided mode. + * Sets the value of this variable for the provided mode. If the modeId belongs to an extended collection, the value will be overridden on the extension. */ setValueForMode(modeId: string, newValue: VariableValue): void /** @@ -10143,6 +10156,16 @@ interface Variable extends PluginDataMixin { * Remove a platform definition from {@link Variable.codeSyntax}. Acceptable parameters are `'WEB'`, `'ANDROID'`, and `'iOS'` if previously defined. */ removeVariableCodeSyntax(platform: CodeSyntaxPlatform): void + /** + * The overridden or inherited values for each mode for the provided collection that inherits this variable. Note that this will not resolve any aliases. To return fully resolved values in all cases, consider using {@link Variable.resolveForConsumer}. + */ + valuesByModeForCollectionAsync(collection: VariableCollection): Promise<{ + [modeId: string]: VariableValue + }> + /** + * Removes the overridden value for the given mode if it exists and returns to the inherited value. + */ + removeOverrideForMode(extendedModeId: string): void } interface VariableCollection extends PluginDataMixin { /** @@ -10161,6 +10184,8 @@ interface VariableCollection extends PluginDataMixin { getPublishStatusAsync(): Promise /** Whether this variable collection is remote or local. */ readonly remote: boolean + /** Whether this variable collection is an extension of another variable collection. */ + readonly isExtension: boolean /** The list of modes defined for this variable collection. */ readonly modes: Array<{ modeId: string @@ -10182,6 +10207,17 @@ interface VariableCollection extends PluginDataMixin { * Note that while this key is present on local and published variable collections, `TeamLibaryAPI` can only be used to query the variables of variable collections that are already published. */ readonly key: string + /** + * Creates an extended variable collection from this variable collection. Returns the newly created extended variable collection. This method is only available on local variable collections. + * + * Note: This API is limited to the Enterprise plan. + * If limited by the current pricing tier, this method will throw an error with the message + * `in extend: Cannot create extended collections outside of enterprise plan.` + * + * See [Figma plans and features](https://help.figma.com/hc/en-us/articles/360040328273) for more information. + * + */ + extend(name: string): ExtendedVariableCollection /** Removes this variable collection and all of its variables from the document. */ remove(): void /** Removes the given mode by ID. */ @@ -10200,6 +10236,34 @@ interface VariableCollection extends PluginDataMixin { /** Renames the given mode. */ renameMode(modeId: string, newName: string): void } +interface ExtendedVariableCollection extends Omit { + /** `isExtension` is set to `true` to distinguish an extended collection from base variable collections. */ + readonly isExtension: true + /** + * The ID of the parent variable collection. + */ + readonly parentVariableCollectionId: string + /** + * The list of variables contained in this extended variable collection including variables that are inherited from its parent collection. + */ + readonly variableIds: string[] + /** The overridden variable values in this extended variable collection. */ + readonly variableOverrides: { + [variableId: string]: { + [extendedModeId: string]: VariableValue + } + } + /** Removes all overridden values in this extended collection for the given variable. */ + removeOverridesForVariable(variableToClear: Variable): void + /** The modes inherited from the parent collection. */ + readonly modes: Array<{ + modeId: string + name: string + parentModeId: string + }> + /** Removes the given mode by ID if its parent mode has been deleted. */ + removeMode(modeId: string): void +} type AnnotationCategoryColor = | 'yellow' | 'orange' @@ -10935,4 +10999,4 @@ interface FindAllCriteria { } // prettier-ignore -export { ArgFreeEventType, PluginAPI, VersionHistoryResult, VariablesAPI, LibraryVariableCollection, LibraryVariable, AnnotationsAPI, BuzzAPI, BuzzTextField, BuzzMediaField, BuzzAssetType, 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, SlidesViewChangeEvent, CanvasViewChangeEvent, 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, TextDecorationStyle, FontStyle, TextDecorationOffset, TextDecorationThickness, TextDecorationColor, OpenTypeFeature, ArcData, DropShadowEffect, InnerShadowEffect, BlurEffectBase, BlurEffectNormal, BlurEffectProgressive, BlurEffect, NoiseEffectBase, NoiseEffectMonotone, NoiseEffectDuotone, NoiseEffectMultitone, NoiseEffect, TextureEffect, GlassEffect, Effect, ConstraintType, Constraints, ColorStop, ImageFilters, SolidPaint, GradientPaint, ImagePaint, VideoPaint, PatternPaint, 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, VariableBindableComponentPropertyDefinitionField, StickableMixin, ChildrenMixin, ConstraintMixin, DimensionAndPositionMixin, LayoutMixin, AspectRatioLockMixin, BlendMixin, ContainerMixin, DeprecatedBackgroundMixin, StrokeCap, StrokeJoin, HandleMirroring, AutoLayoutMixin, GridTrackSize, GridLayoutMixin, AutoLayoutChildrenMixin, GridChildrenMixin, 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, BaseNonResizableTextMixin, NonResizableTextMixin, NonResizableTextPathMixin, TextSublayerNode, DocumentNode, ExplicitVariableModesMixin, PageNode, FrameNode, GroupNode, TransformGroupNode, SliceNode, RectangleNode, LineNode, EllipseNode, PolygonNode, StarNode, VectorNode, TextNode, TextPathNode, 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, AnnotationCategoryColor, AnnotationCategory, 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 } +export { ArgFreeEventType, PluginAPI, VersionHistoryResult, VariablesAPI, LibraryVariableCollection, LibraryVariable, AnnotationsAPI, BuzzAPI, BuzzTextField, BuzzMediaField, BuzzAssetType, 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, SlidesViewChangeEvent, CanvasViewChangeEvent, 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, TextDecorationStyle, FontStyle, TextDecorationOffset, TextDecorationThickness, TextDecorationColor, OpenTypeFeature, ArcData, DropShadowEffect, InnerShadowEffect, BlurEffectBase, BlurEffectNormal, BlurEffectProgressive, BlurEffect, NoiseEffectBase, NoiseEffectMonotone, NoiseEffectDuotone, NoiseEffectMultitone, NoiseEffect, TextureEffect, GlassEffect, Effect, ConstraintType, Constraints, ColorStop, ImageFilters, SolidPaint, GradientPaint, ImagePaint, VideoPaint, PatternPaint, 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, VariableBindableComponentPropertyDefinitionField, StickableMixin, ChildrenMixin, ConstraintMixin, DimensionAndPositionMixin, LayoutMixin, AspectRatioLockMixin, BlendMixin, ContainerMixin, DeprecatedBackgroundMixin, StrokeCap, StrokeJoin, HandleMirroring, AutoLayoutMixin, GridTrackSize, GridLayoutMixin, AutoLayoutChildrenMixin, GridChildrenMixin, 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, BaseNonResizableTextMixin, NonResizableTextMixin, NonResizableTextPathMixin, TextSublayerNode, DocumentNode, ExplicitVariableModesMixin, PageNode, FrameNode, GroupNode, TransformGroupNode, SliceNode, RectangleNode, LineNode, EllipseNode, PolygonNode, StarNode, VectorNode, TextNode, TextPathNode, 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, ExtendedVariableCollection, AnnotationCategoryColor, AnnotationCategory, 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 f9eb0a9..d34b26a 100644 --- a/plugin-api.d.ts +++ b/plugin-api.d.ts @@ -2011,9 +2011,9 @@ interface VariablesAPI { * * @deprecated Use `createVariable(string, VariableCollection, VariableResolvedDataType)` instead. This function will throw an exception if the plugin manifest contains `"documentAccess": "dynamic-page"`. * - * @param name - the name of the newly created variable - * @param collectionId - the ID of a collection object - * @param resolvedType - the resolved type of this variable + * @param name - The name of the newly created variable + * @param collectionId - The ID of a collection object + * @param resolvedType - The resolved type of this variable */ createVariable( name: string, @@ -2023,9 +2023,9 @@ interface VariablesAPI { /** * Creates a variable with a given name and resolved type inside a collection. * - * @param name - the name of the newly created variable + * @param name - The name of the newly created variable * @param collection - A variable collection. Make sure to pass a collection object here; passing a collection ID is deprecated. - * @param resolvedType - the resolved type of this variable + * @param resolvedType - The resolved type of this variable */ createVariable( name: string, @@ -2034,9 +2034,22 @@ interface VariablesAPI { ): Variable /** * Creates a new variable collection with the given name. - * @param name - the name of the newly created variable collection. + * @param name - The name of the newly created variable collection. */ createVariableCollection(name: string): VariableCollection + /** + * Creates a new extended variable collection from a library or local variable collection with the given name. + * @param collectionKey - The key of the library or local variable collection to extend. + * @param name - The name of the newly created variable collection. + * + * Note: This API is limited to the Enterprise plan. + * If limited by the current pricing tier, this method will throw an error with the message + * `in extend: Cannot create extended collections outside of enterprise plan.` + */ + extendLibraryCollectionByKeyAsync( + collectionKey: string, + name: string, + ): Promise /** * Helper function to create a variable alias. * @@ -10082,7 +10095,7 @@ interface Variable extends PluginDataMixin { resolvedType: VariableResolvedDataType } /** - * Sets the value of this variable for the provided mode. + * Sets the value of this variable for the provided mode. If the modeId belongs to an extended collection, the value will be overridden on the extension. */ setValueForMode(modeId: string, newValue: VariableValue): void /** @@ -10139,6 +10152,16 @@ interface Variable extends PluginDataMixin { * Remove a platform definition from {@link Variable.codeSyntax}. Acceptable parameters are `'WEB'`, `'ANDROID'`, and `'iOS'` if previously defined. */ removeVariableCodeSyntax(platform: CodeSyntaxPlatform): void + /** + * The overridden or inherited values for each mode for the provided collection that inherits this variable. Note that this will not resolve any aliases. To return fully resolved values in all cases, consider using {@link Variable.resolveForConsumer}. + */ + valuesByModeForCollectionAsync(collection: VariableCollection): Promise<{ + [modeId: string]: VariableValue + }> + /** + * Removes the overridden value for the given mode if it exists and returns to the inherited value. + */ + removeOverrideForMode(extendedModeId: string): void } interface VariableCollection extends PluginDataMixin { /** @@ -10157,6 +10180,8 @@ interface VariableCollection extends PluginDataMixin { getPublishStatusAsync(): Promise /** Whether this variable collection is remote or local. */ readonly remote: boolean + /** Whether this variable collection is an extension of another variable collection. */ + readonly isExtension: boolean /** The list of modes defined for this variable collection. */ readonly modes: Array<{ modeId: string @@ -10178,6 +10203,17 @@ interface VariableCollection extends PluginDataMixin { * Note that while this key is present on local and published variable collections, `TeamLibaryAPI` can only be used to query the variables of variable collections that are already published. */ readonly key: string + /** + * Creates an extended variable collection from this variable collection. Returns the newly created extended variable collection. This method is only available on local variable collections. + * + * Note: This API is limited to the Enterprise plan. + * If limited by the current pricing tier, this method will throw an error with the message + * `in extend: Cannot create extended collections outside of enterprise plan.` + * + * See [Figma plans and features](https://help.figma.com/hc/en-us/articles/360040328273) for more information. + * + */ + extend(name: string): ExtendedVariableCollection /** Removes this variable collection and all of its variables from the document. */ remove(): void /** Removes the given mode by ID. */ @@ -10196,6 +10232,34 @@ interface VariableCollection extends PluginDataMixin { /** Renames the given mode. */ renameMode(modeId: string, newName: string): void } +interface ExtendedVariableCollection extends Omit { + /** `isExtension` is set to `true` to distinguish an extended collection from base variable collections. */ + readonly isExtension: true + /** + * The ID of the parent variable collection. + */ + readonly parentVariableCollectionId: string + /** + * The list of variables contained in this extended variable collection including variables that are inherited from its parent collection. + */ + readonly variableIds: string[] + /** The overridden variable values in this extended variable collection. */ + readonly variableOverrides: { + [variableId: string]: { + [extendedModeId: string]: VariableValue + } + } + /** Removes all overridden values in this extended collection for the given variable. */ + removeOverridesForVariable(variableToClear: Variable): void + /** The modes inherited from the parent collection. */ + readonly modes: Array<{ + modeId: string + name: string + parentModeId: string + }> + /** Removes the given mode by ID if its parent mode has been deleted. */ + removeMode(modeId: string): void +} type AnnotationCategoryColor = | 'yellow' | 'orange'