@galaxy-blackhole/blackhole-harness 0.1.7 → 0.1.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-blackhole/blackhole-harness",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Galaxy Blackhole harness — boot the DSH host with the blackhole profile (lean npm build)",
@@ -274,15 +274,18 @@ class OpenInAppController {
274
274
  }
275
275
  async run() {
276
276
  let apps = [];
277
- try {
278
- const response = await this.fetcher(ROUTE_APPS, { headers: { accept: "application/json" } });
279
- if (response.ok) {
280
- const payload = await response.json();
281
- if (Array.isArray(payload.apps))
282
- apps = payload.apps.filter((id) => typeof id === "string");
283
- }
284
- } catch {
285
- apps = [];
277
+ for (let attempt = 0; attempt < 4; attempt += 1) {
278
+ try {
279
+ const response = await this.fetcher(ROUTE_APPS, { headers: { accept: "application/json" } });
280
+ if (response.ok) {
281
+ const payload = await response.json();
282
+ if (Array.isArray(payload.apps))
283
+ apps = payload.apps.filter((id) => typeof id === "string");
284
+ break;
285
+ }
286
+ if (response.status !== 404) break;
287
+ } catch {}
288
+ if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, 250 * (attempt + 1)));
286
289
  }
287
290
  this.apps.set(apps);
288
291
  }
@@ -287,15 +287,18 @@
287
287
  }
288
288
  async run() {
289
289
  let apps = [];
290
- try {
291
- const response = await this.fetcher(ROUTE_APPS, { headers: { accept: "application/json" } });
292
- if (response.ok) {
293
- const payload = await response.json();
294
- if (Array.isArray(payload.apps))
295
- apps = payload.apps.filter((id) => typeof id === "string");
296
- }
297
- } catch {
298
- apps = [];
290
+ for (let attempt = 0; attempt < 4; attempt += 1) {
291
+ try {
292
+ const response = await this.fetcher(ROUTE_APPS, { headers: { accept: "application/json" } });
293
+ if (response.ok) {
294
+ const payload = await response.json();
295
+ if (Array.isArray(payload.apps))
296
+ apps = payload.apps.filter((id) => typeof id === "string");
297
+ break;
298
+ }
299
+ if (response.status !== 404) break;
300
+ } catch {}
301
+ if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, 250 * (attempt + 1)));
299
302
  }
300
303
  this.apps.set(apps);
301
304
  }
@@ -150,13 +150,18 @@ window.__ModuleLoader__.load({
150
150
  }
151
151
  async run() {
152
152
  let apps = [];
153
- try {
154
- const response = await this.fetcher(OPEN_IN_APP_APPS_ROUTE, { headers: { accept: "application/json" } });
155
- if (response.ok) {
156
- const payload = await response.json();
157
- if (Array.isArray(payload.apps)) apps = payload.apps.filter((id) => typeof id === "string");
158
- }
159
- } catch {}
153
+ for (let attempt = 0; attempt < 4; attempt += 1) {
154
+ try {
155
+ const response = await this.fetcher(OPEN_IN_APP_APPS_ROUTE, { headers: { accept: "application/json" } });
156
+ if (response.ok) {
157
+ const payload = await response.json();
158
+ if (Array.isArray(payload.apps)) apps = payload.apps.filter((id) => typeof id === "string");
159
+ break;
160
+ }
161
+ if (response.status !== 404) break;
162
+ } catch {}
163
+ if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, 250 * (attempt + 1)));
164
+ }
160
165
  this.apps.set(apps);
161
166
  }
162
167
  };
@@ -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" || facts.platform === "win32")
78
- return "native";
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" || facts.platform === "win32") return "native";
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
  }
@@ -18,9 +18,36 @@ function darwinCandidates() {
18
18
  { id: "terminal", label: "Terminal", bundle: "/System/Applications/Utilities/Terminal.app" }
19
19
  ];
20
20
  }
