Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@sketch-hq/sketch-file-format-ts
Advanced tools
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-ts'
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-ts'
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 discriminate properties on the helper union
types like AnyLayer
import FileFormat from '@sketch-hq/sketch-file-format-ts'
const mapLayers = (layers: FileFormat.AnyLayer[]) => {
return layers.map((layer) => {
switch (layer._class) {
case 'bitmap':
// type narrowed to Bitmap layers
case 'star':
// type narrowed to Star layers
}
})
}
Following is further information for making changes to how the types are generated.
The scripts/generate.ts
ingests the file format JSON Schema, and generates
type definitions using the TypeScript compiler API.
We depend on multiple major versions of the schemas in package.json using yarn aliases, and generate types for each one. This means that users that have to implement multiple versions of the file format don't need to manually manage multiple versions of this package.
Please note that the latest version of the schemas is referenced directly within the monorepo and not using aliases.
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 |
Try and use the conventional commits convention when writing commit messages.
scripts/generate.ts
main
3.4.3
run,yarn add @sketch-hq/sketch-file-format-3@npm:@sketch-hq/sketch-file-format@3.4.3
index.ts
to export the types, and scripts/generate.ts
to generate the new
typesmain
FAQs
TypeScript types for the Sketch File Format
The npm package @sketch-hq/sketch-file-format-ts receives a total of 34,126 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.