@oxvg/napi
v0.0.9
Published
OXVG is the fastest SVG toolchain for optimisation, linting, transformation, and manipulation. Usable via CLI and libraries for [Node](https://www.npmjs.com/package/@oxvg/napi), [WASM](https://www.npmjs.com/package/@oxvg/wasm), or Rust.
Readme
Oxidised Vector Graphics for NAPI
OXVG is the fastest SVG toolchain for optimisation, linting, transformation, and manipulation. Usable via CLI and libraries for Node, WASM, or Rust.
See the main readme for more!
Tools
The following are available through NAPI bindings
🪶 Optimiser
An SVG optimiser similar to SVGO.
Examples
Optimise svg with the default configuration
import { optimise } from "@oxvg/napi";
const result = optimise(`<svg />`);Or, provide your own config
import { optimise } from "@oxvg/napi";
// Only optimise path data
const result = optimise(`<svg />`, { convertPathData: {} });Or, extend a preset
import { optimise, extend, Extends } from "@oxvg/napi";
const result = optimise(
`<svg />`,
extend(Extends.Default, { convertPathData: { removeUseless: false } }),
);You can even make use of your existing SVGO config
import { optimise, convertSvgoConfig } from "@oxvg/napi";
import { config } from "./svgo.config.js";
const result = optimise(`<svg />`, convertSvgoConfig(config.plugins));🤖 Actions
Actions are a set of commands invoked by a program in order to manipulate an SVG document or pull information from it.
import { Actor } from "@oxvg/wasm";
const actor = new Actor(`<svg viewBox="0 0 3 3">
<path d="M0 0h2v2H0Z"/>
<path d="M1 1h2v2H1Z" />
</svg>`);
actor.select("path");
actor.pathIntersect();
console.log(actor.document());