yaver-feedback-react-native 0.7.4 → 0.7.5
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/dist/P2PClient.js +47 -6
- package/package.json +1 -1
- package/src/P2PClient.ts +56 -6
package/dist/P2PClient.js
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.P2PClient = void 0;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
|
+
/**
|
|
6
|
+
* Translate a raw Go-agent error into something a user can act on.
|
|
7
|
+
*
|
|
8
|
+
* The agent surfaces Go's low-level error text verbatim inside JSON,
|
|
9
|
+
* e.g. `Get "http://127.0.0.1:8081/reload": dial tcp 127.0.0.1:8081:
|
|
10
|
+
* connect: connection refused`. That's accurate but unreadable for a
|
|
11
|
+
* phone user and — more importantly — leads them to think the SDK is
|
|
12
|
+
* misconfigured. The real cause is almost always "no dev server
|
|
13
|
+
* running on the host machine".
|
|
14
|
+
*/
|
|
15
|
+
function friendlyReloadError(status, body) {
|
|
16
|
+
const lower = body.toLowerCase();
|
|
17
|
+
if (/connection refused|econnrefused/.test(lower) &&
|
|
18
|
+
/127\.0\.0\.1|localhost/.test(lower)) {
|
|
19
|
+
return ('No dev server running on your machine. ' +
|
|
20
|
+
'Start Metro with `yaver dev start` or use "Screenshot & Fix" instead.');
|
|
21
|
+
}
|
|
22
|
+
if (/no dev server/.test(lower) || /not running/.test(lower)) {
|
|
23
|
+
return 'No dev server running on your machine. Start Metro first.';
|
|
24
|
+
}
|
|
25
|
+
if (status === 403)
|
|
26
|
+
return 'Agent rejected the session — please sign in again.';
|
|
27
|
+
if (status === 401)
|
|
28
|
+
return 'Agent rejected the session — please sign in again.';
|
|
29
|
+
if (status >= 500)
|
|
30
|
+
return 'Agent hit an internal error while reloading. Check `yaver logs`.';
|
|
31
|
+
return `Reload failed (${status}).`;
|
|
32
|
+
}
|
|
5
33
|
/**
|
|
6
34
|
* Lightweight P2P HTTP client for communicating with a Yaver agent.
|
|
7
35
|
*
|
|
@@ -196,23 +224,36 @@ class P2PClient {
|
|
|
196
224
|
if (primary.ok) {
|
|
197
225
|
return primary.json().catch(() => ({ ok: true }));
|
|
198
226
|
}
|
|
199
|
-
|
|
227
|
+
// Common shape of the `/dev/reload` failure when Metro isn't running
|
|
228
|
+
// on the agent's host: the agent tries to forward the reload to
|
|
229
|
+
// `http://127.0.0.1:<metroPort>/reload` and that connection refuses.
|
|
230
|
+
// In that case a JS hot-reload is simply not possible — pivot to
|
|
231
|
+
// `/dev/reload-app` in bundle mode, which rebuilds + pushes a fresh
|
|
232
|
+
// Hermes bundle without needing Metro to be alive.
|
|
233
|
+
const primaryText = await primary.text().catch(() => '');
|
|
234
|
+
const noDevServer = primary.status === 400 ||
|
|
235
|
+
primary.status === 404 ||
|
|
236
|
+
primary.status >= 500 ||
|
|
237
|
+
/connection refused|no dev server|not running|ECONNREFUSED/i.test(primaryText);
|
|
238
|
+
if (noDevServer || mode === 'bundle') {
|
|
239
|
+
const nextMode = mode === 'bundle' ? 'bundle' : 'bundle';
|
|
200
240
|
const fallback = await fetch(`${this.baseUrl}/dev/reload-app`, {
|
|
201
241
|
method: 'POST',
|
|
202
242
|
headers: {
|
|
203
243
|
Authorization: `Bearer ${this.authToken}`,
|
|
204
244
|
'Content-Type': 'application/json',
|
|
205
245
|
},
|
|
206
|
-
body: JSON.stringify({ mode }),
|
|
246
|
+
body: JSON.stringify({ mode: nextMode }),
|
|
207
247
|
});
|
|
208
248
|
if (!fallback.ok) {
|
|
209
|
-
const
|
|
210
|
-
|
|
249
|
+
const fallbackText = await fallback.text().catch(() => '');
|
|
250
|
+
// Give the user something actionable instead of a raw Go error.
|
|
251
|
+
const friendlyFromFallback = friendlyReloadError(fallback.status, fallbackText);
|
|
252
|
+
throw new Error(friendlyFromFallback);
|
|
211
253
|
}
|
|
212
254
|
return fallback.json().catch(() => ({ ok: true }));
|
|
213
255
|
}
|
|
214
|
-
|
|
215
|
-
throw new Error(`[P2PClient] Reload failed (${primary.status}): ${text}`);
|
|
256
|
+
throw new Error(friendlyReloadError(primary.status, primaryText));
|
|
216
257
|
}
|
|
217
258
|
/**
|
|
218
259
|
* Open a vibing session on the connected agent. Vibing is the Yaver
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaver-feedback-react-native",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Visual feedback SDK for Yaver — bug reports, screen recording, voice annotations, and local-first developer workflows",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/P2PClient.ts
CHANGED
|
@@ -7,6 +7,36 @@ export interface FeedbackEvent {
|
|
|
7
7
|
data: any;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Translate a raw Go-agent error into something a user can act on.
|
|
12
|
+
*
|
|
13
|
+
* The agent surfaces Go's low-level error text verbatim inside JSON,
|
|
14
|
+
* e.g. `Get "http://127.0.0.1:8081/reload": dial tcp 127.0.0.1:8081:
|
|
15
|
+
* connect: connection refused`. That's accurate but unreadable for a
|
|
16
|
+
* phone user and — more importantly — leads them to think the SDK is
|
|
17
|
+
* misconfigured. The real cause is almost always "no dev server
|
|
18
|
+
* running on the host machine".
|
|
19
|
+
*/
|
|
20
|
+
function friendlyReloadError(status: number, body: string): string {
|
|
21
|
+
const lower = body.toLowerCase();
|
|
22
|
+
if (
|
|
23
|
+
/connection refused|econnrefused/.test(lower) &&
|
|
24
|
+
/127\.0\.0\.1|localhost/.test(lower)
|
|
25
|
+
) {
|
|
26
|
+
return (
|
|
27
|
+
'No dev server running on your machine. ' +
|
|
28
|
+
'Start Metro with `yaver dev start` or use "Screenshot & Fix" instead.'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (/no dev server/.test(lower) || /not running/.test(lower)) {
|
|
32
|
+
return 'No dev server running on your machine. Start Metro first.';
|
|
33
|
+
}
|
|
34
|
+
if (status === 403) return 'Agent rejected the session — please sign in again.';
|
|
35
|
+
if (status === 401) return 'Agent rejected the session — please sign in again.';
|
|
36
|
+
if (status >= 500) return 'Agent hit an internal error while reloading. Check `yaver logs`.';
|
|
37
|
+
return `Reload failed (${status}).`;
|
|
38
|
+
}
|
|
39
|
+
|
|
10
40
|
/**
|
|
11
41
|
* Lightweight P2P HTTP client for communicating with a Yaver agent.
|
|
12
42
|
*
|
|
@@ -230,23 +260,43 @@ export class P2PClient {
|
|
|
230
260
|
if (primary.ok) {
|
|
231
261
|
return primary.json().catch(() => ({ ok: true }));
|
|
232
262
|
}
|
|
233
|
-
|
|
263
|
+
|
|
264
|
+
// Common shape of the `/dev/reload` failure when Metro isn't running
|
|
265
|
+
// on the agent's host: the agent tries to forward the reload to
|
|
266
|
+
// `http://127.0.0.1:<metroPort>/reload` and that connection refuses.
|
|
267
|
+
// In that case a JS hot-reload is simply not possible — pivot to
|
|
268
|
+
// `/dev/reload-app` in bundle mode, which rebuilds + pushes a fresh
|
|
269
|
+
// Hermes bundle without needing Metro to be alive.
|
|
270
|
+
const primaryText = await primary.text().catch(() => '');
|
|
271
|
+
const noDevServer =
|
|
272
|
+
primary.status === 400 ||
|
|
273
|
+
primary.status === 404 ||
|
|
274
|
+
primary.status >= 500 ||
|
|
275
|
+
/connection refused|no dev server|not running|ECONNREFUSED/i.test(primaryText);
|
|
276
|
+
|
|
277
|
+
if (noDevServer || mode === 'bundle') {
|
|
278
|
+
const nextMode = mode === 'bundle' ? 'bundle' : 'bundle';
|
|
234
279
|
const fallback = await fetch(`${this.baseUrl}/dev/reload-app`, {
|
|
235
280
|
method: 'POST',
|
|
236
281
|
headers: {
|
|
237
282
|
Authorization: `Bearer ${this.authToken}`,
|
|
238
283
|
'Content-Type': 'application/json',
|
|
239
284
|
},
|
|
240
|
-
body: JSON.stringify({ mode }),
|
|
285
|
+
body: JSON.stringify({ mode: nextMode }),
|
|
241
286
|
});
|
|
242
287
|
if (!fallback.ok) {
|
|
243
|
-
const
|
|
244
|
-
|
|
288
|
+
const fallbackText = await fallback.text().catch(() => '');
|
|
289
|
+
// Give the user something actionable instead of a raw Go error.
|
|
290
|
+
const friendlyFromFallback = friendlyReloadError(
|
|
291
|
+
fallback.status,
|
|
292
|
+
fallbackText,
|
|
293
|
+
);
|
|
294
|
+
throw new Error(friendlyFromFallback);
|
|
245
295
|
}
|
|
246
296
|
return fallback.json().catch(() => ({ ok: true }));
|
|
247
297
|
}
|
|
248
|
-
|
|
249
|
-
throw new Error(
|
|
298
|
+
|
|
299
|
+
throw new Error(friendlyReloadError(primary.status, primaryText));
|
|
250
300
|
}
|
|
251
301
|
|
|
252
302
|
/**
|