Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@sketch-hq/sketch-file-format-ts
Advanced tools
TypeScript types for the Sketch File Format
This repo contains TypeScript types automatically generated from the Sketch File Format JSON Schemas.
Types are maintained and exported for each Sketch File Format major version. See usage instructions below for more information.
Add the npm module using npm
or yarn
npm install @sketch-hq/sketch-file-format-ts
Types for the latest file format are on the default export
import FileFormat from '@sketch-hq/sketch-file-format'
Types for historical file formats are accessible via named exports
import {
FileFormat1,
FileFormat2,
FileFormat3,
} from '@sketch-hq/sketch-file-format'
Read about how file format versions map to Sketch document versions here
Create a typed layer blur object
import FileFormat from '@sketch-hq/sketch-file-format'
const blur: FileFormat.Blur = {
_class: 'blur',
isEnabled: false,
center: '{0.5, 0.5}',
motionAngle: 0,
radius: 10,
saturation: 1,
type: FileFormat.BlurType.Gaussian,
}
Layer types can be narrowed using discriminated unions
import FileFormat from '@sketch-hq/sketch-file-format'
const mapLayers = (layers: FileFormat.AnyLayer[]) => {
return layers.map(layer => {
switch (layer._class) {
case 'bitmap':
// layer type narrows to Bitmap
case 'star':
// layer type narrowed to Star
}
})
}
Work with representations of Sketch files that could have a range of document versions
import {
FileFormat1,
FileFormat2,
FileFormat3,
} from '@sketch-hq/sketch-file-format'
const processDocumentContents = (
contents:
| FileFormat1.FileFormat
| FileFormat2.FileFormat
| FileFormat3.FileFormat,
) => {
if (contents.meta.version === 119) {
// type narrowed to file format v1, i.e. Sketch documents with version 119
} else {
// type narrowed to a union of document versions 120 and 121
}
}
Script | Description |
---|---|
yarn build | Builds the project into the dist folder |
yarn test | Build script unit tests |
yarn format-check | Checks the repo with Prettier |
yarn release | Tags the repo and updates the changelog and semver automatically based on commit history. You'll still need to push the changes and yarn publish manually afterwards |
FAQs
TypeScript types for the Sketch File Format
The npm package @sketch-hq/sketch-file-format-ts receives a total of 26,377 weekly downloads. As such, @sketch-hq/sketch-file-format-ts popularity was classified as popular.
We found that @sketch-hq/sketch-file-format-ts 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.