mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-27 21:55:24 +00:00
* feat: add an auto or fixed columns picker to card grids * feat: add safe mode that only runs layout and theme plugins * docs: add simple layout to plugin table * fix: ask for local network access in the macOS app * feat: allow plugin registries on listed private hosts (#1705) * chore: add private registry hosts to the changelog * feat: use the proxy for plugin registry downloads * fix: allow changing connection origin on shared hosts * chore: update translations and plugin pins * chore: lint, format, and bump version to 26.10.5 --------- Co-authored-by: Lukas <80832688+0skater0@users.noreply.github.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import type { PluginManifest } from "./manifest.js";
|
|
|
|
/** TERMIX_SAFE_MODE=1 starts only the plugins that draw the app. */
|
|
export function safeModeOn(): boolean {
|
|
const value = process.env.TERMIX_SAFE_MODE?.trim().toLowerCase();
|
|
return value === "1" || value === "true";
|
|
}
|
|
|
|
function isLookPlugin(manifest: PluginManifest): boolean {
|
|
return (
|
|
(manifest.contributes?.layouts?.length ?? 0) > 0 ||
|
|
(manifest.contributes?.themes?.length ?? 0) > 0
|
|
);
|
|
}
|
|
|
|
/** Layout and theme plugins, plus the plugins they need to start. */
|
|
export function safeModePluginIds(
|
|
plugins: { id: string; manifest: PluginManifest }[],
|
|
): Set<string> {
|
|
const byId = new Map(plugins.map((plugin) => [plugin.id, plugin]));
|
|
const allowed = new Set<string>();
|
|
const add = (id: string) => {
|
|
const plugin = byId.get(id);
|
|
if (!plugin || allowed.has(id)) return;
|
|
allowed.add(id);
|
|
for (const dependency of Object.keys(plugin.manifest.dependencies ?? {})) {
|
|
add(dependency);
|
|
}
|
|
};
|
|
for (const plugin of plugins) {
|
|
if (isLookPlugin(plugin.manifest)) add(plugin.id);
|
|
}
|
|
return allowed;
|
|
}
|
|
|
|
/** Whether a plugin may run now. Always true outside safe mode. */
|
|
export function mayRunInSafeMode(
|
|
pluginId: string,
|
|
plugins: { id: string; manifest: PluginManifest }[],
|
|
): boolean {
|
|
return !safeModeOn() || safeModePluginIds(plugins).has(pluginId);
|
|
}
|