@farmslot/adapter-web 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ 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.4.1 - 2026-10-07
10
+
11
+ - `network-observer`: `createExtensionNetworkObserver` takes an optional `extensionId`, the extension to capture. Without it the observer still takes the first extension with a target, which in a branded Chrome can be a component or policy extension listed before the one under test.
12
+ - Publish with adapter-sdk 0.6.0 and recipe-runner 0.26.0.
13
+
9
14
  ## 0.4.0 - 2026-10-06
10
15
 
11
16
  - Add `network-observer` (`createExtensionNetworkObserver({ cdpPort, runtimeDir })`) and `performance-observer` (`createExtensionPerformanceBackend({ cdpPort, extensionId, uiPaths, kind, platform, markerPrefix })`), the Extension network and performance observers moved from mm-harness. The network observer attaches to every target of the loaded extension and feeds their Network events to a `@farmslot/recipe-runner/cdp-broker`; it returns an `@farmslot/adapter-sdk` `NetworkCaptureBackend`. The performance observer traces the extension page found at the first of `uiPaths` with exactly one open renderer, through `@farmslot/recipe-runner/runtime/cdp-trace`. Both run on `connectBrowserCdp`; `connectTimeoutMs` and `commandTimeoutMs` default to 10 s. The package now depends on `@farmslot/recipe-runner` and `@farmslot/adapter-sdk`.
@@ -1,12 +1,15 @@
1
1
  /**
2
- * @param {{ cdpPort: number, runtimeDir: string, connectTimeoutMs?: number, commandTimeoutMs?: number }} options
2
+ * @param {{ cdpPort: number, runtimeDir: string, extensionId?: string, connectTimeoutMs?: number, commandTimeoutMs?: number }} options
3
3
  * `runtimeDir` keys the broker socket; the timeouts bound the CDP connection
4
- * and every command, broker call and capture control.
4
+ * and every command, broker call and capture control. `extensionId` names the
5
+ * extension to capture; without it, the first extension with a target is
6
+ * used, which can be a component or policy extension in a branded Chrome.
5
7
  * @returns {Promise<import('@farmslot/adapter-sdk').NetworkCaptureBackend>}
6
8
  */
7
- export function createExtensionNetworkObserver({ cdpPort, runtimeDir, connectTimeoutMs, commandTimeoutMs, }: {
9
+ export function createExtensionNetworkObserver({ cdpPort, runtimeDir, extensionId: requestedExtensionId, connectTimeoutMs, commandTimeoutMs, }: {
8
10
  cdpPort: number;
9
11
  runtimeDir: string;
12
+ extensionId?: string;
10
13
  connectTimeoutMs?: number;
11
14
  commandTimeoutMs?: number;
12
15
  }): Promise<import("@farmslot/adapter-sdk").NetworkCaptureBackend>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farmslot/adapter-web",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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": {
@@ -79,7 +79,7 @@
79
79
  "prepublishOnly": "node ../../scripts/quality/check-farmslot-package-readiness.mjs --publish --packages @farmslot/adapter-web"
80
80
  },
81
81
  "dependencies": {
82
- "@farmslot/adapter-sdk": "0.5.1",
82
+ "@farmslot/adapter-sdk": "0.6.0",
83
83
  "@farmslot/recipe-runner": "0.26.0",
84
84
  "ws": "^8.18.0"
85
85
  },
@@ -27,14 +27,17 @@ const asRecord = (value) =>
27
27
  value && typeof value === 'object' && !Array.isArray(value) ? value : {};
28
28
 
29
29
  /**
30
- * @param {{ cdpPort: number, runtimeDir: string, connectTimeoutMs?: number, commandTimeoutMs?: number }} options
30
+ * @param {{ cdpPort: number, runtimeDir: string, extensionId?: string, connectTimeoutMs?: number, commandTimeoutMs?: number }} options
31
31
  * `runtimeDir` keys the broker socket; the timeouts bound the CDP connection
32
- * and every command, broker call and capture control.
32
+ * and every command, broker call and capture control. `extensionId` names the
33
+ * extension to capture; without it, the first extension with a target is
34
+ * used, which can be a component or policy extension in a branded Chrome.
33
35
  * @returns {Promise<import('@farmslot/adapter-sdk').NetworkCaptureBackend>}
34
36
  */
35
37
  async function createExtensionNetworkObserver({
36
38
  cdpPort,
37
39
  runtimeDir,
40
+ extensionId: requestedExtensionId,
38
41
  connectTimeoutMs = DEFAULT_TIMEOUT_MS,
39
42
  commandTimeoutMs = DEFAULT_TIMEOUT_MS,
40
43
  }) {
@@ -133,7 +136,7 @@ async function createExtensionNetworkObserver({
133
136
  await send('Target.setDiscoverTargets', { discover: true });
134
137
  const targetInfos = asRecord(await send('Target.getTargets')).targetInfos;
135
138
  const targets = Array.isArray(targetInfos) ? targetInfos : [];
136
- extensionId = extensionIdFromCdpTargets(targets);
139
+ extensionId = requestedExtensionId || extensionIdFromCdpTargets(targets);
137
140
  if (!extensionId) {
138
141
  connection.close();
139
142
  throw new Error('Extension CDP browser or loaded extension target is unavailable.');
@@ -141,7 +144,11 @@ async function createExtensionNetworkObserver({
141
144
  await Promise.all(targets.map(asBrowserCdpTarget).filter(Boolean).map(attachTarget));
142
145
  if (targetSessions.size === 0) {
143
146
  connection.close();
144
- throw new Error('Extension CDP exposes no attachable extension targets.');
147
+ throw new Error(
148
+ requestedExtensionId
149
+ ? `Extension ${extensionId} has no attachable CDP targets (service worker stopped and no extension page open?).`
150
+ : 'Extension CDP exposes no attachable extension targets.',
151
+ );
145
152
  }
146
153
 
147
154
  const sessions = new Map([[DEVICE_ID, { brokerReady: true }]]);