/* auto-generated by NAPI-RS */ /* eslint-disable */ /** An action is a method that an actor can execute upon a document */ export type ActionNapi = | { type: 'Attr', /** The qualified name of the attribute */ name: string, /** The value of the attribute */ value: string } | { type: 'Class', field0: string } | { type: 'Style', /** The CSS name of the property */ property: string, /** The CSS value of the property */ value: string } | { type: 'Matrix', field0: number, field1: number, field2: number, field3: number, field4: number, field5: number } | { type: 'Translate', field0: number, field1?: number } | { type: 'Scale', field0: number, field1?: number } | { type: 'Rotate', field0: number, field1?: [number, number] } | { type: 'SkewX', field0: number } | { type: 'SkewY', field0: number } | { type: 'Forget' } | { type: 'Select', field0: string } | { type: 'SelectMore', field0: string } | { type: 'Deselect' } /** The attributes common to the selected elements */ export interface AttrModelNapi { /** The expected attribute groups shared by all selected elements */ expectedAttributeGroups: number /** The expected attributes shared by all selected elements */ expectedAttributes: Array /** The attribute values matching between all selected elements */ values: Array<[AttrIdNapi, string]> } /** The content-model common to the selected elements */ export interface ContentModelNapi { /** The element categories permitted by all selected elements */ permittedCategories: number /** The elements permitted by all selected elements */ permittedElements: Array } /** See [`DerivedState`] */ export interface DerivedStateNapi { /** The list of actions specified by `oxvg:history` */ history: Array /** The ids specified by `oxvg:selection` */ selection: Array /** The information shared by elements matching the elements in `oxvg:selection` */ info?: InfoNapi } /** The information shared by elements matching the elements in `oxvg:selection` */ export interface InfoNapi { /** The element id, if all elements are of the same id */ elementId?: ElementIdNapi /** The content-model common to the selected elements */ contentModel: ContentModelNapi /** The attributes common to the selected elements */ attributes: AttrModelNapi /** The text content common to the selected elements */ text?: string } /** r" Specifies which attribute groups an attribute may belong to */ export declare class AttributeGroup { /** Convert from bits */ constructor(bits: number) /** Get the underlying bits */ toBits(): number } /** r" Specifies which categories an element may belong to */ export declare class ElementCategory { /** Convert from bits */ constructor(bits: number) /** Get the underlying bits */ toBits(): number } /** * Identifies one of an element's attributes. * * [MDN | SVG Attribute reference](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute) */ export type AttrIdNapi = | { type: 'AccentHeight' } | { type: 'Accumulate' } | { type: 'Additive' } | { type: 'Alphabetic' } | { type: 'Amplitude' } | { type: 'ArabicForm' } | { type: 'AriaActiveDescendant' } | { type: 'AriaAtomic' } | { type: 'AriaAutocomplete' } | { type: 'AriaBusy' } | { type: 'AriaChecked' } | { type: 'AriaColCount' } | { type: 'AriaColIndex' } | { type: 'AriaColSpan' } | { type: 'AriaControls' } | { type: 'AriaCurrent' } | { type: 'AriaDescribedBy' } | { type: 'AriaDetails' } | { type: 'AriaDisabled' } | { type: 'AriaDropEffect' } | { type: 'AriaErrorMessage' } | { type: 'AriaExpanded' } | { type: 'AriaFlowTo' } | { type: 'AriaGrabbed' } | { type: 'AriaHasPopup' } | { type: 'AriaHidden' } | { type: 'AriaInvalid' } | { type: 'AriaKeyshortcuts' } | { type: 'AriaLabel' } | { type: 'AriaLabelledBy' } | { type: 'AriaLevel' } | { type: 'AriaLive' } | { type: 'AriaModal' } | { type: 'AriaMultiline' } | { type: 'AriaMultiselectable' } | { type: 'AriaOrientation' } | { type: 'AriaOwns' } | { type: 'AriaPlaceholder' } | { type: 'AriaPosInSet' } | { type: 'AriaPressed' } | { type: 'AriaReadonly' } | { type: 'AriaRelevant' } | { type: 'AriaRequired' } | { type: 'AriaRoleDescription' } | { type: 'AriaRowCount' } | { type: 'AriaRowIndex' } | { type: 'AriaRowSpan' } | { type: 'AriaSelected' } | { type: 'AriaSetSize' } | { type: 'AriaSort' } | { type: 'AriaValueMax' } | { type: 'AriaValueMin' } | { type: 'AriaValueNow' } | { type: 'AriaValueText' } | { type: 'Ascent' } | { type: 'AttributeName' } | { type: 'AttributeType' } | { type: 'AutoFocus' } | { type: 'Azimuth' } | { type: 'BaseFrequency' } | { type: 'BaseProfile' } | { type: 'Bbox' } | { type: 'Begin' } | { type: 'Bias' } | { type: 'By' } | { type: 'CalcMode' } | { type: 'CapHeight' } | { type: 'Class' } | { type: 'ClipPathUnits' } | { type: 'ContentScriptType' } | { type: 'ContentStyleType' } | { type: 'CrossOrigin' } | { type: 'CXGeometry' } | { type: 'CXRadialGradient' } | { type: 'CYGeometry' } | { type: 'CYRadialGradient' } | { type: 'D' } | { type: 'Descent' } | { type: 'DiffuseConstant' } | { type: 'Divisor' } | { type: 'Download' } | { type: 'Dur' } | { type: 'DXAltGlyph' } | { type: 'DXFeDropShadow' } | { type: 'DXFeOffset' } | { type: 'DXGlyphRef' } | { type: 'DXText' } | { type: 'DXTSpan' } | { type: 'DYAltGlyph' } | { type: 'DYFeDropShadow' } | { type: 'DYFeOffset' } | { type: 'DYGlyphRef' } | { type: 'DYText' } | { type: 'DYTSpan' } | { type: 'EdgeModeFeConvolveMatrix' } | { type: 'EdgeModeFeGaussianBlur' } | { type: 'Elevation' } | { type: 'End' } | { type: 'Exponent' } | { type: 'ExternalResourcesRequired' } | { type: 'FillAnimate' } | { type: 'FilterRes' } | { type: 'FilterUnits' } | { type: 'Format' } | { type: 'FR' } | { type: 'From' } | { type: 'FX' } | { type: 'FY' } | { type: 'G1' } | { type: 'G2' } | { type: 'GlyphName' } | { type: 'GlyphRef' } | { type: 'GradientTransform' } | { type: 'GradientUnits' } | { type: 'Hanging' } | { type: 'HatchContentUnits' } | { type: 'HatchUnits' } | { type: 'HeightFilter' } | { type: 'HeightForeignObject' } | { type: 'HeightImage' } | { type: 'HeightPattern' } | { type: 'HeightRect' } | { type: 'HeightSvg' } | { type: 'HeightSymbol' } | { type: 'HeightUse' } | { type: 'HeightFe' } | { type: 'HeightMask' } | { type: 'HorizAdvX' } | { type: 'HorizOriginX' } | { type: 'HorizOriginY' } | { type: 'Href' } | { type: 'Hreflang' } | { type: 'Id' } | { type: 'Ideographic' } | { type: 'In' } | { type: 'In2' } | { type: 'Intercept' } | { type: 'K' } | { type: 'K1' } | { type: 'K2' } | { type: 'K3' } | { type: 'K4' } | { type: 'KernelMatrix' } | { type: 'KernelUnitLength' } | { type: 'KeyPoints' } | { type: 'KeySplines' } | { type: 'KeyTimes' } | { type: 'Lang' } | { type: 'LengthAdjust' } | { type: 'LimitingConeAngle' } | { type: 'Local' } | { type: 'MarkerHeight' } | { type: 'MarkerUnits' } | { type: 'MarkerWidth' } | { type: 'MaskContentUnits' } | { type: 'MaskUnits' } | { type: 'Mathematical' } | { type: 'Max' } | { type: 'Media' } | { type: 'Method' } | { type: 'Min' } | { type: 'Mode' } | { type: 'NameColorProfile' } | { type: 'NameFontFace' } | { type: 'NumOctaves' } | { type: 'OffsetStop' } | { type: 'OffsetFe' } | { type: 'OffsetHatchPath' } | { type: 'OnAbort' } | { type: 'OnActivate' } | { type: 'OnBegin' } | { type: 'OnCancel' } | { type: 'OnCanplay' } | { type: 'OnCanplaythrough' } | { type: 'OnChange' } | { type: 'OnClick' } | { type: 'OnClose' } | { type: 'OnCopy' } | { type: 'OnCuechange' } | { type: 'OnCut' } | { type: 'OnDblclick' } | { type: 'OnDrag' } | { type: 'OnDragend' } | { type: 'OnDragenter' } | { type: 'OnDragexit' } | { type: 'OnDragleave' } | { type: 'OnDragover' } | { type: 'OnDragstart' } | { type: 'OnDrop' } | { type: 'OnDurationchange' } | { type: 'OnEmptied' } | { type: 'OnEnd' } | { type: 'OnEnded' } | { type: 'OnError' } | { type: 'OnFocusIn' } | { type: 'OnFocusOut' } | { type: 'OnFocus' } | { type: 'OnInput' } | { type: 'OnInvalid' } | { type: 'OnKeydown' } | { type: 'OnKeypress' } | { type: 'OnKeyup' } | { type: 'OnLoad' } | { type: 'OnLoadeddata' } | { type: 'OnLoadedmetadata' } | { type: 'OnLoadstart' } | { type: 'OnMousedown' } | { type: 'OnMouseenter' } | { type: 'OnMouseleave' } | { type: 'OnMousemove' } | { type: 'OnMouseout' } | { type: 'OnMouseover' } | { type: 'OnMouseup' } | { type: 'OnPaste' } | { type: 'OnPause' } | { type: 'OnPlay' } | { type: 'OnPlaying' } | { type: 'OnProgress' } | { type: 'OnRatechange' } | { type: 'OnRepeat' } | { type: 'OnReset' } | { type: 'OnResize' } | { type: 'OnScroll' } | { type: 'OnSeeked' } | { type: 'OnSeeking' } | { type: 'OnSelect' } | { type: 'OnShow' } | { type: 'OnStalled' } | { type: 'OnSubmit' } | { type: 'OnSuspend' } | { type: 'OnTimeupdate' } | { type: 'OnToggle' } | { type: 'OnUnload' } | { type: 'OnVolumechange' } | { type: 'OnWaiting' } | { type: 'OnWheel' } | { type: 'OnZoom' } | { type: 'OperatorFeComposite' } | { type: 'OperatorFeMorphology' } | { type: 'Order' } | { type: 'Orient' } | { type: 'Orientation' } | { type: 'Origin' } | { type: 'OverlinePosition' } | { type: 'OverlineThickness' } | { type: 'Panose1' } | { type: 'Path' } | { type: 'PathLength' } | { type: 'PatternContentUnits' } | { type: 'PatternTransform' } | { type: 'PatternUnits' } | { type: 'Ping' } | { type: 'Pitch' } | { type: 'Playbackorder' } | { type: 'Points' } | { type: 'PointsAtX' } | { type: 'PointsAtY' } | { type: 'PointsAtZ' } | { type: 'PreserveAlpha' } | { type: 'PreserveAspectRatio' } | { type: 'PrimitiveUnits' } | { type: 'Radius' } | { type: 'ReferrerPolicy' } | { type: 'RefX' } | { type: 'RefY' } | { type: 'Rel' } | { type: 'RenderingIntent' } | { type: 'RepeatCount' } | { type: 'RepeatDur' } | { type: 'RequiredExtensions' } | { type: 'RequiredFeatures' } | { type: 'Restart' } | { type: 'Result' } | { type: 'Role' } | { type: 'RotateText' } | { type: 'RotateAnimate' } | { type: 'RotateHatch' } | { type: 'RX' } | { type: 'RY' } | { type: 'RGeometry' } | { type: 'RRadialGradient' } | { type: 'Scale' } | { type: 'Seed' } | { type: 'Side' } | { type: 'SlopeFont' } | { type: 'SlopeFe' } | { type: 'SolidColor' } | { type: 'SolidOpacity' } | { type: 'Spacing' } | { type: 'SpecularConstant' } | { type: 'SpecularExponent' } | { type: 'SpreadMethod' } | { type: 'StartOffset' } | { type: 'StdDeviationFeDropShadow' } | { type: 'StdDeviationFeGaussianBlur' } | { type: 'Stemh' } | { type: 'Stemv' } | { type: 'StitchTiles' } | { type: 'StrikethroughPosition' } | { type: 'StrikethroughThickness' } | { type: 'String' } | { type: 'Style' } | { type: 'SurfaceScale' } | { type: 'SystemLanguage' } | { type: 'Tabindex' } | { type: 'TableValues' } | { type: 'Target' } | { type: 'TargetX' } | { type: 'TargetY' } | { type: 'TextLength' } | { type: 'Timelinebegin' } | { type: 'Title' } | { type: 'To' } | { type: 'TypeA' } | { type: 'TypeAnimateTransform' } | { type: 'TypeFeColorMatrix' } | { type: 'TypeFeFunc' } | { type: 'TypeFeTurbulence' } | { type: 'TypeScript' } | { type: 'TypeStyle' } | { type: 'U1' } | { type: 'U2' } | { type: 'UnderlinePosition' } | { type: 'UnderlineThickness' } | { type: 'Unicode' } | { type: 'UnicodeRange' } | { type: 'UnitsPerEm' } | { type: 'VAlphabetic' } | { type: 'VHanging' } | { type: 'VIdeographic' } | { type: 'VMathematical' } | { type: 'ValuesFeColorMatrix' } | { type: 'ValuesAnimate' } | { type: 'Version' } | { type: 'VertAdvY' } | { type: 'VertOriginX' } | { type: 'VertOriginY' } | { type: 'ViewBox' } | { type: 'ViewTarget' } | { type: 'WidthFilter' } | { type: 'WidthForeignObject' } | { type: 'WidthImage' } | { type: 'WidthPattern' } | { type: 'WidthRect' } | { type: 'WidthSvg' } | { type: 'WidthSymbol' } | { type: 'WidthUse' } | { type: 'WidthFe' } | { type: 'WidthMask' } | { type: 'Widths' } | { type: 'XAltGlyph' } | { type: 'XCursor' } | { type: 'XFe' } | { type: 'XFePointLight' } | { type: 'XFeSpotLight' } | { type: 'XFilter' } | { type: 'XGeometry' } | { type: 'XGlyphRef' } | { type: 'XHatch' } | { type: 'XMask' } | { type: 'XPattern' } | { type: 'XText' } | { type: 'XTRef' } | { type: 'XHeight' } | { type: 'X1Line' } | { type: 'X1LinearGradient' } | { type: 'X2Line' } | { type: 'X2LinearGradient' } | { type: 'XChannelSelector' } | { type: 'XLinkActuate' } | { type: 'XLinkArcrole' } | { type: 'XLinkHref' } | { type: 'XLinkRole' } | { type: 'XLinkTitle' } | { type: 'XLinkType' } | { type: 'XLinkShow' } | { type: 'XMLNS' } | { type: 'XmlBase' } | { type: 'XmlLang' } | { type: 'XmlSpace' } | { type: 'YAltGlyph' } | { type: 'YCursor' } | { type: 'YFe' } | { type: 'YFePointLight' } | { type: 'YFeSpotLight' } | { type: 'YFilter' } | { type: 'YGeometry' } | { type: 'YGlyphRef' } | { type: 'YHatch' } | { type: 'YMask' } | { type: 'YPattern' } | { type: 'YText' } | { type: 'YTRef' } | { type: 'Y1Line' } | { type: 'Y1LinearGradient' } | { type: 'Y2Line' } | { type: 'Y2LinearGradient' } | { type: 'YChannelSelector' } | { type: 'ZFe' } | { type: 'ZoomAndPan' } | { type: 'AlignmentBaseline' } | { type: 'BaselineShift' } | { type: 'Clip' } | { type: 'ClipPath' } | { type: 'ClipRule' } | { type: 'Color' } | { type: 'ColorInterpolation' } | { type: 'ColorInterpolationFilters' } | { type: 'ColorProfile' } | { type: 'ColorRendering' } | { type: 'Cursor' } | { type: 'Direction' } | { type: 'Display' } | { type: 'DominantBaseline' } | { type: 'EnableBackground' } | { type: 'Fill' } | { type: 'FillOpacity' } | { type: 'FillRule' } | { type: 'Filter' } | { type: 'FloodColor' } | { type: 'FloodOpacity' } | { type: 'Font' } | { type: 'FontFamily' } | { type: 'FontSize' } | { type: 'FontSizeAdjust' } | { type: 'FontStretch' } | { type: 'FontStyle' } | { type: 'FontVariant' } | { type: 'FontWeight' } | { type: 'GlyphOrientationHorizontal' } | { type: 'GlyphOrientationVertical' } | { type: 'ImageRendering' } | { type: 'Kerning' } | { type: 'LetterSpacing' } | { type: 'LightingColor' } | { type: 'MarkerEnd' } | { type: 'MarkerMid' } | { type: 'MarkerStart' } | { type: 'Marker' } | { type: 'Mask' } | { type: 'Opacity' } | { type: 'Overflow' } | { type: 'PaintOrder' } | { type: 'PointerEvents' } | { type: 'ShapeRendering' } | { type: 'StopColor' } | { type: 'StopOpacity' } | { type: 'Stroke' } | { type: 'StrokeDasharray' } | { type: 'StrokeDashoffset' } | { type: 'StrokeLinecap' } | { type: 'StrokeLinejoin' } | { type: 'StrokeMiterlimit' } | { type: 'StrokeOpacity' } | { type: 'StrokeWidth' } | { type: 'TextAnchor' } | { type: 'TextDecoration' } | { type: 'TextRendering' } | { type: 'Transform' } | { type: 'TransformOrigin' } | { type: 'UnicodeBidi' } | { type: 'VectorEffect' } | { type: 'Visibility' } | { type: 'WordSpacing' } | { type: 'WritingMode' } | { type: 'Aliased', /** The prefix assigned to the attribute */ prefix: PrefixNapi, /** The associated attribute */ name: [string, string] } | { type: 'Unknown', field0: QualNameNapi } /** * Identifies an element by it's local-name and namespace * * [MDN | SVG element reference](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element) */ export type ElementIdNapi = | { type: 'A' } | { type: 'AltGlyph' } | { type: 'AltGlyphDef' } | { type: 'AltGlyphItem' } | { type: 'Animate' } | { type: 'AnimateColor' } | { type: 'AnimateMotion' } | { type: 'AnimateTransform' } | { type: 'Circle' } | { type: 'ClipPath' } | { type: 'ColorProfile' } | { type: 'Cursor' } | { type: 'Defs' } | { type: 'Desc' } | { type: 'Ellipse' } | { type: 'FeBlend' } | { type: 'FeColorMatrix' } | { type: 'FeComponentTransfer' } | { type: 'FeComposite' } | { type: 'FeConvolveMatrix' } | { type: 'FeDiffuseLighting' } | { type: 'FeDisplacementMap' } | { type: 'FeDistantLight' } | { type: 'FeDropShadow' } | { type: 'FeFlood' } | { type: 'FeFuncA' } | { type: 'FeFuncB' } | { type: 'FeFuncG' } | { type: 'FeFuncR' } | { type: 'FeGaussianBlur' } | { type: 'FeImage' } | { type: 'FeMerge' } | { type: 'FeMergeNode' } | { type: 'FeMorphology' } | { type: 'FeOffset' } | { type: 'FePointLight' } | { type: 'FeSpecularLighting' } | { type: 'FeSpotLight' } | { type: 'FeTile' } | { type: 'FeTurbulence' } | { type: 'Filter' } | { type: 'Font' } | { type: 'FontFace' } | { type: 'FontFaceFormat' } | { type: 'FontFaceName' } | { type: 'FontFaceSrc' } | { type: 'FontFaceURI' } | { type: 'ForeignObject' } | { type: 'G' } | { type: 'Glyph' } | { type: 'GlyphRef' } | { type: 'Hatch' } | { type: 'HatchPath' } | { type: 'HKern' } | { type: 'Image' } | { type: 'Line' } | { type: 'LinearGradient' } | { type: 'Marker' } | { type: 'Mask' } | { type: 'Metadata' } | { type: 'MissingGlyph' } | { type: 'MPath' } | { type: 'Path' } | { type: 'Pattern' } | { type: 'Polygon' } | { type: 'Polyline' } | { type: 'RadialGradient' } | { type: 'Rect' } | { type: 'Script' } | { type: 'Set' } | { type: 'SolidColor' } | { type: 'Stop' } | { type: 'Style' } | { type: 'Svg' } | { type: 'Switch' } | { type: 'Symbol' } | { type: 'Text' } | { type: 'TextPath' } | { type: 'Title' } | { type: 'TRef' } | { type: 'TSpan' } | { type: 'Use' } | { type: 'View' } | { type: 'VKern' } | { type: 'Aliased', /** The prefix assigned to the element */ prefix: PrefixNapi, /** The associated element */ name: [string, string] } | { type: 'Unknown', field0: QualNameNapi } /** A namespace for a qualified name's prefix */ export type NSNapi = | { type: 'SVG' } | { type: 'HTML' } | { type: 'XML' } | { type: 'XMLNS' } | { type: 'XLink' } | { type: 'MathML' } | { type: 'Unknown', field0: string } /** A prefix for a qualified name, e.g. `xlink` of `xlink:href` */ export type PrefixNapi = | { type: 'SVG' } | { type: 'HTML' } | { type: 'XML' } | { type: 'XMLNS' } | { type: 'XLink' } | { type: 'MathML' } | { type: 'Unknown', /** The prefix name, e.g. `prefix` of `xmlns:prefix=""` */ prefix?: string, /** The unique resource identifier, e.g. `` of `xmlns:prefix=""` */ ns: NSNapi } | { type: 'Aliased', /** The prefix that's being aliased */ prefix: [string, string], /** The name assigned to the prefix */ alias?: string } /** A qualified name used for the names of tags and attributes. */ export interface QualNameNapi { /** The prefix (e.g. `xlink` of `xlink:href`) of a qualified name. */ prefix: PrefixNapi /** The local name (e.g. the `href` of `xlink:href`) of a qualified name. */ local: string } /** * An actor holds a reference to a document to act upon. * * The actor will embed it's state into the document upon parsing and serializing. */ export declare class Actor { /** * Creates a new actor with a reference to the document. The state of the actor will be * derived from the document's `oxvg:state` element. * * # Errors * * If parsing fails */ constructor(document: string) /** * Returns a rich state object based on the `oxvg:state` embedded in the document * * # Errors * * If the state is invalid */ deriveState(): DerivedStateNapi /** * Executes the given action and it's arguments upon the document. * * # Errors * * If the action fails */ dispatch(action: ActionNapi): void /** * Sets the attribute to selected elements. * * # Errors * * When root element is missing. */ attr(name: string, value: string): void /** * Toggles the class-name on selected elements. * * # Errors * * When root element is missing. */ class(name: string): void /** * Appends the style to the selected elements style list. * * # Errors * * When root element is missing. * When the given property and/or value is invalid. */ style(property: string, value: string): void /** * Appends the `matrix` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ matrix(a: number, b: number, c: number, d: number, e: number, f: number): void /** * Appends the `translate` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ translate(x: number, y?: number | undefined | null): void /** * Appends the `scale` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ scale(x: number, y?: number | undefined | null): void /** * Appends the `rotate` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ rotate(angle: number, origin?: [number, number] | undefined | null): void /** * Appends the `skewX` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ skewX(angle: number): void /** * Appends the `skewY` function to the element's `transform` attribute. * * # Errors * * When root element is missing. */ skewY(angle: number): void /** Removes OXVG state from the document */ forget(): void /** * Updates the state of the actor to point to the elements matching the given selector. * Elements can also be selected by a space/comma separated list of allocation-id * integers. * * # Errors * * If the query is invalid */ select(query: string): void /** * Updates the state of the actor to point to the elements matching the given selector, * including any previous selections. * Elements can also be selected by a space/comma separated list of allocation-id * integers. * * # Errors * * If the query is invalid */ selectMore(query: string): void /** Updates the state of the actor to deselected any selected nodes. */ deselect(): void /** * Returns the actor's updated document as a string * * # Errors * * If serialization fails */ document(): string } /** * Converts a JSON value of SVGO's `Config["plugins"]` into [`Jobs`]. * * Note that this will deduplicate any plugins listed. * * # Errors * * If a config file cannot be deserialized into jobs. This may fail even if * the config is valid for SVGO, such as if * * - The config contains custom plugins * - The plugin parameters are incompatible with OXVG * - The underlying deserialization process fails * * If you believe an errors should be fixed, please raise an issue * [here](https://github.com/noahbald/oxvg/issues) */ export declare function convertSvgoConfig(config?: Array<'preset-default' | {[K in keyof Jobs]: K | { name: K, params?: Jobs[K] }}[keyof Jobs]> | undefined | null): Jobs /** * Returns the given config with omitted options replaced with the config provided by `extends`. * I.e. acts like `{ ...extends, ...config }` */ export declare function extend(extend: Extends, config?: Jobs | undefined | null): Jobs /** * Optimise an SVG document using the provided config * * # Errors * - If the document fails to parse * - If any of the optimisations fail * - If the optimised document fails to serialize * * # Examples * * Optimise svg with the default configuration * * ```js * import { optimise } from "@oxvg/napi"; * * const result = optimise(``); * ``` * * Or, provide your own config * * ```js * import { optimise } from "@oxvg/napi"; * * // Only optimise path data * const result = optimise(``, { convertPathData: {} }); * ``` * * Or, extend a preset * * ```js * import { optimise, extend, Extends } from "@oxvg/napi"; * * const result = optimise( * ``, * extend(Extends.Default, { convertPathData: { removeUseless: false } }), * ); * ``` */ export declare function optimise(svg: string, config?: Jobs | undefined | null): string /** * Adds attributes to SVG elements in the document. This is not an optimisation * and will increase the size of SVG documents. * * # Differences to SVGO * * It's not possible to set a *none* value to an attribute. Elements like * `` are valid in HTML but not XML, so it's only possible to create * an attribute like ``. * * It's also not possible to create React-like syntax. In SVGO it's possible to define * an attribute as `{ "key={value}": undefined }` to produce an attribute like * ``, however in OXVG you have to provide a string value, so it's * output would look like ``. * * # Examples * * Add an attribute with a prefix * * ``` * use std::collections::BTreeMap; * use oxvg_optimiser::{Jobs, AddAttributesToSVGElement}; * * let jobs = Jobs { * add_attributes_to_s_v_g_element: Some(AddAttributesToSVGElement { * attributes: BTreeMap::from([(String::from("prefix:local"), String::from("value"))]), * }), * ..Jobs::none() * }; * ``` * * # Correctness * * This job may visually change documents if the attribute is a presentation attribute * or selected via CSS. * * No validation is applied to provided attribute and may produce incorrect or invalid documents. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface AddAttributesToSvgElement { /** Pairs of qualified names and attribute values that are assigned to the `svg` */ attributes: Record } /** * Adds to the `class` attribute of the root `` element, omitting duplicates * * # Differences to SVGO * * The order of CSS classes may not be applied in the order given. * * # Examples * * Use with a list of classes * * ``` * use oxvg_optimiser::{Jobs, AddClassesToSVGElement}; * * let jobs = Jobs { * add_classes_to_s_v_g_element: Some(AddClassesToSVGElement { * class_names: Some(vec![String::from("foo"), String::from("bar")]), * ..AddClassesToSVGElement::default() * }), * ..Jobs::none() * }; * ``` * * Use with a class string * * ``` * use oxvg_optimiser::{Jobs, AddClassesToSVGElement}; * * let jobs = Jobs { * add_classes_to_s_v_g_element: Some(AddClassesToSVGElement { * class_name: Some(String::from("foo bar")), * ..AddClassesToSVGElement::default() * }), * ..Jobs::none() * }; * ``` * * * # Correctness * * This job may visually change documents if an added classname causes it to be * selected by CSS. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface AddClassesToSvgElement { /** Adds each class to the `class` attribute. */ classNames?: Array /** * Adds the classes to the `class` attribute, removing any whitespace between each. This option * is ignored if `class_names` is provided. */ className?: string } /** * Apply transformations of a `transform` attribute to the path data, removing the `transform` * in the process. * * # Differences to SVGO * * In SVGO this job cannot be enabled individually; it always runs with `convertPathData`. * * # Correctness * * By default this job should never visually change the document. * * When specifying a precision there may be rounding errors affecting the accuracy of documents. * * When specifying to apply to apply transforms to a stroked path the stroke may be visually * warped when compared to the original. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface ApplyTransforms { /** The level of precising at which to round transforms applied to the path data. */ transformPrecision?: number /** Whether or not to apply transforms to paths with a stroke. */ applyTransformsStroked: boolean } /** * Removes redundant whitespace from attribute values. * * # Correctness * * By default any whitespace is cleaned up. This shouldn't affect anything within the SVG * but may affect elements within ``, which is treated as HTML. * * For example, whitespace has an effect when between `inline` and `inline-block` elements. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace#spaces_in_between_inline_and_inline-block_elements) for more information. * * In any other case, it should never affect the appearance of the document. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface CleanupAttrs { /** Whether to replace `' '` with `' '`. */ newlines: boolean /** Whether to remove whitespace from each end of the value */ trim: boolean /** Whether to replace multiple whitespace characters with a single `' '`. */ spaces: boolean } /** * Cleans up `enable-background` attributes and styles. It will only remove it if * - The document has no `` element; and * - The value matches the document's width and height; or * - Replace `new` when it matches the width and height of a `` or `` * * This job will: * - Drop `enable-background` on `` node, if it matches the node's width and height * - Set `enable-background` to `"new"` on `` or `` nodes, if it matches the * node's width and height * * # Correctness * * This attribute is deprecated and won't visually affect documents in most renderers. For outdated * renderers that still support it, there may be a visual change. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface CleanupEnableBackground { field0: boolean } /** * Removes unused ids and minifies used ids. * * # Differences to SVGO * * The generated ids may be different to those produced by SVGO * * # Correctness * * By default documents with scripts or style elements are skipped, so the ids aren't selected * and can't affect the document's appearance or behaviour. * * When inlined there's a good chance that existing id selectors will no longer match the ids. * Additionally, when inlining multiple SVGs it's likely ids will overlap. * * You can choose to disable `minify` or use the `prefixIds` job to help with workarounds. * * # Errors * * Never. * * If this job produces an error or panic, please raise an [issue](https://github.com/noahbald/oxvg/issues) */ export interface CleanupIds { /** Whether to remove unreferenced ids. */ remove: boolean /** Whether to minify ids */ minify: boolean /** Skips ids that match an item in the list */ preserve?: Array /** Skips ids that start with a string matching a prefix in the list */ preservePrefixes?: Array /** Whether to run despite `