CH-J Toolsgestión de servidores a través de SSH
Menú
Fuente publicada

CH-J Tools

Busque directorios y archivos para obtener una versión de aplicación específica.

Descargar fuente ZIP
CH-J / Server Manager 406 archivos
core-20261024T135205Z-7c487d719de2 Añadido: · Construido:
pluginPreload.js Añadido: Fecha no registrada 11,6 KB · 174 líneas
Código Descargar archivo
1"use strict";
3const { 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.
7window.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});
58contextBridge.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 virtualMemory: (sessionId, options = {}) => ipcRenderer.invoke("plugin:system:virtualMemory", { ...options, sessionId }),
76 manageVirtualMemory: (sessionId, payload) => ipcRenderer.invoke("plugin:system:manageVirtualMemory", { ...payload, sessionId })
77 }),
78 disks: Object.freeze({
79 inspect: (sessionId, options = {}) => ipcRenderer.invoke("plugin:disks:inspect", { ...options, sessionId }),
80 smart: (sessionId, device, options = {}) => ipcRenderer.invoke("plugin:disks:smart", { ...options, sessionId, device }),
81 plan: (sessionId, operations, options = {}) => ipcRenderer.invoke("plugin:disks:plan", { ...options, sessionId, operations }),
82 autoExpand: (sessionId, suggestionId, options = {}) => ipcRenderer.invoke("plugin:disks:autoExpand", { ...options, sessionId, suggestionId }),
83 cancelPlan: (planId) => ipcRenderer.invoke("plugin:disks:cancelPlan", { planId }),
84 apply: (sessionId, planId, options = {}) => ipcRenderer.invoke("plugin:disks:apply", { ...options, sessionId, planId }),
85 jobs: (sessionId, options = {}) => ipcRenderer.invoke("plugin:disks:jobs", { ...options, sessionId }),
86 jobStatus: (sessionId, jobId, offset = 0, options = {}) => ipcRenderer.invoke("plugin:disks:jobStatus", { ...options, sessionId, jobId, offset })
87 }),
88 keys: Object.freeze({
89 generate: (payload) => ipcRenderer.invoke("plugin:keys:generate", payload),
90 save: (generationId) => ipcRenderer.invoke("plugin:keys:save", { generationId }),
91 password: (options) => ipcRenderer.invoke("plugin:keys:password", options),
92 copyPassword: (passwordId) => ipcRenderer.invoke("plugin:keys:copyPassword", { passwordId })
93 }),
94 logs: Object.freeze({
95 read: (options) => ipcRenderer.invoke("plugin:logs:read", options)
96 }),
97 users: Object.freeze({
98 list: (sessionId) => ipcRenderer.invoke("plugin:users:list", { sessionId }),
99 manage: (sessionId, payload) => ipcRenderer.invoke("plugin:users:manage", { ...payload, sessionId }),
100 privileges: (sessionId, refresh = false) => ipcRenderer.invoke("plugin:users:privileges", { sessionId, refresh }),
101 inventory: (sessionId, options = {}) => ipcRenderer.invoke("plugin:users:inventory", { ...options, sessionId }),
102 detail: (sessionId, username, options = {}) => ipcRenderer.invoke("plugin:users:detail", { ...options, sessionId, username }),
103 keys: (sessionId, payload) => ipcRenderer.invoke("plugin:users:keys", { ...payload, sessionId }),
104 sshPolicy: (sessionId, payload) => ipcRenderer.invoke("plugin:users:sshPolicy", { ...payload, sessionId })
105 }),
106 nginx: Object.freeze({
107 inspect: (sessionId) => ipcRenderer.invoke("plugin:nginx:inspect", { sessionId }),
108 readConfig: (sessionId, payload) => ipcRenderer.invoke("plugin:nginx:readConfig", { ...payload, sessionId }),
109 dumpConfig: (sessionId, sudoPassword) => ipcRenderer.invoke("plugin:nginx:dumpConfig", { sessionId, sudoPassword }),
110 testConfig: (sessionId, sudoPassword) => ipcRenderer.invoke("plugin:nginx:testConfig", { sessionId, sudoPassword }),
111 saveConfig: (sessionId, payload) => ipcRenderer.invoke("plugin:nginx:saveConfig", { ...payload, sessionId }),
112 reload: (sessionId, sudoPassword, confirm = false) => ipcRenderer.invoke("plugin:nginx:reload", { sessionId, sudoPassword, confirm })
113 }),
114 files: Object.freeze({
115 list: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:list", { sessionId, path, options }),
116 privileges: (sessionId) => ipcRenderer.invoke("plugin:files:privileges", { sessionId }),
117 readText: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:readText", { sessionId, path, options }),
118 writeText: (sessionId, path, text, options = {}) => ipcRenderer.invoke("plugin:files:writeText", { sessionId, path, text, options }),
119 saveText: (sessionId, path, text, options = {}) => ipcRenderer.invoke("plugin:files:saveText", { sessionId, path, text, options }),
120 listRecovery: (sessionId, options = {}) => ipcRenderer.invoke("plugin:files:listRecovery", { sessionId, options }),
121 readRecovery: (sessionId, recoveryId, options = {}) => ipcRenderer.invoke("plugin:files:readRecovery", { sessionId, recoveryId, options }),
122 cleanupRecovery: (sessionId, recoveryId, options = {}) => ipcRenderer.invoke("plugin:files:cleanupRecovery", { sessionId, recoveryId, options }),
123 closeText: (editId) => ipcRenderer.invoke("plugin:files:closeText", { editId }),
124 createFile: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:createFile", { sessionId, path, options }),
125 mkdir: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:mkdir", { sessionId, path, options }),
126 rename: (sessionId, from, to, options = {}) => ipcRenderer.invoke("plugin:files:rename", { sessionId, from, to, options }),
127 remove: (sessionId, path, options = {}) => ipcRenderer.invoke("plugin:files:remove", { sessionId, path, options }),
128 removeMany: (sessionId, paths, recursive = false, options = {}) => ipcRenderer.invoke("plugin:files:removeMany", { sessionId, paths, recursive, options }),
129 upload: (sessionId, directory) => ipcRenderer.invoke("plugin:files:upload", { sessionId, directory }),
130 download: (sessionId, path) => ipcRenderer.invoke("plugin:files:download", { sessionId, path }),
131 downloadMany: (sessionId, paths) => ipcRenderer.invoke("plugin:files:downloadMany", { sessionId, paths }),
132 downloadArchive: (sessionId, paths, format) => ipcRenderer.invoke("plugin:files:downloadArchive", { sessionId, paths, format }),
133 transfers: Object.freeze({
134 list: () => ipcRenderer.invoke("plugin:files:transfers:list"),
135 planUpload: (sessionId, directory, options = {}) => ipcRenderer.invoke("plugin:files:transfers:planUpload", { sessionId, directory, options }),
136 planDownload: (sessionId, paths, options = {}) => ipcRenderer.invoke("plugin:files:transfers:planDownload", { sessionId, paths, options }),
137 start: (planId, options = {}) => ipcRenderer.invoke("plugin:files:transfers:start", { planId, options }),
138 pause: (ids) => ipcRenderer.invoke("plugin:files:transfers:pause", { ids }),
139 resume: (ids, options = {}) => ipcRenderer.invoke("plugin:files:transfers:resume", { ids, options }),
140 retry: (ids, options = {}) => ipcRenderer.invoke("plugin:files:transfers:retry", { ids, options }),
141 cancel: (ids) => ipcRenderer.invoke("plugin:files:transfers:cancel", { ids }),
142 remove: (ids) => ipcRenderer.invoke("plugin:files:transfers:remove", { ids }),
143 updateSettings: (settings) => ipcRenderer.invoke("plugin:files:transfers:settings", { settings }),
144 onUpdate: (callback) => {
145 if (typeof callback !== "function") throw new TypeError("Transfer callback must be a function.");
146 const listener = (_event, update) => callback(update);
147 ipcRenderer.on("plugin:files:transfers:update", listener);
148 return () => ipcRenderer.removeListener("plugin:files:transfers:update", listener);
149 }
150 })
151 }),
152 hashing: Object.freeze({
153 getAlgorithms: () => ipcRenderer.invoke("plugin:hashing:algorithms"),
154 selectFiles: (multiple = false) => ipcRenderer.invoke("plugin:hashing:selectFiles", { multiple }),
155 selectDirectory: () => ipcRenderer.invoke("plugin:hashing:selectDirectory"),
156 selectManifest: () => ipcRenderer.invoke("plugin:hashing:selectManifest"),
157 selectManifestDestination: (suggestedName) => ipcRenderer.invoke("plugin:hashing:selectManifestDestination", { suggestedName }),
158 start: (payload) => ipcRenderer.invoke("plugin:hashing:start", payload),
159 verify: (payload) => ipcRenderer.invoke("plugin:hashing:verify", payload),
160 compare: (payload) => ipcRenderer.invoke("plugin:hashing:compare", payload),
161 generateManifest: (payload) => ipcRenderer.invoke("plugin:hashing:generateManifest", payload),
162 verifyManifest: (payload) => ipcRenderer.invoke("plugin:hashing:verifyManifest", payload),
163 exportResults: (payload) => ipcRenderer.invoke("plugin:hashing:exportResults", payload),
164 copyResult: (payload) => ipcRenderer.invoke("plugin:hashing:copyResult", payload),
165 status: (jobId) => ipcRenderer.invoke("plugin:hashing:status", { jobId }),
166 cancel: (jobId) => ipcRenderer.invoke("plugin:hashing:cancel", { jobId }),
167 onProgress: (callback) => {
168 if (typeof callback !== "function") throw new TypeError("Progress callback must be a function.");
169 const listener = (_event, job) => callback(job);
170 ipcRenderer.on("plugin:hashing:progress", listener);
171 return () => ipcRenderer.removeListener("plugin:hashing:progress", listener);
172 }
173 })
174}));
SHA-256e44e2767a0a31af0bd63e926f39d2152501ebd125eb6bc70f5f6bc6b526300a7

CH-J Proprietary Software License 1.14 · La fuente se proporciona en el CH-J Proprietary Software License 1.14. Su disponibilidad no cambia los términos de la licencia ni otorga derechos adicionales.

Archivo SHA-256476ed8aef0f1e96a5acdf223127b6692acdf4492eeaf5d0816b6e2a634fbbda6
Archivos