@sailfish-ai/recorder 1.0.0-alpha-1 → 1.0.0-beta-1
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.
- package/dist/eventCache.js +12 -14
- package/dist/sailfish-recorder.es.js +3 -31
- package/dist/sailfish-recorder.umd.js +3 -31
- package/dist/types/eventCache.d.ts +0 -1
- package/dist/websocket.js +12 -17
- package/package.json +1 -1
package/dist/eventCache.js
CHANGED
|
@@ -2,8 +2,18 @@ let eventCache = [];
|
|
|
2
2
|
export function cacheEvents(event) {
|
|
3
3
|
eventCache.push(event);
|
|
4
4
|
}
|
|
5
|
-
export function sendCachedEvents(webSocket) {
|
|
6
|
-
|
|
5
|
+
// export function sendCachedEvents(webSocket: ReconnectingWebSocket): void {
|
|
6
|
+
// if (eventCache.length > 0 && webSocket.readyState === WebSocket.OPEN) {
|
|
7
|
+
// const message = {
|
|
8
|
+
// type: "events",
|
|
9
|
+
// events: eventCache,
|
|
10
|
+
// };
|
|
11
|
+
// webSocket.send(JSON.stringify(message));
|
|
12
|
+
// eventCache = [];
|
|
13
|
+
// }
|
|
14
|
+
// }
|
|
15
|
+
export function sendRecordingEvents(webSocket, sessionId) {
|
|
16
|
+
if (eventCache.length > 0) {
|
|
7
17
|
const message = {
|
|
8
18
|
type: "events",
|
|
9
19
|
events: eventCache,
|
|
@@ -12,15 +22,3 @@ export function sendCachedEvents(webSocket) {
|
|
|
12
22
|
eventCache = [];
|
|
13
23
|
}
|
|
14
24
|
}
|
|
15
|
-
export function sendRecordingEvents(webSocket, sessionId) {
|
|
16
|
-
if (webSocket && webSocket.readyState === WebSocket.OPEN && sessionId) {
|
|
17
|
-
if (eventCache.length > 0) {
|
|
18
|
-
const message = {
|
|
19
|
-
type: "events",
|
|
20
|
-
events: eventCache,
|
|
21
|
-
};
|
|
22
|
-
webSocket.send(JSON.stringify(message));
|
|
23
|
-
eventCache = [];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -34,8 +34,8 @@ let eventCache = [];
|
|
|
34
34
|
function cacheEvents(event) {
|
|
35
35
|
eventCache.push(event);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
if (eventCache.length > 0
|
|
37
|
+
function sendRecordingEvents(webSocket, sessionId) {
|
|
38
|
+
if (eventCache.length > 0) {
|
|
39
39
|
const message = {
|
|
40
40
|
type: "events",
|
|
41
41
|
events: eventCache
|
|
@@ -44,18 +44,6 @@ function sendCachedEvents(webSocket) {
|
|
|
44
44
|
eventCache = [];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function sendRecordingEvents(webSocket, sessionId) {
|
|
48
|
-
if (webSocket && webSocket.readyState === WebSocket.OPEN && sessionId) {
|
|
49
|
-
if (eventCache.length > 0) {
|
|
50
|
-
const message = {
|
|
51
|
-
type: "events",
|
|
52
|
-
events: eventCache
|
|
53
|
-
};
|
|
54
|
-
webSocket.send(JSON.stringify(message));
|
|
55
|
-
eventCache = [];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
47
|
function sendGraphQLRequest(operationName, query, variables) {
|
|
60
48
|
return fetch(
|
|
61
49
|
`${variables["backendApi"]}/graphql/?apiKey=${variables["apiKey"]}`,
|
|
@@ -20988,24 +20976,9 @@ function initializeWebSocket(backendApi, apiKey, sessionId) {
|
|
|
20988
20976
|
const wsScheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
20989
20977
|
const wsUrl = `${wsScheme}://${wsHost}/ws/notify/?apiKey=${apiKey}&sessionId=${sessionId}`;
|
|
20990
20978
|
const options = {
|
|
20991
|
-
connectionTimeout: 5e3
|
|
20992
|
-
maxRetries: 10
|
|
20979
|
+
connectionTimeout: 5e3
|
|
20993
20980
|
};
|
|
20994
20981
|
const webSocket = new ReconnectingWebSocket(wsUrl, [], options);
|
|
20995
|
-
webSocket.addEventListener("open", () => {
|
|
20996
|
-
sendCachedEvents(webSocket);
|
|
20997
|
-
});
|
|
20998
|
-
webSocket.addEventListener("close", (event) => {
|
|
20999
|
-
console.log("WebSocket closed:", event);
|
|
21000
|
-
if (event.wasClean) {
|
|
21001
|
-
console.log(`Closed cleanly, code=${event.code}, reason=${event.reason}`);
|
|
21002
|
-
} else {
|
|
21003
|
-
console.log("Connection died");
|
|
21004
|
-
}
|
|
21005
|
-
});
|
|
21006
|
-
webSocket.addEventListener("error", (error) => {
|
|
21007
|
-
console.error("WebSocket error:", error);
|
|
21008
|
-
});
|
|
21009
20982
|
return webSocket;
|
|
21010
20983
|
}
|
|
21011
20984
|
function getWebSocketHost(url) {
|
|
@@ -21139,7 +21112,6 @@ export {
|
|
|
21139
21112
|
fetchCaptureSettings,
|
|
21140
21113
|
initializeRecording,
|
|
21141
21114
|
initializeWebSocket,
|
|
21142
|
-
sendCachedEvents,
|
|
21143
21115
|
sendGraphQLRequest,
|
|
21144
21116
|
sendRecordingEvents,
|
|
21145
21117
|
startRecording,
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
function cacheEvents(event) {
|
|
39
39
|
eventCache.push(event);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (eventCache.length > 0
|
|
41
|
+
function sendRecordingEvents(webSocket, sessionId) {
|
|
42
|
+
if (eventCache.length > 0) {
|
|
43
43
|
const message = {
|
|
44
44
|
type: "events",
|
|
45
45
|
events: eventCache
|
|
@@ -48,18 +48,6 @@
|
|
|
48
48
|
eventCache = [];
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function sendRecordingEvents(webSocket, sessionId) {
|
|
52
|
-
if (webSocket && webSocket.readyState === WebSocket.OPEN && sessionId) {
|
|
53
|
-
if (eventCache.length > 0) {
|
|
54
|
-
const message = {
|
|
55
|
-
type: "events",
|
|
56
|
-
events: eventCache
|
|
57
|
-
};
|
|
58
|
-
webSocket.send(JSON.stringify(message));
|
|
59
|
-
eventCache = [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
51
|
function sendGraphQLRequest(operationName, query, variables) {
|
|
64
52
|
return fetch(
|
|
65
53
|
`${variables["backendApi"]}/graphql/?apiKey=${variables["apiKey"]}`,
|
|
@@ -20992,24 +20980,9 @@
|
|
|
20992
20980
|
const wsScheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
20993
20981
|
const wsUrl = `${wsScheme}://${wsHost}/ws/notify/?apiKey=${apiKey}&sessionId=${sessionId}`;
|
|
20994
20982
|
const options = {
|
|
20995
|
-
connectionTimeout: 5e3
|
|
20996
|
-
maxRetries: 10
|
|
20983
|
+
connectionTimeout: 5e3
|
|
20997
20984
|
};
|
|
20998
20985
|
const webSocket = new ReconnectingWebSocket(wsUrl, [], options);
|
|
20999
|
-
webSocket.addEventListener("open", () => {
|
|
21000
|
-
sendCachedEvents(webSocket);
|
|
21001
|
-
});
|
|
21002
|
-
webSocket.addEventListener("close", (event) => {
|
|
21003
|
-
console.log("WebSocket closed:", event);
|
|
21004
|
-
if (event.wasClean) {
|
|
21005
|
-
console.log(`Closed cleanly, code=${event.code}, reason=${event.reason}`);
|
|
21006
|
-
} else {
|
|
21007
|
-
console.log("Connection died");
|
|
21008
|
-
}
|
|
21009
|
-
});
|
|
21010
|
-
webSocket.addEventListener("error", (error) => {
|
|
21011
|
-
console.error("WebSocket error:", error);
|
|
21012
|
-
});
|
|
21013
20986
|
return webSocket;
|
|
21014
20987
|
}
|
|
21015
20988
|
function getWebSocketHost(url) {
|
|
@@ -21142,7 +21115,6 @@
|
|
|
21142
21115
|
exports2.fetchCaptureSettings = fetchCaptureSettings;
|
|
21143
21116
|
exports2.initializeRecording = initializeRecording;
|
|
21144
21117
|
exports2.initializeWebSocket = initializeWebSocket;
|
|
21145
|
-
exports2.sendCachedEvents = sendCachedEvents;
|
|
21146
21118
|
exports2.sendGraphQLRequest = sendGraphQLRequest;
|
|
21147
21119
|
exports2.sendRecordingEvents = sendRecordingEvents;
|
|
21148
21120
|
exports2.startRecording = startRecording;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
2
2
|
export declare function cacheEvents(event: any): void;
|
|
3
|
-
export declare function sendCachedEvents(webSocket: ReconnectingWebSocket): void;
|
|
4
3
|
export declare function sendRecordingEvents(webSocket: ReconnectingWebSocket, sessionId: string): void;
|
package/dist/websocket.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
2
|
-
import { sendCachedEvents } from "./eventCache";
|
|
3
2
|
export function initializeWebSocket(backendApi, apiKey, sessionId) {
|
|
4
3
|
const wsHost = getWebSocketHost(backendApi);
|
|
5
4
|
const wsScheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
6
5
|
const wsUrl = `${wsScheme}://${wsHost}/ws/notify/?apiKey=${apiKey}&sessionId=${sessionId}`;
|
|
7
6
|
const options = {
|
|
8
7
|
connectionTimeout: 5000,
|
|
9
|
-
maxRetries: 10,
|
|
10
8
|
};
|
|
11
9
|
const webSocket = new ReconnectingWebSocket(wsUrl, [], options);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
webSocket.addEventListener("error", (error) => {
|
|
25
|
-
console.error("WebSocket error:", error);
|
|
26
|
-
});
|
|
10
|
+
// This is done automatically via ReconnectingWebSocket
|
|
11
|
+
// webSocket.addEventListener("close", (event: any) => {
|
|
12
|
+
// console.log("WebSocket closed:", event);
|
|
13
|
+
// if (event.wasClean) {
|
|
14
|
+
// console.log(`Closed cleanly, code=${event.code}, reason=${event.reason}`);
|
|
15
|
+
// } else {
|
|
16
|
+
// console.log("Connection died");
|
|
17
|
+
// }
|
|
18
|
+
// });
|
|
19
|
+
// webSocket.addEventListener("error", (error: any) => {
|
|
20
|
+
// console.error("WebSocket error:", error);
|
|
21
|
+
// });
|
|
27
22
|
return webSocket;
|
|
28
23
|
}
|
|
29
24
|
function getWebSocketHost(url) {
|