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

@skpm/sketchapp-json-plugin

v0.2.0

Published

Utilities for working with the Sketch JSON internal formats

Downloads

9

Readme

Sketch.app JSON Plugin library

Provides utilities for basing your plugins on the JSON format instead of learning all of the sketch private API objects.

This is indended to be used within the Sketch plugin environment; to generate sketch files entirely in node.js, you need a different library.

There are 3 main APIs:

// Converts an object, eg from context.selection into a JSON string representation
toSJSON(sketchObject);

// Takes a Sketch JS object tree with (optional) Sketch version and turns it into a native object. May throw on invalid data
fromSJSONDictionary(jsObject, version);

// Convenience method that converts JSON strings to be used with `fromSJSONDictionary`
fromSJSON(json, version);

NOTE: The version parameter is used to specify the highest Sketch version number you would like to support. Also, it doesn't follow the normal Sketch public version numbers (e.g. v45, v46, etc). Instead it uses an internal build number. You can find your desired version using the handy map in this discussion thread: http://sketchplugins.com/d/316-sketch-version.

Additionally, if you would like to create layers from a dictionary, you want this:

// Pass in a javascript object literal
const obj: SJTextLayer = {
"_class": "text",
"do_objectID": generateID(),
"frame": {
  "_class": "rect",
  "constrainProportions": false,
  "height": 17,
  "width": 117,
  "x": 146,
  "y": 253
},
"isVisible": true,
"name": "My hot hot ABCD",
...

};
fromSJSONObject(obj);

If you want to verify your version of Sketch is compatible (v43+):

import JSONPlugin from 'sketchapp-json-plugin';
if (JSONPlugin.appVersionSupported()) {
  const layer = SJSON.fromSJSON(myJSON);
  ...
  document.pages[0].addLayers([layer]);
} else {
  // Use old code path
}