@galaxy-blackhole/blackhole-harness 0.1.7 → 0.1.8
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/client/ui-open-in-app/lib/client.bundle.js +12 -9
- package/packages/client/ui-open-in-app/lib/client.js +12 -9
- package/packages/client/ui-open-in-app/src/parts/part-01.ts +12 -7
- package/packages/host/open-in-app/lib/index.js +35 -4
- package/packages/host/open-in-app/src/catalog.ts +47 -7
package/package.json
CHANGED
|
@@ -274,15 +274,18 @@ class OpenInAppController {
|
|
|
274
274
|
}
|
|
275
275
|
async run() {
|
|
276
276
|
let apps = [];
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
};
|
|
@@ -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
|
-
|
|
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:
|
|
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
|
|
56
|
-
//
|
|
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
|
-
|
|
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:
|
|
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
|
}
|