Skip to content

Releases: noahbald/oxvg

v0.0.9

Choose a tag to compare

@github-actions github-actions released this 05 Oct 08:29

What's Changed

New Contributors

Full Changelog: v0.0.8...v0.0.9

v0.0.8

Choose a tag to compare

@github-actions github-actions released this 18 Sep 23:12

What's Changed

New Contributors

Full Changelog: v0.0.7...v0.0.8

v0.0.7

Choose a tag to compare

@github-actions github-actions released this 09 Aug 09:26

This release introduces a JSX transformer as a new feature to OXVG as well as some fixes to regressions introduced in 0.0.6.

The JSX transformer of OXVG aims to be a drop-in replacement to SVGR. It will take an SVG document, optimise it, and build it into a JSX module.
Optimisation options work the same as the optimiser.

Usage

The JSX transformer aims to work as closely as possible to SVGR and inherits its options, only with deviations in optimisation options, templating, and plugins. You can use it with either the oxvg jsx command or by using the Node bindings from @oxvg/jsx.

Similar to other commands it accepts usage with stdin/stdout

cat my-file.svg | oxvg jsx > my-file.jsx

It also accepts filesystem options in line with other OXVG commands. Note that this deviates from SVGR options.

# Read and transform file to a `.jsx` file.
oxvg jsx my-file.svg

# Read and transform many files to `.jsx` files and creates `index.js`
oxvg jsx svgs/

# Read and transform many files and directories to `.jsx` files and creates `index.js` files
oxvg jsx svgs/ -r

# Read and transform many files and directories to a new location
oxvg jsx svgs/ -r -o output/

# Read and transform many files and directories to a new location, including hidden files
oxvg jsx svgs/ -r -o output/ -. --no-ignore

Optimisation

SVG optimisation is done by the OXVG optimiser. Optimisation is available either through the CLI or NAPI bindings. Optimisation is enabled by default.
Optimisation options can be configured using a configuration file.

If using the @oxvg/jsx Node package, configuration can be passed directly.

import { transform } from "@oxvg/jsx";
const jsxCode = await transform(svgCode, { oxvg: { convertPathData: false } });

Or for ease of migration, you can convert an existing SVGO config.

import { transform } from "@oxvg/jsx";
import { convertSvgoConfig } from "@oxvg/napi";
const jsxCode = await transform(svgCode, { oxvgConfig: convertSvgoConfig(svgoConfig) });

Templates

OXVG supports templates which allow you to generate more bespoke components for whatever your needs may be.

The CLI will read a JavaScript and replace matching identifiers with the generated expressions.

// template.js
$imports;
$interfaces;

class $componentName extends React.Component {
	constructor($props) {
		super(props);
	}

	render() {
		return $jsx;
	}
}
$exports;
cat my-file.svg | oxvg jsx --template template.js > output.jsx
// output.jsx
import * as React from "react";
class SvgComponent extends React.Component {
  constructor(props){
    super(props);
  }
  render() {
    return <svg><g/></svg>;
  }
}
export default SvgComponent;

The Node bindings accept the template as a function, which will receive the chunks as strings to return a final string.

transform(svgCode, { template: ({ imports, interfaces, componentName, props, jsx, exports }) => `${imports};
${interfaces};

class ${componentName} extends React.Component {
	constructor(${props}) {
		super(props);
	}

	render() {
		return ${jsx};
	}
}
${exports};`);

Plugins

OXVG doesn't accept plugins. Consider processing the input/output directly instead.

cat my-file.svg | oxvg jsx --no-oxvg | prettier --stdin-filepath output.jsx > output.jsx

What's Changed

Full Changelog: v0.0.6...v0.0.7

v0.0.6

Choose a tag to compare

@github-actions github-actions released this 23 Jul 00:55

This release introduces actions as well as some performance and ergonomic improvements.

Note

This release skips 0.0.5 for npm so sync npm and cargo versions

What's Changed

New Contributors

Full Changelog: v0.0.4...v0.0.6

v0.0.4

Choose a tag to compare

@github-actions github-actions released this 25 Dec 04:54

Happy Holidays! This release brings strong performance increases to the parsing and optimisation of documents. This release also introduces OXVG as a linter and LSP combo, to help you discover issues in documents.
See the updated wiki for more.

Install artifacts here.

Note

Crates are accidentally released as 0.0.5, future releases until 0.0.6 will be released as 0.0.5-1, 0.0.5-2, etc.

What's Changed

New Contributors

Full Changelog: v0.0.3...v0.0.4

v0.0.4-1

Choose a tag to compare

@github-actions github-actions released this 24 Jun 09:04

Fixes napi pipeline, no changes to binary

v0.0.3

Choose a tag to compare

@github-actions github-actions released this 21 Jun 00:09

Special thanks to @jonasgeiler for producing a playground!

What's Changed

New Contributors

Full Changelog: v0.0.2...v0.0.3

v0.0.3-1

Choose a tag to compare

@github-actions github-actions released this 10 May 06:44
0.0.3-1

v0.0.3-0

Choose a tag to compare

@github-actions github-actions released this 08 May 22:01
0.0.3-0

v0.0.2

Choose a tag to compare

@noahbald noahbald released this 27 Apr 05:51

This release's theme is correctness, where we've managed to get 100% of the SVGs in the w3c test suite and oxygen library optimized without visually changing the document.

Check out the wiki page for more!

There's also new wasm and napi binding that will be coming to npm soon. Plus some performance improvements here and there :)

What's Changed

Full Changelog: 0.0.1...v0.0.2

Self Build

cargo build --release --bin oxvg

SHA256 Checksum

See the artifacts listed here.