Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-ideas-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand-lib": patch
---

rm unused functions
19 changes: 0 additions & 19 deletions lib/dom/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 0 additions & 20 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from "crypto";
import { ZodFirstPartyTypeKind as Kind, z } from "zod";
import { ObserveResult, Page } from ".";
import { LogLine } from "../types/log";
Expand All @@ -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);

Expand Down
12 changes: 0 additions & 12 deletions types/stagehandErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down