Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions build/package/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,41 @@ conditions of the following licenses.
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- '@protobuf-ts/runtime' in extension/dist/ext/extension.js
- '@protobuf-ts/runtime' in node_modules/@omega-edit/client
This product bundles '@protobuf-ts/runtime' from the above files.
This package is available under the BSD-3-Clause License and Apache License 2.0:

BSD 3-Clause License

Copyright (c) Timo Stamm
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- 'protobufjs' in extension/dist/ext/extension.js
- 'protobufjs' in node_modules/@omega-edit/client
This product bundles 'protobufjs' from the above files.
Expand Down Expand Up @@ -5214,6 +5249,33 @@ conditions of the following licenses.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

- '@pinojs/redact' in extension/dist/ext/extension.js
- '@pinojs/redact' in node_modules/@omega-edit/client
This product bundles '@pinojs/redact' from the above files.
These files are available under the MIT License:

MIT License

Copyright (c) 2025 pinojs contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

- 'unicorn-magic' in extension/dist/ext/extension.js
This produces bundles 'unicorn-magic' from the above files
Expand Down
6 changes: 6 additions & 0 deletions build/package/NONOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ The following binary components distributed with this project are licensed under
This package is available under the Apache License v2 without a NOTICE:
Repository at: https://github.com/dcodeIO/long.js

- '@protobuf-ts/runtime-rpc' in extension/dist/ext/extension.js
- '@protobuf-ts/runtime-rpc' in node_modules/@omega-edit/client
This product bundles '@protobuf-ts/runtime-rpc' from the above files.
This package is available under the Apache License v2 without a NOTICE:
Repository at: https://github.com/timostamm/protobuf-ts

