mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
* feat: let the login page send the token back to the mobile app * feat: add host-scripts entry to the plugin sdk * feat: let plugins say how they show in the mobile app * feat: frame host for running one plugin view outside the shell * fix: build the SDK host modules in production mode * chore: note the SDK host build fix in the changelog * feat: list plugin engine ranges for the mobile app * feat: host color and icon columns that sync * chore: update translations and plugin pins * fix: test * fix: show source address when rejecting proxy auth * fix: deleting your own account removes all of its data * fix(deps): update body-parser to 2.4.0 (#1736) * fix: body-parser 보안 패치 반영 * chore: 자동 검사를 막던 기존 JSON 서식 정리 --------- Co-authored-by: renovys <180682734+renovys@users.noreply.github.com> * fix(sdk): decode command output as GBK when it is not valid UTF-8 (#1735) * fix: honor shared credentials on shared hosts (#1730) * fix: honor shared credentials on shared hosts and in personal SSH auth * fix: snapshot shared SSH auth from a credential shared with the host owner * fix: size DataView list columns by the table's own width (#1713) * fix: size DataView list columns by the table's own width The list grid was built from every column, so columns hidden below md/lg left empty tracks and the visible cells landed under the wrong headers. Each width now gets a template of only its visible columns (CSS variables + container queries on the table, so a narrow panel counts, not the window), the header uses the same gap as the rows, and rows use a minimum height so wrapped cells no longer overlap. * test: wait for the title bar offset effect before asserting The bar shows once getTitleBarVisible resolves, but --termix-titlebar-height is set in a later passive effect, so reading it right after findByText raced (3-5 of 40 runs under load, on main too). * chore: rerun CI against dev-26.10.6 * fix: unlock passphrase keys once per connect burst (#1737) * feat: give ssh transports the host origin and sync id (#1717) * fix: wake other clients after a sync push (Plugin-Sync#1) * feat: look up local row ids by sync id for the sync plugin (Plugin-Sync#4) * feat: rail items can show a status dot (Plugin-Sync#5) * fix: add the desktop shared copy banner text (#1709) * feat: sidebar preference for alternating rows (#1712) * fix: striped rows text * feat: shell can open a saved host's editor for plugins (Plugin-SSH-Terminal#36) * fix: show the logo in the macos menu bar (#1728) * fix: number shortcuts skip the home tab (#1724) * fix: show plugins that could not be downloaded as failed (#1714) * fix: pass the host id as text when opening its editor * fix: retry a plugin bundle that was not ready yet (#1708) * fix: let commonjs plugins fall back to core packages on the desktop * fix: let non docker installs switch nginx to https (#1711) * feat: remove a folder share from its hosts too (#1719) * chore: changelog for merged pull requests * fix: accept the release .sig when installing a plugin from a file * feat: folder logins for shared hosts, read only plugin sync, full desktop builds * fix: test * fix: stop dev runner restart loops and narrow plugin watchers * chore: update translations and plugin pins * chore: lint, format, and bump version to 26.10.6 --------- Co-authored-by: renovys <renovy@gmail.com> Co-authored-by: renovys <180682734+renovys@users.noreply.github.com> Co-authored-by: Sebastian Cao <cycsmail@gmail.com> Co-authored-by: Jonathan Rehuel Lewerissa <jonathan.rehuel16@gmail.com> Co-authored-by: Rhiz3K <33246262+Rhiz3K@users.noreply.github.com>
179 lines
6.0 KiB
JavaScript
179 lines
6.0 KiB
JavaScript
/**
|
|
* Builds the pieces of the plugin SDK that come from core:
|
|
*
|
|
* dist/host/ui.js @termix-ssh/plugin-sdk/ui, the shell's UI kit
|
|
* dist/host/testing-host.js what renderWithApp() renders plugins into
|
|
* dist/host/core-classes.json the classes core's CSS has rules for
|
|
* dist/host/frame-host.js runs one plugin outside the shell (mobile app)
|
|
* dist/host/frame-host.css core's compiled CSS for that frame
|
|
*
|
|
* Inside Termix the page's import map points @termix-ssh/plugin-sdk/ui at the
|
|
* shell's own copy, so ui.js is never loaded there. It exists so a plugin in
|
|
* its own repo can typecheck and run its tests without a Termix checkout.
|
|
*
|
|
* One esbuild run with code splitting, so both entries share one copy of the
|
|
* registries: a test host with its own registries would never see what the
|
|
* plugin's components registered.
|
|
*/
|
|
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { spawnSync } from "node:child_process";
|
|
import * as esbuild from "esbuild";
|
|
import { compile, optimize } from "@tailwindcss/node";
|
|
import { Scanner } from "@tailwindcss/oxide";
|
|
import { classNamesInCss } from "../packages/plugin-sdk/cli/lib/css-classes.mjs";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const outDir = path.join(root, "packages", "plugin-sdk", "dist", "host");
|
|
|
|
// Shared with the plugin, so never a second copy. Same list the page's import
|
|
// map provides, plus the test library the host renders with.
|
|
const EXTERNALS = [
|
|
"react",
|
|
"react-dom",
|
|
"react/jsx-runtime",
|
|
"react-dom/client",
|
|
"i18next",
|
|
"react-i18next",
|
|
"sonner",
|
|
"@termix-ssh/plugin-sdk/frontend",
|
|
"@testing-library/react",
|
|
];
|
|
|
|
fs.rmSync(outDir, { recursive: true, force: true });
|
|
|
|
await esbuild.build({
|
|
entryPoints: {
|
|
ui: path.join(root, "src/ui/plugin-host/sdk-ui.ts"),
|
|
"testing-host": path.join(root, "src/ui/plugin-host/testing-host.tsx"),
|
|
"frame-host": path.join(root, "src/ui/plugin-host/frame-host.tsx"),
|
|
},
|
|
outdir: outDir,
|
|
bundle: true,
|
|
splitting: true,
|
|
format: "esm",
|
|
platform: "browser",
|
|
target: "es2022",
|
|
jsx: "automatic",
|
|
logLevel: "warning",
|
|
external: EXTERNALS,
|
|
alias: {
|
|
"@/types": path.join(root, "src/types"),
|
|
"@": path.join(root, "src/ui"),
|
|
},
|
|
loader: {
|
|
".css": "empty",
|
|
".svg": "dataurl",
|
|
".png": "dataurl",
|
|
".woff": "empty",
|
|
".woff2": "empty",
|
|
".ttf": "empty",
|
|
},
|
|
// import.meta.glob is Vite's; outside Termix the host ships English only,
|
|
// so the translated locale files it would list are simply none.
|
|
banner: { js: "const __termixNoGlob = () => ({});" },
|
|
define: {
|
|
// esbuild picks "development" for an unminified build, which sends core's
|
|
// requests to the Vite dev proxy on any server without a port.
|
|
"process.env.NODE_ENV": '"production"',
|
|
"import.meta.glob": "__termixNoGlob",
|
|
"import.meta.env.DEV": "false",
|
|
"import.meta.env.PROD": "true",
|
|
"import.meta.env.MODE": '"production"',
|
|
"import.meta.env.BASE_URL": '"/"',
|
|
"import.meta.env":
|
|
'{"DEV":false,"PROD":true,"MODE":"production","SSR":false,"BASE_URL":"/"}',
|
|
},
|
|
});
|
|
|
|
// Types for @termix-ssh/plugin-sdk/ui: the declarations tsc emits for sdk-ui.ts
|
|
// and everything it reaches, with core's "@/" paths made relative.
|
|
const typesDir = path.join(outDir, "types");
|
|
const tsc = spawnSync(
|
|
process.execPath,
|
|
[
|
|
path.join(root, "node_modules", "typescript", "bin", "tsc"),
|
|
"-p",
|
|
path.join(root, "tsconfig.sdk-ui.json"),
|
|
"--outDir",
|
|
typesDir,
|
|
],
|
|
{ cwd: root, stdio: "inherit" },
|
|
);
|
|
if (tsc.status !== 0) process.exit(tsc.status ?? 1);
|
|
// tsc follows @termix-ssh/plugin-sdk/frontend into the SDK's source; plugins get
|
|
// those types from the package itself.
|
|
fs.rmSync(path.join(typesDir, "packages"), { recursive: true, force: true });
|
|
|
|
const srcTypes = path.join(typesDir, "src");
|
|
function rewrite(dir) {
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
const file = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
rewrite(file);
|
|
continue;
|
|
}
|
|
if (!entry.name.endsWith(".d.ts")) continue;
|
|
const text = fs
|
|
.readFileSync(file, "utf8")
|
|
.replace(
|
|
/(["'])@\/(types(?=[/"'])|)([^"']*)\1/g,
|
|
(_match, quote, types, rest) => {
|
|
const target = types
|
|
? path.join(srcTypes, "types", rest.replace(/^\//, ""))
|
|
: path.join(srcTypes, "ui", rest);
|
|
let relative = path
|
|
.relative(path.dirname(file), target)
|
|
.replaceAll("\\", "/")
|
|
.replace(/\.tsx?$/, "");
|
|
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
return `${quote}${relative}${quote}`;
|
|
},
|
|
);
|
|
fs.writeFileSync(file, text);
|
|
}
|
|
}
|
|
rewrite(srcTypes);
|
|
fs.writeFileSync(
|
|
path.join(outDir, "ui.d.ts"),
|
|
'export * from "./types/src/ui/plugin-host/sdk-ui.js";\n',
|
|
);
|
|
|
|
// The design tokens termix-plugin build compiles a plugin's classes against.
|
|
fs.copyFileSync(
|
|
path.join(root, "src/ui/theme.css"),
|
|
path.join(outDir, "theme.css"),
|
|
);
|
|
|
|
// Every class core's own CSS has a rule for, found the way the Vite build
|
|
// finds them, so termix-plugin build knows which plugin classes it shares.
|
|
const indexCss = path.join(root, "src/ui/index.css");
|
|
const compiler = await compile(fs.readFileSync(indexCss, "utf8"), {
|
|
base: path.dirname(indexCss),
|
|
onDependency: () => {},
|
|
});
|
|
const rootSource =
|
|
compiler.root === "none"
|
|
? []
|
|
: compiler.root === null
|
|
? [{ base: root, pattern: "**/*", negated: false }]
|
|
: [{ ...compiler.root, negated: false }];
|
|
const scanner = new Scanner({
|
|
sources: [...rootSource, ...compiler.sources],
|
|
});
|
|
const coreCss = optimize(compiler.build(scanner.scan()), {
|
|
minify: true,
|
|
}).code;
|
|
const coreClasses = [...classNamesInCss(coreCss)].sort();
|
|
fs.writeFileSync(
|
|
path.join(outDir, "core-classes.json"),
|
|
`${JSON.stringify(coreClasses)}\n`,
|
|
);
|
|
|
|
// The frame host has no Vite build to load core's CSS, so it gets it here.
|
|
fs.writeFileSync(path.join(outDir, "frame-host.css"), coreCss);
|
|
|
|
console.log(`Built the SDK host modules into ${path.relative(root, outDir)}`);
|