

























@@ -1,7 +1,7 @@
1-import type { BrowserActionPathResult, BrowserActionTargetOk } from "./client-actions-types.js";
1+import type { BrowserActionPathResult } from "./client-actions-types.js";
22import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js";
33import { fetchBrowserJson } from "./client-fetch.js";
4-import type { BrowserConsoleMessage, BrowserNetworkRequest } from "./pw-session.js";
4+import type { BrowserConsoleMessage } from "./pw-session.js";
5566function buildQuerySuffix(params: Array<[string, string | boolean | undefined]>): string {
77const query = new URLSearchParams();
@@ -47,120 +47,3 @@ export async function browserPdfSave(
4747timeoutMs: 20000,
4848});
4949}
50-51-export async function browserRequests(
52-baseUrl: string | undefined,
53-opts: {
54-targetId?: string;
55-filter?: string;
56-clear?: boolean;
57-profile?: string;
58-} = {},
59-): Promise<{ ok: true; targetId: string; url?: string; requests: BrowserNetworkRequest[] }> {
60-const suffix = buildQuerySuffix([
61-["targetId", opts.targetId],
62-["filter", opts.filter],
63-["clear", typeof opts.clear === "boolean" ? opts.clear : undefined],
64-["profile", opts.profile],
65-]);
66-return await fetchBrowserJson<{
67-ok: true;
68-targetId: string;
69-url?: string;
70-requests: BrowserNetworkRequest[];
71-}>(withBaseUrl(baseUrl, `/requests${suffix}`), { timeoutMs: 20000 });
72-}
73-74-export async function browserTraceStart(
75-baseUrl: string | undefined,
76-opts: {
77-targetId?: string;
78-screenshots?: boolean;
79-snapshots?: boolean;
80-sources?: boolean;
81-profile?: string;
82-} = {},
83-): Promise<BrowserActionTargetOk> {
84-const q = buildProfileQuery(opts.profile);
85-return await fetchBrowserJson<BrowserActionTargetOk>(withBaseUrl(baseUrl, `/trace/start${q}`), {
86-method: "POST",
87-headers: { "Content-Type": "application/json" },
88-body: JSON.stringify({
89-targetId: opts.targetId,
90-screenshots: opts.screenshots,
91-snapshots: opts.snapshots,
92-sources: opts.sources,
93-}),
94-timeoutMs: 20000,
95-});
96-}
97-98-export async function browserTraceStop(
99-baseUrl: string | undefined,
100-opts: { targetId?: string; path?: string; profile?: string } = {},
101-): Promise<BrowserActionPathResult> {
102-const q = buildProfileQuery(opts.profile);
103-return await fetchBrowserJson<BrowserActionPathResult>(withBaseUrl(baseUrl, `/trace/stop${q}`), {
104-method: "POST",
105-headers: { "Content-Type": "application/json" },
106-body: JSON.stringify({ targetId: opts.targetId, path: opts.path }),
107-timeoutMs: 20000,
108-});
109-}
110-111-export async function browserHighlight(
112-baseUrl: string | undefined,
113-opts: { ref: string; targetId?: string; profile?: string },
114-): Promise<BrowserActionTargetOk> {
115-const q = buildProfileQuery(opts.profile);
116-return await fetchBrowserJson<BrowserActionTargetOk>(withBaseUrl(baseUrl, `/highlight${q}`), {
117-method: "POST",
118-headers: { "Content-Type": "application/json" },
119-body: JSON.stringify({ targetId: opts.targetId, ref: opts.ref }),
120-timeoutMs: 20000,
121-});
122-}
123-124-export async function browserResponseBody(
125-baseUrl: string | undefined,
126-opts: {
127-url: string;
128-targetId?: string;
129-timeoutMs?: number;
130-maxChars?: number;
131-profile?: string;
132-},
133-): Promise<{
134-ok: true;
135-targetId: string;
136-response: {
137-url: string;
138-status?: number;
139-headers?: Record<string, string>;
140-body: string;
141-truncated?: boolean;
142-};
143-}> {
144-const q = buildProfileQuery(opts.profile);
145-return await fetchBrowserJson<{
146-ok: true;
147-targetId: string;
148-response: {
149-url: string;
150-status?: number;
151-headers?: Record<string, string>;
152-body: string;
153-truncated?: boolean;
154-};
155-}>(withBaseUrl(baseUrl, `/response/body${q}`), {
156-method: "POST",
157-headers: { "Content-Type": "application/json" },
158-body: JSON.stringify({
159-targetId: opts.targetId,
160-url: opts.url,
161-timeoutMs: opts.timeoutMs,
162-maxChars: opts.maxChars,
163-}),
164-timeoutMs: 20000,
165-});
166-}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。