@pagepocket/capture-http-puppeteer-unit 0.11.1 → 0.12.0

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,4 +1,4 @@
1
- import { Unit, type CaptureArtifacts } from "@pagepocket/lib";
1
+ import { Unit, type CaptureArtifacts, type UnitContext, type UnitRuntime } from "@pagepocket/lib";
2
2
  import { type PuppeteerAdapterOptions } from "./internal/puppeteer-adapter.js";
3
3
  export type CaptureHttpPuppeteerUnitOptions = PuppeteerAdapterOptions;
4
4
  export declare class CaptureHttpPuppeteerUnit extends Unit {
@@ -6,7 +6,7 @@ export declare class CaptureHttpPuppeteerUnit extends Unit {
6
6
  readonly kind = "capture.http.puppeteer";
7
7
  private adapterOptions;
8
8
  constructor(options?: CaptureHttpPuppeteerUnitOptions);
9
- run(ctx: import("@pagepocket/lib").UnitContext, rt: import("@pagepocket/lib").UnitRuntime): Promise<{
9
+ run(ctx: UnitContext, rt: UnitRuntime): Promise<{
10
10
  capture: CaptureArtifacts;
11
11
  html: {};
12
12
  domHtml: {
@@ -20,21 +20,19 @@ export const createRequestIdStore = () => {
20
20
  const has = (request) => requestIds.has(request);
21
21
  return { getRequestId, has };
22
22
  };
23
- export const createEmitRequest = (handlers, getRequestId) => {
24
- return (request, timestamp) => {
25
- const requestEvent = {
26
- type: "request",
27
- requestId: getRequestId(request),
28
- url: request.url(),
29
- method: request.method(),
30
- headers: normalizeHeaders(request.headers()),
31
- frameId: getFrameId(request),
32
- resourceType: toResourceType(request),
33
- initiator: getInitiator(request),
34
- timestamp
35
- };
36
- handlers.onEvent(requestEvent);
23
+ export const createEmitRequest = (handlers, getRequestId) => (request, timestamp) => {
24
+ const requestEvent = {
25
+ type: "request",
26
+ requestId: getRequestId(request),
27
+ url: request.url(),
28
+ method: request.method(),
29
+ headers: normalizeHeaders(request.headers()),
30
+ frameId: getFrameId(request),
31
+ resourceType: toResourceType(request),
32
+ initiator: getInitiator(request),
33
+ timestamp
37
34
  };
35
+ handlers.onEvent(requestEvent);
38
36
  };
39
37
  export const isExpectedMissingBody = (input) => {
40
38
  const { request, response, headers } = input;
@@ -16,8 +16,7 @@ export const getErrorMessage = (error) => {
16
16
  }
17
17
  return String(error);
18
18
  };
19
- export const buildMissingChromeHelp = () => {
20
- return `Puppeteer could not find a compatible Chrome installation.
19
+ export const buildMissingChromeHelp = () => `Puppeteer could not find a compatible Chrome installation.
21
20
 
22
21
  Reason:
23
22
  This machine does not have a Chrome executable available to Puppeteer.
@@ -30,7 +29,6 @@ Fix options:
30
29
  2) Use an existing system Chrome/Chromium:
31
30
  - Set PUPPETEER_EXECUTABLE_PATH=/path/to/chrome
32
31
  `;
33
- };
34
32
  export const isNoDataForResourceError = (error) => {
35
33
  if (!error || typeof error !== "object") {
36
34
  return false;
@@ -7,13 +7,13 @@ export const runTriggerActions = async (page, actions = []) => {
7
7
  const elements = Array.from(document.querySelectorAll("*"));
8
8
  const trigger = (el) => {
9
9
  const rect = el.getBoundingClientRect();
10
- const x = rect.left + rect.width / 2;
11
- const y = rect.top + rect.height / 2;
10
+ const pointerX = rect.left + rect.width / 2;
11
+ const pointerY = rect.top + rect.height / 2;
12
12
  const event = new MouseEvent("mouseover", {
13
13
  bubbles: true,
14
14
  cancelable: true,
15
- clientX: x,
16
- clientY: y
15
+ clientX: pointerX,
16
+ clientY: pointerY
17
17
  });
18
18
  el.dispatchEvent(event);
19
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagepocket/capture-http-puppeteer-unit",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "PagePocket plugin: capture HTTP events (puppeteer adapter)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,8 +11,8 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "puppeteer": "^22.12.1",
14
- "@pagepocket/lib": "0.11.1",
15
- "@pagepocket/contracts": "0.11.1"
14
+ "@pagepocket/lib": "0.12.0",
15
+ "@pagepocket/contracts": "0.12.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "typescript": "^5.4.5"