21
+ function windowsCandidates() {
22
+ const local = process.env.LOCALAPPDATA ?? "";
23
+ const pf = process.env.ProgramFiles ?? "";
24
+ const pf86 = process.env["ProgramFiles(x86)"] ?? "";
25
+ const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
26
+ return [
27
+ { id: "explorer", label: "File Explorer", bundle: join2(systemRoot, "explorer.exe") },
28
+ { id: "vscode", label: "Visual Studio Code", bundle: join2(local, "Programs", "Microsoft VS Code", "Code.exe") },
29
+ { id: "vscode", label: "Visual Studio Code", bundle: join2(pf, "Microsoft VS Code", "Code.exe") },
30
+ { id: "vscode", label: "Visual Studio Code", bundle: join2(pf86, "Microsoft VS Code", "Code.exe") },
31
+ { id: "windowsterminal", label: "Windows Terminal", bundle: join2(local, "Microsoft", "WindowsApps", "wt.exe") },
32
+ { id: "gitbash", label: "Git Bash", bundle: join2(pf, "Git", "git-bash.exe") },
33
+ { id: "gitbash", label: "Git Bash", bundle: join2(pf86, "Git", "git-bash.exe") }
34
+ ];
35
+ }
21
36
  async function resolveCatalog(platform = process.platform, exists = defaultExists) {
22
- if (platform === "win32")
23
- return [{ id: "explorer", label: "File Explorer", bundle: "explorer.exe" }];
37
+ if (platform === "win32") {
38
+ const found = [];
39
+ const seen = /* @__PURE__ */ new Set();
40
+ for (const candidate of windowsCandidates()) {
41
+ if (seen.has(candidate.id)) continue;
42
+ if (await exists(candidate.bundle)) {
43
+ found.push(candidate);
44
+ seen.add(candidate.id);
45
+ }
46
+ }
47
+ if (!seen.has("explorer"))
48
+ found.unshift({ id: "explorer", label: "File Explorer", bundle: join2(process.env.SystemRoot ?? "C:\\Windows", "explorer.exe") });
49
+ return found;
50
+ }
24
51
  if (platform !== "darwin")
25
52
  return [];
26
53
  const found = [];
@@ -40,8 +67,12 @@ async function defaultExists(path) {
40
67
  }
41
68
  }
42
69
  function openCommand(launcher, path) {
43
- if (launcher.id === "explorer")
44
- return { command: "explorer.exe", args: [path] };
70
+ if (launcher.id === "explorer" || launcher.id === "vscode")
71
+ return { command: launcher.bundle, args: [path] };
72
+ if (launcher.id === "windowsterminal")
73
+ return { command: launcher.bundle, args: ["-d", path] };
74
+ if (launcher.id === "gitbash")
75
+ return { command: launcher.bundle, args: ["--cd=" + path] };
45
76
  return { command: "open", args: ["-a", launcher.bundle, path] };
46
77
  }
47
78
 
@@ -5,15 +5,16 @@
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 { join } from "node:path";
8
9
  /**
9
10
  * Ma ung dung trong catalog — dung y 5 id ma oracle phuc vu tren macOS.
10
11
  */
11
- export type OpenInAppId = "finder" | "explorer" | "vscode" | "xcode" | "iterm" | "terminal";
12
+ export type OpenInAppId = "finder" | "explorer" | "vscode" | "windowsterminal" | "gitbash" | "xcode" | "iterm" | "terminal";
12
13
 
13
14
  /**
14
15
  * Thu tu id trong catalog (giu nguyen thu tu oracle tra ve: finder, vscode, xcode, iterm, terminal).
15
16
  */
16
- export const OPEN_IN_APP_IDS: readonly OpenInAppId[] = ["finder", "explorer", "vscode", "xcode", "iterm", "terminal"];
17
+ export const OPEN_IN_APP_IDS: readonly OpenInAppId[] = ["finder", "explorer", "vscode", "windowsterminal", "gitbash", "xcode", "iterm", "terminal"];
17
18
 
