Skip to content

Commit 65b3fd8

Browse files
Restructure data editor messaging with Message Registry
1 parent b52826f commit 65b3fd8

46 files changed

Lines changed: 1819 additions & 1441 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/dataEditor/dataEditorClient.ts

Lines changed: 321 additions & 336 deletions
Large diffs are not rendered by default.

src/dataEditor/include/server/heartbeat/HeartBeatInfo.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,29 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import { IServerHeartbeat } from '@omega-edit/client'
17+
import { IServerHeartbeat, IServerInfo } from '@omega-edit/client'
1818

19-
export class HeartbeatInfo implements IServerHeartbeat {
20-
omegaEditPort: number = 0 // Ωedit server port
21-
latency: number = 0 // latency in ms
22-
serverCommittedMemory: number = 0 // committed memory in bytes
23-
serverCpuCount: number = 0 // cpu count
24-
serverCpuLoadAverage: number = 0 // cpu load average
25-
serverMaxMemory: number = 0 // max memory in bytes
26-
serverTimestamp: number = 0 // timestamp in ms
27-
serverUptime: number = 0 // uptime in ms
28-
serverUsedMemory: number = 0 // used memory in bytes
29-
sessionCount: number = 0 // session count
19+
export type ServerHeartbeat = IServerHeartbeat & { serverInfo: IServerInfo }
20+
21+
export class HeartbeatInfo {
22+
serverHeartbeat: ServerHeartbeat = {
23+
latency: 0,
24+
sessionCount: 0,
25+
serverTimestamp: 0,
26+
serverUptime: 0,
27+
serverCpuCount: 0,
28+
serverCpuLoadAverage: 0,
29+
serverMaxMemory: 0,
30+
serverCommittedMemory: 0,
31+
serverUsedMemory: 0,
32+
serverInfo: {
33+
serverHostname: '',
34+
serverProcessId: 0,
35+
serverVersion: '',
36+
jvmVersion: '',
37+
jvmVendor: '',
38+
jvmPath: '',
39+
availableProcessors: 0,
40+
},
41+
}
3042
}

src/dataEditor/include/server/heartbeat/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import { getServerHeartbeat, IServerHeartbeat } from '@omega-edit/client'
17+
import { getServerHeartbeat, getServerInfo } from '@omega-edit/client'
1818
import { HeartbeatInfo } from './HeartBeatInfo'
1919

2020
const HEARTBEAT_INTERVAL_MS: number = 1000 // 1 second (1000 ms)
21-
let heartbeatInfo: IServerHeartbeat = new HeartbeatInfo()
21+
let heartbeatInfo = new HeartbeatInfo()
2222
let getHeartbeatIntervalId: NodeJS.Timeout | number | undefined = undefined
2323

2424
export function updateHeartbeatInterval(activeSessions: string[]) {
@@ -28,10 +28,15 @@ export function updateHeartbeatInterval(activeSessions: string[]) {
2828
getHeartbeatIntervalId =
2929
activeSessions.length > 0
3030
? setInterval(async () => {
31-
heartbeatInfo = await getServerHeartbeat(
31+
const heartbeat = await getServerHeartbeat(
3232
activeSessions,
3333
HEARTBEAT_INTERVAL_MS * activeSessions.length
3434
)
35+
const info = await getServerInfo()
36+
heartbeatInfo.serverHeartbeat = {
37+
...heartbeat,
38+
serverInfo: { ...info },
39+
}
3540
})
3641
: undefined
3742
}

src/dataEditor/include/utils.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616
*/
1717
import { debug } from 'vscode'
1818

19-
export function isDFDLDebugSessionActive(): boolean {
20-
return (
21-
debug.activeDebugSession !== undefined &&
22-
debug.activeDebugSession.type === 'dfdl'
23-
)
19+
export function isDFDLDebugSessionActive(file: string): boolean {
20+
if (debug.activeDebugSession === undefined) return false
21+
if (debug.activeDebugSession!.type !== 'dfdl') return false
22+
if (debug.activeDebugSession!.configuration.data !== file) return false
23+
return true
24+
}
25+
26+
export function toEncoding(encoding: string): BufferEncoding {
27+
if (!Buffer.isEncoding(encoding)) {
28+
console.error(`Value (${encoding}) is not a valid BufferEncoding type`)
29+
}
30+
return encoding as BufferEncoding
2431
}

src/dataEditor/svelteWebviewInitializer.ts

Lines changed: 0 additions & 156 deletions
This file was deleted.

src/dataEditor/ui/displayState.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import * as vscode from 'vscode'
18+
19+
interface DisplayStateAttributes {
20+
title: string
21+
encoding: BufferEncoding
22+
colorTheme: vscode.ColorThemeKind
23+
}
24+
25+
export class DisplayState {
26+
private attributes: DisplayStateAttributes = {
27+
title: '',
28+
encoding: 'hex',
29+
colorTheme: vscode.window.activeColorTheme.kind,
30+
}
31+
32+
constructor() {
33+
vscode.window.onDidChangeActiveColorTheme(async (event) => {
34+
this.attributes.colorTheme = event.kind
35+
await this.sendUIThemeUpdate()
36+
}, this)
37+
this.sendUIThemeUpdate()
38+
}
39+
40+
update<K extends keyof DisplayStateAttributes>(
41+
attribute: K,
42+
value: DisplayStateAttributes[K]
43+
): void {
44+
this.attributes[attribute] = value
45+
}
46+
47+
get<K extends keyof DisplayStateAttributes>(
48+
attribute: K
49+
): DisplayStateAttributes[K] {
50+
return this.attributes[attribute]
51+
}
52+
53+
on<K extends keyof DisplayStateAttributes>(
54+
eventType: `${K}_update`,
55+
listener: (value: DisplayStateAttributes[K]) => any
56+
) {}
57+
private sendUIThemeUpdate() {
58+
// return this.panel.webview.postMessage({
59+
// command: MessageCommand.setUITheme,
60+
// theme: this.colorThemeKind,
61+
// })
62+
}
63+
}

0 commit comments

Comments
 (0)