diff --git a/.changeset/rude-ideas-double.md b/.changeset/rude-ideas-double.md new file mode 100644 index 000000000..1d43da211 --- /dev/null +++ b/.changeset/rude-ideas-double.md @@ -0,0 +1,5 @@ +--- +"@browserbasehq/stagehand-lib": patch +--- + +rm unused functions diff --git a/lib/dom/process.ts b/lib/dom/process.ts index 14fa957f0..111483a7f 100644 --- a/lib/dom/process.ts +++ b/lib/dom/process.ts @@ -74,25 +74,6 @@ export async function getScrollableElementXpaths( return xpaths; } -export function getNearestScrollableParent(el: HTMLElement): HTMLElement { - // 1) Get *all* scrollable elements on the page - // (You could pass a large topN or omit it for “all”) - const allScrollables = getScrollableElements(); - - // 2) Climb up the DOM tree - let current: HTMLElement | null = el; - while (current) { - // If `current` is in the scrollable list, we have our nearest scrollable parent - if (allScrollables.includes(current)) { - return current; - } - current = current.parentElement; - } - - // 3) If we exhaust the ancestors, default to root - return document.documentElement; -} - window.waitForDomSettle = waitForDomSettle; window.getScrollableElementXpaths = getScrollableElementXpaths; window.getNodeFromXpath = getNodeFromXpath; diff --git a/lib/utils.ts b/lib/utils.ts index 2c382eed6..4b73e1727 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,4 +1,3 @@ -import crypto from "crypto"; import { ZodFirstPartyTypeKind as Kind, z } from "zod"; import { ObserveResult, Page } from "."; import { LogLine } from "../types/log"; @@ -7,25 +6,6 @@ import { Schema, Type } from "@google/genai"; import { ModelProvider } from "../types/model"; import { ZodSchemaValidationError } from "@/types/stagehandErrors"; -export function generateId(operation: string) { - return crypto.createHash("sha256").update(operation).digest("hex"); -} - -export function logLineToString(logLine: LogLine): string { - try { - const timestamp = logLine.timestamp || new Date().toISOString(); - if (logLine.auxiliary?.error) { - return `${timestamp}::[stagehand:${logLine.category}] ${logLine.message}\n ${logLine.auxiliary.error.value}\n ${logLine.auxiliary.trace.value}`; - } - return `${timestamp}::[stagehand:${logLine.category}] ${logLine.message} ${ - logLine.auxiliary ? JSON.stringify(logLine.auxiliary) : "" - }`; - } catch (error) { - console.error(`Error logging line:`, error); - return "error logging line"; - } -} - export function validateZodSchema(schema: z.ZodTypeAny, data: unknown) { const result = schema.safeParse(data); diff --git a/types/stagehandErrors.ts b/types/stagehandErrors.ts index 590f63ded..7b3232af0 100644 --- a/types/stagehandErrors.ts +++ b/types/stagehandErrors.ts @@ -112,18 +112,6 @@ export class HandlerNotInitializedError extends StagehandError { } } -export class StagehandNotImplementedError extends StagehandError { - constructor(message: string) { - super(`NotImplementedError: ${message}`); - } -} - -export class StagehandDeprecationError extends StagehandError { - constructor(message: string) { - super(`DeprecationError: ${message}`); - } -} - export class StagehandInvalidArgumentError extends StagehandError { constructor(message: string) { super(`InvalidArgumentError: ${message}`);