You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wasm-rust-sample/README.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
3
3
This plugin is a starting point for leveraging Rust and WebAssembly in your UXP plugins. It comes defined with most of the dependencies you need to get started. As this plugin does rely on the [Rust Programming Language](https://www.rust-lang.org/), an environment configured for Rust development will be required before this will be usable in Photoshop.
4
4
5
-
6
5
# Configuration
7
6
8
7
## Rust Environment
@@ -13,16 +12,18 @@ Follow the instructions and the `rustup` installation process. Once completed, y
13
12
14
13
> You **must** have the Rust toolchain installed in order to build the project
**Note:** For Windows users, the [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) must be installed for the Rust compiler to work properly. For more information, consult the [Rust documentation](https://doc.rust-lang.org/book/ch01-01-installation.html#installing-rustup-on-windows).
### 2. Test local Rust configuration and [wasm-pack](https://github.com/rustwasm/wasm-pack) installation
23
+
### 2. Test local Rust configuration and [wasm-pack](https://github.com/rustwasm/wasm-pack) installation
23
24
24
25
```
25
-
$ yarn test # or cargo test && wasm-pack test
26
+
$ yarn test # or cargo test && wasm-pack test --node
26
27
```
27
28
28
29
## Node.js
@@ -33,22 +34,25 @@ $ yarn test # or cargo test && wasm-pack test
33
34
$ yarn install # or npm install
34
35
```
35
36
36
-
### 2. Build plugin
37
-
38
-
To perform a basic, automated build of the plugin:
37
+
### 2. Run plugin in watch or build mode
39
38
40
39
```
40
+
$ yarn watch # or npm run watch
41
+
42
+
# OR
43
+
41
44
$ yarn build # or npm run build
42
45
```
43
46
44
47
> You **must** run `build` prior to trying to use this plugin within Photoshop!
45
48
46
-
This will build a production version of the plugin and place it in `dist`. It will not update every time you make a change to the source files.
49
+
-`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 `dist`.
50
+
-`yarn build` or `npm run build` will build a production version of the plugin and place it in `dist`. It will not update every time you make a change to the source files.
47
51
48
52
**Note:** Since UXP does not have implicit access to `localhost` for leveraging a development server, this plugin uses inline WebAssembly to work properly. As such, you'll find the following import in `js/index.js`:
49
53
50
54
```
51
-
import encodedRust from './uxp.wasm';
55
+
import encodedRust from '../wasm/uxp.wasm';
52
56
```
53
57
54
58
When the build script is triggerred, this JS file with the inline WebAssembly is generated. Should you wish to generate this file yourself, execute the following commands:
@@ -67,4 +71,4 @@ Once added, you can load it into Photoshop by clicking the ••• button on t
67
71
68
72
## What this plugin does
69
73
70
-
This plugin does some basic calculations in Rust and demonstrates a potential build process for leveraging Rust and WebAssembly in your UXP plugins.
74
+
This plugin uses a basic Rust implementation to hold state for a counter component that is surfaced on the UI. It also uses the `wasm-bindgen` API to make use of JavaScript API methods in Rust, such as `console.log`. Finally, the plugin demonstrates a potential build process for leveraging Rust and WebAssembly in your UXP plugins.
0 commit comments