Published source
Download source ZIP
CH-J Server Manager
Browse directories and files for a specific application release.
Source is provided under the CH-J Proprietary Software License 1.14. Its availability does not change the license terms or grant additional rights.
1
"use strict";3
const { contextBridge, ipcRenderer } = require("electron");5
// Core provides the same chrome to bundled and already installed plugins.6
// Shadow DOM keeps plugin styles out of the title bar; the plugin remains sandboxed.7
window.addEventListener("DOMContentLoaded", () => {8
const styleUrl = new URL("/__chj_core__/window-chrome.css", window.location.href).href;9
const host = document.createElement("chj-plugin-chrome");10
host.id = "chj-plugin-window-chrome";11
const shadow = host.attachShadow({ mode: "open" });12
let loadedStyles = 0;13
const stylesheet = () => {14
const link = document.createElement("link");15
link.rel = "stylesheet";16
link.href = styleUrl;17
link.addEventListener("load", () => {18
if (++loadedStyles === 2) host.dataset.ready = "true";19
});20
return link;21
};22
document.head.append(stylesheet());23
const header = document.createElement("header");24
header.id = "chj-chrome-header";25
if (process.platform === "win32" || process.platform === "linux") header.className = "native-controls";26
const mark = document.createElement("span");27
mark.id = "chj-chrome-mark";28
mark.textContent = "CH-J";29
const title = document.createElement("span");30
title.id = "chj-chrome-title";31
title.textContent = document.title || "CH-J Server Manager";32
const collapse = document.createElement("button");33
collapse.type = "button";34
collapse.id = "chj-chrome-collapse";35
const copy = {36
cs: ["Sbalit", "Sbalit do spodní lišty aplikace"],37
de: ["Einklappen", "In die untere Leiste der Anwendung einklappen"],38
en: ["Collapse", "Collapse into the application's bottom bar"]39
};40
const translate = (language) => {41
const [label, description] = copy[language] || copy.en;42
collapse.textContent = label;43
collapse.title = description;44
collapse.setAttribute("aria-label", description);45
};46
translate("en");47
collapse.addEventListener("click", () => {48
void ipcRenderer.invoke("plugin:window:minimize").catch((error) => console.error("Plugin collapse failed.", error));49
});50
ipcRenderer.on("plugin:ui:languageChanged", (_event, language) => translate(language));51
void ipcRenderer.invoke("plugin:ui:getLanguage").then(translate).catch(() => {});52
void ipcRenderer.invoke("plugin:getInfo").then((manifest) => { title.textContent = manifest.name; }).catch(() => {});53
header.append(mark, title, collapse);54
shadow.append(stylesheet(), header);55
document.body.prepend(host);56
});58
contextBridge.exposeInMainWorld("chjPlugin", Object.freeze({59
getInfo: () => ipcRenderer.invoke("plugin:getInfo"),60
ui: Object.freeze({61
getLanguage: () => ipcRenderer.invoke("plugin:ui:getLanguage"),62
onLanguageChanged: (callback) => {63
if (typeof callback !== "function") throw new TypeError("Language callback must be a function.");64
const listener = (_event, language) => callback(language);65
ipcRenderer.on("plugin:ui:languageChanged", listener);66
return () => ipcRenderer.removeListener("plugin:ui:languageChanged", listener);67
}68
}),69
close: () => ipcRenderer.invoke("plugin:close"),70
sessions: Object.freeze({71
list: () => ipcRenderer.invoke("plugin:sessions:list")72
}),73
system: Object.freeze({74
readMetrics: (sessionId) => ipcRenderer.invoke("plugin:system:metrics", { sessionId })75
}),76
keys: Object.freeze({77
generate: (payload) => ipcRenderer.invoke("plugin:keys:generate", payload),78
save: (generationId) => ipcRenderer.invoke("plugin:keys:save", { generationId })79
}),80
logs: Object.freeze({81
read: (options) => ipcRenderer.invoke("plugin:logs:read", options)82
}),83
users: Object.freeze({84
list: (sessionId) => ipcRenderer.invoke("plugin:users:list", { sessionId }),85
manage: (sessionId, payload) => ipcRenderer.invoke("plugin:users:manage", { ...payload, sessionId })86
}),87
nginx: Object.freeze({88
inspect: (sessionId) => ipcRenderer.invoke("plugin:nginx:inspect", { sessionId }),89
readConfig: (sessionId, payload) => ipcRenderer.invoke("plugin:nginx:readConfig", { ...payload, sessionId }),90
dumpConfig: (sessionId, sudoPassword) => ipcRenderer.invoke("plugin:nginx:dumpConfig", { sessionId, sudoPassword }),91
testConfig: (sessionId, sudoPassword) => ipcRenderer.invoke("plugin:nginx:testConfig", { sessionId, sudoPassword }),92
saveConfig: (sessionId, payload) => ipcRenderer.invoke("plugin:nginx:saveConfig", { ...payload, sessionId }),93
reload: (sessionId, sudoPassword, confirm = false) => ipcRenderer.invoke("plugin:nginx:reload", { sessionId, sudoPassword, confirm })94
}),95
files: Object.freeze({96
list: (sessionId, path) => ipcRenderer.invoke("plugin:files:list", { sessionId, path }),97
readText: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:readText", { sessionId, path, options }),98
writeText: (sessionId, path, text, options = {}) => ipcRenderer.invoke("plugin:files:writeText", { sessionId, path, text, options }),99
saveText: (sessionId, path, text, options = {}) => ipcRenderer.invoke("plugin:files:saveText", { sessionId, path, text, options }),100
listRecovery: (sessionId, options = {}) => ipcRenderer.invoke("plugin:files:listRecovery", { sessionId, options }),101
readRecovery: (sessionId, recoveryId, options = {}) => ipcRenderer.invoke("plugin:files:readRecovery", { sessionId, recoveryId, options }),102
cleanupRecovery: (sessionId, recoveryId, options = {}) => ipcRenderer.invoke("plugin:files:cleanupRecovery", { sessionId, recoveryId, options }),103
closeText: (editId) => ipcRenderer.invoke("plugin:files:closeText", { editId }),104
createFile: (sessionId, path) => ipcRenderer.invoke("plugin:files:createFile", { sessionId, path }),105
mkdir: (sessionId, path) => ipcRenderer.invoke("plugin:files:mkdir", { sessionId, path }),106
rename: (sessionId, from, to) => ipcRenderer.invoke("plugin:files:rename", { sessionId, from, to }),107
remove: (sessionId, path) => ipcRenderer.invoke("plugin:files:remove", { sessionId, path }),108
removeMany: (sessionId, paths, recursive = false) => ipcRenderer.invoke("plugin:files:removeMany", { sessionId, paths, recursive }),109
upload: (sessionId, directory) => ipcRenderer.invoke("plugin:files:upload", { sessionId, directory }),110
download: (sessionId, path) => ipcRenderer.invoke("plugin:files:download", { sessionId, path }),111
downloadMany: (sessionId, paths) => ipcRenderer.invoke("plugin:files:downloadMany", { sessionId, paths }),112
downloadArchive: (sessionId, paths, format) => ipcRenderer.invoke("plugin:files:downloadArchive", { sessionId, paths, format })113
}),114
hashing: Object.freeze({115
getAlgorithms: () => ipcRenderer.invoke("plugin:hashing:algorithms"),116
selectFiles: (multiple = false) => ipcRenderer.invoke("plugin:hashing:selectFiles", { multiple }),117
selectDirectory: () => ipcRenderer.invoke("plugin:hashing:selectDirectory"),118
selectManifest: () => ipcRenderer.invoke("plugin:hashing:selectManifest"),119
selectManifestDestination: (suggestedName) => ipcRenderer.invoke("plugin:hashing:selectManifestDestination", { suggestedName }),120
start: (payload) => ipcRenderer.invoke("plugin:hashing:start", payload),121
verify: (payload) => ipcRenderer.invoke("plugin:hashing:verify", payload),122
compare: (payload) => ipcRenderer.invoke("plugin:hashing:compare", payload),123
generateManifest: (payload) => ipcRenderer.invoke("plugin:hashing:generateManifest", payload),124
verifyManifest: (payload) => ipcRenderer.invoke("plugin:hashing:verifyManifest", payload),125
exportResults: (payload) => ipcRenderer.invoke("plugin:hashing:exportResults", payload),126
copyResult: (payload) => ipcRenderer.invoke("plugin:hashing:copyResult", payload),127
status: (jobId) => ipcRenderer.invoke("plugin:hashing:status", { jobId }),128
cancel: (jobId) => ipcRenderer.invoke("plugin:hashing:cancel", { jobId }),129
onProgress: (callback) => {130
if (typeof callback !== "function") throw new TypeError("Progress callback must be a function.");131
const listener = (_event, job) => callback(job);132
ipcRenderer.on("plugin:hashing:progress", listener);133
return () => ipcRenderer.removeListener("plugin:hashing:progress", listener);134
}135
})136
}));SHA-256: da71e3b3ec66c9ef9c17bc2a7581529ab59cf42bc1d3299edd19dbdea6a89347
Archive SHA-256: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0