@dannote/figma-use 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,8 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.3] - 2026-01-19
11
+
12
+ ### Added
13
+
14
+ - **`diff visual`** — create visual diff between two nodes as PNG
15
+ ```bash
16
+ figma-use diff visual --from <id1> --to <id2> --output diff.png
17
+ ```
18
+ Red pixels show differences. Options: `--scale`, `--threshold`
19
+
20
+ ### Changed
21
+
22
+ - `set rotation` now uses `--angle` flag instead of positional argument (fixes negative values like `--angle -15`)
23
+
24
+ ## [0.6.2] - 2026-01-19
25
+
26
+ ### Added
27
+
28
+ - `bun run format` — format code with oxfmt
29
+ - `bun run lint` — lint code with oxlint
30
+
10
31
  ## [0.6.1] - 2026-01-19
11
32
 
33
+ ### Added
34
+
35
+ - **`diff` commands** (experimental) — incremental updates via unified diff patches
36
+ - `diff create --from <id> --to <id>` — compare two node trees and generate patch
37
+ - `diff apply` — apply a patch to Figma nodes (validates old values!)
38
+ - `diff show` — show diff between current state and new properties
39
+ ```bash
40
+ # Compare two frames (e.g., before/after, A/B variants)
41
+ figma-use diff create --from 123:456 --to 789:012
42
+
43
+ # Apply patch (validates old values match)
44
+ figma-use diff apply --stdin < patch.diff
45
+
46
+ # Dry run
47
+ figma-use diff apply --stdin --dry-run < patch.diff
48
+ ```
49
+ - Uses `diff` library for unified diff parsing and validation
50
+
12
51
  ### Fixed
13
52
 
14
53
  - `--timeout` now applies to single commands (e.g., `eval`) via proxy `/command`
@@ -222,7 +261,7 @@ the same batch. See `component-set.tsx` for detailed explanation.
222
261
  - From stdin: `echo '<Frame style={{...}} />' | figma-use render --stdin`
223
262
  - With props: `--props '{"title": "Hello"}'`
224
263
  - Into parent: `--parent "1:23"`
225
- - Dry run: `--dryRun` outputs NodeChanges JSON
264
+ - Dry run: `--dry-run` outputs NodeChanges JSON
226
265
  - **Multiplayer WebSocket connection pooling** in proxy
227
266
  - First render: ~4s (establishes connection)
228
267
  - Subsequent renders: ~0.4s (10x faster!)
package/README.md CHANGED
@@ -304,6 +304,24 @@ figma-use me # Current user info
304
304
  figma-use file info # File key and name
305
305
  ```
306
306
 
307
+ ### Diff (Experimental)
308
+
309
+ Compare two frames and generate a unified diff patch:
310
+
311
+ ```bash
312
+ # Compare original vs modified version
313
+ figma-use diff create --from 123:456 --to 789:012
314
+ ```
315
+
316
+ Apply patch with validation (fails if current state doesn't match expected):
317
+
318
+ ```bash
319
+ figma-use diff apply patch.diff # Apply from file
320
+ figma-use diff apply --stdin < patch.diff # Apply from stdin
321
+ figma-use diff apply patch.diff --dry-run # Preview changes
322
+ figma-use diff apply patch.diff --force # Skip validation
323
+ ```
324
+
307
325
  ### Escape Hatch
308
326
 
309
327
  ```bash
package/SKILL.md CHANGED
@@ -34,57 +34,84 @@ figma-use plugin install
34
34
 
35
35
  ---
36
36
 
37
- ## ⚠️ Incremental Updates (CRITICAL)
37
+ ## ⚠️ Incremental Updates via Diff (Experimental)
38
38
 
39
39
  **After initial render, NEVER re-render the full JSX tree.**
40
40
 
41
- When modifying an existing design:
42
- 1. Save node IDs from the initial render (`--json` output)
43
- 2. Use targeted CLI commands to modify individual nodes
44
- 3. Only re-render if the structure fundamentally changes (>50% new elements)
41
+ Use unified diff patches to apply targeted changes with validation:
45
42
 
46
- ### Modify properties by ID
47
- ```bash
48
- figma-use set fill <id> "#FF0000" # Change color
49
- figma-use set opacity <id> 0.5 # Change opacity
50
- figma-use set radius <id> 12 # Change corner radius
51
- figma-use node resize <id> --width 300 --height 200
52
- figma-use node move <id> --x 100 --y 200
53
- figma-use node rename <id> "New Name"
54
- ```
43
+ > ⚠️ **Experimental:** `diff` commands are new and may change.
55
44
 
