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

@sketchmine/sketch-file-format

v3.0.0

Published

Abstract layer on top of the sketch file format.

Downloads

5

Readme

Github banner for sketchmine

@sketchmine/sketch-file-format

The sketch file format provides a platform independent layer above the Sketch File formats JSON structure. To see the JSON output without unzipping or modifying the .sketch file sketch provides a tool called SketchTool that is shipped with Sketch.

To receive a dump of the JSON structure that is going to be built with this package you can use the following command: sketchtool dump path/to/document.sketch

Dependency graph

Dependency graph of the sketchmine sketch-file-format

Architecture

Interfaces

The most helpful area in this package will be the ./src/interfaces folder that provides all interfaces for the Sketch file format. Everything that is a Sketch related interface should be prefixed with interface Sketch${object-name} {} like interface SketchBase {}.

Be aware that this collection of interfaces was reverse engineered, because there is no official documentation for that.

To gain insight into all the magic numbers in sketch are take a look at the sketch-constants.ts file that provides all the enums with human readable values.

Object Types

Sketch Object types are the _class properties in the JSON tree of a Sketch file.

All available Object Types that have been reverse engineered are listed in an enum in the base.interface.ts. If you add a new model for a new Sketch object please be sure to add it to the ObjectTypes enum as well.

export enum SketchObjectTypes {
  Artboard = 'artboard',
  AttributedString = 'attributedString',
  Bitmap = 'bitmap',
  Blur = 'blur',
  Border = 'border',
  Color = 'color',
  CurvePoint = 'curvePoint',
  Document = 'document',
  ExportOptions = 'exportOptions',
  Fill = 'fill',
  FontDescriptor = 'fontDescriptor',
  Frame = 'rect',
  Gradient = 'gradient',
  GradientStop = 'gradientStop',
  GraphicsContext = 'graphicsContextSettings',
  Group = 'group',
  InnerShadow = 'innerShadow',
  OverrideValue = 'overrideValue',
  Page = 'page',
  ParagraphStyle = 'paragraphStyle',
  Path = 'path',
  Rectangle = 'rectangle',
  RulerData = 'rulerData',
  Shadow = 'shadow',
  ShapeGroup = 'shapeGroup',
  ShapePath = 'shapePath',
  StringAttribute = 'stringAttribute',
  Style = 'style',
  SymbolInstance = 'symbolInstance',
  SymbolMaster = 'symbolMaster',
  Text = 'text',
  TextStyle = 'textStyle',
}

Models

The models are the abstract syntax tree of the Sketch file format. You can build the Object Tree of the Sketch file in Typescript classes.

Every Sketch Object should have its own models file (Try to avoid code duplication – for this purpose there is a base model where the class can extend from).

Building the package

To build the package Rollup.js is used as a module bundler. The configuration can be found in the rollup.config.js file and is orchestrated by the yarn package manager. The package bundle is formatted commonjs and is meant to be consumed only by node.js applications.

The build can be started with the following two commands:

  • yarn build for building the package.
  • yarn dev for building and watching the sources of the package (rebuilds after safe).

Linting

The source code of this package is going to be linted by our CI environment. To ensure a coding standard and quality use the configured linter tslint. This package extends from the tslint-config-airbnb and the linting configuration extends from the root tslint.json.

Run yarn lint to execute the linter.

Testing the package

To ensure that the sketch-file-format is working, write tests and put them in proper named file.

Important!

All tests according to this package should be wrapped in a describe with the prefix: [sketch-file-format] › ... like the following:

// import statements

describe('[sketch-file-format] › ${folder} › ${description of the suite}', () => {
  // your tests should be placed here
});

For tests the jest Framework was chosen, see jestjs.io for details.

Run yarn test to execute all tests specified for the Sketch file format. Run yarn test -f filename.test to execute only tests that match the provided RegExp for the filename.