@tracelane/core 0.1.0-alpha.10 → 0.1.0-alpha.11
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/load-rrweb-bundle.d.ts +13 -0
- package/dist/load-rrweb-bundle.d.ts.map +1 -0
- package/dist/load-rrweb-bundle.js +47 -0
- package/dist/load-rrweb-bundle.js.map +1 -0
- package/dist/network-capture.d.ts +38 -0
- package/dist/network-capture.d.ts.map +1 -0
- package/dist/network-capture.js +125 -0
- package/dist/network-capture.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { BrowserExecutor } from './browser-executor.js';
|
|
2
|
+
export { __internal, attachNetworkCapture } from './network-capture.js';
|
|
3
|
+
export { loadRrwebBundle } from './load-rrweb-bundle.js';
|
|
2
4
|
export { createRecorder, DEFAULT_COOLDOWN_MS, DEFAULT_DRAIN_INTERVAL_MS } from './recorder.js';
|
|
3
5
|
export type { FinalizeResult, Recorder, RecorderOptions, TestOutcome } from './recorder.js';
|
|
4
6
|
export type { ConsolePluginOptions, NetworkPluginOptions } from './page-script.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAO7D,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIxE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/F,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
// Public API surface for @tracelane/core.
|
|
2
|
+
// CDP network capture (Task 2.16 / P1 PRD §E.2) — framework-agnostic, shared by
|
|
3
|
+
// the WDIO and Playwright adapters via the BrowserExecutor surface. `__internal`
|
|
4
|
+
// exposes the pure page-side logger + method resolver so @tracelane/report's
|
|
5
|
+
// cross-package contract test can exercise core's real output (the test must
|
|
6
|
+
// live in report — which depends on core — to keep the dep edge one-directional).
|
|
7
|
+
export { __internal, attachNetworkCapture } from './network-capture.js';
|
|
8
|
+
// In-page rrweb bundle loader — reads the adapter's built dist/rrweb-bundle.js
|
|
9
|
+
// off disk (pass the adapter's import.meta.url). Shared across adapters.
|
|
10
|
+
export { loadRrwebBundle } from './load-rrweb-bundle.js';
|
|
2
11
|
// Recorder controller — in-page buffer install + Node-polled drain (ADR-0006).
|
|
3
12
|
export { createRecorder, DEFAULT_COOLDOWN_MS, DEFAULT_DRAIN_INTERVAL_MS } from './recorder.js';
|
|
4
13
|
// Capture mode switch (ADR-0005).
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAK1C,+EAA+E;AAC/E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAI/F,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGtD,yEAAyE;AACzE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAK1C,gFAAgF;AAChF,iFAAiF;AACjF,6EAA6E;AAC7E,6EAA6E;AAC7E,kFAAkF;AAClF,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAExE,+EAA+E;AAC/E,yEAAyE;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,+EAA+E;AAC/E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAI/F,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGtD,yEAAyE;AACzE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the rrweb in-page bundle source (defines `window.rrweb`) off disk.
|
|
3
|
+
*
|
|
4
|
+
* @param moduleUrl the calling adapter's `import.meta.url`; candidate
|
|
5
|
+
* paths resolve relative to this module.
|
|
6
|
+
* @param candidatePaths optional explicit candidate paths (overrides the
|
|
7
|
+
* defaults). The first that exists is read.
|
|
8
|
+
* @returns the bundle source string.
|
|
9
|
+
* @throws if no candidate exists — that means the package was used without its
|
|
10
|
+
* build step having run.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadRrwebBundle(moduleUrl: string, candidatePaths?: string[]): string;
|
|
13
|
+
//# sourceMappingURL=load-rrweb-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-rrweb-bundle.d.ts","sourceRoot":"","sources":["../src/load-rrweb-bundle.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAUpF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Loads the in-page rrweb bundle source string (framework-agnostic).
|
|
2
|
+
//
|
|
3
|
+
// Each adapter (WDIO, Playwright) ships its own `dist/rrweb-bundle.js` — an
|
|
4
|
+
// esbuild IIFE that defines `window.rrweb` with `record` +
|
|
5
|
+
// `getRecordConsolePlugin` (+ `getRecordNetworkPlugin`). The recorder is
|
|
6
|
+
// bundle-source-agnostic (ADR-0006) and expects this source as a plain string,
|
|
7
|
+
// which it `window.eval`s in the page on every (re-)injection.
|
|
8
|
+
//
|
|
9
|
+
// This loader lives in @tracelane/core so every adapter shares one
|
|
10
|
+
// implementation. The adapter passes its own `import.meta.url` so the candidate
|
|
11
|
+
// paths resolve relative to the ADAPTER's module (where its bundle sits), not to
|
|
12
|
+
// core. We derive the module directory from `fileURLToPath(moduleUrl)` directly
|
|
13
|
+
// (not via `new URL(rel, moduleUrl)`) because under the jsdom test env the
|
|
14
|
+
// global `URL` resolves relative inputs against the page origin, not the file.
|
|
15
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { dirname, join } from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
/**
|
|
19
|
+
* Default candidate locations for the built bundle relative to `moduleUrl`, in
|
|
20
|
+
* priority order. Mirrors the historical wdio layout:
|
|
21
|
+
* - Published: `dist/<loader>.js` sits next to `dist/rrweb-bundle.js`.
|
|
22
|
+
* - Source/test: `src/<loader>.ts` → `../dist/rrweb-bundle.js`.
|
|
23
|
+
*/
|
|
24
|
+
function defaultCandidatePaths(moduleUrl) {
|
|
25
|
+
const moduleDir = dirname(fileURLToPath(moduleUrl));
|
|
26
|
+
return [join(moduleDir, 'rrweb-bundle.js'), join(moduleDir, '..', 'dist', 'rrweb-bundle.js')];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read the rrweb in-page bundle source (defines `window.rrweb`) off disk.
|
|
30
|
+
*
|
|
31
|
+
* @param moduleUrl the calling adapter's `import.meta.url`; candidate
|
|
32
|
+
* paths resolve relative to this module.
|
|
33
|
+
* @param candidatePaths optional explicit candidate paths (overrides the
|
|
34
|
+
* defaults). The first that exists is read.
|
|
35
|
+
* @returns the bundle source string.
|
|
36
|
+
* @throws if no candidate exists — that means the package was used without its
|
|
37
|
+
* build step having run.
|
|
38
|
+
*/
|
|
39
|
+
export function loadRrwebBundle(moduleUrl, candidatePaths) {
|
|
40
|
+
const candidates = candidatePaths && candidatePaths.length > 0 ? candidatePaths : defaultCandidatePaths(moduleUrl);
|
|
41
|
+
const found = candidates.find((p) => existsSync(p));
|
|
42
|
+
if (found === undefined) {
|
|
43
|
+
throw new Error(`tracelane: in-page rrweb bundle not found (looked in ${candidates.join(', ')}). Run the package build to generate dist/rrweb-bundle.js.`);
|
|
44
|
+
}
|
|
45
|
+
return readFileSync(found, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=load-rrweb-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-rrweb-bundle.js","sourceRoot":"","sources":["../src/load-rrweb-bundle.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,4EAA4E;AAC5E,2DAA2D;AAC3D,yEAAyE;AACzE,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,mEAAmE;AACnE,gFAAgF;AAChF,iFAAiF;AACjF,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAChG,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,cAAyB;IAC1E,MAAM,UAAU,GACd,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAClG,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,wDAAwD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,4DAA4D,CAC1I,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BrowserExecutor } from './browser-executor.js';
|
|
2
|
+
/**
|
|
3
|
+
* Page-side logger. Self-contained (no Node closures) so it can be
|
|
4
|
+
* `.toString()`-serialized by `execute` (PRD §A.4). The console plugin captures
|
|
5
|
+
* this `console.error`; the `[tracelane.net]` prefix lets the report's network
|
|
6
|
+
* panel scrape it back out (PRD §E.2).
|
|
7
|
+
*
|
|
8
|
+
* The status is zero-padded to 3 digits so it satisfies panels.ts's
|
|
9
|
+
* `parseNetConsoleLine` regex (`(\d{3})`); `Number('000')` parses back to a
|
|
10
|
+
* genuine `0`, which — paired with the always-present method — panels.ts treats
|
|
11
|
+
* as a true network failure.
|
|
12
|
+
*/
|
|
13
|
+
declare function logNetworkErrorInPage(url: string, status: number, method: string): void;
|
|
14
|
+
/** Pull the request method out of CDP request headers, defaulting to GET. */
|
|
15
|
+
declare function methodOf(headers: Record<string, string> | undefined): string;
|
|
16
|
+
/**
|
|
17
|
+
* Attach CDP network capture to a BrowserExecutor (P1 PRD §E.2).
|
|
18
|
+
*
|
|
19
|
+
* Enables the Network domain and registers subscribers that forward both HTTP
|
|
20
|
+
* error responses (`Network.responseReceived`, `status >= 400`) and no-response
|
|
21
|
+
* failures (`Network.loadingFailed` — CORS/DNS/offline/abort, audit A-6) into
|
|
22
|
+
* `console.error`. Resolves once `Network.enable` has been sent. The
|
|
23
|
+
* subscribers' own `execute` calls are fire-and-forget (their failures must not
|
|
24
|
+
* break the test).
|
|
25
|
+
*
|
|
26
|
+
* To give the methodless `loadingFailed` events a method (required by panels.ts
|
|
27
|
+
* to classify the row as failed), we keep a small `requestId → { method, url }`
|
|
28
|
+
* map populated from `Network.requestWillBeSent`, and evict an entry once it has
|
|
29
|
+
* either succeeded (`responseReceived`) or failed (`loadingFailed`) so the map
|
|
30
|
+
* can't grow unbounded over a long session.
|
|
31
|
+
*/
|
|
32
|
+
export declare function attachNetworkCapture(executor: BrowserExecutor): Promise<void>;
|
|
33
|
+
export declare const __internal: {
|
|
34
|
+
logNetworkErrorInPage: typeof logNetworkErrorInPage;
|
|
35
|
+
methodOf: typeof methodOf;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=network-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-capture.d.ts","sourceRoot":"","sources":["../src/network-capture.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoC7D;;;;;;;;;;GAUG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAMhF;AAED,6EAA6E;AAC7E,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,CAKrE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDnF;AAGD,eAAO,MAAM,UAAU;;;CAAsC,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// CDP network capture wiring (Task 2.16 / P1 PRD §E.2).
|
|
2
|
+
//
|
|
3
|
+
// Enable the CDP Network domain and route failures into the page's
|
|
4
|
+
// `console.error` via `executor.execute`. Two failure classes are surfaced:
|
|
5
|
+
//
|
|
6
|
+
// 1. `Network.responseReceived` with `status >= 400` — a response arrived
|
|
7
|
+
// but the server reported an HTTP error (4xx/5xx).
|
|
8
|
+
// 2. `Network.loadingFailed` — the request produced NO response at all
|
|
9
|
+
// (CORS failure, DNS/connection failure, offline, abort). CDP's
|
|
10
|
+
// `responseReceived` never fires for these, and the in-page status-0
|
|
11
|
+
// wrapper is off by default, so without this branch a genuine failed
|
|
12
|
+
// request would be invisible (audit A-6). We surface it with an explicit
|
|
13
|
+
// status `000` (= a real 0 once parsed) so it reads as a true failure.
|
|
14
|
+
//
|
|
15
|
+
// The rrweb console plugin (installed by the recorder) then captures the
|
|
16
|
+
// console line, so failures show up in the report's network panel "for free" —
|
|
17
|
+
// no dedicated network transport in v1. Framework-agnostic: it talks only to a
|
|
18
|
+
// BrowserExecutor, so the WDIO and Playwright adapters share this one path.
|
|
19
|
+
//
|
|
20
|
+
// The console line is prefixed `[tracelane.net]` so @tracelane/report's network
|
|
21
|
+
// panel can scrape it back out (NETWORK_CONSOLE_PREFIX in panels.ts). The line
|
|
22
|
+
// ALWAYS carries a METHOD: panels.ts classifies a `status === 0` scrape row as
|
|
23
|
+
// a true failure only when a method is present (its "true error path" rule —
|
|
24
|
+
// see `isTrueErrorPath`), so a methodless `loadingFailed` line would be
|
|
25
|
+
// silently dropped from the panel.
|
|
26
|
+
/** Status sentinel for a request that produced no response (a true 0 once parsed). */
|
|
27
|
+
const NO_RESPONSE_STATUS = 0;
|
|
28
|
+
/**
|
|
29
|
+
* Page-side logger. Self-contained (no Node closures) so it can be
|
|
30
|
+
* `.toString()`-serialized by `execute` (PRD §A.4). The console plugin captures
|
|
31
|
+
* this `console.error`; the `[tracelane.net]` prefix lets the report's network
|
|
32
|
+
* panel scrape it back out (PRD §E.2).
|
|
33
|
+
*
|
|
34
|
+
* The status is zero-padded to 3 digits so it satisfies panels.ts's
|
|
35
|
+
* `parseNetConsoleLine` regex (`(\d{3})`); `Number('000')` parses back to a
|
|
36
|
+
* genuine `0`, which — paired with the always-present method — panels.ts treats
|
|
37
|
+
* as a true network failure.
|
|
38
|
+
*/
|
|
39
|
+
function logNetworkErrorInPage(url, status, method) {
|
|
40
|
+
// Zero-pad to 3 digits without String.padStart so the .toString()-serialized
|
|
41
|
+
// form runs on older in-page engines too.
|
|
42
|
+
let code = String(status);
|
|
43
|
+
while (code.length < 3)
|
|
44
|
+
code = `0${code}`;
|
|
45
|
+
console.error(`[tracelane.net] ${method} ${code} ${url}`);
|
|
46
|
+
}
|
|
47
|
+
/** Pull the request method out of CDP request headers, defaulting to GET. */
|
|
48
|
+
function methodOf(headers) {
|
|
49
|
+
if (!headers)
|
|
50
|
+
return 'GET';
|
|
51
|
+
// CDP exposes the pseudo-header `:method` for HTTP/2/3; fall back to a plain
|
|
52
|
+
// `method` header, then GET.
|
|
53
|
+
return headers[':method'] ?? headers.method ?? 'GET';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Attach CDP network capture to a BrowserExecutor (P1 PRD §E.2).
|
|
57
|
+
*
|
|
58
|
+
* Enables the Network domain and registers subscribers that forward both HTTP
|
|
59
|
+
* error responses (`Network.responseReceived`, `status >= 400`) and no-response
|
|
60
|
+
* failures (`Network.loadingFailed` — CORS/DNS/offline/abort, audit A-6) into
|
|
61
|
+
* `console.error`. Resolves once `Network.enable` has been sent. The
|
|
62
|
+
* subscribers' own `execute` calls are fire-and-forget (their failures must not
|
|
63
|
+
* break the test).
|
|
64
|
+
*
|
|
65
|
+
* To give the methodless `loadingFailed` events a method (required by panels.ts
|
|
66
|
+
* to classify the row as failed), we keep a small `requestId → { method, url }`
|
|
67
|
+
* map populated from `Network.requestWillBeSent`, and evict an entry once it has
|
|
68
|
+
* either succeeded (`responseReceived`) or failed (`loadingFailed`) so the map
|
|
69
|
+
* can't grow unbounded over a long session.
|
|
70
|
+
*/
|
|
71
|
+
export async function attachNetworkCapture(executor) {
|
|
72
|
+
await executor.cdp('Network', 'enable');
|
|
73
|
+
// Correlation map: a `loadingFailed` carries only a requestId, so remember the
|
|
74
|
+
// method + url from `requestWillBeSent` to reconstruct a method-bearing line.
|
|
75
|
+
const inflight = new Map();
|
|
76
|
+
const emit = (url, status, method) => {
|
|
77
|
+
// Fire-and-forget: a logging failure (e.g. page mid-navigation) must not
|
|
78
|
+
// surface as a test error.
|
|
79
|
+
void executor
|
|
80
|
+
.execute(logNetworkErrorInPage, url, status, method)
|
|
81
|
+
.catch(() => {
|
|
82
|
+
/* page may be navigating; drop this one line */
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
executor.on('Network.requestWillBeSent', (params) => {
|
|
86
|
+
const e = params;
|
|
87
|
+
const id = e?.requestId;
|
|
88
|
+
const url = e?.request?.url;
|
|
89
|
+
if (typeof id !== 'string' || typeof url !== 'string')
|
|
90
|
+
return;
|
|
91
|
+
const method = typeof e.request?.method === 'string' ? e.request.method : 'GET';
|
|
92
|
+
inflight.set(id, { method, url });
|
|
93
|
+
});
|
|
94
|
+
executor.on('Network.responseReceived', (params) => {
|
|
95
|
+
const e = params;
|
|
96
|
+
const response = e?.response;
|
|
97
|
+
// A response arrived — this request will not surface via loadingFailed, so
|
|
98
|
+
// drop it from the inflight map regardless of status.
|
|
99
|
+
if (typeof e?.requestId === 'string')
|
|
100
|
+
inflight.delete(e.requestId);
|
|
101
|
+
const status = response?.status;
|
|
102
|
+
if (typeof status !== 'number' || status < 400)
|
|
103
|
+
return;
|
|
104
|
+
const url = response?.url ?? '';
|
|
105
|
+
const method = methodOf(response?.requestHeaders);
|
|
106
|
+
emit(url, status, method);
|
|
107
|
+
});
|
|
108
|
+
executor.on('Network.loadingFailed', (params) => {
|
|
109
|
+
const e = params;
|
|
110
|
+
const id = e?.requestId;
|
|
111
|
+
// Correlate back to the request's method + url; CORS/DNS/offline/abort
|
|
112
|
+
// failures produce NO response, so this is the only place they surface.
|
|
113
|
+
const tracked = typeof id === 'string' ? inflight.get(id) : undefined;
|
|
114
|
+
if (typeof id === 'string')
|
|
115
|
+
inflight.delete(id);
|
|
116
|
+
const url = tracked?.url ?? '';
|
|
117
|
+
// Method is required for panels.ts to treat the status-0 row as a failure;
|
|
118
|
+
// default to GET if the requestWillBeSent was missed (e.g. attach mid-flight).
|
|
119
|
+
const method = tracked?.method ?? 'GET';
|
|
120
|
+
emit(url, NO_RESPONSE_STATUS, method);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Exposed for unit tests: the page-side logger + method resolver are pure.
|
|
124
|
+
export const __internal = { logNetworkErrorInPage, methodOf };
|
|
125
|
+
//# sourceMappingURL=network-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-capture.js","sourceRoot":"","sources":["../src/network-capture.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,mE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AG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAClD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,EAAE,CAAC,uBAAuB,EAAE,CAAC,MAAe,EAAE,EAAE;QACvD,MAAM,CAAC,GAAG,MAA4B,CAAC;QACvC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC;QACxB,uEAAuE;QACvE,wEAAwE;QACxE,MAAM,OAAO,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;QAC/B,2EAA2E;QAC3E,+EAA+E;QAC/E,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;QACxC,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracelane/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
4
|
"description": "Framework-agnostic rrweb recording engine for tracelane. Wraps a per-framework browser object behind a common BrowserExecutor interface.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tracelane",
|