Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v45 #80

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

v45 #80

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ab33617
move scenegraph to its own folder
Nov 20, 2021
e18d184
adding placeholder files
Nov 20, 2021
ad9c1d4
reorgainze scenegraph module classes into files
Nov 20, 2021
6947e3e
Add documentation reference links to ReadMe
Nov 20, 2021
b4c3bd6
scenegraph updates with deletion :(
Nov 21, 2021
305541b
scenegraph updates
Nov 21, 2021
977a0d1
updating other modules
Nov 21, 2021
a108166
XDSelection global
Nov 22, 2021
9ec0375
switch all `Array<type>` to `type[]`
Nov 22, 2021
d402531
remove XDSelection from application
Nov 22, 2021
88e2a1e
remove @param {types}
Nov 22, 2021
71902be
move selection interface to scenegraph module
Nov 22, 2021
594e1b0
exporting selection from scenegraph module
Nov 22, 2021
02877b2
removing SceneNodeClass and RootNodeClass
Nov 22, 2021
2f27f64
importWrong alias
Nov 22, 2021
b6b19d5
XDSelection is an alias of Selection
Nov 22, 2021
6b7d590
cleanup docs
Nov 22, 2021
cb212f6
Revert "remove @param {types}"
Nov 22, 2021
3c72196
remove @param {types}
Nov 22, 2021
aa26e63
remove selection from index.d.ts
Nov 22, 2021
e7a84ed
propertly splitting scenegraph module into multiple files
Dec 4, 2021
cbb639d
clean
Dec 4, 2021
17ed9af
single quotes
Dec 4, 2021
67ca39b
moving files 1
Dec 4, 2021
c40e3f9
moving files 2 - split xd and uxp into different folders
Dec 4, 2021
0cb8acb
prep to be pushed to DefinitelyTyped
Dec 4, 2021
3010bac
REVERT ME - before contributing to
Dec 4, 2021
17a19b0
prepping for npm publish
Dec 4, 2021
2ece84f
CommandHandler
Dec 5, 2021
c5810a5
wrong links
Dec 6, 2021
c7d99df
adding jsxWebComponents.d.ts to extend JSX.IntrinsicElements
Jan 30, 2022
3c6dc43
update readme example
Feb 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
# Adobe XD Plugin API typings
Typings for Adobe XD API Surfaces
![typings-supported autocompletion features in JetBrains WebStorm](image.png)

Detailed instructions for using these type declarations to get autocompletion features in editors and IDEs can be found in the [repository's wiki](https://github.com/AdobeXD/typings/wiki/Autocompletion-in-editors-and-IDEs).
Typings for [Adobe XD](https://www.adobe.io/xd/uxp/develop/reference/xd-index/) and (UXP)[https://www.adobe.io/xd/uxp/uxp/] Plugin Development

## Download
The best option to download the typings is to download the latest release from <https://github.com/AdobeXD/typings/releases>.
![typings-supported autocompletion features in JetBrains WebStorm](image.png)

## Getting started
These Type Declaration files provide your IDE (e.g. Visual Studio Code or WebStorm) with information about the XD API surface, enabling type checking, autocomplete suggestions, and more. To get started, simply copy the following resources from this repo into your project's main directory:

- The `jsconfig.json` file.
- The `types` directory.

Your IDE may require further setup to take full advantage of the types. Please see this [wiki page](https://github.com/AdobeXD/typings/wiki/Autocompletion-in-editors-and-IDEs#editor--ide-specific-instructions) for more.

The Type Declaration files also allow you to use TypeScript instead of JavaScript for your plugin development. For that, you'll have to copy the `types` folder to your project and include it in the `paths` of your `tsconfig.json`:
```json
{
"paths": {
"*": [
"types/*"
]
These Type Declaration files provide your IDE (e.g. Visual Studio Code or WebStorm) with information about the XD API surface, enabling type checking, autocomplete suggestions, and more.

To get started
- install the package via npm:
```
npm i @adobexd/typings`
```
- add the typings file to `"typeRoots"` your `jsconfig.json` or `tsconfig.json`:
```json
{
"compilerOptions": {
"typeRoots": ["node_modules/@adobexd/typings"]
},
}
}
```

You may also take a look at the `tsconfig.json` file contained in this repository for reference.

## One last thing
```
- (optional) add the [UXP WebComponents](https://www.adobe.io/xd/uxp/uxp/reference-spectrum/) to the `JSX.IntrinsicElements` namespace by adding a reference to a `types.d.ts` file
```ts
/// <reference path="./node_modules/@adobexd/typings/uxp/jsxWebComponents.d.ts" />
```


## About these type files
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.
- The [`application.import()`](https://www.adobe.io/xd/uxp/develop/reference/application/#import) function cannot be declared because `import` is a reserved TypeScript keyword (not sure if this can be fixed). It is declared as `application.importFiles()` instead.
- To avoid ambiguity with the *DOM* `Selection` type, the interface [`Selection`](https://www.adobe.io/xd/uxp/develop/reference/selection/) is also provided as an alias `XDSelection` and exported from the `'scenegraph'` module

## Original Documentation Links
- [New Adobe.io XD Docs](https://www.adobe.io/xd/uxp/develop/reference/xd-index/)
- [New Adobe.io XD Docs GitHub Repo](https://github.com/AdobeDocs/uxp-xd/tree/main/src/pages/develop/reference)
- [Adobe XD API Updates and Changelog](https://www.adobe.io/xd/uxp/develop/changelog/)
- [Original Adobe XD Platform Docs](https://adobexdplatform.com/plugin-docs/reference/xd-index.html)
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Type definitions for Adobe XD and UXP v45.0.0
// Project: https://www.adobe.io/xd/uxp/develop/reference/xd-index/
// Definitions by: James Bradford <https://github.com/arniebradfo/>
// Pablo Klaschka <https://github.com/pklaschka/>
// Eric Robinson <https://github.com/ericdrobinson/>
// Kerri Shotts <https://github.com/kerrishotts/>
// Jonathan Fontanez <https://github.com/tato123/>
// Definitions: https://github.com/AdobeXD/typings

import './xd'
import './uxp'
33 changes: 23 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
{
"name": "@adobexd/typings",
"version": "25.0.0",
"types": "./types/index.d.ts",
"version": "45.0.0",
"main": "",
"types": "index.d.ts",
"description": "Typings for Adobe XD CC",
"license": "MIT",
"homepage": "https://github.com/AdobeXD/typings#readme",
"repository": {
"type": "git",
"url": "[email protected]:AdobeXD/typings.git"
},
"bugs": {
"url": "https://github.com/AdobeXD/typings/issues"
},
"files": [
"index.d.ts",
"xd",
"uxp"
],
"keywords": [
"typescript",
"adobe-xd",
"xd",
"adobexd",
"plugins",
"types",
"@types",
"typings",
"typescript definitions"
"typescript definitions",
"typescript"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/AdobeXD/typings/issues"
},
"homepage": "https://github.com/AdobeXD/typings#readme",
"contributors": [
{
"name": "James Bradford",
"email": "[email protected]",
"url": "https://github.com/arniebradfo"
},
{
"name": "Pablo Klaschka",
"email": "[email protected]",
Expand All @@ -43,4 +56,4 @@
"url": "https://github.com/tato123"
}
]
}
}
23 changes: 12 additions & 11 deletions sample.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
const {Text, Ellipse, Color} = require("scenegraph");
const clipboard = require("clipboard");
const shell = require("uxp").shell;
const fs = require("uxp").storage.localFileSystem;
const { Text, Ellipse, Color } = require('scenegraph');
const clipboard = require('clipboard');
const shell = require('uxp').shell;
const fs = require('uxp').storage.localFileSystem;
const assets = require('assets');
const uxp = require('uxp');

/**
* @param {XDSelection} selection
* @param {import('scenegraph').Selection} selection
* @param {import('scenegraph').RootNode} documentRoot
*/
async function test(selection, documentRoot) {
for (const node of selection.items) {
console.log("Hello world: ", node);
console.log('Hello world: ', node);
if (node instanceof Text) {
clipboard.copyText(node.text);
} else if (node instanceof Ellipse) {
node.fill = new Color("#ffaaee");
node.fill = new Color('#ffaaee');
await shell.openExternal('https://adobe-xd.gitbook.io/plugin-api-reference/uxp-api-reference/network-apis/shell');
}
}
const tempFolder = await fs.getTemporaryFolder();
const newFile = await tempFolder.createFile("tempfile.txt", {overwrite: true});
await newFile.write("Hello, world!");
await newFile.moveTo(tempFolder, {overwrite: true});
const newFile = await tempFolder.createFile('tempfile.txt', { overwrite: true });
await newFile.write('Hello, world!');
await newFile.moveTo(tempFolder, { overwrite: true });

const anotherFile = await tempFolder.getEntry('tempfile.txt');
if (anotherFile.isFile) {
anotherFile.write("Good day");
anotherFile.write('Good day');
} else if (anotherFile.isFolder) {
console.log("That's a folder. It shouldn't be a folder. What have you done?")
}
Expand All @@ -40,3 +40,4 @@ module.exports = {
test: test
}
};

41 changes: 24 additions & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
{
"compilerOptions": {
"strict": true,
"target": "es2015",
"baseUrl": "./",
"allowJs": true,
"checkJs": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"./types/index.d.ts",
"node_modules/@types"
],
"types": ["./types", "node_modules/types"]
}
}
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"baseUrl": "./",
"typeRoots": [
"./"
],
"types": [],
"lib": [
"es2015",
"dom"
],
"checkJs": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true
},
"files": [
"index.d.ts"
]
}
3 changes: 3 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@definitelytyped/dtslint/dt.json"
}
Loading