@farmslot/adapter-web 0.19.34 → 0.19.36
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 +8 -0
- package/dist/web-dapp/launch.d.mts +1 -0
- package/package.json +3 -3
- package/src/web-dapp/launch.mjs +32 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ All notable changes to `@farmslot/adapter-web` are tracked here.
|
|
|
6
6
|
|
|
7
7
|
- Active-development baseline; add user-facing changes here before release or package publication.
|
|
8
8
|
|
|
9
|
+
## 0.19.36 - 2026-11-26
|
|
10
|
+
|
|
11
|
+
- Recover Web DApp launches when the saved browser has lost its app tab or shows an error page, using the existing profile and network protections.
|
|
12
|
+
|
|
13
|
+
## 0.19.35 - 2026-11-25
|
|
14
|
+
|
|
15
|
+
- Uses recipe-runner 0.52.5: `ui.wait_for` on a busy page ends with its own timeout instead of a raw CDP timeout.
|
|
16
|
+
|
|
9
17
|
## 0.19.34 - 2026-11-25
|
|
10
18
|
|
|
11
19
|
- Republished in the 25 Nov cohort release with the other @farmslot packages, so an install resolves one copy of each.
|
|
@@ -22,6 +22,7 @@ export function checkFocusAfterLaunch(runtime: any, previous: any, { ourPids, fo
|
|
|
22
22
|
ourPids?: number[] | undefined;
|
|
23
23
|
focus?: any;
|
|
24
24
|
}): any;
|
|
25
|
+
export function hasHealthyAppPage(client: any, appOrigin: any): Promise<boolean>;
|
|
25
26
|
export function backgroundWindowParams(url: any, placement: any): {
|
|
26
27
|
left?: any;
|
|
27
28
|
top?: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farmslot/adapter-web",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.36",
|
|
4
4
|
"description": "Web platform adapter for Farmslot recipes: resolve and launch an isolated Chromium, own its CDP port, load unpacked extensions, and keep macOS focus.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"exports": {
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
"prepublishOnly": "node ../../scripts/quality/check-farmslot-package-readiness.mjs --publish --packages @farmslot/adapter-web"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@farmslot/adapter-sdk": "0.31.
|
|
90
|
+
"@farmslot/adapter-sdk": "0.31.4",
|
|
91
91
|
"@farmslot/protocol": "0.92.1",
|
|
92
|
-
"@farmslot/recipe-runner": "0.52.
|
|
92
|
+
"@farmslot/recipe-runner": "0.52.5",
|
|
93
93
|
"ws": "^8.18.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
package/src/web-dapp/launch.mjs
CHANGED
|
@@ -47,6 +47,7 @@ import path from 'node:path';
|
|
|
47
47
|
import { fileURLToPath } from 'node:url';
|
|
48
48
|
|
|
49
49
|
import { disableMacCodeSignClone } from '../chrome-args.cjs';
|
|
50
|
+
import { isAppUrl } from '../origin.cjs';
|
|
50
51
|
|
|
51
52
|
import { blindBrowserOptions } from './lib/blind-browser.mjs';
|
|
52
53
|
import { hostResolverRules } from './lib/blocked-hosts.mjs';
|
|
@@ -284,8 +285,8 @@ function focusLog(runtime, message) {
|
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
// Browser-level CDP helpers for a background launch.
|
|
287
|
-
async function withBrowserClient(cdpPort, callback) {
|
|
288
|
-
const client = await CdpClient.connect(await browserWebSocketUrl(cdpPort,
|
|
288
|
+
async function withBrowserClient(cdpPort, callback, timeoutMs = 15000) {
|
|
289
|
+
const client = await CdpClient.connect(await browserWebSocketUrl(cdpPort, timeoutMs));
|
|
289
290
|
try {
|
|
290
291
|
return await callback(client);
|
|
291
292
|
} finally {
|
|
@@ -293,6 +294,29 @@ async function withBrowserClient(cdpPort, callback) {
|
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
|
|
297
|
+
export async function hasHealthyAppPage(client, appOrigin) {
|
|
298
|
+
const { targetInfos } = await client.send('Target.getTargets');
|
|
299
|
+
const page = targetInfos.find(
|
|
300
|
+
(target) => target.type === 'page' && isAppUrl(target.url, appOrigin),
|
|
301
|
+
);
|
|
302
|
+
if (!page) return false;
|
|
303
|
+
const { sessionId } = await client.send('Target.attachToTarget', {
|
|
304
|
+
targetId: page.targetId,
|
|
305
|
+
flatten: true,
|
|
306
|
+
});
|
|
307
|
+
const { result } = await client.send(
|
|
308
|
+
'Runtime.evaluate',
|
|
309
|
+
{
|
|
310
|
+
// Next can keep the requested URL when it replaces the app with its error document.
|
|
311
|
+
expression:
|
|
312
|
+
"!document.documentURI.startsWith('chrome-error:') && document.documentElement?.id !== '__next_error__'",
|
|
313
|
+
returnByValue: true,
|
|
314
|
+
},
|
|
315
|
+
sessionId,
|
|
316
|
+
);
|
|
317
|
+
return result?.value === true;
|
|
318
|
+
}
|
|
319
|
+
|
|
296
320
|
export function backgroundWindowParams(url, placement) {
|
|
297
321
|
return {
|
|
298
322
|
url,
|
|
@@ -537,14 +561,18 @@ export async function launchWebDappBrowser(
|
|
|
537
561
|
previous.networkEnforcement?.fingerprint === enforcementFingerprint &&
|
|
538
562
|
ownsProcess('browser', previous.browserPid, runtime) &&
|
|
539
563
|
ownsProcess('wallet-host', previous.hostPid, runtime);
|
|
540
|
-
if (
|
|
541
|
-
|
|
564
|
+
if (
|
|
565
|
+
reusable &&
|
|
566
|
+
(await withBrowserClient(cdpPort, (client) => hasHealthyAppPage(client, appOrigin), 5000))
|
|
567
|
+
) {
|
|
542
568
|
log(`reusing browser pid ${previous.browserPid} (${signer}, ${account.name})`);
|
|
543
569
|
const state = { ...previous, slowMoMs };
|
|
544
570
|
if (previous.slowMoMs !== slowMoMs)
|
|
545
571
|
writePrivateFile(stateFile, `${JSON.stringify(state, null, 2)}\n`);
|
|
546
572
|
return { ...state, reused: true };
|
|
547
573
|
}
|
|
574
|
+
if (reusable)
|
|
575
|
+
log('restarting the slot browser because its app tab is missing or on an error page');
|
|
548
576
|
await stopWebDappBrowser(target, { cdpPort, log });
|
|
549
577
|
|
|
550
578
|
const browser = await resolveBrowser(env);
|