rn-studio 0.3.1 β 0.3.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/README.md +213 -54
- package/dist/StudioProvider.d.ts.map +1 -1
- package/dist/StudioProvider.js +44 -15
- package/dist/StudioProvider.js.map +1 -1
- package/dist/components/SelectionOverlay.d.ts.map +1 -1
- package/dist/components/SelectionOverlay.js +3 -30
- package/dist/components/SelectionOverlay.js.map +1 -1
- package/dist/utils/extractStyles.d.ts +8 -0
- package/dist/utils/extractStyles.d.ts.map +1 -0
- package/dist/utils/extractStyles.js +73 -0
- package/dist/utils/extractStyles.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,66 +1,76 @@
|
|
|
1
|
-
# rn-studio
|
|
1
|
+
# π¨ rn-studio
|
|
2
2
|
|
|
3
|
-
> Live UI editor for React Native
|
|
3
|
+
> **Live UI editor for React Native.** Tap any component in your running simulator and edit its styles β every change is written straight back to your source code, with Metro Fast Refresh updating the UI in milliseconds.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/rn-studio)
|
|
6
|
-
[](https://github.com/dgutierrezd/rn-studio/blob/main/LICENSE)
|
|
7
|
-
[](https://www.npmjs.com/package/rn-studio)
|
|
6
|
+
[](https://github.com/dgutierrezd/rn-studio/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/dgutierrezd/rn-studio)
|
|
8
|
+
[](https://github.com/dgutierrezd/rn-studio)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
---
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Demo
|
|
12
|
+
## π¬ Demo
|
|
14
13
|
|
|
15
14
|
[](https://github.com/dgutierrezd/rn-studio/releases/download/v0.2.0/rn-studio-demo.mov)
|
|
16
15
|
|
|
17
16
|
> Tap the floating bubble β selection mode activates β tap any component β the inspector panel slides up with the component's styles, tree, and props. Edit a value, and the source file is rewritten via AST in real time while Metro Fast Refresh re-renders the UI.
|
|
18
17
|
>
|
|
19
|
-
> _Click the thumbnail to watch the full
|
|
18
|
+
> _Click the thumbnail to watch the full video._
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## β¨ What you get
|
|
23
|
+
|
|
24
|
+
| | Feature | Details |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| π― | **Tap-to-inspect** | Tap any on-screen component. Walks the React fiber tree to find the nearest user-code source, skipping library internals. Works on both **Fabric** and the **legacy architecture**. |
|
|
27
|
+
| π
| **Live style editing** | Edit any style and watch it apply instantly via Metro Fast Refresh. The AST engine rewrites the exact JSX element in your source β including `style={styles.foo}` references, which are resolved back into your `StyleSheet.create()` declaration. |
|
|
28
|
+
| π | **Preview mode** | Every edit is held in a server-side preview buffer until you tap **β Commit** or **βΊ Cancel**. Cancel reverts the file to its exact original state β your git diff stays clean. |
|
|
29
|
+
| βΆβ· | **Undo / Redo** | 50-deep edit history. Commit a preview β get a single consolidated undo entry. Tap βΆ to revert the whole batch in one go. |
|
|
30
|
+
| β | **Add any RN property** | Tap "+ Add property" to open a searchable modal of ~80 React Native style properties, grouped by category (Layout, Flex, Spacing, Sizing, Position, Background, Border, Shadow, Typography, Transform, Visibility). |
|
|
31
|
+
| π | **Auto-scroll on select** | Tap a component hidden behind the inspector panel and rn-studio walks the fiber tree to find the nearest `ScrollView` / `FlatList` / `SectionList` ancestor and scrolls it so your component lands in the top 12% of the screen. |
|
|
32
|
+
| πΎ | **Selection persists across reloads** | Cmd+R the simulator and your last-selected component is re-selected automatically via the React DevTools fiber-root walker. |
|
|
33
|
+
| ποΈ | **Three-tab inspector** | **Styles** (edit), **Tree** (component hierarchy), **Props** (read-only inspection). All scrollable. |
|
|
34
|
+
| π¨ | **Minimal indigo UI** | Clean `#7C9BFF` accent on a pure `#111` dark background. No distracting lime greens. |
|
|
35
|
+
| πͺΆ | **Zero extra deps** | No `react-native-reanimated`, no `react-native-gesture-handler` required. Pure RN + stock `Animated` API. |
|
|
36
|
+
| π« | **Zero production overhead** | `<StudioProvider enabled={__DEV__}>` short-circuits to `{children}` in release builds. Babel plugin is dev-only. |
|
|
37
|
+
| π | **One-command setup** | `npx rn-studio init` wires up `babel.config.js` and `package.json` for you. |
|
|
20
38
|
|
|
21
|
-
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## π¦ Install
|
|
22
42
|
|
|
23
43
|
```bash
|
|
24
44
|
npm install rn-studio
|
|
25
45
|
```
|
|
26
46
|
|
|
27
|
-
|
|
47
|
+
Then run the init command β it patches `babel.config.js`, adds the `studio` script to `package.json`, and prints the snippet to paste into `App.tsx`:
|
|
28
48
|
|
|
29
49
|
```bash
|
|
30
|
-
|
|
50
|
+
npx rn-studio init
|
|
31
51
|
```
|
|
32
52
|
|
|
33
|
-
>
|
|
34
|
-
|
|
35
|
-
> `Animated` API so consumers don't need the worklets babel plugin.
|
|
36
|
-
|
|
37
|
-
## Setup
|
|
53
|
+
<details>
|
|
54
|
+
<summary><strong>π Manual setup (if you prefer)</strong></summary>
|
|
38
55
|
|
|
39
|
-
### 1.
|
|
56
|
+
### 1. Register the babel plugin (dev only)
|
|
40
57
|
|
|
41
58
|
```js
|
|
42
59
|
// babel.config.js
|
|
43
60
|
module.exports = {
|
|
44
|
-
presets: ['module
|
|
61
|
+
presets: ['module:@react-native/babel-preset'],
|
|
45
62
|
plugins: [
|
|
46
|
-
...(process.env.NODE_ENV !== 'production'
|
|
63
|
+
...(process.env.NODE_ENV !== 'production'
|
|
64
|
+
? ['rn-studio/babel-plugin']
|
|
65
|
+
: []),
|
|
47
66
|
],
|
|
48
67
|
};
|
|
49
68
|
```
|
|
50
69
|
|
|
51
|
-
### 2.
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Terminal 1
|
|
55
|
-
npx react-native start
|
|
56
|
-
|
|
57
|
-
# Terminal 2
|
|
58
|
-
npm run studio
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Add to your app's `package.json`:
|
|
70
|
+
### 2. Add the studio script
|
|
62
71
|
|
|
63
72
|
```json
|
|
73
|
+
// package.json
|
|
64
74
|
{
|
|
65
75
|
"scripts": {
|
|
66
76
|
"studio": "rn-studio-server"
|
|
@@ -82,47 +92,196 @@ export default function App() {
|
|
|
82
92
|
}
|
|
83
93
|
```
|
|
84
94
|
|
|
85
|
-
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## βΆοΈ Run it
|
|
100
|
+
|
|
101
|
+
Open two terminal tabs:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Terminal 1 β Metro
|
|
105
|
+
npx react-native start
|
|
106
|
+
|
|
107
|
+
# Terminal 2 β rn-studio server
|
|
108
|
+
npm run studio
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Launch your app in the simulator. A floating π¨ bubble appears in the bottom-right. Tap it, tap any component, and start editing.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## π§ How it works
|
|
86
116
|
|
|
87
117
|
| Layer | What it does |
|
|
88
118
|
|---|---|
|
|
89
|
-
| Babel plugin | Annotates every JSX element with file
|
|
90
|
-
| Floating bubble | Toggles selection mode
|
|
91
|
-
| Selection overlay |
|
|
92
|
-
| Inspector panel |
|
|
93
|
-
| WebSocket bridge |
|
|
94
|
-
| AST engine |
|
|
95
|
-
| Metro Fast Refresh | Picks up the file change and updates
|
|
119
|
+
| π§ **Babel plugin** | Annotates every JSX element at compile time with `__rnStudioSource = { file, line, column, componentName }` |
|
|
120
|
+
| π«§ **Floating bubble** | Toggles selection mode with a spring-animated draggable overlay |
|
|
121
|
+
| π― **Selection overlay** | Uses RN's built-in `getInspectorDataForViewAtPoint` (Fabric + legacy) to hit-test touches, then walks the fiber `.return` chain to the nearest user-code source |
|
|
122
|
+
| πͺ **Inspector panel** | Bottom-sheet with Styles / Tree / Props tabs β fully scrollable, auto-scrolls the underlying `ScrollView` so the selected component stays visible |
|
|
123
|
+
| π **WebSocket bridge** | Streams edits from the app over `ws://localhost:7878` with exponential-backoff reconnect |
|
|
124
|
+
| π οΈ **AST engine** | Reads the target file with `recast` + `@babel/parser`, locates the exact JSX opening element by `(line, column)`, and rewrites the `style` prop. Handles inline objects, array styles, and `StyleSheet.create()` references. Refuses to touch `node_modules`. |
|
|
125
|
+
| π **Metro Fast Refresh** | Picks up the file change and updates your UI in milliseconds |
|
|
126
|
+
| π **Undo / Preview state** | Server keeps a 50-deep undo stack plus a preview buffer for uncommitted edits |
|
|
127
|
+
|
|
128
|
+
---
|
|
96
129
|
|
|
97
|
-
## API
|
|
130
|
+
## π API
|
|
98
131
|
|
|
99
132
|
### `<StudioProvider>` props
|
|
100
133
|
|
|
101
134
|
| Prop | Type | Default | Description |
|
|
102
135
|
|---|---|---|---|
|
|
103
|
-
| `enabled` | `boolean` | `false` | Show the studio UI |
|
|
136
|
+
| `enabled` | `boolean` | `false` | Show the studio UI. Pass `__DEV__` to enable in development only. |
|
|
104
137
|
| `serverPort` | `number` | `7878` | CLI server port |
|
|
105
|
-
| `bubblePosition` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | `'bottom-right'` |
|
|
106
|
-
| `theme` | `'dark' \| 'light'` | `'dark'` | Panel theme |
|
|
138
|
+
| `bubblePosition` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | `'bottom-right'` | Starting corner for the floating bubble |
|
|
139
|
+
| `theme` | `'dark' \| 'light'` | `'dark'` | Panel theme (currently dark only) |
|
|
107
140
|
|
|
108
141
|
### `useStudio()`
|
|
109
142
|
|
|
110
143
|
```ts
|
|
111
144
|
const {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
// Selection state
|
|
146
|
+
isActive, // boolean β selection mode toggled?
|
|
147
|
+
isSelecting, // boolean β waiting for a tap?
|
|
148
|
+
selectedComponent, // ComponentNode | null
|
|
149
|
+
|
|
150
|
+
// Actions
|
|
151
|
+
toggleActive, // () => void
|
|
152
|
+
selectComponent, // (node: ComponentNode) => void
|
|
153
|
+
clearSelection, // () => void
|
|
154
|
+
|
|
155
|
+
// Style editing
|
|
156
|
+
updateStyle, // (key: string, value: string | number) => void
|
|
157
|
+
addStyleProperty, // (key: string, value: string | number | boolean) => void
|
|
158
|
+
|
|
159
|
+
// Undo / Redo
|
|
160
|
+
undo, // () => void
|
|
161
|
+
redo, // () => void
|
|
162
|
+
canUndo, // boolean
|
|
163
|
+
canRedo, // boolean
|
|
164
|
+
|
|
165
|
+
// Preview mode
|
|
166
|
+
hasPendingPreview, // boolean
|
|
167
|
+
commitPreview, // () => void
|
|
168
|
+
cancelPreview, // () => void
|
|
119
169
|
} = useStudio();
|
|
120
170
|
```
|
|
121
171
|
|
|
122
|
-
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## π‘οΈ Preview mode explained
|
|
175
|
+
|
|
176
|
+
Every edit made while a component is selected is held in a **server-side preview buffer** until you explicitly commit or cancel.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
180
|
+
β Tap component β BEGIN_PREVIEW β server snapshots β
|
|
181
|
+
β the file β
|
|
182
|
+
β β
|
|
183
|
+
β Edit fontSize 14β28 β β
|
|
184
|
+
β Edit color #fffβblue βββ each write hits disk β
|
|
185
|
+
β Edit padding 10β24 β Metro Fast Refresh shows it β
|
|
186
|
+
β β BUT nothing enters the undo stack β
|
|
187
|
+
β β
|
|
188
|
+
β βββββ Preview badge shows in panel header βββββ β
|
|
189
|
+
β β βΊ β replace βΆ β· β β
|
|
190
|
+
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
191
|
+
β β
|
|
192
|
+
β Your choice: β
|
|
193
|
+
β β
|
|
194
|
+
β β Commit β server packs all edits into a SINGLE undo β
|
|
195
|
+
β entry labeled "preview (N edits)". β
|
|
196
|
+
β You can still βΆ to revert the whole batch. β
|
|
197
|
+
β β
|
|
198
|
+
β βΊ Cancel β server writes the original snapshot back. β
|
|
199
|
+
β File is pristine. No undo entry created. β
|
|
200
|
+
β Your git diff stays clean. β
|
|
201
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Auto-commit triggers:** switching to a different component, closing the panel, toggling the bubble off. **Auto-cancel triggers:** client disconnect (app reload, server restart).
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## π‘ Tips
|
|
209
|
+
|
|
210
|
+
- ποΈ **Drag the floating bubble** anywhere on screen β its position is saved to `AsyncStorage` (optional dependency).
|
|
211
|
+
- β« **Cmd+R** in the simulator β your last-selected component is re-selected automatically.
|
|
212
|
+
- π¨ **Tap a color swatch** to see it highlighted, then edit the hex directly.
|
|
213
|
+
- β **Tap "+ Add property"** inside the Styles tab to search all ~80 React Native style properties.
|
|
214
|
+
- π **Switch to the Props tab** to inspect every non-style prop of the selected component (read-only for now).
|
|
215
|
+
- π³ **Switch to the Tree tab** to navigate nested rn-studio-annotated children.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## π« Production safety
|
|
220
|
+
|
|
221
|
+
Three independent guarantees ensure **zero production overhead**:
|
|
222
|
+
|
|
223
|
+
1. π **Babel plugin** early-returns when `NODE_ENV === 'production'` β `__rnStudioSource` is never emitted in release bundles.
|
|
224
|
+
2. π§© **`<StudioProvider enabled={false}>`** short-circuits to `<>{children}</>` β no context, no WebSocket, no overlay.
|
|
225
|
+
3. π¦ **Consumer convention** β pass `enabled={__DEV__}` so the whole system ties to React Native's own dev flag.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## π Changelog highlights
|
|
230
|
+
|
|
231
|
+
<details>
|
|
232
|
+
<summary><strong>v0.3.2</strong> β Fix styles disappearing on undo</summary>
|
|
233
|
+
|
|
234
|
+
Undo/redo/cancel now refresh the inspector's style list from the live fiber tree instead of leaving stale or empty state. New shared `extractStylesFromFiber` utility used by both the overlay and the provider.
|
|
235
|
+
|
|
236
|
+
</details>
|
|
237
|
+
|
|
238
|
+
<details>
|
|
239
|
+
<summary><strong>v0.3.1</strong> β Preview mode β βΊ</summary>
|
|
240
|
+
|
|
241
|
+
Every style edit is held in a server-side preview buffer. Tap β to commit (single consolidated undo entry) or βΊ to revert the file to its exact state at selection time. Auto-commits on deselect, auto-cancels on disconnect.
|
|
242
|
+
|
|
243
|
+
</details>
|
|
244
|
+
|
|
245
|
+
<details>
|
|
246
|
+
<summary><strong>v0.3.0</strong> β Add property picker, init CLI, undo/redo, persistence, auto-scroll</summary>
|
|
247
|
+
|
|
248
|
+
Five major features shipped together:
|
|
249
|
+
- Searchable modal listing ~80 RN style properties across 11 groups
|
|
250
|
+
- `npx rn-studio init` β zero-config project bootstrap
|
|
251
|
+
- 50-deep undo/redo stack with βΆ β· buttons
|
|
252
|
+
- Selection persistence across Cmd+R via AsyncStorage + fiber walker
|
|
253
|
+
- Auto-scroll walks the fiber tree to bring the selected component into view above the 60% panel
|
|
254
|
+
|
|
255
|
+
</details>
|
|
256
|
+
|
|
257
|
+
<details>
|
|
258
|
+
<summary><strong>v0.2.0</strong> β Selection flow fix for Fabric + AST StyleSheet resolution</summary>
|
|
259
|
+
|
|
260
|
+
Replaces legacy `UIManager.findSubviewIn` with `getInspectorDataForViewAtPoint`. Walks the fiber `.return` chain instead of the flat hierarchy. AST engine resolves `style={styles.foo}` into `StyleSheet.create()` entries. Dropped hard peer deps on reanimated and gesture-handler.
|
|
261
|
+
|
|
262
|
+
</details>
|
|
263
|
+
|
|
264
|
+
Full history: [GitHub Releases](https://github.com/dgutierrezd/rn-studio/releases)
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## π€ Contributing
|
|
269
|
+
|
|
270
|
+
Pull requests welcome! For major changes, please open an issue first so we can talk it through.
|
|
271
|
+
|
|
272
|
+
Local development:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
git clone https://github.com/dgutierrezd/rn-studio.git
|
|
276
|
+
cd rn-studio
|
|
277
|
+
npm install
|
|
278
|
+
npm run build # compile TS to dist/
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
The `dist/` output is what gets published to npm. The `bin/` folder contains the CLI entry points (`rn-studio-server`, `rn-studio-init`), which run against the compiled `dist/ast/AstEngine.js`.
|
|
123
282
|
|
|
124
|
-
|
|
283
|
+
---
|
|
125
284
|
|
|
126
|
-
## License
|
|
285
|
+
## π License
|
|
127
286
|
|
|
128
287
|
MIT Β© [dgutierrezd](https://github.com/dgutierrezd)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StudioProvider.d.ts","sourceRoot":"","sources":["../src/StudioProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,gBAAgB,EAMjB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StudioProvider.d.ts","sourceRoot":"","sources":["../src/StudioProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,gBAAgB,EAMjB,MAAM,OAAO,CAAC;AAaf,OAAO,KAAK,EACV,cAAc,EAEd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAEjB,UAAU,KAAM,SAAQ,OAAO,CAAC,YAAY,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;GAIG;AAEH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAqB,CAAC;AAEnE,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAe,EACf,UAAiB,EACjB,cAA+B,GAChC,EAAE,KAAK,qBAYP;AAsSD,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,0EAA0E;AAC1E,wBAAgB,SAAS,IAAI,kBAAkB,CAM9C"}
|
package/dist/StudioProvider.js
CHANGED
|
@@ -45,6 +45,7 @@ const SelectionOverlay_1 = require("./components/SelectionOverlay");
|
|
|
45
45
|
const InspectorPanel_1 = require("./components/InspectorPanel");
|
|
46
46
|
const persistence_1 = require("./utils/persistence");
|
|
47
47
|
const findFiberBySource_1 = require("./utils/findFiberBySource");
|
|
48
|
+
const extractStyles_1 = require("./utils/extractStyles");
|
|
48
49
|
/**
|
|
49
50
|
* Shared mutable ref to the app root view. Populated by
|
|
50
51
|
* `<StudioProvider>` and consumed by `<SelectionOverlay>` for
|
|
@@ -113,7 +114,7 @@ const StudioProviderInner = ({ serverPort, bubblePosition, children }) => {
|
|
|
113
114
|
componentName: saved.componentName,
|
|
114
115
|
source: saved,
|
|
115
116
|
props,
|
|
116
|
-
styles:
|
|
117
|
+
styles: (0, extractStyles_1.extractStylesFromFiber)(fiber),
|
|
117
118
|
children: [],
|
|
118
119
|
};
|
|
119
120
|
// Silently restore in ACTIVE state so the user can tap the
|
|
@@ -127,6 +128,28 @@ const StudioProviderInner = ({ serverPort, bubblePosition, children }) => {
|
|
|
127
128
|
cancelled = true;
|
|
128
129
|
};
|
|
129
130
|
}, []);
|
|
131
|
+
/**
|
|
132
|
+
* Re-read the currently selected component's styles from the live
|
|
133
|
+
* React fiber tree. Called after undo/redo/cancel operations where
|
|
134
|
+
* the file on disk has changed and Metro Fast Refresh has committed
|
|
135
|
+
* new props to the component. Without this, the inspector would
|
|
136
|
+
* show stale or empty style lists.
|
|
137
|
+
*/
|
|
138
|
+
const refreshSelection = (0, react_1.useCallback)(() => {
|
|
139
|
+
setSelectedComponent((prev) => {
|
|
140
|
+
if (!prev)
|
|
141
|
+
return prev;
|
|
142
|
+
const fiber = (0, findFiberBySource_1.findFiberBySource)(prev.source);
|
|
143
|
+
if (!fiber)
|
|
144
|
+
return prev;
|
|
145
|
+
const props = (fiber.memoizedProps || {});
|
|
146
|
+
return {
|
|
147
|
+
...prev,
|
|
148
|
+
props,
|
|
149
|
+
styles: (0, extractStyles_1.extractStylesFromFiber)(fiber),
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}, []);
|
|
130
153
|
/**
|
|
131
154
|
* Tell the server to consolidate any pending preview edits into a
|
|
132
155
|
* single undo entry. Safe to call even if no preview is active.
|
|
@@ -198,12 +221,23 @@ const StudioProviderInner = ({ serverPort, bubblePosition, children }) => {
|
|
|
198
221
|
styles: upsertLocalStyle(current.styles, key, value),
|
|
199
222
|
});
|
|
200
223
|
}, [selectedComponent]);
|
|
224
|
+
/**
|
|
225
|
+
* Wait for Metro Fast Refresh to commit the updated file into the
|
|
226
|
+
* running JS bundle, then re-read the selected component's styles
|
|
227
|
+
* from the live fiber tree. ~350 ms covers typical Fast Refresh
|
|
228
|
+
* latencies on both iOS Simulator and Android Emulator.
|
|
229
|
+
*/
|
|
230
|
+
const scheduleRefresh = (0, react_1.useCallback)(() => {
|
|
231
|
+
setTimeout(refreshSelection, 350);
|
|
232
|
+
}, [refreshSelection]);
|
|
201
233
|
const undo = (0, react_1.useCallback)(() => {
|
|
202
234
|
bridgeRef.current?.send({ type: 'UNDO' });
|
|
203
|
-
|
|
235
|
+
scheduleRefresh();
|
|
236
|
+
}, [scheduleRefresh]);
|
|
204
237
|
const redo = (0, react_1.useCallback)(() => {
|
|
205
238
|
bridgeRef.current?.send({ type: 'REDO' });
|
|
206
|
-
|
|
239
|
+
scheduleRefresh();
|
|
240
|
+
}, [scheduleRefresh]);
|
|
207
241
|
const commitPreview = (0, react_1.useCallback)(() => {
|
|
208
242
|
if (!previewFileRef.current) {
|
|
209
243
|
setHasPendingPreview(false);
|
|
@@ -227,24 +261,19 @@ const StudioProviderInner = ({ serverPort, bubblePosition, children }) => {
|
|
|
227
261
|
}
|
|
228
262
|
bridgeRef.current?.send({ type: 'CANCEL_PREVIEW' });
|
|
229
263
|
// After the server restores the file, Metro Fast Refresh will
|
|
230
|
-
// re-render the component with its original styles.
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
// time the user taps the component).
|
|
264
|
+
// re-render the component with its original styles. Refresh the
|
|
265
|
+
// inspector's style list from the live fiber so the editor
|
|
266
|
+
// reflects the restored values.
|
|
234
267
|
const file = previewFileRef.current;
|
|
235
268
|
setHasPendingPreview(false);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
styles: [],
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
// Re-open a fresh preview buffer on the same file.
|
|
269
|
+
scheduleRefresh();
|
|
270
|
+
// Re-open a fresh preview buffer on the same file so the next
|
|
271
|
+
// round of edits stays safely sandboxed.
|
|
243
272
|
bridgeRef.current?.send({
|
|
244
273
|
type: 'BEGIN_PREVIEW',
|
|
245
274
|
payload: { file },
|
|
246
275
|
});
|
|
247
|
-
}, [
|
|
276
|
+
}, [scheduleRefresh]);
|
|
248
277
|
const setAppRootRef = (0, react_1.useCallback)((r) => {
|
|
249
278
|
exports.appRootRef.current = r;
|
|
250
279
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StudioProvider.js","sourceRoot":"","sources":["../src/StudioProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StudioProvider.js","sourceRoot":"","sources":["../src/StudioProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,wCAiBC;AAySD,8BAMC;AA7WD,+CAOe;AACf,+CAAoC;AACpC,2DAAwD;AACxD,8DAA2D;AAC3D,gEAA6D;AAC7D,oEAAiE;AACjE,gEAA6D;AAC7D,qDAG6B;AAC7B,iEAA8D;AAC9D,yDAA+D;AAkB/D;;;;GAIG;AACH,uDAAuD;AAC1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AAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectionOverlay.d.ts","sourceRoot":"","sources":["../../src/components/SelectionOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA8K3D;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAuHpC,CAAC"}
|
|
@@ -38,6 +38,7 @@ const react_1 = __importStar(require("react"));
|
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
39
|
const StudioProvider_1 = require("../StudioProvider");
|
|
40
40
|
const autoScroll_1 = require("../utils/autoScroll");
|
|
41
|
+
const extractStyles_1 = require("../utils/extractStyles");
|
|
41
42
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
42
43
|
// React Native's built-in inspector data API. Uses the React DevTools
|
|
43
44
|
// hook under the hood and works on both the Fabric and legacy
|
|
@@ -64,35 +65,7 @@ function triggerHaptic(type) {
|
|
|
64
65
|
}
|
|
65
66
|
catch { }
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
if (typeof value === 'number')
|
|
69
|
-
return 'number';
|
|
70
|
-
if (typeof value === 'boolean')
|
|
71
|
-
return 'boolean';
|
|
72
|
-
if (typeof value === 'string') {
|
|
73
|
-
if (/color/i.test(key) ||
|
|
74
|
-
/^#[0-9a-f]{3,8}$/i.test(value) ||
|
|
75
|
-
/^rgba?\(/i.test(value) ||
|
|
76
|
-
/^hsla?\(/i.test(value)) {
|
|
77
|
-
return 'color';
|
|
78
|
-
}
|
|
79
|
-
return 'string';
|
|
80
|
-
}
|
|
81
|
-
return 'string';
|
|
82
|
-
}
|
|
83
|
-
function extractStyles(rawStyle) {
|
|
84
|
-
const flat = (react_native_1.StyleSheet.flatten(rawStyle) || {});
|
|
85
|
-
const out = [];
|
|
86
|
-
for (const key of Object.keys(flat)) {
|
|
87
|
-
const value = flat[key];
|
|
88
|
-
if (value == null)
|
|
89
|
-
continue;
|
|
90
|
-
if (typeof value === 'object')
|
|
91
|
-
continue; // skip nested (shadowOffset etc.)
|
|
92
|
-
out.push({ key, value, type: inferStyleType(key, value) });
|
|
93
|
-
}
|
|
94
|
-
return out;
|
|
95
|
-
}
|
|
68
|
+
// extractStyles now lives in ../utils/extractStyles for reuse.
|
|
96
69
|
/**
|
|
97
70
|
* Excludes known library paths so the AST engine only ever rewrites
|
|
98
71
|
* files in the user's project.
|
|
@@ -246,7 +219,7 @@ const SelectionOverlay = () => {
|
|
|
246
219
|
}
|
|
247
220
|
return true;
|
|
248
221
|
}
|
|
249
|
-
const nodeStyles = extractStyles(resolved.props.style);
|
|
222
|
+
const nodeStyles = (0, extractStyles_1.extractStyles)(resolved.props.style);
|
|
250
223
|
const node = {
|
|
251
224
|
id: `${resolved.source.file}:${resolved.source.line}:${resolved.source.column}`,
|
|
252
225
|
componentName: resolved.componentName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionOverlay.js","sourceRoot":"","sources":["../../src/components/SelectionOverlay.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,+CAKsB;AACtB,sDAA0D;AAC1D,oDAA4D;
|
|
1
|
+
{"version":3,"file":"SelectionOverlay.js","sourceRoot":"","sources":["../../src/components/SelectionOverlay.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,+CAKsB;AACtB,sDAA0D;AAC1D,oDAA4D;AAC5D,0DAAuD;AAGvD,uDAAuD;AAEvD,sEAAsE;AACtE,8DAA8D;AAC9D,mEAAmE;AACnE,kEAAkE;AAClE,IAAI,8BAA8B,GAOvB,IAAI,CAAC;AAChB,IAAI,CAAC;IACH,8DAA8D;IAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,6FAA6F,CAAC,CAAC;IACnH,8BAA8B,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,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E,CAAC;gBACd,WAAW,EAAE,SAAS;gBACtB,YAAY,EAAE,CAAC;aAChB,GACD,CACH,CACI,CACR,CAAC;AACJ,CAAC,CAAC;AAvHW,QAAA,gBAAgB,oBAuH3B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StyleProperty } from '../types';
|
|
2
|
+
export declare function extractStyles(rawStyle: unknown): StyleProperty[];
|
|
3
|
+
/**
|
|
4
|
+
* Walks a fiber (and its host children) looking for a `style` prop,
|
|
5
|
+
* then flattens it into an array of StyleProperty entries.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractStylesFromFiber(fiber: any): StyleProperty[];
|
|
8
|
+
//# sourceMappingURL=extractStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractStyles.d.ts","sourceRoot":"","sources":["../../src/utils/extractStyles.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAwB9C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,aAAa,EAAE,CAahE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,EAAE,CAuBlE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractStyles = extractStyles;
|
|
4
|
+
exports.extractStylesFromFiber = extractStylesFromFiber;
|
|
5
|
+
/**
|
|
6
|
+
* extractStyles
|
|
7
|
+
*
|
|
8
|
+
* Converts a raw React Native style prop (object, array, StyleSheet
|
|
9
|
+
* ID, etc.) into a flat `StyleProperty[]` list suitable for rendering
|
|
10
|
+
* in the inspector. Shared between `SelectionOverlay` (building the
|
|
11
|
+
* initial selection) and `StudioProvider` (refreshing the current
|
|
12
|
+
* selection after undo/redo/cancel).
|
|
13
|
+
*/
|
|
14
|
+
const react_native_1 = require("react-native");
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
+
function inferStyleType(key, value) {
|
|
17
|
+
if (typeof value === 'number')
|
|
18
|
+
return 'number';
|
|
19
|
+
if (typeof value === 'boolean')
|
|
20
|
+
return 'boolean';
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
if (/color/i.test(key) ||
|
|
23
|
+
/^#[0-9a-f]{3,8}$/i.test(value) ||
|
|
24
|
+
/^rgba?\(/i.test(value) ||
|
|
25
|
+
/^hsla?\(/i.test(value)) {
|
|
26
|
+
return 'color';
|
|
27
|
+
}
|
|
28
|
+
return 'string';
|
|
29
|
+
}
|
|
30
|
+
return 'string';
|
|
31
|
+
}
|
|
32
|
+
function extractStyles(rawStyle) {
|
|
33
|
+
const flat = (react_native_1.StyleSheet.flatten(rawStyle) || {});
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const key of Object.keys(flat)) {
|
|
36
|
+
const value = flat[key];
|
|
37
|
+
if (value == null)
|
|
38
|
+
continue;
|
|
39
|
+
if (typeof value === 'object')
|
|
40
|
+
continue; // skip nested (shadowOffset etc.)
|
|
41
|
+
out.push({ key, value, type: inferStyleType(key, value) });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Walks a fiber (and its host children) looking for a `style` prop,
|
|
47
|
+
* then flattens it into an array of StyleProperty entries.
|
|
48
|
+
*/
|
|
49
|
+
function extractStylesFromFiber(fiber) {
|
|
50
|
+
if (!fiber)
|
|
51
|
+
return [];
|
|
52
|
+
// First try the fiber's own memoizedProps.
|
|
53
|
+
const ownProps = fiber.memoizedProps;
|
|
54
|
+
if (ownProps && ownProps.style !== undefined) {
|
|
55
|
+
return extractStyles(ownProps.style);
|
|
56
|
+
}
|
|
57
|
+
// Fall back to the first host-fiber descendant that has a style
|
|
58
|
+
// prop β useful when the selected fiber is a component wrapper
|
|
59
|
+
// whose rendered host actually holds the resolved styles.
|
|
60
|
+
let current = fiber.child;
|
|
61
|
+
let safety = 0;
|
|
62
|
+
while (current && safety < 20) {
|
|
63
|
+
safety++;
|
|
64
|
+
if (typeof current.type === 'string') {
|
|
65
|
+
const p = current.memoizedProps;
|
|
66
|
+
if (p && p.style !== undefined)
|
|
67
|
+
return extractStyles(p.style);
|
|
68
|
+
}
|
|
69
|
+
current = current.child;
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=extractStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractStyles.js","sourceRoot":"","sources":["../../src/utils/extractStyles.ts"],"names":[],"mappings":";;AAkCA,sCAaC;AAMD,wDAuBC;AA5ED;;;;;;;;GAQG;AACH,+CAA0C;AAG1C,uDAAuD;AAEvD,SAAS,cAAc,CACrB,GAAW,EACX,KAAsB;IAEtB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IACE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;YAClB,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;YAC/B,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;YACvB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EACvB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,aAAa,CAAC,QAAiB;IAC7C,MAAM,IAAI,GAAG,CAAC,yBAAU,CAAC,OAAO,CAAC,QAAe,CAAC,IAAI,EAAE,CAGtD,CAAC;IACF,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,C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