Skip to content

Commit

Permalink
v20.1 – Merge pull request #51 from AdobeXD/uxp-options-fix
Browse files Browse the repository at this point in the history
Moved from JSDoc to type declarations for options objects
  • Loading branch information
pklaschka authored Jun 29, 2019
2 parents 2bc1dca + bdf43da commit a5305e1
Show file tree
Hide file tree
Showing 15 changed files with 672 additions and 701 deletions.
13 changes: 13 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Contents of this Pull Request
This PR makes changes to
- [ ] The typings in the `types` folder
- [ ] Configuration files (`tsconfig.json`, `jsconfig.json`, `.gitignore` etc.)
- [ ] The sample files (e.g., `sample.js`)
- [ ] The `README.md` or other files containing documentation
- [ ] Other

### Purpose of this Pull Request
\[Description of what this pull request achieves / why it should get merged\]

### Issues resolved by this Pull Request
- fixes \[issue id\]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# typings
Typings for Adobe XD API Surfaces

Instructions for using these type defintions 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).
Instructions for using these type definitions 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).

## Download

The best option to download the typings is to download the latest release from https://github.com/AdobeXD/typings/releases.
The best option to download the typings is to download the latest release from <https://github.com/AdobeXD/typings/releases>.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobexd/typings",
"version": "19.0.0",
"version": "20.1.0",
"typings": "./types/index.d.ts",
"description": "Typings for Adobe XD CC",
"repository": {
Expand All @@ -27,6 +27,11 @@
"email": "[email protected]",
"url": "https://github.com/pklaschka"
},
{
"name": "Eric Robinson",
"email": "[email protected]",
"url": "https://github.com/ericdrobinson"
},
{
"name": "Kerri Shotts",
"email": "[email protected]",
Expand Down
8 changes: 6 additions & 2 deletions sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ const {Text, Ellipse, Color, RootNode} = require("scenegraph");
const clipboard = require("clipboard");
const shell = require("uxp").shell;
const fs = require("uxp").storage.localFileSystem;
const assets = require('assets');

/**
* @param {Selection} selection
* @param {RootNode} documentRoot
*/
async function test(selection, documentRoot) {
selection.items.forEach(node => {
selection.items.forEach(async node => {
console.log("Hello world: ", node);
if (node instanceof Text) {
clipboard.copyText(node.text);
} else if (node instanceof Ellipse) {
node.fill = new Color("#ffaaee");
shell.openExternal('https://adobe-xd.gitbook.io/plugin-api-reference/uxp-api-reference/network-apis/shell');
await shell.openExternal('https://adobe-xd.gitbook.io/plugin-api-reference/uxp-api-reference/network-apis/shell');
}
});
const tempFolder = await fs.getTemporaryFolder();
Expand All @@ -28,6 +29,9 @@ async function test(selection, documentRoot) {
} else if (anotherFile.isFolder) {
console.log("That's a folder. It shouldn't be a folder. What have you done?")
}

const colors = assets.colors.get();
console.log(colors);
}

module.exports = {
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"strict": true,
"target": "es2015",
"baseUrl": "./",
"lib": [
"es2015",
"dom"
],
"paths": {
"*": [
"types/*"
]
}
}
}
48 changes: 20 additions & 28 deletions types/application.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Color, SceneNode} from "./scenegraph";
import {Color, SceneNode} from "scenegraph";

/**
* All rendition settings fields are required (for a given rendition type) unless otherwise specified.
Expand Down Expand Up @@ -49,34 +49,26 @@ type RenditionResult = {
}

/**
* The application module exposes useful information about XD's state, along with APIs for exporting content.
* Generate renditions of nodes in the document in a batch. Overwrites any existing files without warning.
*
* A single createRenditions() call can generate any number of renditions, including multiple renditions of the same node (with different output settings) or renditions of multiple different nodes. Only one createRenditions() call can be executing at any given time, so wait for the Promise it returns before calling it again.
*
* @param renditions List of renditions to generate
* @return Promise<Array<RenditionResult>, string> - Promise which is fulfilled with an array of RenditionResults (pointing to the same outputFiles that were originally passed in, or rejected with an error string if one or more renditions failed for any reason.
*/
declare class application {
export function createRenditions(renditions: RenditionSettings[]): Promise<RenditionResult[] | string>;

/**
* Generate renditions of nodes in the document in a batch. Overwrites any existing files without warning.
*
* A single createRenditions() call can generate any number of renditions, including multiple renditions of the same node (with different output settings) or renditions of multiple different nodes. Only one createRenditions() call can be executing at any given time, so wait for the Promise it returns before calling it again.
*
* @param renditions List of renditions to generate
* @return Promise<Array<RenditionResult>, string> - Promise which is fulfilled with an array of RenditionResults (pointing to the same outputFiles that were originally passed in, or rejected with an error string if one or more renditions failed for any reason.
*/
static createRenditions(renditions: RenditionSettings[]): Promise<RenditionResult[] | string>;

/**
* Adobe XD version number in the form "major.minor.patch.build"
*/
static readonly version: string;

/**
* Current language the application UI is using. This may not equal the user's OS locale setting: it is the closest locale supported by XD - use this when you want your plugin's UI to be consistent with XD's UI. Specifies language only, with no region info (e.g. "fr", not "fr_FR").
*/
static readonly appLanguage: string;
/**
* Adobe XD version number in the form "major.minor.patch.build"
*/
export const version: string;

/**
* User's OS-wide locale setting. May not match the XD UI, since XD does not support all world languages. Includes both language and region (e.g. "fr_CA" or "en_US").
*/
static readonly systemLocale: string;
}
/**
* Current language the application UI is using. This may not equal the user's OS locale setting: it is the closest locale supported by XD - use this when you want your plugin's UI to be consistent with XD's UI. Specifies language only, with no region info (e.g. "fr", not "fr_FR").
*/
export const appLanguage: string;

export = application;
/**
* User's OS-wide locale setting. May not match the XD UI, since XD does not support all world languages. Includes both language and region (e.g. "fr_CA" or "en_US").
*/
export const systemLocale: string;
Loading

0 comments on commit a5305e1

Please sign in to comment.