CH-J ToolsSerververwaltung über SSH
Menü
Veröffentlichte Quellen

CH-J Tools

Durchsuchen Sie Verzeichnisse und Dateien einer bestimmten Anwendungsausgabe.

Quellen als ZIP herunterladen
CH-J / Server Manager 872 Dateien
core-20261030T220507Z-61e4558d889f Hinzugefügt: · Erstellt:
module-bridge.ts Hinzugefügt: Datum nicht erfasst 3,6 KB · 88 Zeilen
Code Datei herunterladen
1/**
2 * Module-window bridge. Exposes the public Module API as `window.chjModule` and, for
3 * backwards compatibility, under the 0.1.0 name `window.chjPlugin` (same object, same
4 * method names). Also injects the shared Core window chrome (title + "Collapse").
5 */
6import { moduleApi } from "../index";
7import { subscribe } from "../transport";
8import { bootInfo } from "./boot";
9import { installWindowChrome } from "./windowChrome";
10import { installActivityReporter } from "./activity";
12const boot = bootInfo();
14const 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.hashing
28});
30for (const name of ["chjModule", "chjPlugin"]) {
31 Object.defineProperty(window, name, { value: api, writable: false, configurable: false, enumerable: true });
34// "Collapse" texts come from the core catalogs (i18n/core/<language>.json), injected by the Core.
35declare global { var __CHJ_I18N__: { catalogs?: { chrome?: Record<string, Record<string, string>> } } | undefined }
36function 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"];
42let chromeRoot: ShadowRoot | null = null;
44window.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});
87installWindowChrome(boot.platform, ["#chj-chrome-header"], () => (chromeRoot ? [document, chromeRoot] : [document]));
88installActivityReporter();
SHA-2567511660d0f2675bee883e2653dd34cd8e1a1da78cb0712546fe05568a6a25285

CH-J Proprietary Software License 1.14 · Die Quellen werden unter der CH-J Proprietary Software License 1.14 bereitgestellt. Ihre Verfügbarkeit ändert die Lizenzbedingungen nicht und gewährt keine zusätzlichen Rechte.

SHA-256 des Archivs77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df
Dateien