@haibun/web-playwright 1.32.7 → 1.32.9
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.
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { TTag } from '@haibun/core/build/lib/defs.js';
|
|
2
2
|
import { ILogger } from '@haibun/core/build/lib/interfaces/logger.js';
|
|
3
3
|
import { Page } from 'playwright';
|
|
4
|
+
type TEtc = {
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
method?: string;
|
|
7
|
+
postData?: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
statusText?: string;
|
|
10
|
+
};
|
|
4
11
|
export declare class PlaywrightEvents {
|
|
5
12
|
page: Page;
|
|
6
13
|
tag: TTag;
|
|
@@ -10,4 +17,6 @@ export declare class PlaywrightEvents {
|
|
|
10
17
|
private routeRequest;
|
|
11
18
|
private logResponse;
|
|
12
19
|
close(): void;
|
|
20
|
+
log(type: string, maybeFrameURL: string, targetURL: string, etc: TEtc): void;
|
|
13
21
|
}
|
|
22
|
+
export {};
|
|
@@ -14,30 +14,12 @@ export class PlaywrightEvents {
|
|
|
14
14
|
}
|
|
15
15
|
async logRequest(request, type = 'request') {
|
|
16
16
|
const frameURL = request.frame().url();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const headers = request.headers();
|
|
22
|
-
const postData = request.postData();
|
|
23
|
-
const logData = {
|
|
24
|
-
requestingURL,
|
|
25
|
-
targetURL,
|
|
26
|
-
method,
|
|
27
|
-
headers,
|
|
28
|
-
postData
|
|
29
|
-
};
|
|
30
|
-
const mc = {
|
|
31
|
-
topic: {
|
|
32
|
-
stage: 'action',
|
|
33
|
-
event: 'debug',
|
|
34
|
-
},
|
|
35
|
-
artifact: {
|
|
36
|
-
content: logData,
|
|
37
|
-
type: 'json/playwright/trace'
|
|
38
|
-
}
|
|
17
|
+
const etc = {
|
|
18
|
+
method: request.method(),
|
|
19
|
+
headers: request.headers(),
|
|
20
|
+
postData: request.postData(),
|
|
39
21
|
};
|
|
40
|
-
this.
|
|
22
|
+
this.log(type, frameURL, request.url(), etc);
|
|
41
23
|
}
|
|
42
24
|
async routeRequest(route, request) {
|
|
43
25
|
await this.logRequest(request, 'route');
|
|
@@ -46,19 +28,30 @@ export class PlaywrightEvents {
|
|
|
46
28
|
}
|
|
47
29
|
async logResponse(response) {
|
|
48
30
|
const frameURL = response.request().frame().url();
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
const etc = {
|
|
32
|
+
status: response.status(),
|
|
33
|
+
statusText: response.statusText(),
|
|
34
|
+
headers: response.headers()
|
|
35
|
+
};
|
|
36
|
+
this.log('response', frameURL, response.url(), etc);
|
|
37
|
+
}
|
|
38
|
+
close() {
|
|
39
|
+
this.page.off('request', this.logRequest.bind(this));
|
|
40
|
+
// Note: Playwright doesn't provide a direct way to remove a specific route handler
|
|
41
|
+
this.page.off('response', this.logResponse.bind(this));
|
|
42
|
+
}
|
|
43
|
+
log(type, maybeFrameURL, targetURL, etc) {
|
|
44
|
+
const requestingPage = this.page.url();
|
|
45
|
+
const frameURL = maybeFrameURL === requestingPage ? undefined : maybeFrameURL;
|
|
46
|
+
const requestingURL = frameURL ? `frame ${frameURL} on ${requestingPage}` : requestingPage;
|
|
55
47
|
const logData = {
|
|
48
|
+
frameURL,
|
|
49
|
+
requestingPage,
|
|
56
50
|
requestingURL,
|
|
57
|
-
|
|
58
|
-
status,
|
|
59
|
-
statusText,
|
|
60
|
-
headers
|
|
51
|
+
...etc
|
|
61
52
|
};
|
|
53
|
+
const requestingBase = requestingPage.replace(/\/[^/]*$/, '');
|
|
54
|
+
const targetWithoutRequestingBase = targetURL.replace(requestingBase, '');
|
|
62
55
|
const mc = {
|
|
63
56
|
topic: {
|
|
64
57
|
stage: 'action',
|
|
@@ -69,12 +62,7 @@ export class PlaywrightEvents {
|
|
|
69
62
|
type: 'json/playwright/trace'
|
|
70
63
|
}
|
|
71
64
|
};
|
|
72
|
-
this.logger.debug(`playwright
|
|
73
|
-
}
|
|
74
|
-
close() {
|
|
75
|
-
this.page.off('request', this.logRequest.bind(this));
|
|
76
|
-
// Note: Playwright doesn't provide a direct way to remove a specific route handler
|
|
77
|
-
this.page.off('response', this.logResponse.bind(this));
|
|
65
|
+
this.logger.debug(`playwright ${type} ${logData.requestingURL} -> ${targetWithoutRequestingBase}`, mc);
|
|
78
66
|
}
|
|
79
67
|
}
|
|
80
68
|
//# sourceMappingURL=PlaywrightEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightEvents.js","sourceRoot":"","sources":["../src/PlaywrightEvents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlaywrightEvents.js","sourceRoot":"","sources":["../src/PlaywrightEvents.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,gBAAgB;IACzB,IAAI,CAAO;IACX,GAAG,CAAO;IACV,MAAM,CAAU;IAEhB,YAAY,MAAe,EAAE,IAAU,EAAE,GAAS;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,mEAAmE;QACnE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IACO,KAA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AAC,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,IAAY,EAAE,aAAqB,EAAE,SAAiB,EAAE,GAAS;QACjE,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,aAAa,KAAK,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;QAC9E,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,QAAQ,OAAO,cAAc,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;QAC3F,MAAM,OAAO,GAAG;YACZ,QAAQ;YACR,cAAc;YACd,aAAa;YACb,GAAG,GAAG;SACT,CAAC;QACF,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC9D,MAAM,2BAA2B,GAAG,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAE1E,MAAM,EAAE,GAA4B;YAChC,KAAK,EAAE;gBACH,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,OAAO;aACjB;YACD,QAAQ,EAAE;gBACN,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,uBAAuB;aAChC;SACJ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,OAAO,CAAC,aAAa,OAAO,2BAA2B,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3G,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haibun/web-playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.32.
|
|
4
|
+
"version": "1.32.9",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "build/web-playwright.js",
|
|
7
7
|
"files": [
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@haibun/core": "1.32.
|
|
24
|
-
"@haibun/domain-storage": "1.32.
|
|
25
|
-
"@haibun/domain-webpage": "1.32.
|
|
23
|
+
"@haibun/core": "1.32.9",
|
|
24
|
+
"@haibun/domain-storage": "1.32.9",
|
|
25
|
+
"@haibun/domain-webpage": "1.32.9",
|
|
26
26
|
"playwright": "^1.40.1"
|
|
27
27
|
},
|
|
28
28
|
"gitHead": "7cf9680bd922fb622fb59f1e6bf5b65284cb8fd5"
|