PerfectPan/svgo/plugins does not have a README file

    Context

    pub struct Context {
    precision : Int
    params :
    Json

    optimized_paths : Map[String, Int]
    path_hulls : Map[String, Array[Array[(Double, Double)]]]
    } derive(
    Debug
    )

    Shared state passed to every plugin: the numeric precision plus a cache that lives for the whole run.

    Context::has_param

    fn Context::has_param(self : Context, name : String) -> Bool

    Whether a parameter was supplied, including explicit false or empty arrays.

    Context::new

    fn Context::new(precision? : Int) -> Context

    A fresh context; create one per optimize run.

    Context::param_bool

    fn Context::param_bool(self : Context, name : String, default : Bool) -> Bool

    Read a boolean, falling back for absent or incorrectly typed values.

    Context::param_int

    fn Context::param_int(self : Context, name : String, default : Int) -> Int

    Read an integer parameter, falling back for absent or incorrectly typed values.

    Context::param_string

    fn Context::param_string(self : Context, name : String, default : String) -> String

    Read a string parameter, falling back for absent or incorrectly typed values.

    Context::param_strings

    fn Context::param_strings(self : Context, name : String) -> Array[String]

    Read a string or an array of strings; ignore non-string entries.

    Context::set_params

    fn Context::set_params(self : Context, params :
    Json
    ) -> Unit

    Set the current plugin's parameters; non-object values behave as empty objects.

    Context::to_repr

    Plugin

    pub(all) struct Plugin {
    name : String
    description : String
    run : (
    Document
    , Context) -> Bool
    }

    A plugin transforms the document in place and reports whether it changed anything, which drives multipass optimization. Built-in plugins and the ones a caller passes in Config::custom follow the same rules:

    • only remove or rewrite what a renderer cannot observe at Context::precision;
    • return true exactly when the document changed, otherwise every run takes the maximum of 10 passes;
    • run on any document, in any position of the pipeline, without raising;
    • read parameters with Context::param_bool, param_int, param_string and param_strings, which see the object Config::params holds under the plugin's name.

    Plugin::to_repr

    find_plugin

    fn find_plugin(name : String) -> Plugin?

    Look a plugin up by its svgo name (for example "convertPathData").

    optional_plugins

    let optional_plugins : Array[Plugin]

    Plugins that are available but not enabled by default.

    move_group_attrs_to_elems is implemented and passes svgo's cases for it, but it stays off here: pushing a group's transform onto its children lets convert_path_data bake the matrix into every path, which lengthens the coordinates and leaves formerly identical siblings unmergeable. Measured over the eleven files in svgo/testdata/ and packages/compare/corpus/, enabling it costs 15,859 bytes on the Ghostscript tiger and saves 48 bytes everywhere else combined (it does help small icons: 27 bytes on the Sketch export, 21 on the twelve-fold world map). svgo's own output shows the same effect (68,101 bytes with it, 52,029 without), so this is a deliberate deviation, not a missing plugin. Enable it with --enable moveGroupAttrsToElems.

    preset_default

    let preset_default : Array[Plugin]

    The default plugin pipeline, in svgo's preset-default order (the plugins that are not implemented yet are listed in the README). remove_desc sits last because svgo removes descriptions after the structural passes.