Sorgente pubblicata
Scarica sorgente ZIP
CH-J Tools
Sfoglia directory e file per una specifica release di applicazioni.
CH-J / Server Manager
872 file
core-20261030T220507Z-61e4558d889f
Aggiunto: · Costruito:
1
/**2
* Module-window bridge. Exposes the public Module API as `window.chjModule` and, for3
* backwards compatibility, under the 0.1.0 name `window.chjPlugin` (same object, same4
* method names). Also injects the shared Core window chrome (title + "Collapse").5
*/6
import { moduleApi } from "../index";7
import { subscribe } from "../transport";8
import { bootInfo } from "./boot";9
import { installWindowChrome } from "./windowChrome";10
import { installActivityReporter } from "./activity";12
const boot = bootInfo();14
const api = Object.freeze({15
apiVersion: moduleApi.version,16
getInfo: moduleApi.getInfo,17
ui: moduleApi.ui,18
close: moduleApi.close,19
sessions: moduleApi.sessions,20
system: moduleApi.system,21
disks: moduleApi.disks,22
keys: moduleApi.keys,23
logs: moduleApi.logs,24
users: moduleApi.users,25
nginx: moduleApi.nginx,26
files: moduleApi.files,27
hashing: moduleApi.hashing28
});30
for (const name of ["chjModule", "chjPlugin"]) {31
Object.defineProperty(window, name, { value: api, writable: false, configurable: false, enumerable: true });32
}34
// "Collapse" texts come from the core catalogs (i18n/core/<language>.json), injected by the Core.35
declare global { var __CHJ_I18N__: { catalogs?: { chrome?: Record<string, Record<string, string>> } } | undefined }36
function chromeCopy(language: string): [string, string] {37
const catalogs = globalThis.__CHJ_I18N__?.catalogs?.chrome || {};38
const entry = catalogs[language] || catalogs.en || {};39
return [entry["chrome.collapse"] || "Collapse", entry["chrome.collapseDescription"] || "Collapse into the application's bottom bar"];40
}42
let chromeRoot: ShadowRoot | null = null;44
window.addEventListener("DOMContentLoaded", () => {45
const styleUrl = new URL("/__chj_core__/window-chrome.css", window.location.href).href;46
const host = document.createElement("chj-plugin-chrome");47
host.id = "chj-plugin-window-chrome";48
const shadow = host.attachShadow({ mode: "open" });49
chromeRoot = shadow;50
let loaded = 0;51
const stylesheet = () => {52
const link = document.createElement("link");53
link.rel = "stylesheet";54
link.href = styleUrl;55
link.addEventListener("load", () => { if (++loaded === 2) host.dataset.ready = "true"; });56
return link;57
};58
document.head.append(stylesheet());59
const header = document.createElement("header");60
header.id = "chj-chrome-header";61
if (boot.platform === "win32" || boot.platform === "linux") header.className = "native-controls";62
const mark = document.createElement("span");63
mark.id = "chj-chrome-mark";64
mark.textContent = "CH-J";65
const title = document.createElement("span");66
title.id = "chj-chrome-title";67
title.textContent = document.title || "CH-J Server Manager";68
const collapse = document.createElement("button");69
collapse.type = "button";70
collapse.id = "chj-chrome-collapse";71
const translate = (language: string) => {72
const [label, description] = chromeCopy(language);73
collapse.textContent = label;74
collapse.title = description;75
collapse.setAttribute("aria-label", description);76
};77
translate("en");78
collapse.addEventListener("click", () => { void moduleApi.minimize().catch((error) => console.error("Module collapse failed.", error)); });79
subscribe<string>("module:ui:languageChanged", translate);80
void moduleApi.ui.getLanguage().then(translate).catch(() => {});81
void moduleApi.getInfo().then((manifest) => { title.textContent = manifest.name; }).catch(() => {});82
header.append(mark, title, collapse);83
shadow.append(stylesheet(), header);84
document.body.prepend(host);85
});87
installWindowChrome(boot.platform, ["#chj-chrome-header"], () => (chromeRoot ? [document, chromeRoot] : [document]));88
installActivityReporter();SHA-256
7511660d0f2675bee883e2653dd34cd8e1a1da78cb0712546fe05568a6a25285CH-J Proprietary Software License 1.14 · La sorgente è fornita sotto CH-J Proprietary Software License 1.14. La sua disponibilità non modifica i termini di licenza o concede diritti aggiuntivi.
Archivio SHA-256
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df