|
1 | 1 | # Available APIs
|
2 | 2 |
|
3 |
| -Adobe XD provides several APIs to you, via the `require` method. You can also import your own modules and files using `require`. |
| 3 | +Adobe XD provides several categories of APIs: |
4 | 4 |
|
5 |
| -## Principal API modules |
| 5 | +* **[APIs for interacting with XD itself](#xd-specific-apis)**, especially its document model, the **scenegraph** |
| 6 | + |
| 7 | +* The **UXP runtime**, which provides all the capabilities that aren't XD-specific: |
| 8 | + * A [_browser-like_ HTML and CSS engine](../uxp/ui-index.md) which drives actual XD _native UI components_ -- it is **not** a complete browser engine, but lets you build your UI using familiar web APIs and frameworks. |
| 9 | + * [Network APIs](../uxp/network-index.md) similar to the web standard XHR, `fetch`, and WebSocket found in browsers. |
| 10 | + * The [`storage` API](../uxp/storage-index.md), offering sandboxed filesystem access. |
| 11 | + |
| 12 | +* The usual **[core JavaScript language APIs](../javascript/javascript-support.md)** you see in all JS runtimes, such as `setTimeout()` and `Date`. |
| 13 | + |
| 14 | +* A simple **[module-loader `require()` API](../javascript/javascript-support.md#can-i-use-require)** |
| 15 | + |
| 16 | +Read below for **how to access** XD and UXP APIs... |
| 17 | + |
| 18 | + |
| 19 | +## XD-specific APIs |
| 20 | + |
| 21 | +Most XD APIs are accessed by loading a module via `require()`, but some are passed directly to your plugin's handler functions. |
6 | 22 |
|
7 | 23 | * [selection](../selection.md) - Indicates the selected nodes and related context
|
8 | 24 | * This object is passed as an argument to your command handler function (see above)
|
9 | 25 | * [scenegraph](../scenegraph.md) - APIs available on document nodes
|
10 |
| - * Normally you can use these APIs by simply accessing the arguments passed to your command's handler function |
| 26 | + * Typically you use scenegraph objects by simply accessing the arguments passed to your command's handler function |
11 | 27 | (`selection` and `documentRoot`).
|
12 | 28 | * To create _new_ nodes in the document, load this module explicitly to access the constructor functions:
|
13 | 29 | ```js
|
14 | 30 | let Rectangle = require("scenegraph").Rectangle;
|
15 | 31 | let node = new Rectangle();
|
16 | 32 | ```
|
17 | 33 | * [commands](../commands.md) - Invoke commands to change the document structure and perform other complex operations.
|
18 |
| - * Load this module explicitly: `let commands = require("commands");` |
| 34 | + * `let commands = require("commands");` |
19 | 35 | * [interactions](../interactions.md) - Data model for interactive prototyping features (also accessible from scenegraph nodes).
|
20 |
| - * Load this module explicitly: `let interactions = require("interactions");` |
21 |
| -* [storage](../uxp/storage-index.md) - Read and write files on disk |
22 |
| - * Load this module explicitly: `const fs = require("uxp").storage.localFileSystem;` |
23 |
| -* [Network](../uxp/network-index.md) - Use browser-style `XMLHttpRequest`, `fetch()`, and `WebSocket` APIs to access the network. |
24 |
| - * These APIs are in the global namespace, so you can use them without any `require()` statements |
| 36 | + * `let interactions = require("interactions");` |
25 | 37 | * [application](../application.md) - Version and locale information, and APIs for exporting content.
|
26 |
| - * Load this module explicitly: `let application = require("application");` |
| 38 | + * `let application = require("application");` |
27 | 39 | * [clipboard](../clipboard.md) - Copy text to the clipboard.
|
28 |
| - * Load this module explicitly: `let clipboard = require("clipboard");` |
| 40 | + * `let clipboard = require("clipboard");` |
| 41 | + |
| 42 | + |
| 43 | +## UXP |
| 44 | + |
| 45 | +* HTML DOM APIs -- access just as in a browser, via the global `document`. Each plugin in XD gets its own `document` tree. |
29 | 46 |
|
30 |
| -## Helper classes |
| 47 | +* Network APIs -- access just as in a browser, via the global classes `XMLHttpRequest` and `WebSocket`, and the global function `fetch()` |
31 | 48 |
|
32 |
| -* [SceneNodeList](../SceneNodeList.md) - This is the type of the `children` property on scenenodes |
| 49 | +* Storage APIs -- access via `const fs = require("uxp").storage.localFileSystem;` |
0 commit comments