
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
@sketch-hq/sketch-file
Advanced tools
Read and write Sketch documents from TypeScript.
fromFile
functionRead a Sketch Library file containing Color Variables, and dump them to JSON:
import { fromFile } from '@sketch-hq/sketch-file'
import { resolve } from 'path'
const sketchDocumentPath = './sketch-color-library.sketch'
// Custom type color swatches should be converted to
type ColorToken = {
name: string
value: {
r: number
g: number
b: number
a: number
}
}
// Transform swatches into list of `ColorToken` after parsing the file successfully
fromFile(resolve(__dirname, sketchDocumentPath)).then((parsedFile) => {
const doc = parsedFile.contents.document
if (!doc.sharedSwatches) return
var colors: Array<ColorToken> = []
doc.sharedSwatches.objects.forEach((color) => {
colors.push({
name: color.name,
value: {
r: color.value.red,
g: color.value.green,
b: color.value.blue,
a: color.value.alpha,
},
})
})
console.log(JSON.stringify(colors, null, 2))
})
toFile
functionSet the'Background color › Include in Export' option to true
for all Artboards
in a Sketch document:
import { fromFile, SketchFile, toFile } from '@sketch-hq/sketch-file'
import { Artboard } from '@sketch-hq/sketch-file-format-ts/dist/cjs/types'
import { resolve } from 'path'
const sketchDocumentPath = './artboards-with-background.sketch'
fromFile(resolve(__dirname, sketchDocumentPath)).then((parsedFile) => {
parsedFile.contents.document.pages.forEach((page) => {
page.layers
.filter((layer): layer is Artboard => true)
.forEach((artboard) => {
artboard.includeBackgroundColorInExport = true
})
})
var exportableFile: SketchFile = {
contents: parsedFile.contents,
filepath: sketchDocumentPath,
}
toFile(exportableFile)
})
FAQs
Utilities to read and write Sketch documents
The npm package @sketch-hq/sketch-file receives a total of 98 weekly downloads. As such, @sketch-hq/sketch-file popularity was classified as not popular.
We found that @sketch-hq/sketch-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.