|
1 | 1 | # Desktop Helper Example |
2 | | -This sample has two components, a Ps plugin and an Electron application built in React. |
| 2 | + |
| 3 | +This sample has two components, a UXP plugin and an Electron application built in React. |
3 | 4 |
|
4 | 5 | For developers who have used `create-react-app` before, the folder structure and tools used in the Electron application will be familiar. |
5 | 6 |
|
6 | 7 | Both components must be running for the example to work correctly. |
7 | 8 |
|
8 | 9 | # Configuration |
| 10 | + |
9 | 11 | The following steps will help you load the plugin into Photoshop and get the Electron app up and running. |
10 | 12 |
|
11 | 13 | ## UXP Plugin |
12 | 14 |
|
13 | 15 | ### 1. Install Node.js dependencies |
| 16 | + |
14 | 17 | ``` |
15 | 18 | $ cd uxp |
16 | 19 | $ yarn install # or npm install |
17 | 20 | ``` |
18 | 21 |
|
19 | | -### 2. Run plugin in watch or build mode |
| 22 | +### 2. Run plugin in watch or build mode |
| 23 | + |
20 | 24 | ``` |
21 | | -$ cd uxp |
| 25 | +$ cd uxp |
22 | 26 | $ yarn watch # or npm run watch |
23 | 27 |
|
24 | 28 | # OR |
25 | 29 |
|
26 | 30 | $ yarn build # or npm run build |
27 | 31 | ``` |
28 | 32 |
|
29 | | -* `yarn watch` or `npm run watch` will build a development version of the plugin, and recompile everytime you make a change to the source files. The result is placed in `uxp/dist`. |
30 | | -* `yarn build` or `npm run build` will build a production version of the plugin and place it in `uxp/dist`. It will not update every time you make a change to the source files. |
| 33 | +- `yarn watch` or `npm run watch` will build a development version of the plugin, and recompile everytime you make a change to the source files. The result is placed in `uxp/dist`. |
| 34 | +- `yarn build` or `npm run build` will build a production version of the plugin and place it in `uxp/dist`. It will not update every time you make a change to the source files. |
31 | 35 |
|
32 | 36 | > You **must** run either `watch` or `build` prior to trying to use within Photoshop! |
33 | 37 |
|
34 | 38 | ## Electron Helper |
35 | 39 |
|
36 | | -### 1. Install Node.js dependencies |
| 40 | +### 1. Install Node.js dependencies |
| 41 | + |
37 | 42 | ``` |
38 | | -$ cd helper |
| 43 | +$ cd helper |
39 | 44 | $ yarn install # or npm install |
40 | 45 | ``` |
41 | 46 |
|
42 | 47 | ### 2. Run helper app |
| 48 | + |
43 | 49 | ``` |
44 | 50 | $ cd helper |
45 | 51 | $ yarn start |
46 | 52 | ``` |
47 | 53 |
|
48 | | -### 3. (Optional) Build the helper app |
| 54 | +### 3. (Optional) Build the helper app |
| 55 | + |
49 | 56 | ``` |
50 | 57 | $ cd helper |
51 | 58 | $ yarn build |
52 | 59 | ``` |
53 | 60 |
|
54 | 61 | **Warning:** This command will take quite some time to execute. |
55 | 62 |
|
56 | | -In Electron, production builds compile JavaScript into a binary executable on the target platform for distribution or personal use. It is recommended that you build for production when you finish development. |
| 63 | +In Electron, production builds compile JavaScript into a binary executable on the target platform for distribution or personal use. It is recommended that you build for production when you finish development. |
57 | 64 |
|
58 | | -Once built, navigate to the `helper/dist` folder and double click the `UXP Helper App Setup 1.0.0` installer. Upon installation, the helper app can be run locally. Please note, the Electron project will have to be rebuilt and reinstalled for any future changes to take effect in production. |
| 65 | +Once built, navigate to the `helper/dist` folder and double click the `UXP Helper App Setup 1.0.0` installer. Upon installation, the helper app can be run locally. Please note, the Electron project will have to be rebuilt and reinstalled for any future changes to take effect in production. |
59 | 66 |
|
60 | 67 | # Load the Plugin |
| 68 | + |
61 | 69 | You can use the UXP Developer Tools to load the plugin into Photoshop. |
62 | 70 |
|
63 | 71 | If the plugin hasn't already been added to your workspace in the UXP Developer Tools, you can add it by clicking "Add Plugin..." and selecting `uxp/dist/manifest.json`. **DO NOT** select the `manifest.json` file inside the `uxp/plugin` folder. |
64 | 72 |
|
65 | | -Once added, you can load it into Photoshop by clicking the ••• button on the corresponding row, and clicking "Load". Switch to Photoshop and you should see the sample panel. |
| 73 | +Once added, you can load it into Photoshop by clicking the ••• button on the corresponding row, and clicking "Load". Switch to Photoshop and you should see the sample panel. |
| 74 | + |
| 75 | +# Using the Plugin |
| 76 | + |
| 77 | +This plugin uses an embedded websocket server to communicate between the Electron helper app and UXP. |
| 78 | + |
| 79 | +Files for the server and electron configuration are located in the `helper/public` folder and are served as entrypoints for Electron on build. |
| 80 | + |
| 81 | +Once both components are launched, you should be greeted with `'Connected'` status' on both components. If one component disconnects, the other will automatically recognize this disconnect as well, and the changes should be reflected with a `'Disconnected'` status. |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +Since it's an embedded server, its worth noting that this only runs on `localhost` and only administers communication between a single instance of the helper app and the UXP plugin. By default, the websocket server runs on port `4040` and the Electron helper app is served from port `3000`. |
| 86 | + |
| 87 | +Other than connecting with one another, the two components can also pass strings of text which get reflected in their `Received data from the helper` and `Received data from UXP` sections. |
0 commit comments