npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@novafex/cvg

v0.2.0

Published

Compressed Vector Graphics as a smaller SVG alternative for browsers and web apps

Downloads

4

Readme

CVG - Compressed Vector Graphics

Compressed Vector Graphics (CVG) is an alternative format for encoding vector graphics which is based on interoperability with SVG. Essentially, it transforms SVG for optimized over-the-wire transmission, and usage within JavaScript environments. It does this by converting SVG's XML nodes into a JSON structure with some liberties taken in flexibility for short-hand declarations.

[!WARNING] Not for production use yet as it is still a heavy work-in-progress.

npm install --save @novafex/cvg
yarn add @novafex/cvg

Implementations

It's suggested to use the CLI for use in transforming files locally in your shell. For React projects there is a simple component react-cvg which expands CVG into the SVG for use in browsers.

Format

The CVG format is based on JSON objects makes heavy usage of tuples and dynamic types. There are TypeScript definitions for use with other libraries as well that will help.

A CVG "definition" is held as an array, the first element is the root declaration which declares the attributes within the root SVG node. After the root declaration, the remaining elements are children of the root node.

Root Declaration

The root declaration accepts variable types depending on how much definition is needed. As is the whole point of CVG, using the least amount of information is the target.

CVGRoot = CVGViewport | object
CVGViewport = string | [number, number] | [number, number, number, number]
  • string will use the contents as the viewport attribute on the root node.
  • [number, number] interprets as [width, height] for the viewport attribute and will set the position parts as 0.
  • [number, number, number, number] interprets as [x, y, width, height] and will construct the viewport attribute using all values.
  • object should be a string indexible object in which each attribute is declared as properties in it. They are passed through directly.

Children

After the root declaration, the remaining elements in the CVG definition are considered children of the root element and define the parts of the graphic.

CVGChild = string | CVGElement
CVGElement = [ string, object, string? ]

If the child is a string type, it is treated as short-hand for a path node with a d path definition being supplied by the string. This makes it easier for quick path-only icons. The contents of the string are taken directly.

For more flexibility, the element can be declared manually with a tuple containing looking like [tag, attributes, innerContent]. The tag is a string representing the SVG tag name such as "path", or "circle". The attributes object is a string- indexable record containing the attributes as key/value properties. Finally, the last innerContent portion is for injection of text inside the node and is used for style tags or other text block elements.

[!WARNING] There is a known limitation in which groups and nested elements are not implemented yet. They will be added, but the current version does not handle it.

Credits

Created and written by Chris Pikul

License

MIT License

Copyright (c) 2023 Novafex Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.