56
- ### Add new elements to existing parent
45
+ ### Compare two frames and generate patch
57
46
  ```bash
58
- figma-use create rect --parent <parent-id> --width 50 --height 50 --fill "#00F"
59
- figma-use create text --parent <parent-id> --text "Label" --fontSize 14
47
+ # Compare original vs modified version
48
+ figma-use diff create --from 123:456 --to 789:012
60
49
  ```
61
50
 
62
- ### Delete elements
63
- ```bash
64
- figma-use node delete <id>
51
+ Output (unified diff format):
52
+ ```diff
53
+ --- /Card/Header #123:457
54
+ +++ /Card/Header #789:013
55
+ @@ -1,5 +1,5 @@
56
+ type: FRAME
57
+ size: 200 50
58
+ pos: 0 0
59
+ -fill: #FFFFFF
60
+ +fill: #F0F0F0
61
+ -opacity: 0.8
62
+ +opacity: 1
65
63
  ```
66
64
 
67
- ### Example: Fixing transparency issues
65
+ ⚠️ **Don't forget space prefix on context lines** — `size: 48 40` will fail, ` size: 48 40` works.
66
+
67
+ ### Apply patch (validates old values!)
68
68
  ```bash
69
- # BAD: Re-rendering 60 elements to fix one opacity
70
- cat <<'EOF' | figma-use render --stdin
71
- <Frame>... 60 elements ...</Frame>
72
- EOF
69
+ # Dry run preview changes
70
+ figma-use diff apply patch.diff --dry-run
73
71
 
74
- # GOOD: Fix the specific node
75
- figma-use set opacity 123:456 1.0
72
+ # Apply changes (fails if old values don't match)
73
+ figma-use diff apply patch.diff
74
+
75
+ # Force apply (skip validation)
76
+ figma-use diff apply patch.diff --force
77
+
78
+ # From stdin
79
+ cat patch.diff | figma-use diff apply --stdin
76
80
  ```
77
81
 
78
- ### Example: Adjusting colors after critique
82
+ ### Visual diff (PNG)
79
83
  ```bash
80
- # Change shadow color from black to warm orange
81
- figma-use set fill 123:789 "#D97706"
84
+ figma-use diff visual --from <id1> --to <id2> --output diff.png
85
+ figma-use diff visual --from <id1> --to <id2> --output diff.png --threshold 0.05 # Stricter
86
+ ```
87
+
88
+ Red pixels show differences. Useful for verifying modifications.
89
+
90
+ ### Workflow: Iterative design with critique
91
+
92
+ 1. **Render initial design:**
93
+ ```bash
94
+ cat design.jsx | figma-use render --stdin --json > nodes.json
95
+ ```
82
96
 
83
- # Move misaligned element
84
- figma-use node move 123:790 --x 240 --y 100
97
+ 2. **Get critique, then generate patch:**
98
+ ```bash
99
+ # Clone and modify (or compare to another frame)
100
+ figma-use diff create --from <original> --to <modified>
101
+ ```
85
102
 
86
- # Resize tail to better proportions
87
- figma-use node resize 123:791 --width 120 --height 30
103
+ 3. **Apply patch to original:**
104
+ ```bash
105
+ figma-use diff apply --stdin < changes.diff
106
+ ```
107
+
108
+ ### Direct commands (for simple changes)
109
+ ```bash
110
+ figma-use set fill <id> "#FF0000"
111
+ figma-use set opacity <id> 0.5
112
+ figma-use node resize <id> --width 300 --height 200
113
+ figma-use node move <id> --x 100 --y 200
114
+ figma-use node delete <id>
88
115
  ```
89
116
 
90
117
  ---
@@ -301,6 +328,18 @@ figma-use export node <id> --scale 0.5 --output /tmp/check.png # Overview
301
328
  figma-use export node <id> --scale 2 --output /tmp/detail.png # Details
302
329
  ```
303
330
 
331
+ For modifications, use visual diff to highlight changes:
332
+
333
+ ```bash
334
+ # Before modifying, export original
335
+ figma-use export node <id> --output /tmp/before.png
336
+
337
+ # After changes, compare visually
338
+ figma-use diff visual --from <original-id> --to <modified-id> --output /tmp/diff.png
339
+ ```
340
+
341
+ Red pixels = differences. Use `--threshold 0.05` for stricter comparison.
342
+
304
343
  ### Copying Elements Between Pages
305
344
 
306
345
  `node clone` creates a copy in the same parent. To move to another page: