@sailfish-ai/recorder 1.0.0-alpha-1 → 1.0.0-alpha-2
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 -20
- package/dist/sailfish-recorder.umd.js +3 -20
- package/dist/types/eventCache.d.ts +0 -1
- package/dist/websocket.js +1 -5
- 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,13 +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
20982
|
webSocket.addEventListener("close", (event) => {
|
|
20999
20983
|
console.log("WebSocket closed:", event);
|
|
21000
20984
|
if (event.wasClean) {
|
|
@@ -21139,7 +21123,6 @@ export {
|
|
|
21139
21123
|
fetchCaptureSettings,
|
|
21140
21124
|
initializeRecording,
|
|
21141
21125
|
initializeWebSocket,
|
|
21142
|
-
sendCachedEvents,
|
|
21143
21126
|
sendGraphQLRequest,
|
|
21144
21127
|
sendRecordingEvents,
|
|
21145
21128
|
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,13 +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
20986
|
webSocket.addEventListener("close", (event) => {
|
|
21003
20987
|
console.log("WebSocket closed:", event);
|
|
21004
20988
|
if (event.wasClean) {
|
|
@@ -21142,7 +21126,6 @@
|
|
|
21142
21126
|
exports2.fetchCaptureSettings = fetchCaptureSettings;
|
|
21143
21127
|
exports2.initializeRecording = initializeRecording;
|
|
21144
21128
|
exports2.initializeWebSocket = initializeWebSocket;
|
|
21145
|
-
exports2.sendCachedEvents = sendCachedEvents;
|
|
21146
21129
|
exports2.sendGraphQLRequest = sendGraphQLRequest;
|
|
21147
21130
|
exports2.sendRecordingEvents = sendRecordingEvents;
|
|
21148
21131
|
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,17 +1,13 @@
|
|
|
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
|
-
sendCachedEvents(webSocket);
|
|
14
|
-
});
|
|
10
|
+
// This is done automatically via ReconnectingWebSocket
|
|
15
11
|
webSocket.addEventListener("close", (event) => {
|
|
16
12
|
console.log("WebSocket closed:", event);
|
|
17
13
|
if (event.wasClean) {
|