tamga-vdesktop 1.1.3 → 1.1.5
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/dist/cli.js +433 -128
- package/dist/client/assets/index-BiXKIozf.js +418 -0
- package/dist/client/assets/{index-CIRRVu-Z.css → index-BojLP2ND.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/helpers/x11_bridge.py +366 -135
- package/dist/helpers/x11_streamer.py +39 -6
- package/dist/server.js +433 -128
- package/package.json +1 -1
- package/dist/client/assets/index-CkivpiEX.js +0 -415
package/dist/cli.js
CHANGED
|
@@ -381,17 +381,25 @@ var LinuxAppManager = class {
|
|
|
381
381
|
if (path2.isAbsolute(iconName) && fs2.existsSync(iconName)) return iconName;
|
|
382
382
|
const safe = path2.basename(iconName).replace(/[^a-z0-9._-]/gi, "");
|
|
383
383
|
if (!safe) return null;
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
384
|
+
const aliasMap = {
|
|
385
|
+
chrome: ["google-chrome", "chromium", "chromium-browser"],
|
|
386
|
+
mousepad: ["org.xfce.mousepad", "mousepad"],
|
|
387
|
+
vscode: ["com.visualstudio.code", "vscode", "visual-studio-code"]
|
|
388
|
+
};
|
|
389
|
+
const candidates = Array.from(/* @__PURE__ */ new Set([safe, ...aliasMap[safe] || []]));
|
|
390
|
+
for (const name of candidates) {
|
|
391
|
+
const searchPaths = [
|
|
392
|
+
`/usr/share/icons/hicolor/128x128/apps/${name}.png`,
|
|
393
|
+
`/usr/share/icons/hicolor/64x64/apps/${name}.png`,
|
|
394
|
+
`/usr/share/icons/hicolor/48x48/apps/${name}.png`,
|
|
395
|
+
`/usr/share/icons/hicolor/scalable/apps/${name}.svg`,
|
|
396
|
+
`/usr/share/pixmaps/${name}.png`,
|
|
397
|
+
`/usr/share/pixmaps/${name}.svg`,
|
|
398
|
+
`/usr/share/pixmaps/${name}.xpm`
|
|
399
|
+
];
|
|
400
|
+
for (const p of searchPaths) {
|
|
401
|
+
if (fs2.existsSync(p)) return p;
|
|
402
|
+
}
|
|
395
403
|
}
|
|
396
404
|
return null;
|
|
397
405
|
}
|
|
@@ -2248,6 +2256,19 @@ import fs6 from "node:fs";
|
|
|
2248
2256
|
import os4 from "node:os";
|
|
2249
2257
|
import path6 from "node:path";
|
|
2250
2258
|
import { execSync as execSync2, spawn as spawn3 } from "node:child_process";
|
|
2259
|
+
var SLOT_W = 1920;
|
|
2260
|
+
var SLOT_H = 1080;
|
|
2261
|
+
var SLOT_COLS = 2;
|
|
2262
|
+
var PROFILE_LOCKED_APPS = /* @__PURE__ */ new Set([
|
|
2263
|
+
"firefox",
|
|
2264
|
+
"firefox-esr",
|
|
2265
|
+
"chrome",
|
|
2266
|
+
"google-chrome",
|
|
2267
|
+
"google-chrome-stable",
|
|
2268
|
+
"chromium",
|
|
2269
|
+
"chromium-browser",
|
|
2270
|
+
"antigravity"
|
|
2271
|
+
]);
|
|
2251
2272
|
function findFreeDisplay(inUse) {
|
|
2252
2273
|
for (let d = 100; d < 250; d++) {
|
|
2253
2274
|
if (inUse.has(d)) continue;
|
|
@@ -2258,14 +2279,13 @@ function findFreeDisplay(inUse) {
|
|
|
2258
2279
|
return 100 + Math.floor(Math.random() * 100);
|
|
2259
2280
|
}
|
|
2260
2281
|
function hasTurboJpegAndXDamage() {
|
|
2261
|
-
const
|
|
2282
|
+
const tjCandidates = [
|
|
2262
2283
|
"/lib/x86_64-linux-gnu/libturbojpeg.so.0",
|
|
2263
2284
|
"/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0",
|
|
2264
2285
|
"/lib/aarch64-linux-gnu/libturbojpeg.so.0",
|
|
2265
2286
|
"/usr/lib/aarch64-linux-gnu/libturbojpeg.so.0",
|
|
2266
2287
|
"/usr/lib/libturbojpeg.so.0"
|
|
2267
2288
|
];
|
|
2268
|
-
const hasTj = candidates.some((p) => fs6.existsSync(p));
|
|
2269
2289
|
const dmgCandidates = [
|
|
2270
2290
|
"/lib/x86_64-linux-gnu/libXdamage.so.1",
|
|
2271
2291
|
"/usr/lib/x86_64-linux-gnu/libXdamage.so.1",
|
|
@@ -2273,17 +2293,17 @@ function hasTurboJpegAndXDamage() {
|
|
|
2273
2293
|
"/usr/lib/aarch64-linux-gnu/libXdamage.so.1",
|
|
2274
2294
|
"/usr/lib/libXdamage.so.1"
|
|
2275
2295
|
];
|
|
2276
|
-
|
|
2277
|
-
return hasTj && hasDmg;
|
|
2296
|
+
return tjCandidates.some((p) => fs6.existsSync(p)) && dmgCandidates.some((p) => fs6.existsSync(p));
|
|
2278
2297
|
}
|
|
2279
2298
|
function buildOpenboxRcXml() {
|
|
2280
2299
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
2281
2300
|
<openbox_config xmlns="http://openbox.org/3.4/rc">
|
|
2282
2301
|
<resistance><strength>0</strength><screen_edge_strength>0</screen_edge_strength></resistance>
|
|
2283
2302
|
<focus><focusNew>yes</focusNew><followMouse>no</followMouse></focus>
|
|
2284
|
-
<placement><policy>Smart</policy><center>
|
|
2303
|
+
<placement><policy>Smart</policy><center>no</center></placement>
|
|
2285
2304
|
<theme><name>Clearlooks</name><titleLayout>NLIMC</titleLayout><keepBorder>no</keepBorder></theme>
|
|
2286
2305
|
<desktops><number>1</number></desktops>
|
|
2306
|
+
<margins><top>0</top><bottom>0</bottom><left>0</left><right>0</right></margins>
|
|
2287
2307
|
<applications>
|
|
2288
2308
|
<application class="*">
|
|
2289
2309
|
<decor>no</decor>
|
|
@@ -2293,6 +2313,14 @@ function buildOpenboxRcXml() {
|
|
|
2293
2313
|
</openbox_config>
|
|
2294
2314
|
`;
|
|
2295
2315
|
}
|
|
2316
|
+
function clampDim(w, h) {
|
|
2317
|
+
const cw = Math.max(240, Math.min(SLOT_W, Math.round(w || 1100)));
|
|
2318
|
+
const ch = Math.max(180, Math.min(SLOT_H, Math.round(h || 680)));
|
|
2319
|
+
return {
|
|
2320
|
+
width: cw - cw % 2,
|
|
2321
|
+
height: ch - ch % 2
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2296
2324
|
var LinuxAppSession = class {
|
|
2297
2325
|
sessionId;
|
|
2298
2326
|
desktopId;
|
|
@@ -2312,17 +2340,14 @@ var LinuxAppSession = class {
|
|
|
2312
2340
|
command;
|
|
2313
2341
|
needsNoSandbox;
|
|
2314
2342
|
tempDir;
|
|
2343
|
+
baseEnv = {};
|
|
2315
2344
|
xvfbProc = null;
|
|
2316
2345
|
openboxProc = null;
|
|
2317
2346
|
appProc = null;
|
|
2318
2347
|
x11BridgeProc = null;
|
|
2319
|
-
streamerProc = null;
|
|
2320
|
-
streamerMode = "xdamage";
|
|
2321
2348
|
parecProc = null;
|
|
2322
2349
|
pulseSinkName = "";
|
|
2323
|
-
|
|
2324
|
-
lastFrame = null;
|
|
2325
|
-
resizeTimer = null;
|
|
2350
|
+
views = /* @__PURE__ */ new Map();
|
|
2326
2351
|
hadWindow = false;
|
|
2327
2352
|
closed = false;
|
|
2328
2353
|
onCloseCb;
|
|
@@ -2337,10 +2362,9 @@ var LinuxAppSession = class {
|
|
|
2337
2362
|
this.desktopDataRoot = opts.desktopDataRoot;
|
|
2338
2363
|
this.displayNum = displayNum;
|
|
2339
2364
|
this.displayStr = `:${displayNum}`;
|
|
2340
|
-
|
|
2341
|
-
this.
|
|
2342
|
-
this.
|
|
2343
|
-
this.height = this.height - this.height % 2;
|
|
2365
|
+
const dims = clampDim(opts.width || 1100, opts.height || 680);
|
|
2366
|
+
this.width = dims.width;
|
|
2367
|
+
this.height = dims.height;
|
|
2344
2368
|
this.fps = Math.max(10, Math.min(30, opts.fps || 24));
|
|
2345
2369
|
this.quality = Math.max(2, Math.min(10, opts.quality || 4));
|
|
2346
2370
|
this.enableAudio = opts.enableAudio ?? true;
|
|
@@ -2349,6 +2373,19 @@ var LinuxAppSession = class {
|
|
|
2349
2373
|
`tamga-gui-${this.sessionId.replace(/[^a-z0-9_-]/gi, "")}`
|
|
2350
2374
|
);
|
|
2351
2375
|
this.onCloseCb = onCloseCb;
|
|
2376
|
+
this.views.set("main", {
|
|
2377
|
+
viewId: "main",
|
|
2378
|
+
title: this.appName,
|
|
2379
|
+
width: this.width,
|
|
2380
|
+
height: this.height,
|
|
2381
|
+
offsetX: 0,
|
|
2382
|
+
offsetY: 0,
|
|
2383
|
+
lastFrame: null,
|
|
2384
|
+
streamerProc: null,
|
|
2385
|
+
streamerMode: "xdamage",
|
|
2386
|
+
resizeTimer: null,
|
|
2387
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
2388
|
+
});
|
|
2352
2389
|
}
|
|
2353
2390
|
async start() {
|
|
2354
2391
|
fs6.mkdirSync(this.tempDir, { recursive: true });
|
|
@@ -2360,7 +2397,7 @@ var LinuxAppSession = class {
|
|
|
2360
2397
|
this.displayStr,
|
|
2361
2398
|
"-screen",
|
|
2362
2399
|
"0",
|
|
2363
|
-
"
|
|
2400
|
+
"3840x2160x24",
|
|
2364
2401
|
"-ac",
|
|
2365
2402
|
"+extension",
|
|
2366
2403
|
"RANDR",
|
|
@@ -2389,6 +2426,8 @@ var LinuxAppSession = class {
|
|
|
2389
2426
|
NO_AT_BRIDGE: "1",
|
|
2390
2427
|
XCURSOR_THEME: "DMZ-White"
|
|
2391
2428
|
};
|
|
2429
|
+
delete baseEnv.DBUS_SESSION_BUS_ADDRESS;
|
|
2430
|
+
this.baseEnv = baseEnv;
|
|
2392
2431
|
this.openboxProc = spawn3("openbox", ["--config-file", obRcPath], {
|
|
2393
2432
|
env: baseEnv,
|
|
2394
2433
|
stdio: "ignore"
|
|
@@ -2398,11 +2437,8 @@ var LinuxAppSession = class {
|
|
|
2398
2437
|
}
|
|
2399
2438
|
this.startX11Bridge(baseEnv);
|
|
2400
2439
|
this.launchTargetApp(baseEnv);
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
} else {
|
|
2404
|
-
this.startFfmpegFallbackCapture();
|
|
2405
|
-
}
|
|
2440
|
+
const mainView = this.views.get("main");
|
|
2441
|
+
this.startViewStreamer(mainView);
|
|
2406
2442
|
}
|
|
2407
2443
|
setupPulseAudio(baseEnv) {
|
|
2408
2444
|
try {
|
|
@@ -2440,7 +2476,9 @@ var LinuxAppSession = class {
|
|
|
2440
2476
|
const CHUNK_BYTES = 2048;
|
|
2441
2477
|
let pcmBuf = Buffer.alloc(0);
|
|
2442
2478
|
parec.stdout?.on("data", (chunk) => {
|
|
2443
|
-
if (this.closed
|
|
2479
|
+
if (this.closed) return;
|
|
2480
|
+
const audioView = this.views.get("main") || this.views.values().next().value;
|
|
2481
|
+
if (!audioView || audioView.subscribers.size === 0) return;
|
|
2444
2482
|
pcmBuf = Buffer.concat([pcmBuf, chunk]);
|
|
2445
2483
|
while (pcmBuf.length >= CHUNK_BYTES) {
|
|
2446
2484
|
const slice = pcmBuf.subarray(0, CHUNK_BYTES);
|
|
@@ -2452,7 +2490,7 @@ var LinuxAppSession = class {
|
|
|
2452
2490
|
if (peak > 45) break;
|
|
2453
2491
|
}
|
|
2454
2492
|
if (peak > 45) {
|
|
2455
|
-
for (const sub of
|
|
2493
|
+
for (const sub of audioView.subscribers) {
|
|
2456
2494
|
sub.onAudioChunk(slice);
|
|
2457
2495
|
}
|
|
2458
2496
|
}
|
|
@@ -2461,6 +2499,14 @@ var LinuxAppSession = class {
|
|
|
2461
2499
|
} catch {
|
|
2462
2500
|
}
|
|
2463
2501
|
}
|
|
2502
|
+
getEventHostView() {
|
|
2503
|
+
const main2 = this.views.get("main");
|
|
2504
|
+
if (main2 && main2.subscribers.size > 0) return main2;
|
|
2505
|
+
for (const v of this.views.values()) {
|
|
2506
|
+
if (v.subscribers.size > 0) return v;
|
|
2507
|
+
}
|
|
2508
|
+
return main2;
|
|
2509
|
+
}
|
|
2464
2510
|
startX11Bridge(baseEnv) {
|
|
2465
2511
|
const scriptPath = resolveHelperPath("x11_bridge.py");
|
|
2466
2512
|
const proc = spawn3(
|
|
@@ -2482,21 +2528,7 @@ var LinuxAppSession = class {
|
|
|
2482
2528
|
if (line) {
|
|
2483
2529
|
try {
|
|
2484
2530
|
const msg = JSON.parse(line);
|
|
2485
|
-
|
|
2486
|
-
this.hadWindow = true;
|
|
2487
|
-
this.title = msg.title;
|
|
2488
|
-
} else if (msg.type === "cursor" && typeof msg.cursor === "string") {
|
|
2489
|
-
this.cursor = msg.cursor;
|
|
2490
|
-
} else if (msg.type === "all_windows_closed" && !this.closed) {
|
|
2491
|
-
for (const sub of this.subscribers) {
|
|
2492
|
-
sub.onEvent({ type: "app_exit", code: 0 });
|
|
2493
|
-
}
|
|
2494
|
-
this.close();
|
|
2495
|
-
return;
|
|
2496
|
-
}
|
|
2497
|
-
for (const sub of this.subscribers) {
|
|
2498
|
-
sub.onEvent(msg);
|
|
2499
|
-
}
|
|
2531
|
+
this.handleBridgeEvent(msg);
|
|
2500
2532
|
} catch {
|
|
2501
2533
|
}
|
|
2502
2534
|
}
|
|
@@ -2504,13 +2536,128 @@ var LinuxAppSession = class {
|
|
|
2504
2536
|
}
|
|
2505
2537
|
});
|
|
2506
2538
|
}
|
|
2507
|
-
|
|
2539
|
+
handleBridgeEvent(msg) {
|
|
2540
|
+
if (this.closed) return;
|
|
2541
|
+
if (msg.type === "title" && typeof msg.title === "string") {
|
|
2542
|
+
this.hadWindow = true;
|
|
2543
|
+
const vid = typeof msg.view === "string" ? msg.view : "main";
|
|
2544
|
+
const v = this.views.get(vid);
|
|
2545
|
+
if (v) {
|
|
2546
|
+
v.title = msg.title;
|
|
2547
|
+
for (const sub of v.subscribers) {
|
|
2548
|
+
sub.onEvent({ type: "title", title: msg.title });
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
if (vid === "main") this.title = msg.title;
|
|
2552
|
+
return;
|
|
2553
|
+
}
|
|
2554
|
+
if (msg.type === "cursor" && typeof msg.cursor === "string") {
|
|
2555
|
+
this.cursor = msg.cursor;
|
|
2556
|
+
for (const v of this.views.values()) {
|
|
2557
|
+
for (const sub of v.subscribers) {
|
|
2558
|
+
sub.onEvent(msg);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
if (msg.type === "window_opened" && typeof msg.view === "string") {
|
|
2564
|
+
this.hadWindow = true;
|
|
2565
|
+
const slot = Math.max(0, Math.min(3, Number(msg.slot) || 1));
|
|
2566
|
+
const dims = clampDim(Number(msg.width) || 900, Number(msg.height) || 640);
|
|
2567
|
+
const offsetX = slot % SLOT_COLS * SLOT_W;
|
|
2568
|
+
const offsetY = Math.floor(slot / SLOT_COLS) * SLOT_H;
|
|
2569
|
+
const title = typeof msg.title === "string" && msg.title ? msg.title : this.appName;
|
|
2570
|
+
if (!this.views.has(msg.view)) {
|
|
2571
|
+
const view = {
|
|
2572
|
+
viewId: msg.view,
|
|
2573
|
+
title,
|
|
2574
|
+
width: dims.width,
|
|
2575
|
+
height: dims.height,
|
|
2576
|
+
offsetX,
|
|
2577
|
+
offsetY,
|
|
2578
|
+
lastFrame: null,
|
|
2579
|
+
streamerProc: null,
|
|
2580
|
+
streamerMode: "xdamage",
|
|
2581
|
+
resizeTimer: null,
|
|
2582
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
2583
|
+
};
|
|
2584
|
+
this.views.set(msg.view, view);
|
|
2585
|
+
this.startViewStreamer(view);
|
|
2586
|
+
}
|
|
2587
|
+
const hostView2 = this.getEventHostView();
|
|
2588
|
+
if (hostView2) {
|
|
2589
|
+
for (const sub of hostView2.subscribers) {
|
|
2590
|
+
sub.onEvent({
|
|
2591
|
+
type: "window_opened",
|
|
2592
|
+
view: msg.view,
|
|
2593
|
+
title,
|
|
2594
|
+
width: dims.width,
|
|
2595
|
+
height: dims.height
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
if (msg.type === "view_geometry" && typeof msg.view === "string") {
|
|
2602
|
+
const v = this.views.get(msg.view);
|
|
2603
|
+
if (!v) return;
|
|
2604
|
+
const dims = clampDim(Number(msg.width) || v.width, Number(msg.height) || v.height);
|
|
2605
|
+
v.width = dims.width;
|
|
2606
|
+
v.height = dims.height;
|
|
2607
|
+
if (v.viewId === "main") {
|
|
2608
|
+
this.width = dims.width;
|
|
2609
|
+
this.height = dims.height;
|
|
2610
|
+
}
|
|
2611
|
+
this.resizeViewCapture(v, dims.width, dims.height);
|
|
2612
|
+
for (const sub of v.subscribers) {
|
|
2613
|
+
sub.onEvent({ type: "view_geometry", width: dims.width, height: dims.height });
|
|
2614
|
+
}
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
if (msg.type === "view_maximize" && typeof msg.view === "string") {
|
|
2618
|
+
const v = this.views.get(msg.view);
|
|
2619
|
+
if (!v) return;
|
|
2620
|
+
for (const sub of v.subscribers) {
|
|
2621
|
+
sub.onEvent({ type: "view_maximize" });
|
|
2622
|
+
}
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
if (msg.type === "view_closed" && typeof msg.view === "string") {
|
|
2626
|
+
const v = this.views.get(msg.view);
|
|
2627
|
+
if (!v) return;
|
|
2628
|
+
for (const sub of v.subscribers) {
|
|
2629
|
+
sub.onEvent({ type: "app_exit", code: 0 });
|
|
2630
|
+
}
|
|
2631
|
+
this.destroyView(v);
|
|
2632
|
+
return;
|
|
2633
|
+
}
|
|
2634
|
+
if (msg.type === "all_windows_closed") {
|
|
2635
|
+
for (const v of this.views.values()) {
|
|
2636
|
+
for (const sub of v.subscribers) {
|
|
2637
|
+
sub.onEvent({ type: "app_exit", code: 0 });
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
this.close();
|
|
2641
|
+
return;
|
|
2642
|
+
}
|
|
2643
|
+
const hostView = this.getEventHostView();
|
|
2644
|
+
if (hostView) {
|
|
2645
|
+
for (const sub of hostView.subscribers) {
|
|
2646
|
+
sub.onEvent(msg);
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
getProfileDir() {
|
|
2508
2651
|
const profileDir = path6.join(
|
|
2509
2652
|
this.desktopDataRoot,
|
|
2510
2653
|
"app-profiles",
|
|
2511
2654
|
this.appId.replace(/[^a-z0-9_-]/gi, "_")
|
|
2512
2655
|
);
|
|
2513
2656
|
fs6.mkdirSync(profileDir, { recursive: true });
|
|
2657
|
+
return profileDir;
|
|
2658
|
+
}
|
|
2659
|
+
buildLaunchCommand(extraNewWindow = false) {
|
|
2660
|
+
const profileDir = this.getProfileDir();
|
|
2514
2661
|
const desktopFilesDir = path6.join(this.desktopDataRoot, "vfs", "Desktop");
|
|
2515
2662
|
fs6.mkdirSync(desktopFilesDir, { recursive: true });
|
|
2516
2663
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -2534,6 +2681,8 @@ var LinuxAppSession = class {
|
|
|
2534
2681
|
'user_pref("toolkit.cosmeticAnimations.enabled", false);',
|
|
2535
2682
|
'user_pref("ui.prefersReducedMotion", 1);',
|
|
2536
2683
|
'user_pref("dom.ipc.processCount", 2);',
|
|
2684
|
+
'user_pref("dom.disable_window_move_resize", false);',
|
|
2685
|
+
'user_pref("browser.link.open_newwindow.restriction", 0);',
|
|
2537
2686
|
'user_pref("browser.sessionstore.interval", 60000);',
|
|
2538
2687
|
'user_pref("browser.newtabpage.activity-stream.feeds.topsites", false);',
|
|
2539
2688
|
'user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);',
|
|
@@ -2544,7 +2693,7 @@ var LinuxAppSession = class {
|
|
|
2544
2693
|
].join("\n") + "\n",
|
|
2545
2694
|
"utf-8"
|
|
2546
2695
|
);
|
|
2547
|
-
finalCmd = `${finalCmd} --
|
|
2696
|
+
finalCmd = extraNewWindow ? `${finalCmd} -profile "${profileDir}" --new-window about:home` : `${finalCmd} -profile "${profileDir}" --width=${this.width} --height=${this.height}`;
|
|
2548
2697
|
} else if (this.needsNoSandbox || ["code", "antigravity", "chromium", "chromium-browser", "google-chrome", "google-chrome-stable"].includes(baseBin)) {
|
|
2549
2698
|
const extraFlags = [];
|
|
2550
2699
|
if (isRoot && !finalCmd.includes("--no-sandbox")) {
|
|
@@ -2559,10 +2708,19 @@ var LinuxAppSession = class {
|
|
|
2559
2708
|
if ((baseBin === "code" || baseBin === "antigravity") && !finalCmd.includes("--verbose")) {
|
|
2560
2709
|
extraFlags.push("--verbose");
|
|
2561
2710
|
}
|
|
2711
|
+
if (extraNewWindow && !finalCmd.includes("--new-window")) {
|
|
2712
|
+
extraFlags.push("--new-window");
|
|
2713
|
+
}
|
|
2562
2714
|
finalCmd = `${finalCmd} ${extraFlags.join(" ")}`;
|
|
2715
|
+
} else if (extraNewWindow && baseBin === "gimp") {
|
|
2716
|
+
finalCmd = `${finalCmd} -n`;
|
|
2563
2717
|
}
|
|
2564
|
-
|
|
2565
|
-
|
|
2718
|
+
return { cmd: finalCmd, cwd: desktopFilesDir };
|
|
2719
|
+
}
|
|
2720
|
+
launchTargetApp(baseEnv) {
|
|
2721
|
+
const { cmd, cwd } = this.buildLaunchCommand(false);
|
|
2722
|
+
this.appProc = spawn3("/bin/bash", ["-c", `exec ${cmd}`], {
|
|
2723
|
+
cwd,
|
|
2566
2724
|
env: {
|
|
2567
2725
|
...baseEnv,
|
|
2568
2726
|
HOME: baseEnv.HOME || os4.homedir(),
|
|
@@ -2576,7 +2734,7 @@ var LinuxAppSession = class {
|
|
|
2576
2734
|
setTimeout(() => {
|
|
2577
2735
|
if (this.closed) return;
|
|
2578
2736
|
try {
|
|
2579
|
-
const out = execSync2(
|
|
2737
|
+
const out = execSync2("wmctrl -l", {
|
|
2580
2738
|
env: { ...process.env, DISPLAY: this.displayStr },
|
|
2581
2739
|
stdio: ["ignore", "pipe", "ignore"],
|
|
2582
2740
|
timeout: 1200
|
|
@@ -2588,16 +2746,40 @@ var LinuxAppSession = class {
|
|
|
2588
2746
|
} catch {
|
|
2589
2747
|
}
|
|
2590
2748
|
if (!this.hadWindow || code !== 0) {
|
|
2591
|
-
for (const
|
|
2592
|
-
|
|
2749
|
+
for (const v of this.views.values()) {
|
|
2750
|
+
for (const sub of v.subscribers) {
|
|
2751
|
+
sub.onEvent({ type: "app_exit", code: code ?? 0 });
|
|
2752
|
+
}
|
|
2593
2753
|
}
|
|
2594
2754
|
this.close();
|
|
2595
2755
|
}
|
|
2596
2756
|
}, 1500);
|
|
2597
2757
|
});
|
|
2598
2758
|
}
|
|
2599
|
-
|
|
2600
|
-
this.
|
|
2759
|
+
spawnExtraWindow(customCommand) {
|
|
2760
|
+
if (this.closed) return;
|
|
2761
|
+
const { cmd, cwd } = customCommand ? { cmd: customCommand, cwd: path6.join(this.desktopDataRoot, "vfs", "Desktop") } : this.buildLaunchCommand(true);
|
|
2762
|
+
const child = spawn3("/bin/bash", ["-c", cmd], {
|
|
2763
|
+
cwd,
|
|
2764
|
+
detached: true,
|
|
2765
|
+
env: {
|
|
2766
|
+
...this.baseEnv,
|
|
2767
|
+
HOME: this.baseEnv.HOME || os4.homedir(),
|
|
2768
|
+
DONT_PROMPT_WSL_INSTALL: "1"
|
|
2769
|
+
},
|
|
2770
|
+
stdio: "ignore"
|
|
2771
|
+
});
|
|
2772
|
+
child.unref();
|
|
2773
|
+
}
|
|
2774
|
+
startViewStreamer(view) {
|
|
2775
|
+
if (hasTurboJpegAndXDamage()) {
|
|
2776
|
+
this.startViewXDamageStreamer(view);
|
|
2777
|
+
} else {
|
|
2778
|
+
this.startViewFfmpegCapture(view);
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
startViewXDamageStreamer(view) {
|
|
2782
|
+
view.streamerMode = "xdamage";
|
|
2601
2783
|
const scriptPath = resolveHelperPath("x11_streamer.py");
|
|
2602
2784
|
const jpegQual = Math.max(60, Math.min(88, 92 - this.quality * 4));
|
|
2603
2785
|
const proc = spawn3(
|
|
@@ -2606,20 +2788,26 @@ var LinuxAppSession = class {
|
|
|
2606
2788
|
"-u",
|
|
2607
2789
|
scriptPath,
|
|
2608
2790
|
this.displayStr,
|
|
2609
|
-
String(
|
|
2610
|
-
String(
|
|
2791
|
+
String(view.width),
|
|
2792
|
+
String(view.height),
|
|
2611
2793
|
String(this.fps),
|
|
2612
|
-
String(jpegQual)
|
|
2794
|
+
String(jpegQual),
|
|
2795
|
+
String(view.offsetX),
|
|
2796
|
+
String(view.offsetY)
|
|
2613
2797
|
],
|
|
2614
2798
|
{
|
|
2615
|
-
env: baseEnv,
|
|
2616
|
-
stdio: ["pipe", "pipe", "
|
|
2799
|
+
env: this.baseEnv,
|
|
2800
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2617
2801
|
}
|
|
2618
2802
|
);
|
|
2619
|
-
|
|
2803
|
+
view.streamerProc = proc;
|
|
2804
|
+
proc.stderr?.on("data", (err) => {
|
|
2805
|
+
const msg = err.toString("utf-8").trim();
|
|
2806
|
+
if (msg) console.error(`[x11_streamer ${this.displayStr}/${view.viewId}]`, msg);
|
|
2807
|
+
});
|
|
2620
2808
|
let acc = Buffer.alloc(0);
|
|
2621
2809
|
proc.stdout?.on("data", (chunk) => {
|
|
2622
|
-
if (this.closed) return;
|
|
2810
|
+
if (this.closed || !this.views.has(view.viewId)) return;
|
|
2623
2811
|
acc = Buffer.concat([acc, chunk]);
|
|
2624
2812
|
while (acc.length >= 4) {
|
|
2625
2813
|
const frameLen = acc.readUInt32BE(0);
|
|
@@ -2632,8 +2820,8 @@ var LinuxAppSession = class {
|
|
|
2632
2820
|
}
|
|
2633
2821
|
const frame = Buffer.from(acc.subarray(4, 4 + frameLen));
|
|
2634
2822
|
acc = acc.subarray(4 + frameLen);
|
|
2635
|
-
|
|
2636
|
-
if (
|
|
2823
|
+
view.lastFrame = frame;
|
|
2824
|
+
if (view.subscribers.size === 0) {
|
|
2637
2825
|
if (proc.stdin?.writable) proc.stdin.write("a\n");
|
|
2638
2826
|
continue;
|
|
2639
2827
|
}
|
|
@@ -2646,27 +2834,27 @@ var LinuxAppSession = class {
|
|
|
2646
2834
|
}
|
|
2647
2835
|
}
|
|
2648
2836
|
};
|
|
2649
|
-
for (const sub of
|
|
2837
|
+
for (const sub of view.subscribers) {
|
|
2650
2838
|
sub.onVideoFrame(frame, sendAckOnce);
|
|
2651
2839
|
}
|
|
2652
2840
|
setTimeout(sendAckOnce, 180).unref();
|
|
2653
2841
|
}
|
|
2654
2842
|
});
|
|
2655
2843
|
proc.on("exit", (code) => {
|
|
2656
|
-
if (!this.closed && code !== 0) {
|
|
2657
|
-
this.
|
|
2844
|
+
if (!this.closed && this.views.has(view.viewId) && code !== 0 && view.streamerProc === proc) {
|
|
2845
|
+
this.startViewFfmpegCapture(view);
|
|
2658
2846
|
}
|
|
2659
2847
|
});
|
|
2660
2848
|
}
|
|
2661
|
-
|
|
2662
|
-
if (this.closed) return;
|
|
2663
|
-
|
|
2664
|
-
if (
|
|
2849
|
+
startViewFfmpegCapture(view) {
|
|
2850
|
+
if (this.closed || !this.views.has(view.viewId)) return;
|
|
2851
|
+
view.streamerMode = "ffmpeg";
|
|
2852
|
+
if (view.streamerProc) {
|
|
2665
2853
|
try {
|
|
2666
|
-
|
|
2854
|
+
view.streamerProc.kill("SIGTERM");
|
|
2667
2855
|
} catch {
|
|
2668
2856
|
}
|
|
2669
|
-
|
|
2857
|
+
view.streamerProc = null;
|
|
2670
2858
|
}
|
|
2671
2859
|
const args = [
|
|
2672
2860
|
"-loglevel",
|
|
@@ -2680,11 +2868,11 @@ var LinuxAppSession = class {
|
|
|
2680
2868
|
"-draw_mouse",
|
|
2681
2869
|
"0",
|
|
2682
2870
|
"-video_size",
|
|
2683
|
-
`${
|
|
2871
|
+
`${view.width}x${view.height}`,
|
|
2684
2872
|
"-framerate",
|
|
2685
2873
|
String(Math.min(15, this.fps)),
|
|
2686
2874
|
"-i",
|
|
2687
|
-
`${this.displayStr}.0
|
|
2875
|
+
`${this.displayStr}.0+${view.offsetX},${view.offsetY}`,
|
|
2688
2876
|
"-f",
|
|
2689
2877
|
"image2pipe",
|
|
2690
2878
|
"-vcodec",
|
|
@@ -2696,12 +2884,12 @@ var LinuxAppSession = class {
|
|
|
2696
2884
|
"-"
|
|
2697
2885
|
];
|
|
2698
2886
|
const ff = spawn3("ffmpeg", args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
2699
|
-
|
|
2887
|
+
view.streamerProc = ff;
|
|
2700
2888
|
let acc = Buffer.alloc(0);
|
|
2701
2889
|
const SOI = Buffer.from([255, 216]);
|
|
2702
2890
|
const EOI = Buffer.from([255, 217]);
|
|
2703
2891
|
ff.stdout?.on("data", (chunk) => {
|
|
2704
|
-
if (this.closed) return;
|
|
2892
|
+
if (this.closed || !this.views.has(view.viewId)) return;
|
|
2705
2893
|
acc = Buffer.concat([acc, chunk]);
|
|
2706
2894
|
if (acc.length > 4 * 1024 * 1024) {
|
|
2707
2895
|
acc = acc.subarray(acc.length - 512 * 1024);
|
|
@@ -2719,63 +2907,99 @@ var LinuxAppSession = class {
|
|
|
2719
2907
|
}
|
|
2720
2908
|
const frame = Buffer.from(acc.subarray(start, end + 2));
|
|
2721
2909
|
acc = acc.subarray(end + 2);
|
|
2722
|
-
if (
|
|
2910
|
+
if (view.lastFrame && view.lastFrame.length === frame.length && view.lastFrame.equals(frame)) {
|
|
2723
2911
|
continue;
|
|
2724
2912
|
}
|
|
2725
|
-
|
|
2726
|
-
for (const sub of
|
|
2913
|
+
view.lastFrame = frame;
|
|
2914
|
+
for (const sub of view.subscribers) {
|
|
2727
2915
|
sub.onVideoFrame(frame);
|
|
2728
2916
|
}
|
|
2729
2917
|
}
|
|
2730
2918
|
});
|
|
2731
2919
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2920
|
+
resizeViewCapture(view, evenW, evenH) {
|
|
2921
|
+
if (view.streamerMode === "xdamage" && view.streamerProc?.stdin?.writable) {
|
|
2922
|
+
view.streamerProc.stdin.write(
|
|
2923
|
+
JSON.stringify({ type: "resize", width: evenW, height: evenH }) + "\n"
|
|
2924
|
+
);
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2927
|
+
if (view.resizeTimer) clearTimeout(view.resizeTimer);
|
|
2928
|
+
view.resizeTimer = setTimeout(() => {
|
|
2929
|
+
if (!this.closed && this.views.has(view.viewId) && view.streamerMode === "ffmpeg") {
|
|
2930
|
+
view.lastFrame = null;
|
|
2931
|
+
this.startViewFfmpegCapture(view);
|
|
2932
|
+
}
|
|
2933
|
+
}, 160);
|
|
2934
|
+
}
|
|
2935
|
+
destroyView(view) {
|
|
2936
|
+
this.views.delete(view.viewId);
|
|
2937
|
+
if (view.resizeTimer) clearTimeout(view.resizeTimer);
|
|
2938
|
+
if (view.streamerProc) {
|
|
2939
|
+
try {
|
|
2940
|
+
view.streamerProc.kill("SIGTERM");
|
|
2941
|
+
} catch {
|
|
2942
|
+
}
|
|
2943
|
+
view.streamerProc = null;
|
|
2944
|
+
}
|
|
2945
|
+
view.subscribers.clear();
|
|
2946
|
+
}
|
|
2947
|
+
subscribeView(viewId, sub) {
|
|
2948
|
+
const view = this.views.get(viewId || "main") || this.views.get("main");
|
|
2949
|
+
if (!view) {
|
|
2950
|
+
sub.onEvent({ type: "app_exit", code: 0 });
|
|
2951
|
+
return () => {
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
view.subscribers.add(sub);
|
|
2955
|
+
sub.onEvent({ type: "title", title: view.title });
|
|
2735
2956
|
sub.onEvent({ type: "cursor", cursor: this.cursor });
|
|
2736
|
-
if (
|
|
2737
|
-
sub.onVideoFrame(
|
|
2738
|
-
} else if (
|
|
2739
|
-
|
|
2957
|
+
if (view.lastFrame) {
|
|
2958
|
+
sub.onVideoFrame(view.lastFrame);
|
|
2959
|
+
} else if (view.streamerMode === "xdamage" && view.streamerProc?.stdin?.writable) {
|
|
2960
|
+
view.streamerProc.stdin.write(JSON.stringify({ type: "refresh" }) + "\n");
|
|
2740
2961
|
}
|
|
2741
2962
|
return () => {
|
|
2742
|
-
|
|
2963
|
+
view.subscribers.delete(sub);
|
|
2743
2964
|
};
|
|
2744
2965
|
}
|
|
2745
|
-
sendInput(msg) {
|
|
2966
|
+
sendInput(msg, viewId = "main") {
|
|
2746
2967
|
if (this.closed || !this.x11BridgeProc?.stdin?.writable) return;
|
|
2747
|
-
this.x11BridgeProc.stdin.write(JSON.stringify(msg) + "\n");
|
|
2968
|
+
this.x11BridgeProc.stdin.write(JSON.stringify({ ...msg, view: msg.view || viewId }) + "\n");
|
|
2748
2969
|
}
|
|
2749
|
-
|
|
2970
|
+
resizeView(viewId, width, height) {
|
|
2750
2971
|
if (this.closed) return;
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2753
|
-
const
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2972
|
+
const view = this.views.get(viewId || "main");
|
|
2973
|
+
if (!view) return;
|
|
2974
|
+
const dims = clampDim(width, height);
|
|
2975
|
+
if (Math.abs(dims.width - view.width) < 4 && Math.abs(dims.height - view.height) < 4) return;
|
|
2976
|
+
view.width = dims.width;
|
|
2977
|
+
view.height = dims.height;
|
|
2978
|
+
if (view.viewId === "main") {
|
|
2979
|
+
this.width = dims.width;
|
|
2980
|
+
this.height = dims.height;
|
|
2981
|
+
}
|
|
2982
|
+
this.sendInput({ type: "resize", width: dims.width, height: dims.height }, view.viewId);
|
|
2983
|
+
this.resizeViewCapture(view, dims.width, dims.height);
|
|
2984
|
+
}
|
|
2985
|
+
focusView(viewId) {
|
|
2986
|
+
this.sendInput({ type: "focus_view" }, viewId || "main");
|
|
2987
|
+
}
|
|
2988
|
+
closeView(viewId) {
|
|
2989
|
+
if (this.closed) return;
|
|
2990
|
+
if (!viewId || this.views.size <= 1) {
|
|
2991
|
+
this.close();
|
|
2763
2992
|
return;
|
|
2764
2993
|
}
|
|
2765
|
-
|
|
2766
|
-
this.resizeTimer = setTimeout(() => {
|
|
2767
|
-
if (!this.closed && this.streamerMode === "ffmpeg") {
|
|
2768
|
-
this.lastFrame = null;
|
|
2769
|
-
this.startFfmpegFallbackCapture();
|
|
2770
|
-
}
|
|
2771
|
-
}, 160);
|
|
2994
|
+
this.sendInput({ type: "close_view" }, viewId);
|
|
2772
2995
|
}
|
|
2773
2996
|
close() {
|
|
2774
2997
|
if (this.closed) return;
|
|
2775
2998
|
this.closed = true;
|
|
2776
|
-
|
|
2999
|
+
for (const v of Array.from(this.views.values())) {
|
|
3000
|
+
this.destroyView(v);
|
|
3001
|
+
}
|
|
2777
3002
|
const procs = [
|
|
2778
|
-
this.streamerProc,
|
|
2779
3003
|
this.parecProc,
|
|
2780
3004
|
this.x11BridgeProc,
|
|
2781
3005
|
this.appProc,
|
|
@@ -2813,16 +3037,35 @@ var LinuxAppSession = class {
|
|
|
2813
3037
|
} catch {
|
|
2814
3038
|
}
|
|
2815
3039
|
}
|
|
2816
|
-
this.subscribers.clear();
|
|
2817
3040
|
this.onCloseCb();
|
|
2818
3041
|
}
|
|
2819
3042
|
};
|
|
2820
3043
|
var LinuxDisplayBridge = class {
|
|
2821
3044
|
sessions = /* @__PURE__ */ new Map();
|
|
2822
3045
|
usedDisplays = /* @__PURE__ */ new Set();
|
|
3046
|
+
findActiveProfileSession(desktopId, appId, command) {
|
|
3047
|
+
const baseBin = path6.basename(command.split(/\s+/)[0] || "");
|
|
3048
|
+
const isLocked = PROFILE_LOCKED_APPS.has(appId) || PROFILE_LOCKED_APPS.has(baseBin);
|
|
3049
|
+
if (!isLocked) return void 0;
|
|
3050
|
+
for (const s of this.sessions.values()) {
|
|
3051
|
+
if (s.desktopId === desktopId && (s.appId === appId || path6.basename(s.appId) === baseBin)) {
|
|
3052
|
+
return s;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
return void 0;
|
|
3056
|
+
}
|
|
2823
3057
|
async launchApp(opts) {
|
|
2824
|
-
const
|
|
2825
|
-
if (
|
|
3058
|
+
const existingById = this.sessions.get(opts.sessionId);
|
|
3059
|
+
if (existingById) return { session: existingById, openedAsExtraWindow: false };
|
|
3060
|
+
const existingProfileSession = this.findActiveProfileSession(
|
|
3061
|
+
opts.desktopId,
|
|
3062
|
+
opts.appId,
|
|
3063
|
+
opts.command
|
|
3064
|
+
);
|
|
3065
|
+
if (existingProfileSession) {
|
|
3066
|
+
existingProfileSession.spawnExtraWindow();
|
|
3067
|
+
return { session: existingProfileSession, openedAsExtraWindow: true };
|
|
3068
|
+
}
|
|
2826
3069
|
const displayNum = findFreeDisplay(this.usedDisplays);
|
|
2827
3070
|
this.usedDisplays.add(displayNum);
|
|
2828
3071
|
const session = new LinuxAppSession(opts, displayNum, () => {
|
|
@@ -2831,7 +3074,7 @@ var LinuxDisplayBridge = class {
|
|
|
2831
3074
|
});
|
|
2832
3075
|
this.sessions.set(opts.sessionId, session);
|
|
2833
3076
|
await session.start();
|
|
2834
|
-
return session;
|
|
3077
|
+
return { session, openedAsExtraWindow: false };
|
|
2835
3078
|
}
|
|
2836
3079
|
getSession(sessionId) {
|
|
2837
3080
|
return this.sessions.get(sessionId);
|
|
@@ -2847,9 +3090,14 @@ var LinuxDisplayBridge = class {
|
|
|
2847
3090
|
height: s.height
|
|
2848
3091
|
}));
|
|
2849
3092
|
}
|
|
2850
|
-
closeSession(sessionId) {
|
|
3093
|
+
closeSession(sessionId, viewId) {
|
|
2851
3094
|
const s = this.sessions.get(sessionId);
|
|
2852
|
-
if (s)
|
|
3095
|
+
if (!s) return;
|
|
3096
|
+
if (viewId) {
|
|
3097
|
+
s.closeView(viewId);
|
|
3098
|
+
} else {
|
|
3099
|
+
s.close();
|
|
3100
|
+
}
|
|
2853
3101
|
}
|
|
2854
3102
|
destroyDesktopSessions(desktopId) {
|
|
2855
3103
|
for (const s of Array.from(this.sessions.values())) {
|
|
@@ -3018,12 +3266,38 @@ var VSCodeServerManager = class {
|
|
|
3018
3266
|
});
|
|
3019
3267
|
});
|
|
3020
3268
|
}
|
|
3269
|
+
patchWorkbenchHtml(html, tamgaTheme) {
|
|
3270
|
+
return html.replace(
|
|
3271
|
+
/(<meta\s+id=["']vscode-workbench-web-configuration["']\s+data-settings=["'])([^"']+)(["'])/i,
|
|
3272
|
+
(full, prefix, encoded, suffix) => {
|
|
3273
|
+
try {
|
|
3274
|
+
const decoded = encoded.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3275
|
+
const cfg = JSON.parse(decoded);
|
|
3276
|
+
cfg.enableWorkspaceTrust = false;
|
|
3277
|
+
const prevDefaults = typeof cfg.configurationDefaults === "object" && cfg.configurationDefaults ? cfg.configurationDefaults : {};
|
|
3278
|
+
cfg.configurationDefaults = {
|
|
3279
|
+
...prevDefaults,
|
|
3280
|
+
"security.workspace.trust.enabled": false,
|
|
3281
|
+
"workbench.startupEditor": "none",
|
|
3282
|
+
"window.confirmBeforeClose": "never",
|
|
3283
|
+
"window.autoDetectColorScheme": false,
|
|
3284
|
+
"workbench.colorTheme": tamgaTheme === "light" ? "Default Light Modern" : "Default Dark Modern"
|
|
3285
|
+
};
|
|
3286
|
+
const reEncoded = JSON.stringify(cfg).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
3287
|
+
return `${prefix}${reEncoded}${suffix}`;
|
|
3288
|
+
} catch {
|
|
3289
|
+
return full;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
);
|
|
3293
|
+
}
|
|
3021
3294
|
proxyHttp = (req, res) => {
|
|
3022
3295
|
if (!this.ready) {
|
|
3023
3296
|
res.status(503).send("VS Code haz\u0131rlan\u0131yor...");
|
|
3024
3297
|
return;
|
|
3025
3298
|
}
|
|
3026
3299
|
const acceptGzip = String(req.headers["accept-encoding"] || "").includes("gzip");
|
|
3300
|
+
const tamgaTheme = String(req.query?.tamgaTheme || "dark");
|
|
3027
3301
|
const headers = { ...req.headers };
|
|
3028
3302
|
const upstream = http.request(
|
|
3029
3303
|
{
|
|
@@ -3047,6 +3321,31 @@ var VSCodeServerManager = class {
|
|
|
3047
3321
|
);
|
|
3048
3322
|
}
|
|
3049
3323
|
const ctype = String(outHeaders["content-type"] || "").toLowerCase();
|
|
3324
|
+
if (req.method !== "HEAD" && ctype.includes("text/html") && !outHeaders["content-encoding"]) {
|
|
3325
|
+
const chunks = [];
|
|
3326
|
+
upRes.on("data", (chunk) => chunks.push(chunk));
|
|
3327
|
+
upRes.on("end", () => {
|
|
3328
|
+
const rawHtml = Buffer.concat(chunks).toString("utf-8");
|
|
3329
|
+
const patched = Buffer.from(this.patchWorkbenchHtml(rawHtml, tamgaTheme), "utf-8");
|
|
3330
|
+
if (acceptGzip) {
|
|
3331
|
+
delete outHeaders["content-length"];
|
|
3332
|
+
outHeaders["content-encoding"] = "gzip";
|
|
3333
|
+
res.writeHead(upRes.statusCode || 200, outHeaders);
|
|
3334
|
+
zlib.gzip(patched, { level: 1 }, (err, gzBuf) => {
|
|
3335
|
+
if (err) res.end(patched);
|
|
3336
|
+
else res.end(gzBuf);
|
|
3337
|
+
});
|
|
3338
|
+
} else {
|
|
3339
|
+
outHeaders["content-length"] = String(patched.length);
|
|
3340
|
+
res.writeHead(upRes.statusCode || 200, outHeaders);
|
|
3341
|
+
res.end(patched);
|
|
3342
|
+
}
|
|
3343
|
+
});
|
|
3344
|
+
upRes.on("error", () => {
|
|
3345
|
+
if (!res.headersSent) res.status(502).end("VS Code yan\u0131t hatas\u0131");
|
|
3346
|
+
});
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3050
3349
|
const shouldGzip = acceptGzip && req.method !== "HEAD" && !outHeaders["content-encoding"] && /(javascript|css|json|html|svg|wasm|xml|text\/plain)/.test(ctype);
|
|
3051
3350
|
if (shouldGzip) {
|
|
3052
3351
|
delete outHeaders["content-length"];
|
|
@@ -3102,7 +3401,7 @@ var VSCodeServerManager = class {
|
|
|
3102
3401
|
};
|
|
3103
3402
|
|
|
3104
3403
|
// server/index.ts
|
|
3105
|
-
var TAMGA_VERSION = "1.1.
|
|
3404
|
+
var TAMGA_VERSION = "1.1.5";
|
|
3106
3405
|
var MIME_MAP = {
|
|
3107
3406
|
html: "text/html; charset=utf-8",
|
|
3108
3407
|
htm: "text/html; charset=utf-8",
|
|
@@ -3353,7 +3652,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
3353
3652
|
return;
|
|
3354
3653
|
}
|
|
3355
3654
|
const sessionId = String(req.body?.sessionId || "") || `app-${appId}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
3356
|
-
const session = await linuxDisplayBridge.launchApp({
|
|
3655
|
+
const { session, openedAsExtraWindow } = await linuxDisplayBridge.launchApp({
|
|
3357
3656
|
sessionId,
|
|
3358
3657
|
desktopId,
|
|
3359
3658
|
appId,
|
|
@@ -3373,7 +3672,8 @@ async function startTamgaServer(opts = {}) {
|
|
|
3373
3672
|
appName: session.appName,
|
|
3374
3673
|
title: session.title,
|
|
3375
3674
|
width: session.width,
|
|
3376
|
-
height: session.height
|
|
3675
|
+
height: session.height,
|
|
3676
|
+
openedAsExtraWindow
|
|
3377
3677
|
});
|
|
3378
3678
|
} catch (e) {
|
|
3379
3679
|
res.status(400).json({ error: e.message });
|
|
@@ -3381,7 +3681,8 @@ async function startTamgaServer(opts = {}) {
|
|
|
3381
3681
|
});
|
|
3382
3682
|
app.post("/api/apps/close", (req, res) => {
|
|
3383
3683
|
const sessionId = String(req.body?.sessionId || "");
|
|
3384
|
-
|
|
3684
|
+
const viewId = req.body?.viewId ? String(req.body.viewId) : void 0;
|
|
3685
|
+
if (sessionId) linuxDisplayBridge.closeSession(sessionId, viewId);
|
|
3385
3686
|
res.json({ ok: true });
|
|
3386
3687
|
});
|
|
3387
3688
|
app.post("/api/apps/install", (req, res) => {
|
|
@@ -3415,10 +3716,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3415
3716
|
const { vfs } = getDesktopContext(desktopId);
|
|
3416
3717
|
await vscodeManager.ensureStarted();
|
|
3417
3718
|
const targetVPath = String(req.body?.folderPath || "/Projects");
|
|
3719
|
+
const theme = req.body?.theme === "light" ? "light" : "dark";
|
|
3418
3720
|
const diskFolder = vfs.resolveDiskPath(targetVPath);
|
|
3419
3721
|
fs8.mkdirSync(diskFolder, { recursive: true });
|
|
3420
3722
|
res.json({
|
|
3421
|
-
url: `/vscode-web/?folder=${encodeURIComponent(diskFolder)}`
|
|
3723
|
+
url: `/vscode-web/?folder=${encodeURIComponent(diskFolder)}&tamgaTheme=${theme}`
|
|
3422
3724
|
});
|
|
3423
3725
|
} catch (e) {
|
|
3424
3726
|
res.status(400).json({ error: e.message });
|
|
@@ -3832,13 +4134,14 @@ async function startTamgaServer(opts = {}) {
|
|
|
3832
4134
|
appWss.on("connection", (ws, req) => {
|
|
3833
4135
|
const reqUrl = new URL(req.url || "/ws/app", "http://localhost");
|
|
3834
4136
|
const sessionId = reqUrl.searchParams.get("sessionId") || "";
|
|
4137
|
+
const viewId = reqUrl.searchParams.get("view") || "main";
|
|
3835
4138
|
const session = linuxDisplayBridge.getSession(sessionId);
|
|
3836
4139
|
if (!session) {
|
|
3837
4140
|
sendJson(ws, { type: "error", message: "Uygulama oturumu bulunamad\u0131." });
|
|
3838
4141
|
ws.close();
|
|
3839
4142
|
return;
|
|
3840
4143
|
}
|
|
3841
|
-
const unsub = session.
|
|
4144
|
+
const unsub = session.subscribeView(viewId, {
|
|
3842
4145
|
onVideoFrame: (jpeg, done) => {
|
|
3843
4146
|
const pkt = Buffer.allocUnsafe(1 + jpeg.length);
|
|
3844
4147
|
pkt[0] = PACKET_VIDEO_JPEG;
|
|
@@ -3857,9 +4160,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3857
4160
|
try {
|
|
3858
4161
|
const msg = JSON.parse(raw.toString("utf-8"));
|
|
3859
4162
|
if (msg.type === "resize") {
|
|
3860
|
-
session.
|
|
4163
|
+
session.resizeView(viewId, Number(msg.width), Number(msg.height));
|
|
4164
|
+
} else if (msg.type === "focus") {
|
|
4165
|
+
session.focusView(viewId);
|
|
3861
4166
|
} else {
|
|
3862
|
-
session.sendInput(msg);
|
|
4167
|
+
session.sendInput(msg, viewId);
|
|
3863
4168
|
}
|
|
3864
4169
|
} catch {
|
|
3865
4170
|
}
|