@galaxy-blackhole/blackhole-harness 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/host/directory-picker-auto/lib/index.js +3 -2
- package/packages/host/directory-picker-auto/src/plugin.ts +1 -0
- package/packages/host/directory-picker-auto/src/resolve.ts +6 -1
- package/packages/host/open-in-app/lib/index.js +33 -2
- package/packages/host/open-in-app/src/catalog.ts +18 -3
- package/packages/host/open-in-app/src/icons.ts +26 -0
package/package.json
CHANGED
|
@@ -74,8 +74,8 @@ function resolveDirectoryPickerBackend(facts) {
|
|
|
74
74
|
return "browse";
|
|
75
75
|
if (facts.ssh)
|
|
76
76
|
return "browse";
|
|
77
|
-
if (facts.platform === "darwin"
|
|
78
|
-
|
|
77
|
+
if (facts.platform === "darwin") return "native";
|
|
78
|
+
if (facts.platform === "win32") return facts.win32Native === true ? "native" : "browse";
|
|
79
79
|
if (facts.platform !== "linux" || !facts.linuxChooser)
|
|
80
80
|
return "browse";
|
|
81
81
|
return present(facts.env.DISPLAY) || present(facts.env.WAYLAND_DISPLAY) ? "native" : "browse";
|
|
@@ -111,6 +111,7 @@ async function apply(ctx) {
|
|
|
111
111
|
bindHost: bindHostOf(ctx),
|
|
112
112
|
allowsRemoteAuthorities: allowsRemoteAuthoritiesOf(ctx),
|
|
113
113
|
platform: process.platform,
|
|
114
|
+
win32Native: process.env.GBH_TAURI_ROOT !== undefined || process.env.GBH_DESKTOP_PORT !== undefined,
|
|
114
115
|
ssh: launchedThroughSsh(launchEnvironmentOf(ctx)),
|
|
115
116
|
env: { DISPLAY: process.env.DISPLAY, WAYLAND_DISPLAY: process.env.WAYLAND_DISPLAY },
|
|
116
117
|
linuxChooser: hasLinuxChooserBinary(process.env.PATH, canExecute)
|
|
@@ -125,6 +125,7 @@ export async function apply(ctx: PickerContext): Promise<void> {
|
|
|
125
125
|
bindHost: bindHostOf(ctx),
|
|
126
126
|
allowsRemoteAuthorities: allowsRemoteAuthoritiesOf(ctx),
|
|
127
127
|
platform: process.platform,
|
|
128
|
+
win32Native: process.env.GBH_TAURI_ROOT !== undefined || process.env.GBH_DESKTOP_PORT !== undefined,
|
|
128
129
|
ssh: launchedThroughSsh(launchEnvironmentOf(ctx)),
|
|
129
130
|
env: { DISPLAY: process.env.DISPLAY, WAYLAND_DISPLAY: process.env.WAYLAND_DISPLAY },
|
|
130
131
|
linuxChooser: hasLinuxChooserBinary(process.env.PATH, canExecute),
|
|
@@ -29,6 +29,8 @@ export interface DirectoryPickerHostFacts {
|
|
|
29
29
|
env: DirectoryPickerEnv;
|
|
30
30
|
/** Có binary chọn thư mục (zenity/kdialog) trên PATH hay không; chỉ xét khi platform là linux. */
|
|
31
31
|
linuxChooser: boolean;
|
|
32
|
+
/** Windows đang chạy trong desktop shell (Tauri) — native dùng koffi; CLI web phải dùng browse. */
|
|
33
|
+
win32Native?: boolean;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/** Một env chỉ tính khi được đặt và không rỗng (export rỗng là "không đặt" theo quy ước shell). */
|
|
@@ -84,7 +86,10 @@ export function isLoopbackHost(host: string): boolean {
|
|
|
84
86
|
export function resolveDirectoryPickerBackend(facts: DirectoryPickerHostFacts): DirectoryPickerBackendKind {
|
|
85
87
|
if (facts.allowsRemoteAuthorities || !isLoopbackHost(facts.bindHost)) return "browse";
|
|
86
88
|
if (facts.ssh) return "browse";
|
|
87
|
-
if (facts.platform === "darwin"
|
|
89
|
+
if (facts.platform === "darwin") return "native";
|
|
90
|
+
// 20/11/2026 — Windows CLI web KHÔNG có koffi/COM dialog sẵn (npm 11 chặn install-script của koffi);
|
|
91
|
+
// chọn native sẽ làm workspace picker im lặng biến mất. Chỉ native khi chạy trong Tauri desktop.
|
|
92
|
+
if (facts.platform === "win32") return facts.win32Native === true ? "native" : "browse";
|
|
88
93
|
if (facts.platform !== "linux" || !facts.linuxChooser) return "browse";
|
|
89
94
|
return present(facts.env.DISPLAY) || present(facts.env.WAYLAND_DISPLAY) ? "native" : "browse";
|
|
90
95
|
}
|
|
@@ -23,15 +23,27 @@ function windowsCandidates() {
|
|
|
23
23
|
const pf = process.env.ProgramFiles ?? "";
|
|
24
24
|
const pf86 = process.env["ProgramFiles(x86)"] ?? "";
|
|
25
25
|
const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
|
|
26
|
-
|
|
26
|
+
const candidates = [
|
|
27
27
|
{ id: "explorer", label: "File Explorer", bundle: join2(systemRoot, "explorer.exe") },
|
|
28
28
|
{ id: "vscode", label: "Visual Studio Code", bundle: join2(local, "Programs", "Microsoft VS Code", "Code.exe") },
|
|
29
29
|
{ id: "vscode", label: "Visual Studio Code", bundle: join2(pf, "Microsoft VS Code", "Code.exe") },
|
|
30
30
|
{ id: "vscode", label: "Visual Studio Code", bundle: join2(pf86, "Microsoft VS Code", "Code.exe") },
|
|
31
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join2(local, "Programs", "IntelliJ IDEA Ultimate", "bin", "idea64.exe") },
|
|
32
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join2(local, "Programs", "IntelliJ IDEA Community Edition", "bin", "idea64.exe") },
|
|
33
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join2(pf, "JetBrains", "IntelliJ IDEA Ultimate", "bin", "idea64.exe") },
|
|
34
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join2(pf, "JetBrains", "IntelliJ IDEA Community Edition", "bin", "idea64.exe") },
|
|
31
35
|
{ id: "windowsterminal", label: "Windows Terminal", bundle: join2(local, "Microsoft", "WindowsApps", "wt.exe") },
|
|
36
|
+
{ id: "windowsterminal", label: "Windows Terminal", bundle: join2(pf, "WindowsApps", "wt.exe") },
|
|
32
37
|
{ id: "gitbash", label: "Git Bash", bundle: join2(pf, "Git", "git-bash.exe") },
|
|
38
|
+
{ id: "gitbash", label: "Git Bash", bundle: join2(local, "Programs", "Git", "git-bash.exe") },
|
|
33
39
|
{ id: "gitbash", label: "Git Bash", bundle: join2(pf86, "Git", "git-bash.exe") }
|
|
34
40
|
];
|
|
41
|
+
try {
|
|
42
|
+
const toolbox = join2(local, "JetBrains", "Toolbox", "apps", "IDEA-U", "ch-0");
|
|
43
|
+
for (const build of readdirSync(toolbox))
|
|
44
|
+
candidates.push({ id: "intellij", label: "IntelliJ IDEA", bundle: join2(toolbox, build, "bin", "idea64.exe") });
|
|
45
|
+
} catch {}
|
|
46
|
+
return candidates;
|
|
35
47
|
}
|
|
36
48
|
async function resolveCatalog(platform = process.platform, exists = defaultExists) {
|
|
37
49
|
if (platform === "win32") {
|
|
@@ -67,7 +79,7 @@ async function defaultExists(path) {
|
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
81
|
function openCommand(launcher, path) {
|
|
70
|
-
if (launcher.id === "explorer" || launcher.id === "vscode")
|
|
82
|
+
if (launcher.id === "explorer" || launcher.id === "vscode" || launcher.id === "intellij")
|
|
71
83
|
return { command: launcher.bundle, args: [path] };
|
|
72
84
|
if (launcher.id === "windowsterminal")
|
|
73
85
|
return { command: launcher.bundle, args: ["-d", path] };
|
|
@@ -112,7 +124,26 @@ function firstIconInResources(bundle) {
|
|
|
112
124
|
return null;
|
|
113
125
|
}
|
|
114
126
|
}
|
|
127
|
+
function extractWindowsIconPng(exe, timeoutMs) {
|
|
128
|
+
const workDir = mkdtempSync(join(tmpdir(), "gbh-open-in-app-"));
|
|
129
|
+
try {
|
|
130
|
+
const outPng = join(workDir, "icon.png");
|
|
131
|
+
const script = "Add-Type -AssemblyName System.Drawing; $i=[System.Drawing.Icon]::ExtractAssociatedIcon($env:GBH_ICON_EXE); if ($i -ne $null) { $i.ToBitmap().Save($env:GBH_ICON_OUT,[System.Drawing.Imaging.ImageFormat]::Png) }";
|
|
132
|
+
const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script], {
|
|
133
|
+
timeout: Math.max(timeoutMs, 15e3),
|
|
134
|
+
windowsHide: true,
|
|
135
|
+
env: { ...process.env, GBH_ICON_EXE: exe, GBH_ICON_OUT: outPng }
|
|
136
|
+
});
|
|
137
|
+
if (result.status !== 0) return null;
|
|
138
|
+
return readFileSync(outPng);
|
|
139
|
+
} catch {
|
|
140
|
+
return null;
|
|
141
|
+
} finally {
|
|
142
|
+
rmSync(workDir, { recursive: true, force: true });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
115
145
|
function extractBundleIconPng(bundle, timeoutMs) {
|
|
146
|
+
if (process.platform === "win32") return extractWindowsIconPng(bundle, timeoutMs);
|
|
116
147
|
const named = readIconName(bundle, timeoutMs);
|
|
117
148
|
const icns = named === null ? firstIconInResources(bundle) : join(bundle, "Contents", "Resources", named);
|
|
118
149
|
if (icns === null)
|
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
* modify date 17/10/2026
|
|
6
6
|
* desc Bang ung dung mo duoc (catalog cua row open-in-app) + nhan dien tren macOS.
|
|
7
7
|
*/
|
|
8
|
+
import { readdirSync } from "node:fs";
|
|
8
9
|
import { join } from "node:path";
|
|
9
10
|
/**
|
|
10
11
|
* Ma ung dung trong catalog — dung y 5 id ma oracle phuc vu tren macOS.
|
|
11
12
|
*/
|
|
12
|
-
export type OpenInAppId = "finder" | "explorer" | "vscode" | "windowsterminal" | "gitbash" | "xcode" | "iterm" | "terminal";
|
|
13
|
+
export type OpenInAppId = "finder" | "explorer" | "vscode" | "intellij" | "windowsterminal" | "gitbash" | "xcode" | "iterm" | "terminal";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Thu tu id trong catalog (giu nguyen thu tu oracle tra ve: finder, vscode, xcode, iterm, terminal).
|
|
16
17
|
*/
|
|
17
|
-
export const OPEN_IN_APP_IDS: readonly OpenInAppId[] = ["finder", "explorer", "vscode", "windowsterminal", "gitbash", "xcode", "iterm", "terminal"];
|
|
18
|
+
export const OPEN_IN_APP_IDS: readonly OpenInAppId[] = ["finder", "explorer", "vscode", "intellij", "windowsterminal", "gitbash", "xcode", "iterm", "terminal"];
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Mot muc catalog da resolve: bundle .app ton tai tren may.
|
|
@@ -52,15 +53,29 @@ export function windowsCandidates(): readonly OpenInAppLauncher[] {
|
|
|
52
53
|
const pf = process.env.ProgramFiles ?? "";
|
|
53
54
|
const pf86 = process.env["ProgramFiles(x86)"] ?? "";
|
|
54
55
|
const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
|
|
55
|
-
|
|
56
|
+
const candidates: OpenInAppLauncher[] = [
|
|
56
57
|
{ id: "explorer", label: "File Explorer", bundle: join(systemRoot, "explorer.exe") },
|
|
57
58
|
{ id: "vscode", label: "Visual Studio Code", bundle: join(local, "Programs", "Microsoft VS Code", "Code.exe") },
|
|
58
59
|
{ id: "vscode", label: "Visual Studio Code", bundle: join(pf, "Microsoft VS Code", "Code.exe") },
|
|
59
60
|
{ id: "vscode", label: "Visual Studio Code", bundle: join(pf86, "Microsoft VS Code", "Code.exe") },
|
|
61
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join(local, "Programs", "IntelliJ IDEA Ultimate", "bin", "idea64.exe") },
|
|
62
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join(local, "Programs", "IntelliJ IDEA Community Edition", "bin", "idea64.exe") },
|
|
63
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join(pf, "JetBrains", "IntelliJ IDEA Ultimate", "bin", "idea64.exe") },
|
|
64
|
+
{ id: "intellij", label: "IntelliJ IDEA", bundle: join(pf, "JetBrains", "IntelliJ IDEA Community Edition", "bin", "idea64.exe") },
|
|
60
65
|
{ id: "windowsterminal", label: "Windows Terminal", bundle: join(local, "Microsoft", "WindowsApps", "wt.exe") },
|
|
66
|
+
{ id: "windowsterminal", label: "Windows Terminal", bundle: join(pf, "WindowsApps", "wt.exe") },
|
|
61
67
|
{ id: "gitbash", label: "Git Bash", bundle: join(pf, "Git", "git-bash.exe") },
|
|
68
|
+
{ id: "gitbash", label: "Git Bash", bundle: join(local, "Programs", "Git", "git-bash.exe") },
|
|
62
69
|
{ id: "gitbash", label: "Git Bash", bundle: join(pf86, "Git", "git-bash.exe") },
|
|
63
70
|
];
|
|
71
|
+
// JetBrains Toolbox: %LOCALAPPDATA%\JetBrains\Toolbox\apps\IDEA-U\ch-0\<build>\bin\idea64.exe
|
|
72
|
+
try {
|
|
73
|
+
const toolbox = join(local, "JetBrains", "Toolbox", "apps", "IDEA-U", "ch-0");
|
|
74
|
+
for (const build of readdirSync(toolbox)) {
|
|
75
|
+
candidates.push({ id: "intellij", label: "IntelliJ IDEA", bundle: join(toolbox, build, "bin", "idea64.exe") });
|
|
76
|
+
}
|
|
77
|
+
} catch {}
|
|
78
|
+
return candidates;
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
/**
|
|
@@ -58,6 +58,31 @@ function firstIconInResources(bundle: string): string | null {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Trich icon cua mot file .exe tren Windows thanh PNG bang System.Drawing (PowerShell).
|
|
63
|
+
* @param exe - duong dan tuyet doi toi .exe (VS Code, IntelliJ, explorer...).
|
|
64
|
+
* @param timeoutMs - han chot cho tien trinh PowerShell.
|
|
65
|
+
* @returns bytes PNG, hoac null khi khong trich duoc.
|
|
66
|
+
*/
|
|
67
|
+
function extractWindowsIconPng(exe: string, timeoutMs: number): Buffer | null {
|
|
68
|
+
const workDir = mkdtempSync(join(tmpdir(), "gbh-open-in-app-"));
|
|
69
|
+
try {
|
|
70
|
+
const outPng = join(workDir, "icon.png");
|
|
71
|
+
const script = "Add-Type -AssemblyName System.Drawing; $i=[System.Drawing.Icon]::ExtractAssociatedIcon($env:GBH_ICON_EXE); if ($i -ne $null) { $i.ToBitmap().Save($env:GBH_ICON_OUT,[System.Drawing.Imaging.ImageFormat]::Png) }";
|
|
72
|
+
const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script], {
|
|
73
|
+
timeout: Math.max(timeoutMs, 15000),
|
|
74
|
+
windowsHide: true,
|
|
75
|
+
env: { ...process.env, GBH_ICON_EXE: exe, GBH_ICON_OUT: outPng },
|
|
76
|
+
});
|
|
77
|
+
if (result.status !== 0) return null;
|
|
78
|
+
return readFileSync(outPng);
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
} finally {
|
|
82
|
+
rmSync(workDir, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
61
86
|
/**
|
|
62
87
|
* Trich icon cua bundle thanh PNG 128x128 (RGBA) — hai buoc y nhu upstream:
|
|
63
88
|
* plutil doc CFBundleIconFile (thieu duoi .icns thi tu them; khong co thi lay .icns dau tien trong Resources),
|
|
@@ -67,6 +92,7 @@ function firstIconInResources(bundle: string): string | null {
|
|
|
67
92
|
* @returns bytes PNG, hoac null khi khong trich duoc (route se tra 404).
|
|
68
93
|
*/
|
|
69
94
|
export function extractBundleIconPng(bundle: string, timeoutMs: number): Buffer | null {
|
|
95
|
+
if (process.platform === "win32") return extractWindowsIconPng(bundle, timeoutMs);
|
|
70
96
|
const named = readIconName(bundle, timeoutMs);
|
|
71
97
|
const icns = named === null ? firstIconInResources(bundle) : join(bundle, "Contents", "Resources", named);
|
|
72
98
|
if (icns === null) return null;
|