- com.fasterxml.woodstox.woodstox-core-<VERSION>.jar in daffodil-debugger-<VERSION>.zip
This product bundles 'woodstox-core' from the above files.
These packages are available under the Apache License v2 without a NOTICE:
Expand Down
3 changes: 1 addition & 2 deletions build/yarn-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ function package() {
# limitations under the License.

**/node_modules/**/*
!node_modules/@omega-edit/server/bin
!node_modules/@omega-edit/server/lib
!node_modules/@omega-edit/server/out/**/*
!node_modules/@vscode/webview-ui-toolkit/**/*
`
)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"watch:vite-dev": "yarn vite build --mode development -c ./vite.config.mjs --watch"
},
"dependencies": {
"@omega-edit/client": "^1.0.1",
"@omega-edit/client": "https://github.com/ctc-oss/omega-edit/releases/download/v2.0.0-rc1/omega-edit-node-client-v2.0.0-rc1.tgz",
"@omega-edit/server": "https://github.com/ctc-oss/omega-edit/releases/download/v2.0.0-rc1/omega-edit-node-server-v2.0.0-rc1.tgz",
"@viperproject/locate-java-home": "1.1.17",
"@vscode/debugadapter": "1.67.0",
"@vscode/webview-ui-toolkit": "^1.2.2",
Expand Down Expand Up @@ -110,6 +111,7 @@
"vscode-extension-tester": "5.9.1"
},
"resolutions": {
"@omega-edit/server": "https://github.com/ctc-oss/omega-edit/releases/download/v2.0.0-rc1/omega-edit-node-server-v2.0.0-rc1.tgz",
"cookie": ">=0.7.0",
"diff": ">=8.0.3",
"serialize-javascript": ">=7.0.3"
Expand Down
107 changes: 53 additions & 54 deletions src/dataEditor/dataEditorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import {
ALL_EVENTS,
beginSessionTransaction,
clear,
countCharacters,
CountKind,
Expand All @@ -26,9 +25,6 @@ import {
createViewport,
del,
edit,
EditorClient,
endSessionTransaction,
EventSubscriptionRequest,
getByteOrderMark,
getClient,
getClientVersion,
Expand All @@ -45,15 +41,16 @@ import {
profileSession,
redo,
replaceOneSession,
runSessionTransaction,
saveSession,
SaveStatus,
searchSession,
setLogger,
startServer,
stopProcessUsingPID,
subscribeViewportEvents,
undo,
ViewportDataResponse,
ViewportEvent,
ViewportEventKind,
} from '@omega-edit/client'
import assert from 'assert'
Expand Down Expand Up @@ -107,7 +104,6 @@ const OPEN_EDITORS = new Map<string, vscode.WebviewPanel>()
// *****************************************************************************
let serverInfo: ServerInfo = new ServerInfo()
let checkpointPath: string = ''
let client: EditorClient
let omegaEditPort: number = 0

// *****************************************************************************
Expand Down Expand Up @@ -139,6 +135,11 @@ export class DataEditorClient implements vscode.Disposable {
private omegaSessionId = ''
private sendHeartbeatIntervalId: NodeJS.Timeout | number | undefined =
undefined
private viewportSubscription:
| {
cancel(): void
}
| undefined = undefined
private disposables: vscode.Disposable[] = []

constructor(
Expand Down Expand Up @@ -179,6 +180,8 @@ export class DataEditorClient implements vscode.Disposable {
clearInterval(this.sendHeartbeatIntervalId)
this.sendHeartbeatIntervalId = undefined
}
this.viewportSubscription?.cancel()
this.viewportSubscription = undefined

for (let i = 0; i < this.disposables.length; i++)
this.disposables[i].dispose()
Expand Down Expand Up @@ -387,7 +390,10 @@ export class DataEditorClient implements vscode.Disposable {
)
this.currentViewportId = viewportDataResponse.getViewportId()
assert(this.currentViewportId.length > 0, 'currentViewportId is not set')
await viewportSubscribe(this.panel, this.currentViewportId)
this.viewportSubscription = await viewportSubscribe(
this.panel,
this.currentViewportId
)
await sendViewportRefresh(this.panel, viewportDataResponse)
} catch {
const msg = `Failed to create viewport for ${this.fileToEdit}`
Expand Down Expand Up @@ -416,18 +422,25 @@ export class DataEditorClient implements vscode.Disposable {
latency: heartbeatInfo.latency,
omegaEditPort: this.configVars.port,
serverCpuLoadAverage: heartbeatInfo.serverCpuLoadAverage,
serverTimestamp: heartbeatInfo.serverTimestamp,
serverUptime: heartbeatInfo.serverUptime,
serverUsedMemory: heartbeatInfo.serverUsedMemory,
serverResidentMemoryBytes: heartbeatInfo.serverResidentMemoryBytes,
serverVirtualMemoryBytes: heartbeatInfo.serverVirtualMemoryBytes,
serverPeakResidentMemoryBytes:
heartbeatInfo.serverPeakResidentMemoryBytes,
sessionCount: heartbeatInfo.sessionCount,
serverInfo: {
omegaEditPort: this.configVars.port,
serverVersion: serverInfo.serverVersion,
serverHostname: serverInfo.serverHostname,
serverProcessId: serverInfo.serverProcessId,
jvmVersion: serverInfo.jvmVersion,
jvmVendor: serverInfo.jvmVendor,
jvmPath: serverInfo.jvmPath,
runtimeKind: serverInfo.runtimeKind,
runtimeName: serverInfo.runtimeName,
platform: serverInfo.platform,
availableProcessors: serverInfo.availableProcessors,
compiler: serverInfo.compiler,
buildType: serverInfo.buildType,
cppStandard: serverInfo.cppStandard,
},
},
})
Expand All @@ -436,9 +449,9 @@ export class DataEditorClient implements vscode.Disposable {
private async sendChangesInfo() {
// get the counts from the server
const counts = await getCounts(this.omegaSessionId, [
CountKind.COUNT_COMPUTED_FILE_SIZE,
CountKind.COUNT_CHANGE_TRANSACTIONS,
CountKind.COUNT_UNDO_TRANSACTIONS,
CountKind.COMPUTED_FILE_SIZE,
CountKind.CHANGE_TRANSACTIONS,
CountKind.UNDO_TRANSACTIONS,
])

// accumulate the counts into a single object
Expand All @@ -450,13 +463,13 @@ export class DataEditorClient implements vscode.Disposable {
}
counts.forEach((count) => {
switch (count.getKind()) {
case CountKind.COUNT_COMPUTED_FILE_SIZE:
case CountKind.COMPUTED_FILE_SIZE:
data.computedFileSize = count.getCount()
break
case CountKind.COUNT_CHANGE_TRANSACTIONS:
case CountKind.CHANGE_TRANSACTIONS:
data.changeCount = count.getCount()
break
case CountKind.COUNT_UNDO_TRANSACTIONS:
case CountKind.UNDO_TRANSACTIONS:
data.undoCount = count.getCount()
break
}
Expand Down Expand Up @@ -750,15 +763,15 @@ export class DataEditorClient implements vscode.Disposable {
await del(this.omegaSessionId, 0, offset)
await this.sendChangesInfo()
} else {
// delete from length to the end of the file and from 0 to offset in a single transaction
await beginSessionTransaction(this.omegaSessionId)
await del(
this.omegaSessionId,
offset + length,
computedFileSize - length
)
await del(this.omegaSessionId, 0, offset)
await endSessionTransaction(this.omegaSessionId)
// Trim both sides atomically so undo/redo treats the segment save as one edit.
await runSessionTransaction(this.omegaSessionId, async () => {
await del(
this.omegaSessionId,
offset + length,
computedFileSize - offset - length
)
await del(this.omegaSessionId, 0, offset)
})
await this.sendChangesInfo()
}
// save the segment to the file using the typical save method
Expand All @@ -771,7 +784,7 @@ export class DataEditorClient implements vscode.Disposable {
const saveResponse = await saveSession(
this.omegaSessionId,
fileToSave,
IOFlags.IO_FLG_OVERWRITE,
IOFlags.OVERWRITE,
offset,
length
)
Expand All @@ -789,7 +802,7 @@ export class DataEditorClient implements vscode.Disposable {
const saveResponse2 = await saveSession(
this.omegaSessionId,
fileToSave,
IOFlags.IO_FLG_FORCE_OVERWRITE,
IOFlags.FORCE_OVERWRITE,
offset,
length
)
Expand Down Expand Up @@ -819,7 +832,7 @@ export class DataEditorClient implements vscode.Disposable {
const saveResponse = await saveSession(
this.omegaSessionId,
fileToSave,
IOFlags.IO_FLG_OVERWRITE
IOFlags.OVERWRITE
)
if (saveResponse.getSaveStatus() === SaveStatus.MODIFIED) {
// the file was modified since the session was created, query user to overwrite the modified file
Expand All @@ -835,7 +848,7 @@ export class DataEditorClient implements vscode.Disposable {
const saveResponse2 = await saveSession(
this.omegaSessionId,
fileToSave,
IOFlags.IO_FLG_FORCE_OVERWRITE
IOFlags.FORCE_OVERWRITE
)
saved = saveResponse2.getSaveStatus() === SaveStatus.SUCCESS
} else {
Expand Down Expand Up @@ -933,7 +946,7 @@ async function createDataEditorWebviewPanel(
if (!(await checkServerListening(omegaEditPort, OMEGA_EDIT_HOST))) {
await setupLogging(launchConfigVars)
await serverStart()
client = await getClient(omegaEditPort, OMEGA_EDIT_HOST)
await getClient(omegaEditPort, OMEGA_EDIT_HOST)
assert(
await checkServerListening(omegaEditPort, OMEGA_EDIT_HOST),
'server not listening'
Expand Down Expand Up @@ -1033,28 +1046,17 @@ async function viewportSubscribe(
panel: vscode.WebviewPanel,
viewportId: string
) {
// subscribe to all viewport events
client
.subscribeToViewportEvents(
new EventSubscriptionRequest()
.setId(viewportId)
.setInterest(ALL_EVENTS & ~ViewportEventKind.VIEWPORT_EVT_MODIFY)
)
.on('data', async (event: ViewportEvent) => {
return await subscribeViewportEvents({
viewportId,
interest: ALL_EVENTS & ~ViewportEventKind.MODIFY,
onEvent: async (event) => {
getLogger().debug({
viewportId: event.getViewportId(),
event: event.getViewportEventKind(),
})
await sendViewportRefresh(panel, await getViewportData(viewportId))
})
.on('error', (err) => {
// Call cancelled thrown sometimes when server is shutdown
if (
!err.message.includes('Call cancelled') &&
!err.message.includes('UNAVAILABLE')
)
throw err
})
},
})
}

class DisplayState {
Expand Down Expand Up @@ -1341,12 +1343,9 @@ async function serverStart() {

// Start the server and wait up to 10 seconds for it to start
const serverPid = (await Promise.race([
startServer(
omegaEditPort,
OMEGA_EDIT_HOST,
getPidFile(omegaEditPort),
logConfigFile
),
startServer(omegaEditPort, OMEGA_EDIT_HOST, getPidFile(omegaEditPort), {
logConfigFile,
}),
new Promise((_resolve, reject) => {
setTimeout(() => {
reject((): Error => {
Expand Down
9 changes: 6 additions & 3 deletions src/dataEditor/include/server/ServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export class ServerInfo implements IServerInfo {
serverHostname: string = 'unknown'
serverProcessId: number = 0
serverVersion: string = 'unknown'
jvmVersion: string = 'unknown'
jvmVendor: string = 'unknown'
jvmPath: string = 'unknown'
runtimeKind: string = 'unknown'
runtimeName: string = 'unknown'
platform: string = 'unknown'
availableProcessors: number = 0
compiler: string = 'unknown'
buildType: string = 'unknown'
cppStandard: string = 'unknown'
}

const OMEGA_EDIT_MAX_PORT: number = 65535
Expand Down
Loading