Skip to content

Commit

Permalink
Added sections to README, renamed LinearGradient & fixed `secenegra…
Browse files Browse the repository at this point in the history
…ph.selection` type

- fixes #72
- fixes #60
- closes #41
  • Loading branch information
pklaschka committed Jan 1, 2020
1 parent 51fcec1 commit 1bd37f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ You may also take a look at the `tsconfig.json` file contained in this repositor

## One last thing
These type declarations track the contents of the official documentation. If an issue with the type declarations stems from an issue with the official documentation, then the type declaration files will be fixed once the issue is addressed in the documentation. This is intentional so as to keep the type declarations both maintainable and in sync with the documentation.

A few notable exceptions include:
- `scenegraph.SceneNode` and `scenegraph.RootNode`, are documented as classes, but implemented as interfaces (in the TypeScript-sense, i.e., without a constructor), which is how they get declared in the typings
- To avoid ambiguity with the *DOM* `Selection` type, the interface [`Selection`](https://adobexdplatform.com/plugin-docs/reference/selection.html) is implemented under the name `XDSelection` (in the global namespace), here.
- The `LinearGradient` type is incorrectly documented as [`LinearGradientFill`](https://adobexdplatform.com/plugin-docs/reference/LinearGradientFill.html). This is implemented "the right way" in the typings.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobexd/typings",
"version": "22.0.0",
"version": "25.0.0",
"typings": "./types/index.d.ts",
"description": "Typings for Adobe XD CC",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions types/assets.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'assets' {
import {Color, LinearGradientFill, RadialGradientFill} from "scenegraph";
import {Color, LinearGradient, RadialGradient} from "scenegraph";

/**
* Type of gradient color element: linear gradient or radial gradient
Expand Down Expand Up @@ -37,7 +37,7 @@ declare module 'assets' {
*/
gradientType: GradientType;
/**
* Array of color stops used in the gradient, where stop >= 0 and <= 1, and the values are strictly increasing. Same format as the colorStops property of a LinearGradientFill object.
* Array of color stops used in the gradient, where stop >= 0 and <= 1, and the values are strictly increasing. Same format as the colorStops property of a LinearGradient object.
*/
colorStops: Array<{ stop: number, color: Color }>
}
Expand Down Expand Up @@ -132,7 +132,7 @@ declare module 'assets' {
* @param colorAssets The color assets
* @returns {number} number of assets added (may be less than requested if duplicates already exist)
*/
add(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
add(colorAssets: Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset | Array<Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset>): number;

/**
* Delete color/gradient assets from the collection.
Expand All @@ -142,7 +142,7 @@ declare module 'assets' {
* @param colorAssets The color assets
* @returns {number} number of assets deleted (may be less than requested if some didn't exist)
*/
delete(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
delete(colorAssets: Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset | Array<Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset>): number;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions types/scenegraph.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ declare module 'scenegraph' {
clone(): Color;
}

export class LinearGradientFill {
export class LinearGradient {
/**
* Array of objects representing each color and its position along the gradient line. The position (stop value) is a number 0.0 - 1.0.
*/
Expand All @@ -234,14 +234,14 @@ declare module 'scenegraph' {
endY: number;

/**
* Create a new LinearGradientFill instance.
* Create a new LinearGradient instance.
*/
constructor();

/**
* Returns a copy of this instance.
*/
clone(): LinearGradientFill;
clone(): LinearGradient;

/**
* Returns an array of [startX, startY, endX, endY].
Expand All @@ -259,9 +259,9 @@ declare module 'scenegraph' {
}

/**
* **The RadialGradientFill type is not documented and its API may change. Plugins currently cannot modify or otherwise work with radial gradients.**
* **The RadialGradient type is not documented and its API may change. Plugins currently cannot modify or otherwise work with radial gradients.**
*/
export class RadialGradientFill {
export class RadialGradient {
// TODO: Waiting for documentation to arrive
}

Expand Down Expand Up @@ -612,8 +612,8 @@ declare module 'scenegraph' {
fill:
| null
| Color
| LinearGradientFill
| RadialGradientFill
| LinearGradient
| RadialGradient
| ImageFill;

/**
Expand Down Expand Up @@ -1355,7 +1355,7 @@ declare module 'scenegraph' {
* **Since:** XD 14
* Object representing the current selection state and edit context. Also available as the first argument passed to your plugin command handler function.
*/
export const selection: SceneNodeList;
export const selection: XDSelection;

/**
* **Since:** XD 14
Expand Down

0 comments on commit 1bd37f0

Please sign in to comment.