Skip to content

Commit 1bd37f0

Browse files
committed
Added sections to README, renamed LinearGradient & fixed secenegraph.selection type
- fixes #72 - fixes #60 - closes #41
1 parent 51fcec1 commit 1bd37f0

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ You may also take a look at the `tsconfig.json` file contained in this repositor
3030

3131
## One last thing
3232
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.
33+
34+
A few notable exceptions include:
35+
- `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
36+
- 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.
37+
- 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.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobexd/typings",
3-
"version": "22.0.0",
3+
"version": "25.0.0",
44
"typings": "./types/index.d.ts",
55
"description": "Typings for Adobe XD CC",
66
"repository": {

types/assets.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'assets' {
2-
import {Color, LinearGradientFill, RadialGradientFill} from "scenegraph";
2+
import {Color, LinearGradient, RadialGradient} from "scenegraph";
33

44
/**
55
* Type of gradient color element: linear gradient or radial gradient
@@ -37,7 +37,7 @@ declare module 'assets' {
3737
*/
3838
gradientType: GradientType;
3939
/**
40-
* 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.
40+
* 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.
4141
*/
4242
colorStops: Array<{ stop: number, color: Color }>
4343
}
@@ -132,7 +132,7 @@ declare module 'assets' {
132132
* @param colorAssets The color assets
133133
* @returns {number} number of assets added (may be less than requested if duplicates already exist)
134134
*/
135-
add(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
135+
add(colorAssets: Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset | Array<Color | ColorAsset | LinearGradient | RadialGradient | GradientAsset>): number;
136136

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

148148
/**

types/scenegraph.d.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ declare module 'scenegraph' {
207207
clone(): Color;
208208
}
209209

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

236236
/**
237-
* Create a new LinearGradientFill instance.
237+
* Create a new LinearGradient instance.
238238
*/
239239
constructor();
240240

241241
/**
242242
* Returns a copy of this instance.
243243
*/
244-
clone(): LinearGradientFill;
244+
clone(): LinearGradient;
245245

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

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

@@ -612,8 +612,8 @@ declare module 'scenegraph' {
612612
fill:
613613
| null
614614
| Color
615-
| LinearGradientFill
616-
| RadialGradientFill
615+
| LinearGradient
616+
| RadialGradient
617617
| ImageFill;
618618

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

13601360
/**
13611361
* **Since:** XD 14

0 commit comments

Comments
 (0)