@dev-blinq/cucumber_client 1.0.1546-dev → 1.0.1548-dev
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.
|
@@ -144,7 +144,7 @@ class BVTRecorder {
|
|
|
144
144
|
getAction: (e) => {
|
|
145
145
|
this.eventUtils.consumeEvent(e);
|
|
146
146
|
},
|
|
147
|
-
getInterestedElement: () => {
|
|
147
|
+
getInterestedElement: () => {},
|
|
148
148
|
hoverOutlineStyle: "",
|
|
149
149
|
});
|
|
150
150
|
|
|
@@ -159,7 +159,7 @@ class BVTRecorder {
|
|
|
159
159
|
};
|
|
160
160
|
},
|
|
161
161
|
getAction: () => null,
|
|
162
|
-
getInterestedElement: () => {
|
|
162
|
+
getInterestedElement: () => {},
|
|
163
163
|
hoverOutlineStyle: "",
|
|
164
164
|
});
|
|
165
165
|
|
|
@@ -174,7 +174,7 @@ class BVTRecorder {
|
|
|
174
174
|
};
|
|
175
175
|
},
|
|
176
176
|
getAction: () => null,
|
|
177
|
-
getInterestedElement: () => {
|
|
177
|
+
getInterestedElement: () => {},
|
|
178
178
|
hoverOutlineStyle: "",
|
|
179
179
|
});
|
|
180
180
|
|
|
@@ -684,7 +684,7 @@ class BVTRecorder {
|
|
|
684
684
|
this.PW.roleUtils.getElementAccessibleName(el, true) ||
|
|
685
685
|
"";
|
|
686
686
|
const result = this.getElementProperties(el);
|
|
687
|
-
const elText = this.PW.selectorUtils.elementText(new Map(), el)
|
|
687
|
+
const elText = this.PW.selectorUtils.elementText(new Map(), el);
|
|
688
688
|
return {
|
|
689
689
|
role,
|
|
690
690
|
label,
|
|
@@ -80,9 +80,9 @@ const timeOutForFunction = async (promise, timeout = 5000) => {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN }) {
|
|
83
|
+
async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN, socket = null }) {
|
|
84
84
|
console.log("Connecting to " + WS_URL);
|
|
85
|
-
|
|
85
|
+
socket = socket || io(WS_URL);
|
|
86
86
|
socketLogger.init(socket, { context: "BVTRecorder", eventName: "BVTRecorder.log" });
|
|
87
87
|
socket.on("connect", () => {
|
|
88
88
|
socketLogger.info("Connected to BVTRecorder server");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { io } from "socket.io-client";
|
|
2
|
+
import { BVTRecorderInit } from "./bvt_init.js";
|
|
3
|
+
const requiredEnvVars = ["PROJECT_ID", "BLINQ_TOKEN", "SESSION_ID", "WORKER_WS_SERVER_URL"];
|
|
4
|
+
function validateEnvVariables() {
|
|
5
|
+
const missingVars = requiredEnvVars.filter((varName) => !process.env[varName]);
|
|
6
|
+
if (missingVars.length > 0) {
|
|
7
|
+
throw new Error(`Missing required environment variables: ${missingVars.join(", ")}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const socket = io(process.env.WORKER_WS_SERVER_URL, {
|
|
11
|
+
path: "/ws",
|
|
12
|
+
transports: ["websocket", "polling"],
|
|
13
|
+
reconnection: true,
|
|
14
|
+
});
|
|
15
|
+
function initWebBVTRecorder(socket) {
|
|
16
|
+
validateEnvVariables();
|
|
17
|
+
const WORKER_WS_SERVER_URL = process.env.WORKER_WS_SERVER_URL;
|
|
18
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
19
|
+
const TOKEN = process.env.BLINQ_TOKEN;
|
|
20
|
+
const ROOM_ID = process.env.SESSION_ID;
|
|
21
|
+
BVTRecorderInit({
|
|
22
|
+
envName: WORKER_WS_SERVER_URL,
|
|
23
|
+
projectDir: PROJECT_ID,
|
|
24
|
+
roomId: ROOM_ID,
|
|
25
|
+
TOKEN: TOKEN,
|
|
26
|
+
socket: socket,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
initWebBVTRecorder(socket);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// web-ipcMain.ts
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export class WebIpcMain extends EventEmitter {
|
|
4
|
+
socket;
|
|
5
|
+
handlers = new Map();
|
|
6
|
+
constructor(socket) {
|
|
7
|
+
super();
|
|
8
|
+
this.socket = socket;
|
|
9
|
+
this.setupSocketListeners();
|
|
10
|
+
}
|
|
11
|
+
setupSocketListeners() {
|
|
12
|
+
// Handle invoke calls from renderer (via relay server)
|
|
13
|
+
this.socket.on("invoke", async ({ channel, args, invokeId, clientId }) => {
|
|
14
|
+
const handler = this.handlers.get(channel);
|
|
15
|
+
if (!handler) {
|
|
16
|
+
this.socket.emit("invoke-response", {
|
|
17
|
+
invokeId,
|
|
18
|
+
clientId,
|
|
19
|
+
error: `No handler registered for channel: ${channel}`,
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const event = {
|
|
25
|
+
frameId: 0,
|
|
26
|
+
processId: 0,
|
|
27
|
+
sender: {
|
|
28
|
+
send: (replyChannel, ...replyArgs) => {
|
|
29
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
senderFrame: null,
|
|
33
|
+
};
|
|
34
|
+
const result = await Promise.resolve(handler(event, ...args));
|
|
35
|
+
this.socket.emit("invoke-response", { invokeId, clientId, result });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
this.socket.emit("invoke-response", {
|
|
39
|
+
invokeId,
|
|
40
|
+
clientId,
|
|
41
|
+
error: error.message || "Handler error",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// Handle send calls from renderer (fire and forget)
|
|
46
|
+
this.socket.on("send", ({ channel, args, clientId }) => {
|
|
47
|
+
const event = {
|
|
48
|
+
frameId: 0,
|
|
49
|
+
processId: 0,
|
|
50
|
+
sender: {
|
|
51
|
+
send: (replyChannel, ...replyArgs) => {
|
|
52
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
senderFrame: null,
|
|
56
|
+
ports: [],
|
|
57
|
+
reply: (replyChannel, ...replyArgs) => {
|
|
58
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
this.emit(channel, event, ...args);
|
|
62
|
+
});
|
|
63
|
+
// Handle postMessage
|
|
64
|
+
this.socket.on("postMessage", ({ channel, message, clientId }) => {
|
|
65
|
+
const event = {
|
|
66
|
+
frameId: 0,
|
|
67
|
+
processId: 0,
|
|
68
|
+
sender: {
|
|
69
|
+
send: (replyChannel, ...replyArgs) => {
|
|
70
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
senderFrame: null,
|
|
74
|
+
ports: [],
|
|
75
|
+
reply: (replyChannel, ...replyArgs) => {
|
|
76
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
this.emit(channel, event, message);
|
|
80
|
+
});
|
|
81
|
+
// Handle sendToHost
|
|
82
|
+
this.socket.on("sendToHost", ({ channel, args, clientId }) => {
|
|
83
|
+
const event = {
|
|
84
|
+
frameId: 0,
|
|
85
|
+
processId: 0,
|
|
86
|
+
sender: {
|
|
87
|
+
send: (replyChannel, ...replyArgs) => {
|
|
88
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
senderFrame: null,
|
|
92
|
+
ports: [],
|
|
93
|
+
reply: (replyChannel, ...replyArgs) => {
|
|
94
|
+
this.socket.emit("message", { channel: replyChannel, args: replyArgs, clientId });
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
this.emit(channel, event, ...args);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
handle(channel, listener) {
|
|
101
|
+
if (this.handlers.has(channel)) {
|
|
102
|
+
throw new Error(`Handler for channel '${channel}' already exists`);
|
|
103
|
+
}
|
|
104
|
+
this.handlers.set(channel, listener);
|
|
105
|
+
}
|
|
106
|
+
handleOnce(channel, listener) {
|
|
107
|
+
const onceWrapper = async (event, ...args) => {
|
|
108
|
+
this.removeHandler(channel);
|
|
109
|
+
return await Promise.resolve(listener(event, ...args));
|
|
110
|
+
};
|
|
111
|
+
this.handle(channel, onceWrapper);
|
|
112
|
+
}
|
|
113
|
+
removeHandler(channel) {
|
|
114
|
+
this.handlers.delete(channel);
|
|
115
|
+
}
|
|
116
|
+
// Send message to all connected clients (via relay server)
|
|
117
|
+
sendToAll(channel, ...args) {
|
|
118
|
+
this.socket.emit("broadcast", { channel, args });
|
|
119
|
+
}
|
|
120
|
+
// Send message to specific client by client ID (via relay server)
|
|
121
|
+
sendToClient(clientId, channel, ...args) {
|
|
122
|
+
this.socket.emit("message", { channel, args, clientId });
|
|
123
|
+
}
|
|
124
|
+
// Cleanup
|
|
125
|
+
destroy() {
|
|
126
|
+
this.handlers.clear();
|
|
127
|
+
this.removeAllListeners();
|
|
128
|
+
}
|
|
129
|
+
}
|