gravity-core 1.0.1

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/SETUP.md ADDED
@@ -0,0 +1,458 @@
1
+ # Gravity - Complete Setup Guide
2
+
3
+ **Gravity** enables AI assistants (Kiro, Cursor, VSCode, etc.) to diagnose CSS layout issues in real browser tabs.
4
+
5
+ ## 🎯 What It Does
6
+
7
+ When you ask an AI "why is my modal not showing?", Gravity:
8
+ 1. Connects to your browser via extension
9
+ 2. Inspects the actual DOM element
10
+ 3. Analyzes its position, styles, and visibility
11
+ 4. Returns specific issues and fixes
12
+
13
+ ## 📋 Prerequisites
14
+
15
+ - **Node.js 16+** - [Download](https://nodejs.org)
16
+ - **Chrome or Edge browser** - Already have it? Great!
17
+ - **Any IDE** - VSCode, Cursor, Kiro, Warp, or any tool with MCP support
18
+
19
+ ## 🚀 Installation (3 Steps)
20
+
21
+ ### Step 1: Install npm Package
22
+
23
+ ```bash
24
+ npm install gravity-core
25
+ ```
26
+
27
+ ### Step 2: Load Chrome Extension
28
+
29
+ 1. Clone or download the extension folder from the repo
30
+ 2. Open Chrome → `chrome://extensions`
31
+ 3. Enable **"Developer mode"** (top right)
32
+ 4. Click **"Load unpacked"**
33
+ 5. Select the `extension/` folder
34
+ 6. ✅ Extension loaded!
35
+
36
+ ### Step 3: Connect Extension to Tab
37
+
38
+ 1. Open any website in Chrome/Edge
39
+ 2. Click the **Gravity** extension icon (top right)
40
+ 3. Click **"Connect to Tab"**
41
+ 4. Status turns **🟢 Green** = Connected!
42
+
43
+ **The extension now runs a WebSocket server on port 9224** - the MCP server connects to it automatically!
44
+
45
+ ---
46
+
47
+ ## 💻 Configure Your IDE
48
+
49
+ ### VSCode
50
+
51
+ 1. Open `.vscode/settings.json` (or create it)
52
+ 2. Add MCP server config:
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "gravity": {
58
+ "command": "npx",
59
+ "args": ["gravity-core"],
60
+ "disabled": false
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ 3. Restart VSCode
67
+ 4. Open any HTML/CSS file
68
+ 5. Ask the AI: "Diagnose the #modal element"
69
+
70
+ ### Cursor
71
+
72
+ Same as VSCode - add to `.cursor/settings.json`:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "gravity": {
78
+ "command": "npx",
79
+ "args": ["gravity-core"],
80
+ "disabled": false
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Kiro
87
+
88
+ Add to `.kiro/settings/mcp.json`:
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "gravity": {
94
+ "command": "npx",
95
+ "args": ["gravity-core"],
96
+ "disabled": false
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Restart Kiro. Now ask the AI:
103
+ - "Check if browser is connected"
104
+ - "Diagnose the #modal element"
105
+ - "Highlight the .button element"
106
+
107
+ ### Warp
108
+
109
+ Add to `.warp/config.json`:
110
+
111
+ ```json
112
+ {
113
+ "mcpServers": {
114
+ "gravity": {
115
+ "command": "npx",
116
+ "args": ["gravity-core"],
117
+ "disabled": false
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Any IDE with MCP Support
124
+
125
+ Add this to your IDE's MCP configuration:
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "gravity": {
131
+ "command": "npx",
132
+ "args": ["gravity-core"],
133
+ "disabled": false
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ---
140
+
141
+ ## 🔄 How It Works
142
+
143
+ ```
144
+ Your IDE (VSCode, Cursor, Kiro, etc.)
145
+
146
+ MCP Server (gravity-core)
147
+
148
+ WebSocket Connection (port 9224)
149
+
150
+ Chrome Extension (running WebSocket server)
151
+
152
+ Chrome Debugger API
153
+
154
+ Browser Tab (DOM, CSS, Layout data)
155
+ ```
156
+
157
+ **Flow:**
158
+ 1. You ask AI to diagnose an element
159
+ 2. IDE sends request to MCP server
160
+ 3. MCP server connects to extension via WebSocket on port 9224
161
+ 4. Extension uses Chrome Debugger API to query browser
162
+ 5. Results flow back to your IDE
163
+ 6. AI shows you the issues and fixes
164
+
165
+ ---
166
+
167
+ ## 📊 Example Output
168
+
169
+ ```json
170
+ {
171
+ "element": "#modal",
172
+ "found": true,
173
+ "issues": [
174
+ {
175
+ "type": "offscreen-right",
176
+ "severity": "high",
177
+ "message": "Element extends 50px beyond right edge of viewport",
178
+ "suggestion": "Add max-width: 100% or use overflow: hidden on parent"
179
+ }
180
+ ],
181
+ "position": {
182
+ "left": 100,
183
+ "top": 50,
184
+ "width": 500,
185
+ "height": 300
186
+ },
187
+ "viewport": {
188
+ "width": 1920,
189
+ "height": 1080
190
+ }
191
+ }
192
+ ```
193
+
194
+ ---
195
+
196
+ ## 🎯 Common Workflows
197
+
198
+ ### Workflow 1: Fix Offscreen Element (VSCode)
199
+
200
+ 1. **Browser**: Open page with broken layout
201
+ 2. **Extension**: Click icon → "Connect to Tab" (🟢 Green)
202
+ 3. **VSCode**: Open CSS file
203
+ 4. **VSCode**: Ask AI: "Diagnose the .modal element"
204
+ 5. **AI**: Shows "Element extends 50px beyond right edge"
205
+ 6. **You**: Add `max-width: 100%` to CSS
206
+ 7. **Browser**: Refreshes automatically
207
+ 8. **AI**: Diagnose again → ✅ Fixed!
208
+
209
+ ### Workflow 2: Debug Hidden Element (Kiro)
210
+
211
+ 1. **Browser**: Open page with hidden element
212
+ 2. **Extension**: Click icon → "Connect to Tab" (🟢 Green)
213
+ 3. **Kiro**: Ask AI: "Why is the #button not showing?"
214
+ 4. **AI**: "The element has display: none"
215
+ 5. **You**: Change CSS to `display: block`
216
+ 6. **AI**: Diagnose again → ✅ Visible!
217
+
218
+ ### Workflow 3: Check Multiple Elements (Cursor)
219
+
220
+ 1. **Browser**: Open page
221
+ 2. **Extension**: Connect to tab
222
+ 3. **Cursor**: Ask AI: "Check these elements: #modal, .button, .header"
223
+ 4. **AI**: Shows issues for all three
224
+ 5. **You**: Fix them one by one
225
+
226
+ ---
227
+
228
+ ## 🔧 Configuration
229
+
230
+ ### Custom Port
231
+
232
+ If port 9224 is in use, you can configure a different port:
233
+
234
+ 1. Edit the extension's `background.js`:
235
+ ```javascript
236
+ const WEBSOCKET_PORT = 9225; // Change from 9224
237
+ ```
238
+
239
+ 2. Update your IDE config with environment variable:
240
+ ```json
241
+ {
242
+ "mcpServers": {
243
+ "gravity": {
244
+ "command": "npx",
245
+ "args": ["gravity-core"],
246
+ "env": {
247
+ "GRAVITY_PORT": "9225"
248
+ },
249
+ "disabled": false
250
+ }
251
+ }
252
+ }
253
+ ```
254
+
255
+ ### Timeout
256
+
257
+ In your IDE config:
258
+
259
+ ```json
260
+ {
261
+ "mcpServers": {
262
+ "gravity": {
263
+ "command": "npx",
264
+ "args": ["gravity-core"],
265
+ "env": {
266
+ "GRAVITY_TIMEOUT": "20000"
267
+ },
268
+ "disabled": false
269
+ }
270
+ }
271
+ }
272
+ ```
273
+
274
+ ---
275
+
276
+ ## 🐛 Troubleshooting
277
+
278
+ ### "Not connected to browser"
279
+
280
+ **Problem**: Error says "Not connected"
281
+
282
+ **Solution**:
283
+ 1. Make sure Chrome/Edge is open
284
+ 2. Click extension icon → "Connect to Tab"
285
+ 3. Status should turn green
286
+ 4. Try again in your IDE
287
+
288
+ ### "Extension not loaded"
289
+
290
+ **Problem**: Extension icon doesn't appear
291
+
292
+ **Solution**:
293
+ 1. Go to `chrome://extensions`
294
+ 2. Enable "Developer mode" (top right)
295
+ 3. Click "Load unpacked"
296
+ 4. Select the `extension/` folder
297
+ 5. Refresh the page
298
+
299
+ ### "Port 9224 already in use"
300
+
301
+ **Problem**: Error "Port 9224 already in use"
302
+
303
+ **Solution**:
304
+ 1. Edit extension's `background.js`
305
+ 2. Change `WEBSOCKET_PORT` to 9225
306
+ 3. Update IDE config with `DEVTOOLS_BRIDGE_PORT: 9225`
307
+ 4. Reload extension
308
+
309
+ ### "Element not found"
310
+
311
+ **Problem**: Error "Element not found: #modal"
312
+
313
+ **Solution**:
314
+ 1. Check selector is correct
315
+ 2. Make sure element exists in page
316
+ 3. Try simpler selector: `div` instead of `#modal`
317
+ 4. Check browser console for errors
318
+
319
+ ### "Connection timeout"
320
+
321
+ **Problem**: Error "Connection timeout"
322
+
323
+ **Solution**:
324
+ 1. Make sure extension is connected (green status)
325
+ 2. Check firewall isn't blocking port 9224
326
+ 3. Restart browser
327
+ 4. Reload extension
328
+
329
+ ---
330
+
331
+ ## 📚 API Reference
332
+
333
+ ### Gravity
334
+
335
+ ```typescript
336
+ import { Gravity } from 'gravity-core';
337
+
338
+ const bridge = new Gravity(options);
339
+ ```
340
+
341
+ #### Options
342
+
343
+ ```typescript
344
+ {
345
+ port?: number; // Default: 9224
346
+ timeout?: number; // Default: 10000 (ms)
347
+ autoReconnect?: boolean; // Default: true
348
+ }
349
+ ```
350
+
351
+ #### Methods
352
+
353
+ ##### `connectBrowser(port?: number): Promise<void>`
354
+
355
+ Connect to browser.
356
+
357
+ ```javascript
358
+ await bridge.connectBrowser();
359
+ ```
360
+
361
+ ##### `disconnectBrowser(): Promise<void>`
362
+
363
+ Disconnect from browser.
364
+
365
+ ```javascript
366
+ await bridge.disconnectBrowser();
367
+ ```
368
+
369
+ ##### `isConnected(): boolean`
370
+
371
+ Check if connected.
372
+
373
+ ```javascript
374
+ if (bridge.isConnected()) {
375
+ console.log('Connected!');
376
+ }
377
+ ```
378
+
379
+ ##### `diagnoseLayout(selector: string): Promise<DiagnosticResult>`
380
+
381
+ Diagnose layout issues.
382
+
383
+ ```javascript
384
+ const result = await bridge.diagnoseLayout('#modal');
385
+ console.log(result.issues);
386
+ ```
387
+
388
+ #### Events
389
+
390
+ ```javascript
391
+ bridge.on('connected', () => {
392
+ console.log('Connected to browser!');
393
+ });
394
+
395
+ bridge.on('disconnected', () => {
396
+ console.log('Disconnected from browser');
397
+ });
398
+
399
+ bridge.on('error', (error) => {
400
+ console.error('Error:', error);
401
+ });
402
+ ```
403
+
404
+ ---
405
+
406
+ ## 🎓 Detected Issues
407
+
408
+ Gravity detects:
409
+
410
+ | Issue | Severity | What It Means |
411
+ |-------|----------|--------------|
412
+ | `offscreen-right` | 🔴 High | Element extends beyond right edge |
413
+ | `offscreen-left` | 🔴 High | Element extends beyond left edge |
414
+ | `offscreen-top` | 🔴 High | Element extends beyond top edge |
415
+ | `offscreen-bottom` | 🟡 Medium | Element extends beyond bottom edge |
416
+ | `hidden-display` | 🔴 High | `display: none` |
417
+ | `hidden-visibility` | 🔴 High | `visibility: hidden` |
418
+ | `hidden-opacity` | 🔴 High | `opacity: 0` |
419
+ | `low-opacity` | 🟡 Medium | `opacity < 0.1` |
420
+ | `modal-no-zindex` | 🟡 Medium | Positioned element without z-index |
421
+ | `modal-low-zindex` | 🟢 Low | `z-index < 100` |
422
+ | `overflow-hidden` | 🟢 Low | May clip content |
423
+
424
+ ---
425
+
426
+ ## 🚀 Next Steps
427
+
428
+ 1. **Install package**: `npm install gravity-core`
429
+ 2. **Load extension**: `chrome://extensions` → Load unpacked → select `extension/` folder
430
+ 3. **Connect browser**: Click extension → "Connect to Tab"
431
+ 4. **Configure IDE**: Add MCP server config (see above)
432
+ 5. **Start diagnosing**: Ask your AI to diagnose elements!
433
+
434
+ ---
435
+
436
+ ## 📞 Support
437
+
438
+ - **GitHub Issues**: [Report bugs](https://github.com/gravity/core/issues)
439
+ - **Documentation**: [Full docs](https://gravity.dev)
440
+ - **Examples**: Check `examples/` folder in repo
441
+
442
+ ---
443
+
444
+ ## 🎉 You're Ready!
445
+
446
+ You now have everything to diagnose layouts in real-time. Start with:
447
+
448
+ ```bash
449
+ npm install gravity-core
450
+ ```
451
+
452
+ Then:
453
+ 1. Load extension in Chrome
454
+ 2. Connect to tab
455
+ 3. Add MCP config to your IDE
456
+ 4. Ask your AI to diagnose elements!
457
+
458
+ Happy debugging! 🚀
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Main Gravity class
3
+ * Provides unified API for browser diagnostics
4
+ */
5
+ import { DiagnosticResult, ConnectionStatus, BridgeOptions } from './types.js';
6
+ export declare class Gravity {
7
+ private connection;
8
+ private diagnostics;
9
+ private listeners;
10
+ constructor(options?: BridgeOptions);
11
+ /**
12
+ * Connect to browser
13
+ */
14
+ connectBrowser(port?: number): Promise<void>;
15
+ /**
16
+ * Disconnect from browser
17
+ */
18
+ disconnectBrowser(): Promise<void>;
19
+ /**
20
+ * Check if connected
21
+ */
22
+ isConnected(): boolean;
23
+ /**
24
+ * Get connection status
25
+ */
26
+ getStatus(): ConnectionStatus;
27
+ /**
28
+ * Diagnose layout issues
29
+ */
30
+ diagnoseLayout(selector: string): Promise<DiagnosticResult>;
31
+ /**
32
+ * Event emitter
33
+ */
34
+ on(event: string, callback: Function): void;
35
+ /**
36
+ * Remove event listener
37
+ */
38
+ off(event: string, callback: Function): void;
39
+ /**
40
+ * Emit event
41
+ */
42
+ private emit;
43
+ }
44
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/E,qBAAa,OAAO;IAClB,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,SAAS,CAAyC;gBAE9C,OAAO,GAAE,aAAkB;IAKvC;;OAEG;IACG,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,SAAS,IAAI,gBAAgB;IAI7B;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQjE;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAO3C;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAM5C;;OAEG;IACH,OAAO,CAAC,IAAI;CAOb"}
package/dist/bridge.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Main Gravity class
3
+ * Provides unified API for browser diagnostics
4
+ */
5
+ import { BrowserConnection } from './browser-connection.js';
6
+ import { DiagnosticsEngine } from './diagnostics.js';
7
+ export class Gravity {
8
+ constructor(options = {}) {
9
+ this.listeners = new Map();
10
+ this.connection = new BrowserConnection(options);
11
+ this.diagnostics = new DiagnosticsEngine(this.connection);
12
+ }
13
+ /**
14
+ * Connect to browser
15
+ */
16
+ async connectBrowser(port) {
17
+ if (port) {
18
+ this.connection = new BrowserConnection({ port });
19
+ this.diagnostics = new DiagnosticsEngine(this.connection);
20
+ }
21
+ try {
22
+ await this.connection.connect();
23
+ this.emit('connected');
24
+ }
25
+ catch (error) {
26
+ this.emit('error', error);
27
+ throw error;
28
+ }
29
+ }
30
+ /**
31
+ * Disconnect from browser
32
+ */
33
+ async disconnectBrowser() {
34
+ await this.connection.disconnect();
35
+ this.emit('disconnected');
36
+ }
37
+ /**
38
+ * Check if connected
39
+ */
40
+ isConnected() {
41
+ return this.connection.getStatus().connected;
42
+ }
43
+ /**
44
+ * Get connection status
45
+ */
46
+ getStatus() {
47
+ return this.connection.getStatus();
48
+ }
49
+ /**
50
+ * Diagnose layout issues
51
+ */
52
+ async diagnoseLayout(selector) {
53
+ if (!this.isConnected()) {
54
+ throw new Error('Not connected to browser. Call connectBrowser() first.');
55
+ }
56
+ return this.diagnostics.diagnose(selector);
57
+ }
58
+ /**
59
+ * Event emitter
60
+ */
61
+ on(event, callback) {
62
+ if (!this.listeners.has(event)) {
63
+ this.listeners.set(event, new Set());
64
+ }
65
+ this.listeners.get(event).add(callback);
66
+ }
67
+ /**
68
+ * Remove event listener
69
+ */
70
+ off(event, callback) {
71
+ if (this.listeners.has(event)) {
72
+ this.listeners.get(event).delete(callback);
73
+ }
74
+ }
75
+ /**
76
+ * Emit event
77
+ */
78
+ emit(event, ...args) {
79
+ if (this.listeners.has(event)) {
80
+ for (const callback of this.listeners.get(event)) {
81
+ callback(...args);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,OAAO,OAAO;IAKlB,YAAY,UAAyB,EAAE;QAF/B,cAAS,GAA+B,IAAI,GAAG,EAAE,CAAC;QAGxD,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAAa;QAChC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,QAAgB;QACnC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,EAAE,CAAC,KAAa,EAAE,QAAkB;QAClC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAa,EAAE,QAAkB;QACnC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;OAEG;IACK,IAAI,CAAC,KAAa,EAAE,GAAG,IAAW;QACxC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,EAAE,CAAC;gBAClD,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Browser connection management
3
+ * Handles WebSocket connection to native host
4
+ */
5
+ import { ConnectionStatus, BridgeOptions } from './types.js';
6
+ export declare class BrowserConnection {
7
+ private socket;
8
+ private isConnected;
9
+ private port;
10
+ private timeout;
11
+ private autoReconnect;
12
+ private reconnectTimer;
13
+ private reconnectAttempts;
14
+ private maxReconnectAttempts;
15
+ private reconnectInterval;
16
+ private messageIdCounter;
17
+ private pendingRequests;
18
+ constructor(options?: BridgeOptions);
19
+ /**
20
+ * Connect to browser via native host
21
+ */
22
+ connect(): Promise<void>;
23
+ /**
24
+ * Attempt to connect to native host
25
+ */
26
+ private attemptConnect;
27
+ /**
28
+ * Schedule a reconnection attempt
29
+ */
30
+ private scheduleReconnect;
31
+ /**
32
+ * Disconnect from browser
33
+ */
34
+ disconnect(): Promise<void>;
35
+ /**
36
+ * Check if connected
37
+ */
38
+ getStatus(): ConnectionStatus;
39
+ /**
40
+ * Send CDP command
41
+ */
42
+ sendCommand(method: string, params?: any): Promise<any>;
43
+ /**
44
+ * Handle incoming messages
45
+ */
46
+ private handleMessage;
47
+ }
48
+ //# sourceMappingURL=browser-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-connection.d.ts","sourceRoot":"","sources":["../src/browser-connection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,eAAe,CAIlB;gBAEO,OAAO,GAAE,aAAkB;IAMvC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;OAEG;IACH,OAAO,CAAC,cAAc;IAwEtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC;;OAEG;IACH,SAAS,IAAI,gBAAgB;IAQ7B;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,GAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAgCjE;;OAEG;IACH,OAAO,CAAC,aAAa;CAgBtB"}