дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
feat(plugins): import IntelliJ theme plugins (#1184)
Settings › Plugins (gear menu) gets Import Theme from IntelliJ IDE… (theme plugins of the JetBrains IDEs on this machine, the one each IDE uses first) and Import IntelliJ Theme from File… (a Marketplace .jar / .zip or a .theme.json). The host reads the plugin with size limits; the UI converts it with the IntelliJ mapping (moved from scripts/theme to src/features/plugins/intellijTheme.ts, still used by pnpm theme:import-intellij) into one OpenIDEA theme plugin (engines.openidea ^1.0) with all of its themes, installed through the usual install page, and applies the chosen theme. Theme pickers separate each plugin's themes, and Quick Switch Scheme › Theme previews the theme under the pointer or keyboard after 500 ms and restores the selected one when closed without a choice. Co-authored-by: ldg030201 <[email protected]>
Цей коміт міститься в:
1 джерело
a610982655
коміт
6dec1252db
33 files changed
+2284
-87
No files matched your search
@@ -5,9 +5,10 @@ import {
|
||||
convertIntellijTheme,
|
||||
ICLS_ATTRIBUTES,
|
||||
ICLS_COLORS,
|
||||
intellijThemePackage,
|
||||
pluginManifest,
|
||||
UI_KEYS,
|
||||
} from "./intellij.ts";
|
||||
} from "../../src/features/plugins/intellijTheme.ts";
|
||||
import { referenceMarkdown, stripJsonComments, themeTokenGroups, tokenSets, withReference } from "./tokens.ts";
|
||||
|
||||
const read = (p: string) => readFileSync(p, "utf8");
|
||||
@@ -129,7 +130,7 @@ describe("IntelliJ theme import", () => {
|
||||
</scheme>`;
|
||||
|
||||
it("maps ui keys, named colours and wildcards", () => {
|
||||
const { theme: t, scheme: s } = convertIntellijTheme(themeJson);
|
||||
const { theme: t, scheme: s } = convertIntellijTheme(stripJsonComments(themeJson));
|
||||
expect(t).toMatchObject({ id: "deep-sea", name: "Deep Sea", kind: "dark" });
|
||||
expect(t.tokens["--bg-app"]).toBe("#101820"); // *.background → named colour
|
||||
expect(t.tokens["--accent"]).toBe("#33aaff");
|
||||
@@ -172,12 +173,71 @@ describe("IntelliJ theme import", () => {
|
||||
});
|
||||
|
||||
it("produces an installable package", () => {
|
||||
const c = convertIntellijTheme(themeJson.replace('"dark": true,', ""), icls.replace("Darcula", "Default"), "sea");
|
||||
const light = stripJsonComments(themeJson.replace('"dark": true,', ""));
|
||||
const c = convertIntellijTheme(light, icls.replace("Darcula", "Default"), "sea");
|
||||
expect(c.theme.kind).toBe("light");
|
||||
expect(c.theme.id).toBe("sea");
|
||||
expect(c.theme.tokens["--bg-island"]).toBe("#101820"); // ToolWindow ← *.background wins over the editor
|
||||
const toml = pluginManifest(c, "Someone", "DeepSea.theme.json");
|
||||
const info = {
|
||||
id: "theme-sea",
|
||||
name: 'Sea "Deep"',
|
||||
version: "1.0.0",
|
||||
description: "a\\b\nc",
|
||||
authors: ["Someone"],
|
||||
};
|
||||
const toml = pluginManifest(info, [c], "Converted from\nDeepSea.theme.json");
|
||||
expect(toml).toContain("# Converted from DeepSea.theme.json\n");
|
||||
expect(toml).toContain('id = "theme-sea"');
|
||||
expect(toml).toContain('name = "Sea \\"Deep\\""');
|
||||
expect(toml).toContain('description = "a\\\\b\\u000ac"');
|
||||
expect(toml).toContain('engines.openidea = "^1.0"');
|
||||
expect(toml).toContain('editor-scheme = "themes/sea.scheme.json"');
|
||||
});
|
||||
|
||||
it("turns a theme plugin into one package with all its themes", () => {
|
||||
const deep = stripJsonComments(themeJson);
|
||||
const pkg = intellijThemePackage({
|
||||
name: "Deep Sea Themes",
|
||||
pluginId: "com.example.DeepSea",
|
||||
version: "2.3",
|
||||
vendor: "Someone",
|
||||
themes: [
|
||||
{ id: "deep-sea-id", theme: deep, editorScheme: icls },
|
||||
{ id: "copy-id", theme: deep, editorScheme: null },
|
||||
{ id: "light-id", theme: '{"name":"Shallow","dark":false}', editorScheme: null },
|
||||
],
|
||||
});
|
||||
expect(pkg.id).toBe("intellij.com-example-deepsea");
|
||||
expect(pkg.themes).toEqual([
|
||||
{ id: "deep-sea", sourceId: "deep-sea-id", name: "Deep Sea" },
|
||||
{ id: "deep-sea-2", sourceId: "copy-id", name: "Deep Sea" },
|
||||
{ id: "shallow", sourceId: "light-id", name: "Shallow" },
|
||||
]);
|
||||
expect(pkg.files.map((f) => f.path)).toEqual([
|
||||
"plugin.toml",
|
||||
"themes/deep-sea.theme.json",
|
||||
"themes/deep-sea.scheme.json",
|
||||
"themes/deep-sea-2.theme.json",
|
||||
"themes/shallow.theme.json",
|
||||
]);
|
||||
const manifest = pkg.files[0]!.text;
|
||||
expect(manifest).toContain('version = "2.3.0"');
|
||||
expect(manifest).toContain('authors = ["Someone"]');
|
||||
expect(manifest.match(/\[\[contributes\.themes\]\]/g)).toHaveLength(3);
|
||||
const shallow = JSON.parse(pkg.files[4]!.text) as { id: string; kind: string };
|
||||
expect(shallow).toMatchObject({ id: "shallow", kind: "light" });
|
||||
expect(
|
||||
intellijThemePackage({
|
||||
name: "X",
|
||||
pluginId: null,
|
||||
version: "SNAPSHOT",
|
||||
vendor: null,
|
||||
themes: [{ id: "x", theme: "{}", editorScheme: null }],
|
||||
}).files[0]!.text,
|
||||
).toContain('version = "1.0.0"');
|
||||
expect(() =>
|
||||
intellijThemePackage({ name: "Empty", pluginId: null, version: null, vendor: null, themes: [] }),
|
||||
).toThrow();
|
||||
expect(() => convertIntellijTheme("[1]")).toThrow("Not an IntelliJ theme");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Заблокувати користувача