@pagepocket/capture-http-lighterceptor-unit 0.11.1 → 0.13.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,12 +1,12 @@
1
- import { Unit, type CaptureArtifacts } from "@pagepocket/lib";
1
+ import { Unit, type CaptureArtifacts, type UnitContext, type UnitRuntime } from "@pagepocket/lib";
2
2
  import { type LighterceptorAdapterOptions } from "./internal/lighterceptor-adapter.js";
3
3
  export type CaptureHttpLighterceptorUnitOptions = LighterceptorAdapterOptions;
4
4
  export declare class CaptureHttpLighterceptorUnit extends Unit {
5
5
  readonly id = "captureHttpLighterceptor";
6
- readonly kind = "capture.http.lighterceptor";
6
+ readonly description = "Capturing page via Lighterceptor";
7
7
  private adapterOptions;
8
8
  constructor(options?: CaptureHttpLighterceptorUnitOptions);
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
  }>;
@@ -1,5 +1,5 @@
1
1
  import { NETWORK } from "@pagepocket/contracts";
2
- import { Unit, createMemoryContentStore, InflightTracker, mapKind, networkIdle, normalizeCompletion, throwUnsupportedEntryKind, timeout } from "@pagepocket/lib";
2
+ import { Unit, createMemoryContentStore, debugLog, InflightTracker, mapKind, networkIdle, normalizeCompletion, throwUnsupportedEntryKind, timeout } from "@pagepocket/lib";
3
3
  import { LighterceptorAdapter } from "./internal/lighterceptor-adapter.js";
4
4
  const headersRecordToList = (headers) => {
5
5
  if (!headers) {
@@ -23,7 +23,7 @@ export class CaptureHttpLighterceptorUnit extends Unit {
23
23
  constructor(options) {
24
24
  super();
25
25
  this.id = "captureHttpLighterceptor";
26
- this.kind = "capture.http.lighterceptor";
26
+ this.description = "Capturing page via Lighterceptor";
27
27
  this.adapterOptions = options ?? {};
28
28
  }
29
29
  async run(ctx, rt) {
@@ -98,7 +98,7 @@ export class CaptureHttpLighterceptorUnit extends Unit {
98
98
  void handleNetworkEvent(event);
99
99
  },
100
100
  onError: (error) => {
101
- console.warn("[pagepocket][capture-http-lighterceptor] adapter error", error);
101
+ debugLog("[pagepocket][capture-http-lighterceptor] adapter error", error);
102
102
  }
103
103
  }, this.adapterOptions);
104
104
  const html = ctx.value.html ?? (await session.waitForHtml());
@@ -16,13 +16,13 @@ const simulateHoverAll = async () => {
16
16
  const elements = Array.from(document.querySelectorAll("*"));
17
17
  for (const element of elements) {
18
18
  const rect = element.getBoundingClientRect();
19
- const x = rect.left + rect.width / 2;
20
- const y = rect.top + rect.height / 2;
19
+ const pointerX = rect.left + rect.width / 2;
20
+ const pointerY = rect.top + rect.height / 2;
21
21
  const event = new MouseEvent("mouseover", {
22
22
  bubbles: true,
23
23
  cancelable: true,
24
- clientX: x,
25
- clientY: y
24
+ clientX: pointerX,
25
+ clientY: pointerY
26
26
  });
27
27
  element.dispatchEvent(event);
28
28
  }
@@ -2,8 +2,8 @@ export const decodeBase64 = (input) => {
2
2
  if (typeof atob === "function") {
3
3
  const binary = atob(input);
4
4
  const bytes = new Uint8Array(binary.length);
5
- for (let i = 0; i < binary.length; i++) {
6
- bytes[i] = binary.charCodeAt(i);
5
+ for (let byteIndex = 0; byteIndex < binary.length; byteIndex += 1) {
6
+ bytes[byteIndex] = binary.charCodeAt(byteIndex);
7
7
  }
8
8
  return bytes;
9
9
  }
@@ -1,4 +1,4 @@
1
1
  export const getHeaderValue = (headers, name) => {
2
- const key = Object.keys(headers).find((k) => k.toLowerCase() === name.toLowerCase());
3
- return key ? headers[key] : undefined;
2
+ const headerKey = Object.keys(headers).find((existingHeaderName) => existingHeaderName.toLowerCase() === name.toLowerCase());
3
+ return headerKey ? headers[headerKey] : undefined;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagepocket/capture-http-lighterceptor-unit",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "PagePocket plugin: capture HTTP events (lighterceptor adapter)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,9 +10,9 @@
10
10
  ],
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@pagepocket/contracts": "0.11.1",
14
- "@pagepocket/lib": "0.11.1",
15
- "@pagepocket/lighterceptor": "0.11.1"
13
+ "@pagepocket/lib": "0.13.0",
14
+ "@pagepocket/contracts": "0.13.0",
15
+ "@pagepocket/lighterceptor": "0.13.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "typescript": "^5.4.5"