Merge branch 'develop' into macset-fix
This commit is contained in:
@@ -234,11 +234,11 @@ const handleMousemove = async (activeBrowser: RemoteBrowser, page: Page, { x, y
|
||||
|
||||
const generator = activeBrowser.generator;
|
||||
await page.mouse.move(x, y);
|
||||
throttle(async () => {
|
||||
if (!page.isClosed()) {
|
||||
await generator.generateDataForHighlighter(page, { x, y });
|
||||
}
|
||||
}, 100)();
|
||||
// throttle(async () => {
|
||||
// if (!page.isClosed()) {
|
||||
// await generator.generateDataForHighlighter(page, { x, y });
|
||||
// }
|
||||
// }, 100)();
|
||||
logger.log("debug", `Moved over position x:${x}, y:${y}`);
|
||||
} catch (e) {
|
||||
const { message } = e as Error;
|
||||
|
||||
@@ -145,6 +145,22 @@ if (require.main === module) {
|
||||
|
||||
io = new Server(server);
|
||||
|
||||
io.of('/queued-run').on('connection', (socket) => {
|
||||
const userId = socket.handshake.query.userId as string;
|
||||
|
||||
if (userId) {
|
||||
socket.join(`user-${userId}`);
|
||||
logger.log('info', `Client joined queued-run namespace for user: ${userId}, socket: ${socket.id}`);
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
logger.log('info', `Client disconnected from queued-run namespace: ${socket.id}`);
|
||||
});
|
||||
} else {
|
||||
logger.log('warn', `Client connected to queued-run namespace without userId: ${socket.id}`);
|
||||
socket.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
if (!isProduction) {
|
||||
if (process.platform === 'win32') {
|
||||
workerProcess = fork(workerPath, [], {
|
||||
|
||||
@@ -541,6 +541,10 @@ export class WorkflowGenerator {
|
||||
}
|
||||
|
||||
if ((elementInfo?.tagName === 'INPUT' || elementInfo?.tagName === 'TEXTAREA') && selector) {
|
||||
if (page.isClosed()) {
|
||||
logger.log('debug', 'Page is closed, cannot get cursor position');
|
||||
return;
|
||||
}
|
||||
const positionAndCursor = await page.evaluate(
|
||||
({ selector, coords }) => {
|
||||
const getCursorPosition = (element: any, clickX: any) => {
|
||||
@@ -1342,4 +1346,4 @@ export class WorkflowGenerator {
|
||||
public clearLastIndex = () => {
|
||||
this.generatedData.lastIndex = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ export const getElementInformation = async (
|
||||
) => {
|
||||
try {
|
||||
if (!getList || listSelector !== '') {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get element information');
|
||||
return null;
|
||||
}
|
||||
const elementInfo = await page.evaluate(
|
||||
async ({ x, y }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
@@ -302,6 +306,10 @@ export const getElementInformation = async (
|
||||
);
|
||||
return elementInfo;
|
||||
} else {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get element information (else branch)');
|
||||
return null;
|
||||
}
|
||||
const elementInfo = await page.evaluate(
|
||||
async ({ x, y }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
@@ -611,6 +619,10 @@ export const getElementInformation = async (
|
||||
export const getRect = async (page: Page, coordinates: Coordinates, listSelector: string, getList: boolean) => {
|
||||
try {
|
||||
if (!getList || listSelector !== '') {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get element rect');
|
||||
return null;
|
||||
}
|
||||
const rect = await page.evaluate(
|
||||
async ({ x, y }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
@@ -834,6 +846,10 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector
|
||||
);
|
||||
return rect;
|
||||
} else {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get element rect (else branch)');
|
||||
return null;
|
||||
}
|
||||
const rect = await page.evaluate(
|
||||
async ({ x, y }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
@@ -1076,6 +1092,10 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector
|
||||
*/
|
||||
export const getSelectors = async (page: Page, coordinates: Coordinates) => {
|
||||
try {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get selectors');
|
||||
return null;
|
||||
}
|
||||
const selectors: any = await page.evaluate(async ({ x, y }) => {
|
||||
// version @medv/finder
|
||||
// https://github.com/antonmedv/finder/blob/master/finder.ts
|
||||
@@ -2010,6 +2030,10 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
||||
|
||||
try {
|
||||
if (!listSelector) {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get non-unique selectors');
|
||||
return { generalSelector: '' };
|
||||
}
|
||||
const selectors = await page.evaluate(({ x, y }: { x: number, y: number }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
let elements = document.elementsFromPoint(x, y) as HTMLElement[];
|
||||
@@ -2364,6 +2388,10 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
||||
return selectors || { generalSelector: '' };
|
||||
} else {
|
||||
// When we have a list selector, we need special handling while maintaining shadow DOM and frame support
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get list selectors');
|
||||
return { generalSelector: '' };
|
||||
}
|
||||
const selectors = await page.evaluate(({ x, y }: { x: number, y: number }) => {
|
||||
const getDeepestElementFromPoint = (x: number, y: number): HTMLElement | null => {
|
||||
let elements = document.elementsFromPoint(x, y) as HTMLElement[];
|
||||
@@ -2725,6 +2753,10 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
||||
|
||||
export const getChildSelectors = async (page: Page, parentSelector: string): Promise<string[]> => {
|
||||
try {
|
||||
if (page.isClosed()) {
|
||||
logger.debug('Page is closed, cannot get child selectors');
|
||||
return [];
|
||||
}
|
||||
const childSelectors = await page.evaluate((parentSelector: string) => {
|
||||
// Function to get a non-unique selector based on tag and class (if present)
|
||||
function getNonUniqueSelector(element: HTMLElement): string {
|
||||
|
||||
Reference in New Issue
Block a user