@sketch-hq/sketch-file-format-ts
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -1,56 +0,6 @@ | ||
# Changelog | ||
# @sketch-hq/sketch-file-format-ts | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
## 4.0.3 | ||
### Patch Changes | ||
### [4.0.2](https://github.com/sketch-hq/sketch-file-format-ts/compare/v4.0.1...v4.0.2) (2020-02-10) | ||
### [4.0.1](https://github.com/sketch-hq/sketch-file-format-ts/compare/v4.0.0...v4.0.1) (2020-01-22) | ||
## [4.0.0](https://github.com/sketch-hq/sketch-file-format-ts/compare/v3.0.0...v4.0.0) (2019-12-09) | ||
## [3.0.0](https://github.com/sketch-hq/sketch-file-format-ts/compare/v1.0.0...v3.0.0) (2019-11-15) | ||
### ⚠ BREAKING CHANGES | ||
* Code will have to use the new type name to avoid compilation errors | ||
### Features | ||
* add `AnyObject` type ([79be064](https://github.com/sketch-hq/sketch-file-format-ts/commit/79be06429f36228a0c3127f0f909b3fa08f8cff0)) | ||
### Bug Fixes | ||
* upgrade to sketch-file-format@3.2.0 ([2b8eb4a](https://github.com/sketch-hq/sketch-file-format-ts/commit/2b8eb4ab3e883c5b9cafba9617ddeba579e95b24)), closes [#5](https://github.com/sketch-hq/sketch-file-format-ts/issues/5) [#4](https://github.com/sketch-hq/sketch-file-format-ts/issues/4) [#2](https://github.com/sketch-hq/sketch-file-format-ts/issues/2) | ||
### improvement | ||
* rename FileFormat type to Contents ([1ea31fc](https://github.com/sketch-hq/sketch-file-format-ts/commit/1ea31fccc9da92758af357b49c0b47bbd4a555fc)) | ||
## [2.0.0](https://github.com/sketch-hq/sketch-file-format-ts/compare/v1.1.0...v2.0.0) (2019-11-11) | ||
### ⚠ BREAKING CHANGES | ||
* Code will have to use the new type name to avoid compilation errors | ||
### improvement | ||
* rename FileFormat type to Contents ([f79c5a5](https://github.com/sketch-hq/sketch-file-format-ts/commit/f79c5a5d2aee306dfd5e459c669fcd60ac404fab)) | ||
## [1.1.0](https://github.com/sketch-hq/sketch-file-format-ts/compare/v1.0.0...v1.1.0) (2019-11-11) | ||
### Features | ||
* add `AnyObject` type ([03f2659](https://github.com/sketch-hq/sketch-file-format-ts/commit/03f2659a3d7df43657da95c681f516c5d95b7259)) | ||
## 1.0.0 (2019-11-08) | ||
### Features | ||
* export historical types by file format semver not document version ([b75e52f](https://github.com/sketch-hq/sketch-file-format-ts/commit/b75e52fbd82fb1a2d3642b6812a26913b875dbad)) | ||
* initial commit ([5e2191a](https://github.com/sketch-hq/sketch-file-format-ts/commit/5e2191aad340290c5ae1136602aaf881a5c1afb3)) | ||
- 4d07d47: Update to file format `3.5.3` |
@@ -607,5 +607,4 @@ /** | ||
export declare enum InferredLayoutAxis { | ||
None = 0, | ||
Horizontal = 1, | ||
Vertical = 2 | ||
Horizontal = 0, | ||
Vertical = 1 | ||
} | ||
@@ -1036,3 +1035,4 @@ /** | ||
Flexible = 0, | ||
Fixed = 1 | ||
Fixed = 1, | ||
FixedWidthAndHeight = 2 | ||
} | ||
@@ -1259,2 +1259,26 @@ /** | ||
/** | ||
* Defines font data embedded in the document | ||
*/ | ||
export declare type EmbeddedFontRef = { | ||
_class: 'embeddedFontReference'; | ||
embeddedFontData: FontDataRef; | ||
fontFamilyName: string; | ||
fontFileType: string; | ||
embedded: boolean; | ||
}; | ||
/** | ||
* Defines a reference to base64 font data within the document bundle | ||
*/ | ||
export declare type FontDataRef = { | ||
_class: 'MSJSONOriginalDataReference'; | ||
_ref_class: 'MSEmbeddedFontData'; | ||
_ref: string; | ||
data: { | ||
_data: string; | ||
}; | ||
sha1: { | ||
_data: string; | ||
}; | ||
}; | ||
/** | ||
* Defines a reference to a JSON page file within the document bundle | ||
@@ -1319,3 +1343,3 @@ */ | ||
}; | ||
version: 121 | 122 | 123; | ||
version: 121 | 122 | 123 | 124 | 125 | 126 | 127; | ||
fonts: string[]; | ||
@@ -1361,9 +1385,9 @@ compatibilityVersion: 99; | ||
export declare type SketchVariant = 'NONAPPSTORE' | 'APPSTORE' | 'BETA' | 'PRIVATE' | 'INTERNAL' | 'EXPERIMENTAL' | 'TESTING' | 'UNITTEST'; | ||
/** | ||
* TODO | ||
*/ | ||
export declare type User = { | ||
document: { | ||
pageListHeight: number; | ||
pageListCollapsed: number; | ||
pageListCollapsed: NumericalBool; | ||
expandedSymbolPathsInSidebar?: []; | ||
expandedTextStylePathsInPopover?: []; | ||
libraryListCollapsed?: NumericalBool; | ||
}; | ||
@@ -1388,2 +1412,3 @@ [key: string]: any; | ||
layerSymbols?: SymbolContainer; | ||
embeddedFontReferences?: EmbeddedFontRef[]; | ||
pages: Page[]; | ||
@@ -1409,2 +1434,3 @@ }; | ||
layerSymbols?: SymbolContainer; | ||
embeddedFontReferences?: EmbeddedFontRef[]; | ||
pages: PageFileRef[]; | ||
@@ -1423,2 +1449,2 @@ }; | ||
*/ | ||
export declare type AnyObject = AssetCollection | ImageCollection | ColorAsset | Color | GradientAsset | Gradient | GradientStop | ImageFileRef | ImageDataRef | ForeignLayerStyle | SharedStyle | Style | Border | GraphicsContextSettings | BorderOptions | Blur | Fill | TextStyle | ParagraphStyle | FontDescriptor | Shadow | InnerShadow | ColorControls | ForeignSymbol | SymbolMaster | ExportOptions | ExportFormat | Rect | FlowConnection | FreeformGroupLayout | InferredGroupLayout | Artboard | Group | Oval | CurvePoint | Polygon | Rectangle | ShapePath | Star | Triangle | ShapeGroup | Text | AttributedString | StringAttribute | SymbolInstance | OverrideValue | Slice | Hotspot | Bitmap | RulerData | LayoutGrid | SimpleGrid | OverrideProperty | ForeignTextStyle | SharedStyleContainer | SharedTextStyleContainer | SymbolContainer | PageFileRef | Page; | ||
export declare type AnyObject = AssetCollection | ImageCollection | ColorAsset | Color | GradientAsset | Gradient | GradientStop | ImageFileRef | ImageDataRef | ForeignLayerStyle | SharedStyle | Style | Border | GraphicsContextSettings | BorderOptions | Blur | Fill | TextStyle | ParagraphStyle | FontDescriptor | Shadow | InnerShadow | ColorControls | ForeignSymbol | SymbolMaster | ExportOptions | ExportFormat | Rect | FlowConnection | FreeformGroupLayout | InferredGroupLayout | Artboard | Group | Oval | CurvePoint | Polygon | Rectangle | ShapePath | Star | Triangle | ShapeGroup | Text | AttributedString | StringAttribute | SymbolInstance | OverrideValue | Slice | Hotspot | Bitmap | RulerData | LayoutGrid | SimpleGrid | OverrideProperty | ForeignTextStyle | SharedStyleContainer | SharedTextStyleContainer | SymbolContainer | EmbeddedFontRef | FontDataRef | PageFileRef | Page; |
@@ -235,5 +235,4 @@ "use strict"; | ||
(function (InferredLayoutAxis) { | ||
InferredLayoutAxis[InferredLayoutAxis["None"] = 0] = "None"; | ||
InferredLayoutAxis[InferredLayoutAxis["Horizontal"] = 1] = "Horizontal"; | ||
InferredLayoutAxis[InferredLayoutAxis["Vertical"] = 2] = "Vertical"; | ||
InferredLayoutAxis[InferredLayoutAxis["Horizontal"] = 0] = "Horizontal"; | ||
InferredLayoutAxis[InferredLayoutAxis["Vertical"] = 1] = "Vertical"; | ||
})(InferredLayoutAxis = exports.InferredLayoutAxis || (exports.InferredLayoutAxis = {})); | ||
@@ -286,2 +285,3 @@ /** | ||
TextBehaviour[TextBehaviour["Fixed"] = 1] = "Fixed"; | ||
TextBehaviour[TextBehaviour["FixedWidthAndHeight"] = 2] = "FixedWidthAndHeight"; | ||
})(TextBehaviour = exports.TextBehaviour || (exports.TextBehaviour = {})); | ||
@@ -288,0 +288,0 @@ /** |
@@ -5,6 +5,17 @@ MIT License | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "@sketch-hq/sketch-file-format-ts", | ||
"description": "TypeScript types for the Sketch File Format", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"main": "dist/index", | ||
"types": "dist/index", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"files": ["dist"], | ||
"repository": "github:sketch-hq/sketch-file-format-ts", | ||
@@ -21,21 +19,16 @@ "keywords": [ | ||
"devDependencies": { | ||
"@commitlint/cli": "8.2.0", | ||
"@commitlint/config-conventional": "8.2.0", | ||
"@changesets/cli": "2.6.2", | ||
"@sketch-hq/sketch-file-format-1": "npm:@sketch-hq/sketch-file-format@1.1.7", | ||
"@sketch-hq/sketch-file-format-2": "npm:@sketch-hq/sketch-file-format@2.0.3", | ||
"@sketch-hq/sketch-file-format-3": "npm:@sketch-hq/sketch-file-format@3.4.2", | ||
"@types/humps": "1.1.2", | ||
"@types/jest": "24.0.22", | ||
"@types/node": "12.12.7", | ||
"@types/prettier": "1.18.3", | ||
"commitizen": "4.0.3", | ||
"cz-conventional-changelog": "3.0.2", | ||
"@sketch-hq/sketch-file-format-3": "npm:@sketch-hq/sketch-file-format@3.5.3", | ||
"@types/humps": "1.1.3", | ||
"@types/jest": "25.2.1", | ||
"@types/node": "13.7.4", | ||
"@types/prettier": "2.0.0", | ||
"humps": "2.0.1", | ||
"husky": "3.0.9", | ||
"jest": "24.9.0", | ||
"prettier": "1.19.1", | ||
"standard-version": "7.0.0", | ||
"ts-jest": "24.1.0", | ||
"ts-node": "8.5.0", | ||
"typescript": "3.7.2" | ||
"jest": "25.3.0", | ||
"prettier": "2.0.4", | ||
"ts-jest": "25.3.1", | ||
"ts-node": "8.8.2", | ||
"typescript": "3.8.3" | ||
}, | ||
@@ -46,21 +39,5 @@ "scripts": { | ||
"test": "jest", | ||
"release": "HUSKY_SKIP_HOOKS=1 standard-version --no-verify", | ||
"format-check": "prettier --check **/*.{ts,md,json}", | ||
"commitlint": "commitlint --from HEAD~1 --to HEAD --verbose" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true" | ||
} | ||
}, | ||
"standard-version": { | ||
"scripts": { | ||
"prerelease": "yarn build" | ||
} | ||
"release": "yarn build && changeset publish", | ||
"format-check": "prettier --check {**/,}*.{ts,md,json}" | ||
} | ||
} |
@@ -7,9 +7,13 @@ # Sketch File Format TS | ||
This repo contains TypeScript types automatically generated from the [Sketch File Format](https://github.com/sketch-hq/sketch-file-format) JSON Schemas. | ||
This repo contains TypeScript types automatically generated from the | ||
[Sketch File Format](https://github.com/sketch-hq/sketch-file-format) JSON | ||
Schemas. | ||
Types are maintained and exported for each Sketch File Format major version. See usage instructions below for more information. | ||
Types are maintained and exported for each Sketch File Format major version. See | ||
usage instructions below for more information. | ||
## Use cases | ||
- Strongly type objects representing Sketch documents, or fragments of Sketch documents in TypeScript projects | ||
- Strongly type objects representing Sketch documents, or fragments of Sketch | ||
documents in TypeScript projects | ||
@@ -19,3 +23,2 @@ ## Related projects | ||
- [sketch-file-format](https://github.com/sketch-hq/sketch-file-format) | ||
- [sketch-reference-files](https://github.com/sketch-hq/sketch-reference-files) | ||
@@ -39,10 +42,7 @@ ## Usage | ||
```typescript | ||
import { | ||
FileFormat1, | ||
FileFormat2, | ||
FileFormat3, | ||
} from '@sketch-hq/sketch-file-format-ts' | ||
import { FileFormat1, FileFormat2 } from '@sketch-hq/sketch-file-format-ts' | ||
``` | ||
> Read about how file format versions map to Sketch document versions [here](https://github.com/sketch-hq/sketch-file-format#sketch-document-version-mapping) | ||
> Read about how file format versions map to Sketch document versions | ||
> [here](https://github.com/sketch-hq/sketch-file-format) | ||
@@ -67,3 +67,4 @@ ## Examples | ||
Layer types can be narrowed using discriminated unions | ||
Layer types can be narrowed using discriminate properties on the helper union | ||
types like `AnyLayer` | ||
@@ -74,8 +75,8 @@ ```typescript | ||
const mapLayers = (layers: FileFormat.AnyLayer[]) => { | ||
return layers.map(layer => { | ||
return layers.map((layer) => { | ||
switch (layer._class) { | ||
case 'bitmap': | ||
// type narrowed to Bitmap | ||
// type narrowed to Bitmap layers | ||
case 'star': | ||
// type narrowed to Star | ||
// type narrowed to Star layers | ||
} | ||
@@ -86,3 +87,4 @@ }) | ||
Work with representations of Sketch files that could have a range of document versions | ||
Work with representations of Sketch files that could have a range of document | ||
versions | ||
@@ -101,4 +103,2 @@ ```typescript | ||
// 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 | ||
} | ||
@@ -108,9 +108,56 @@ } | ||
## Scripts | ||
## Development | ||
| 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 | | ||
This section of the readme is related to developing the file format spec. If you | ||
just want to consume the schemas you can safely ignore this. | ||
### Approach | ||
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](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias), | ||
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. | ||
### Scripts | ||
| 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 | | ||
### Workflows | ||
#### Conventional commits | ||
Try and use the | ||
[conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) | ||
convention when writing commit messages. | ||
#### Changing how the types are generated | ||
1. Update `scripts/generate.ts` | ||
1. Unit test your changes | ||
1. Determine the semver bump type and call yarn changeset to create an intent to | ||
release your changes (read more about changesets | ||
[here](https://github.com/atlassian/changesets)). | ||
1. Open a PR to `master` | ||
#### Adding or updating a file format version | ||
1. Use the yarn aliases syntax to add new schema version | ||
1. Use exact semvers, for example to update or add v3 of the schemas as `3.4.3` | ||
run,<br/>`yarn add @sketch-hq/sketch-file-format-3@npm:@sketch-hq/sketch-file-format@3.4.3` | ||
1. If the schema version is new to the repo you'll also need to update the | ||
`index.ts` to export the types, and `scripts/generate.ts` to generate the new | ||
types | ||
1. Open a PR to `master` | ||
#### Release | ||
1. Merge the release PR maintained by the changesets | ||
[GitHub Action](https://github.com/changesets/action). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14
5128
156
159021
1