18
19
  /**
19
20
  * Mot muc catalog da resolve: bundle .app ton tai tren may.
@@ -41,6 +42,27 @@ export function darwinCandidates(): readonly OpenInAppLauncher[] {
41
42
  ];
42
43
  }
43
44
 
45
+ /**
46
+ * Ung vien tren Windows: File Explorer, VS Code, Windows Terminal, Git Bash.
47
+ * Duong dan tuyet doi de `launch` khong phu thuoc PATH/resolveExecutable.
48
+ * @returns danh sach ung vien theo thu tu menu.
49
+ */
50
+ export function windowsCandidates(): readonly OpenInAppLauncher[] {
51
+ const local = process.env.LOCALAPPDATA ?? "";
52
+ const pf = process.env.ProgramFiles ?? "";
53
+ const pf86 = process.env["ProgramFiles(x86)"] ?? "";
54
+ const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
55
+ return [
56
+ { id: "explorer", label: "File Explorer", bundle: join(systemRoot, "explorer.exe") },
57
+ { id: "vscode", label: "Visual Studio Code", bundle: join(local, "Programs", "Microsoft VS Code", "Code.exe") },
58
+ { id: "vscode", label: "Visual Studio Code", bundle: join(pf, "Microsoft VS Code", "Code.exe") },
59
+ { id: "vscode", label: "Visual Studio Code", bundle: join(pf86, "Microsoft VS Code", "Code.exe") },
60
+ { id: "windowsterminal", label: "Windows Terminal", bundle: join(local, "Microsoft", "WindowsApps", "wt.exe") },
61
+ { id: "gitbash", label: "Git Bash", bundle: join(pf, "Git", "git-bash.exe") },
62
+ { id: "gitbash", label: "Git Bash", bundle: join(pf86, "Git", "git-bash.exe") },
63
+ ];
64
+ }
65
+
44
66
  /**
45
67
  * Loc ung vien con cai thuc su ton tai tren may.
46
68
  * Nguon su that la he thong tep (khong doan): chi bundle co that moi vao catalog.
@@ -52,10 +74,22 @@ export async function resolveCatalog(
52
74
  platform: string = process.platform,
53
75
  exists: (path: string) => Promise<boolean> = defaultExists,
54
76
  ): Promise<OpenInAppLauncher[]> {
55
- // 20/11/2026 — Windows cũng phải có "Mở dự án" như macOS. explorer.exe luôn tồn tại trên Windows;
56
- // trước đây catalog chỉ có macOS nên client nhận [] và ẩn nút Open in app trên Windows.
77
+ // 20/11/2026 — Windows phải có menu "Mở bằng" giống macOS. Catalog gồm File Explorer,
78
+ // VS Code, Windows Terminal, Git Bash; chỉ entry có thật trên máy mới được trả về.
57
79
  if (platform === "win32") {
58
- return [{ id: "explorer", label: "File Explorer", bundle: "explorer.exe" }];
80
+ const found: OpenInAppLauncher[] = [];
81
+ const seen = new Set<OpenInAppId>();
82
+ for (const candidate of windowsCandidates()) {
83
+ if (seen.has(candidate.id)) continue;
84
+ if (await exists(candidate.bundle)) {
85
+ found.push(candidate);
86
+ seen.add(candidate.id);
87
+ }
88
+ }
89
+ if (!seen.has("explorer")) {
90
+ found.unshift({ id: "explorer", label: "File Explorer", bundle: join(process.env.SystemRoot ?? "C:\\Windows", "explorer.exe") });
91
+ }
92
+ return found;
59
93
  }
60
94
  if (platform !== "darwin") return [];
61
95
  const found: OpenInAppLauncher[] = [];
@@ -87,8 +121,14 @@ async function defaultExists(path: string): Promise<boolean> {
87
121
  * @returns cap lenh + tham so cho node:child_process.
88
122
  */
89
123
  export function openCommand(launcher: OpenInAppLauncher, path: string): { command: string; args: string[] } {
90
- if (launcher.id === "explorer") {
91
- return { command: "explorer.exe", args: [path] };
124
+ if (launcher.id === "explorer" || launcher.id === "vscode") {
125
+ return { command: launcher.bundle, args: [path] };
126
+ }
127
+ if (launcher.id === "windowsterminal") {
128
+ return { command: launcher.bundle, args: ["-d", path] };
129
+ }
130
+ if (launcher.id === "gitbash") {
131
+ return { command: launcher.bundle, args: ["--cd=" + path] };
92
132
  }
93
133
  return { command: "open", args: ["-a", launcher.bundle, path] };
94
134
  }