Files
a89ccc6b07 v26.10.3 (#1692)
* feat: shell controller, TabStage, layout and theme plugins with repair view

* feat: move the classic layout into its own bundled plugin

* feat: move color themes into a bundled themes plugin

* fix: plugin tests and type checks work with a linked sdk

* fix: home tab, layout switch and missing layout fallbacks for looks

* chore: add classic layout and themes to the readme

* chore: drop example plugin links from the plugin guide

* feat: plugin filters by type, paged browse, hide plugins needing newer termix

* feat: move desktop, status, import, audit and branding features into plugins

* feat: host lock api so a plugin can load hosts from a config file (#1581)

* chore: add hosts config to the plugin table

* feat: login policy hook for plugins and optional https redirect (#1584)

* chore: add login security to the plugin table

* feat: api key socket tickets so a master can open remote sessions (#1654)

* feat: sync moves to a plugin, desktop gets multiple accounts (#1580, #1654)

* chore: add sync to the plugin table

* feat: move the sync screens and wizard out of core into the plugin (#1580)

* fix: add a neutral linked desktop hook for plugins (#1580)

* fix: show the linked account's name and admin flag in the app (#1580)

* feat: ssh transport providers, core ssh relay and plugin folders api

* feat: support FIDO2 security keys through ssh agent

* feat: add companion panels beside host tabs

* feat: mTLS client certificates for desktop server links

* feat: native web view for plugins in the desktop app

* fix: detect the desktop link window by Electron's default user agent

Fixes #1675

* fix: changelog for desktop link fix

* fix: keep text primary keys in the plugin data export

* fix: ship sharp binaries for Windows arm64 builds

* feat: client cert on the sync link types (sdk 1.0.18)

* chore: update translations

* feat: themed title bar for the desktop app (#1690)

* chore: changelog for the themed title bar

* fix: draw the title bar in the sidebar color

* feat: per host layout for the terminal panel bar

* chore: sdk 1.0.19 for the panel bar layout

* chore: bundle all 43 plugins for 26.10.3

* chore: update translations

---------

Co-authored-by: SirHephaistos <60616553+SirHephaistos@users.noreply.github.com>
Co-authored-by: Giovanny Aranda <garanda21@gmail.com>
2026-10-20 16:03:29 -05:00

119 lines
3.6 KiB
JavaScript

import fs from "node:fs";
import path from "node:path";
import zlib from "node:zlib";
/** Theme CSS files a manifest declares, which travel with the plugin too. */
export function themeFiles(manifest) {
const themes = manifest?.contributes?.themes;
if (!Array.isArray(themes)) return [];
return themes
.map((theme) => theme?.css)
.filter((css) => typeof css === "string");
}
/** What a .tmxplug holds, in the order the spec lists it. */
export const TMXPLUG_CONTENTS = [
"manifest.json",
"dist",
"locales",
"migrations",
"README.md",
"CHANGELOG.md",
"icon.svg",
// Licence texts, so third-party notices travel with the plugin.
"LICENSE",
"NOTICE",
];
const BLOCK = 512;
/**
* Every file under the given top-level entries, as sorted posix paths.
* Directories are implied by their files, so none get their own entry.
*/
export function collectFiles(cwd, entries = TMXPLUG_CONTENTS) {
const files = [];
const walk = (rel) => {
const full = path.join(cwd, rel);
const stat = fs.lstatSync(full);
if (stat.isSymbolicLink()) {
throw new Error(`${rel} is a symlink; a .tmxplug holds plain files only`);
}
if (stat.isDirectory()) {
for (const child of fs.readdirSync(full)) {
walk(path.posix.join(rel, child));
}
} else if (stat.isFile()) {
files.push(rel);
}
};
for (const entry of entries) {
if (fs.existsSync(path.join(cwd, entry))) walk(entry);
}
return files.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
}
function writeString(buf, offset, length, value) {
const bytes = Buffer.from(value, "utf8");
if (bytes.length > length) throw new Error(`"${value}" is too long`);
bytes.copy(buf, offset);
}
function writeOctal(buf, offset, length, value) {
writeString(buf, offset, length, value.toString(8).padStart(length - 1, "0"));
}
function splitName(name) {
if (Buffer.byteLength(name) <= 100) return { name, prefix: "" };
for (let i = name.length - 1; i > 0; i--) {
if (name[i] !== "/") continue;
const prefix = name.slice(0, i);
const rest = name.slice(i + 1);
if (Buffer.byteLength(prefix) <= 155 && Buffer.byteLength(rest) <= 100) {
return { name: rest, prefix };
}
}
throw new Error(`${name} is too long for a .tmxplug entry`);
}
function header(name, size) {
const buf = Buffer.alloc(BLOCK);
const split = splitName(name);
writeString(buf, 0, 100, split.name);
writeOctal(buf, 100, 8, 0o644);
writeOctal(buf, 108, 8, 0);
writeOctal(buf, 116, 8, 0);
writeOctal(buf, 124, 12, size);
writeOctal(buf, 136, 12, 0);
buf.fill(0x20, 148, 156);
buf[156] = 0x30;
writeString(buf, 257, 6, "ustar");
writeString(buf, 263, 2, "00");
writeString(buf, 345, 155, split.prefix);
let sum = 0;
for (const byte of buf) sum += byte;
writeString(buf, 148, 8, sum.toString(8).padStart(6, "0") + "\0 ");
return buf;
}
/**
* A gzipped ustar archive that depends only on file names and contents:
* fixed mode, owner and mtime, sorted entries, and a gzip header with no
* timestamp and a fixed OS byte (Node on Windows writes a different one).
* Rebuilding from the same tag gives the same sha256 on any machine.
*/
export function createTmxplug(cwd, files) {
const parts = [];
for (const rel of files) {
const data = fs.readFileSync(path.join(cwd, rel));
parts.push(header(rel, data.length), data);
const pad = (BLOCK - (data.length % BLOCK)) % BLOCK;
if (pad) parts.push(Buffer.alloc(pad));
}
parts.push(Buffer.alloc(BLOCK * 2));
const gz = zlib.gzipSync(Buffer.concat(parts), { level: 9 });
gz.writeUInt32LE(0, 4);
gz[9] = 0x03;
return gz;
}