websocket-text-relay 1.1.4 → 1.1.6
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/changelog.md +4 -0
- package/docs/code-structure.md +15 -11
- package/eslint.config.js +5 -1
- package/package.json +9 -9
- package/src/ui/css/main.css +22 -78
- package/src/ui/favicon.png +0 -0
- package/src/ui/index.html +19 -14
- package/src/ui/js/components/activityLabels.js +41 -0
- package/src/ui/js/components/activityTimeSeries.js +58 -0
- package/src/ui/js/components/drawSessionLabel.js +117 -0
- package/src/ui/js/components/footerStatus.js +37 -0
- package/src/ui/js/components/headers.js +100 -0
- package/src/ui/js/components/sessionWedges.js +96 -0
- package/src/ui/js/components/statusRing.js +51 -0
- package/src/ui/js/data/wtrActivity.js +85 -0
- package/src/ui/js/data/wtrActivity.types.js +3 -0
- package/src/ui/js/data/wtrStatus.js +134 -0
- package/src/ui/js/data/wtrStatus.types.js +61 -0
- package/src/ui/js/{util → setup}/EventEmitter.js +5 -1
- package/src/ui/js/{util → setup}/WebsocketClient.js +1 -4
- package/src/ui/js/setup/dependencyManager.js +9 -0
- package/src/ui/js/setup/evalOnChange.js +18 -0
- package/src/ui/js/setup/eventSubscriber.js +21 -0
- package/src/ui/js/setup.js +141 -0
- package/src/ui/js/util/constants.js +5 -1
- package/src/ui/js/util/drawing.js +26 -76
- package/src/websocket-interface/httpServer.js +1 -1
- package/src/ui/js/components/ActivityTimeseriesGraph.js +0 -194
- package/src/ui/js/components/HeaderSummary.js +0 -22
- package/src/ui/js/components/ServerStatus.js +0 -43
- package/src/ui/js/components/SessionLabels.js +0 -319
- package/src/ui/js/components/SessionWedges.js +0 -127
- package/src/ui/js/components/StatusRing.js +0 -54
- package/src/ui/js/components/grids.js +0 -36
- package/src/ui/js/index.js +0 -121
- package/src/ui/js/main.js +0 -128
- package/src/ui/js/util/DependencyManager.js +0 -31
package/src/ui/js/main.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* eslint no-unused-vars: 0 */
|
|
2
|
-
const {
|
|
3
|
-
HeaderSummary,
|
|
4
|
-
StatusRing,
|
|
5
|
-
onEvent,
|
|
6
|
-
statusDataEmitter,
|
|
7
|
-
SessionWedges,
|
|
8
|
-
ClientLabel,
|
|
9
|
-
ActivityTimeseriesGraph,
|
|
10
|
-
EditorLabel,
|
|
11
|
-
ServerStatus,
|
|
12
|
-
constants,
|
|
13
|
-
} = window.__WTR__
|
|
14
|
-
const { outerRingRadius, innerRingRadius, outerArcSize } = constants
|
|
15
|
-
|
|
16
|
-
const gridGroup = document.getElementById("grid_group")
|
|
17
|
-
gridGroup.innerHTML = ""
|
|
18
|
-
// drawPolarGrid(gridGroup)
|
|
19
|
-
// drawGrid(gridGroup)
|
|
20
|
-
|
|
21
|
-
const headerSummaryNode = document.getElementById("header_summary_group")
|
|
22
|
-
new HeaderSummary({ parentNode: headerSummaryNode })
|
|
23
|
-
|
|
24
|
-
const statusRingNode = document.getElementById("status_ring_group")
|
|
25
|
-
const statusRing = new StatusRing({
|
|
26
|
-
innerRingRadius,
|
|
27
|
-
outerRingRadius,
|
|
28
|
-
outerArcSize,
|
|
29
|
-
parentNode: statusRingNode,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const clientWedgesNode = document.getElementById("client_wedges_group")
|
|
33
|
-
const clientWedges = new SessionWedges({
|
|
34
|
-
outerRingRadius,
|
|
35
|
-
outerArcSize,
|
|
36
|
-
direction: -1,
|
|
37
|
-
Label: ClientLabel,
|
|
38
|
-
parentNode: clientWedgesNode,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const editorWedgesNode = document.getElementById("editor_wedges_group")
|
|
42
|
-
const editorWedges = new SessionWedges({
|
|
43
|
-
outerRingRadius,
|
|
44
|
-
outerArcSize,
|
|
45
|
-
Label: EditorLabel,
|
|
46
|
-
parentNode: editorWedgesNode,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const activityGraphNode = document.getElementById("activity_timeseries_graph")
|
|
50
|
-
const activityGraph = new ActivityTimeseriesGraph({
|
|
51
|
-
innerRingRadius,
|
|
52
|
-
parentNode: activityGraphNode,
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const serverStatusNode = document.getElementById("server_status_group")
|
|
56
|
-
const serverStatus = new ServerStatus({ parentNode: serverStatusNode })
|
|
57
|
-
|
|
58
|
-
const statusDataTranform = (rawData) => {
|
|
59
|
-
const editors = []
|
|
60
|
-
const clients = []
|
|
61
|
-
const allSessions = new Map()
|
|
62
|
-
|
|
63
|
-
rawData.sessions.forEach((session) => {
|
|
64
|
-
allSessions.set(session.id, session)
|
|
65
|
-
session.activeWatchCount = 0
|
|
66
|
-
session.activeOpenCount = 0
|
|
67
|
-
const isEditor = session.editorPid != null || session.lsPid != null
|
|
68
|
-
if (isEditor) {
|
|
69
|
-
editors.push(session)
|
|
70
|
-
} else {
|
|
71
|
-
clients.push(session)
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
for (const session of allSessions.values()) {
|
|
76
|
-
const openFileLinks = Object.values(session.openFileLinks)
|
|
77
|
-
session.activeOpenCount = openFileLinks.length
|
|
78
|
-
openFileLinks.forEach((links) => {
|
|
79
|
-
links.forEach(({ clientId }) => {
|
|
80
|
-
const clientSession = allSessions.get(clientId)
|
|
81
|
-
if (!clientSession) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
clientSession.activeWatchCount++
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return { editors, clients }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const getServerPid = (editors) => {
|
|
93
|
-
for (const editor of editors) {
|
|
94
|
-
if (editor.isServer) {
|
|
95
|
-
return editor.lsPid
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const handleStatusData = (rawData) => {
|
|
102
|
-
window.__WTR__.lastStatusData = rawData
|
|
103
|
-
const data = statusDataTranform(rawData)
|
|
104
|
-
console.log("status data updated", data)
|
|
105
|
-
statusRing.update(data)
|
|
106
|
-
clientWedges.update(data.clients)
|
|
107
|
-
editorWedges.update(data.editors)
|
|
108
|
-
serverStatus.update(getServerPid(data.editors))
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
onEvent(statusDataEmitter, "data", handleStatusData)
|
|
112
|
-
|
|
113
|
-
if (window.__WTR__.lastStatusData) {
|
|
114
|
-
handleStatusData(window.__WTR__.lastStatusData)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const handleActivity = (data) => {
|
|
118
|
-
editorWedges.triggerActivity(data.relayer)
|
|
119
|
-
clientWedges.triggerActivity(new Set(data.watchers))
|
|
120
|
-
activityGraph.triggerActivity()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
onEvent(statusDataEmitter, "activity", handleActivity)
|
|
124
|
-
|
|
125
|
-
onEvent(statusDataEmitter, "socket-close", () => {
|
|
126
|
-
console.log("socket closed!")
|
|
127
|
-
serverStatus.update(null)
|
|
128
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "./EventEmitter.js"
|
|
2
|
-
|
|
3
|
-
const dependencies = {}
|
|
4
|
-
window.__WTR__ = dependencies
|
|
5
|
-
|
|
6
|
-
const exportDeps = (exportObj) => Object.assign(dependencies, exportObj)
|
|
7
|
-
|
|
8
|
-
const statusDataEmitter = new EventEmitter()
|
|
9
|
-
|
|
10
|
-
const cleanupFuncs = []
|
|
11
|
-
|
|
12
|
-
const onEvent = (emitter, event, func) => {
|
|
13
|
-
if (typeof emitter.on === "function") {
|
|
14
|
-
emitter.on(event, func)
|
|
15
|
-
cleanupFuncs.push(() => emitter.removeListener(event, func))
|
|
16
|
-
} else if (typeof emitter.addEventListener === "function") {
|
|
17
|
-
emitter.addEventListener(event, func)
|
|
18
|
-
cleanupFuncs.push(() => emitter.removeEventListener(event, func))
|
|
19
|
-
} else {
|
|
20
|
-
throw new Error("target is not an event emitter")
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const cleanupEventHandlers = () => {
|
|
25
|
-
cleanupFuncs.forEach((f) => f())
|
|
26
|
-
cleanupFuncs.length = 0
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exportDeps({ exportDeps, statusDataEmitter, onEvent, cleanupEventHandlers })
|
|
30
|
-
|
|
31
|
-
export default dependencies
|