tamga-vdesktop 1.1.8 → 1.2.0
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 +1680 -1435
- package/dist/client/assets/index-BpTZrftb.css +32 -0
- package/dist/client/assets/index-zQEP78M7.js +418 -0
- package/dist/client/index.html +2 -2
- package/dist/server.js +239 -52
- package/package.json +5 -3
- package/dist/client/assets/index-DPU6NGIA.css +0 -32
- package/dist/client/assets/index-bk8UF-lM.js +0 -418
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs9 from "node:fs";
|
|
|
5
5
|
import os6 from "node:os";
|
|
6
6
|
import path9 from "node:path";
|
|
7
7
|
import readline from "node:readline";
|
|
8
|
-
import { execSync as execSync4, spawnSync } from "node:child_process";
|
|
8
|
+
import { execSync as execSync4, spawnSync as spawnSync2 } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
// server/config.ts
|
|
11
11
|
import fs from "node:fs";
|
|
@@ -448,1573 +448,1792 @@ apt-get update -y && apt-get install -y ${cleanPkg}`;
|
|
|
448
448
|
}
|
|
449
449
|
};
|
|
450
450
|
|
|
451
|
-
// server/
|
|
452
|
-
import express from "express";
|
|
453
|
-
import cors from "cors";
|
|
454
|
-
import http2 from "node:http";
|
|
455
|
-
import os5 from "node:os";
|
|
456
|
-
import path8 from "node:path";
|
|
457
|
-
import fs8 from "node:fs";
|
|
458
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
459
|
-
import multer from "multer";
|
|
460
|
-
import { WebSocketServer, WebSocket } from "ws";
|
|
461
|
-
|
|
462
|
-
// server/vfsManager.ts
|
|
451
|
+
// server/chromiumManager.ts
|
|
463
452
|
import fs3 from "node:fs";
|
|
453
|
+
import os3 from "node:os";
|
|
464
454
|
import path3 from "node:path";
|
|
465
|
-
import
|
|
466
|
-
|
|
467
|
-
var
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
var SYSTEM_DIRS = ["/Desktop", "/Documents", "/Downloads", "/Projects", "/.trash"];
|
|
476
|
-
function sanitizeDesktopId(raw) {
|
|
477
|
-
const cleaned = (raw || "main").toLowerCase().replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
478
|
-
return cleaned || "main";
|
|
479
|
-
}
|
|
480
|
-
function extractExtension(name, isDir) {
|
|
481
|
-
if (isDir) return "";
|
|
482
|
-
const lower = name.toLowerCase();
|
|
483
|
-
if (lower.endsWith(".tar.gz")) return "tar.gz";
|
|
484
|
-
if (lower.startsWith(".") && !lower.slice(1).includes(".")) {
|
|
485
|
-
return lower.slice(1);
|
|
455
|
+
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
456
|
+
import { createRequire } from "node:module";
|
|
457
|
+
var require2 = createRequire(import.meta.url);
|
|
458
|
+
async function loadPlaywrightChromium() {
|
|
459
|
+
try {
|
|
460
|
+
const pw = await import("playwright-core");
|
|
461
|
+
return pw.chromium;
|
|
462
|
+
} catch {
|
|
463
|
+
throw new Error("Yerle\u015Fik Playwright Chromium y\xFCkl\xFC de\u011Fil.");
|
|
486
464
|
}
|
|
487
|
-
const idx = lower.lastIndexOf(".");
|
|
488
|
-
if (idx <= 0 || idx === lower.length - 1) return "";
|
|
489
|
-
return lower.slice(idx + 1);
|
|
490
465
|
}
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
466
|
+
var PACKET_VIDEO_JPEG = 1;
|
|
467
|
+
var PACKET_AUDIO_PCM = 2;
|
|
468
|
+
function collectPlaywrightRoots() {
|
|
469
|
+
const home = os3.homedir();
|
|
470
|
+
return Array.from(
|
|
471
|
+
new Set(
|
|
472
|
+
[
|
|
473
|
+
process.env.PLAYWRIGHT_BROWSERS_PATH || "",
|
|
474
|
+
path3.join(home, "Library", "Caches", "ms-playwright"),
|
|
475
|
+
path3.join(home, ".cache", "ms-playwright"),
|
|
476
|
+
"/root/.cache/ms-playwright",
|
|
477
|
+
"/var/cache/tamga-playwright",
|
|
478
|
+
process.env.LOCALAPPDATA ? path3.join(process.env.LOCALAPPDATA, "ms-playwright") : ""
|
|
479
|
+
].filter(Boolean)
|
|
480
|
+
)
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
function findChromiumExecutable(chromiumRef) {
|
|
484
|
+
try {
|
|
485
|
+
const defaultPath = chromiumRef?.executablePath();
|
|
486
|
+
if (defaultPath && fs3.existsSync(defaultPath)) {
|
|
487
|
+
return defaultPath;
|
|
509
488
|
}
|
|
489
|
+
} catch {
|
|
510
490
|
}
|
|
511
|
-
|
|
512
|
-
if (fs3.existsSync(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
491
|
+
for (const root of collectPlaywrightRoots()) {
|
|
492
|
+
if (!fs3.existsSync(root)) continue;
|
|
493
|
+
let entries = [];
|
|
494
|
+
try {
|
|
495
|
+
entries = fs3.readdirSync(root);
|
|
496
|
+
} catch {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const shellDirs = entries.filter((d) => d.startsWith("chromium_headless_shell-")).sort().reverse();
|
|
500
|
+
for (const dir of shellDirs) {
|
|
501
|
+
const shellCandidates = [
|
|
502
|
+
path3.join(root, dir, "chrome-headless-shell-linux64", "chrome-headless-shell"),
|
|
503
|
+
path3.join(root, dir, "chrome-linux", "headless_shell"),
|
|
504
|
+
path3.join(root, dir, "chrome-headless-shell-mac-arm64", "chrome-headless-shell"),
|
|
505
|
+
path3.join(root, dir, "chrome-headless-shell-mac-x64", "chrome-headless-shell"),
|
|
506
|
+
path3.join(root, dir, "chrome-mac", "headless_shell"),
|
|
507
|
+
path3.join(root, dir, "chrome-mac-arm64", "headless_shell"),
|
|
508
|
+
path3.join(root, dir, "chrome-headless-shell-win64", "chrome-headless-shell.exe"),
|
|
509
|
+
path3.join(root, dir, "chrome-win", "headless_shell.exe")
|
|
510
|
+
];
|
|
511
|
+
for (const candidate of shellCandidates) {
|
|
512
|
+
if (fs3.existsSync(candidate)) return candidate;
|
|
520
513
|
}
|
|
521
514
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
515
|
+
const fullDirs = entries.filter((d) => d.startsWith("chromium-")).sort().reverse();
|
|
516
|
+
for (const dir of fullDirs) {
|
|
517
|
+
const fullCandidates = [
|
|
518
|
+
path3.join(root, dir, "chrome-mac-arm64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
519
|
+
path3.join(root, dir, "chrome-mac", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
520
|
+
path3.join(root, dir, "chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
521
|
+
path3.join(root, dir, "chrome-mac-arm64", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
522
|
+
path3.join(root, dir, "chrome-linux", "chrome"),
|
|
523
|
+
path3.join(root, dir, "chrome-linux64", "chrome"),
|
|
524
|
+
path3.join(root, dir, "chrome-win", "chrome.exe")
|
|
525
|
+
];
|
|
526
|
+
for (const candidate of fullCandidates) {
|
|
527
|
+
if (fs3.existsSync(candidate)) return candidate;
|
|
527
528
|
}
|
|
528
|
-
|
|
529
|
-
this.save();
|
|
530
|
-
}
|
|
531
|
-
save() {
|
|
532
|
-
fs3.mkdirSync(DESKTOPS_ROOT, { recursive: true });
|
|
533
|
-
fs3.writeFileSync(REGISTRY_FILE, JSON.stringify(this.desktops, null, 2), "utf-8");
|
|
529
|
+
}
|
|
534
530
|
}
|
|
535
|
-
|
|
536
|
-
|
|
531
|
+
const systemCandidates = [
|
|
532
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
533
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
534
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
535
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
536
|
+
"/usr/bin/chromium",
|
|
537
|
+
"/usr/bin/chromium-browser",
|
|
538
|
+
"/usr/bin/google-chrome-stable",
|
|
539
|
+
"/usr/bin/google-chrome"
|
|
540
|
+
];
|
|
541
|
+
for (const candidate of systemCandidates) {
|
|
542
|
+
if (fs3.existsSync(candidate)) return candidate;
|
|
537
543
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
546
|
-
};
|
|
547
|
-
this.desktops.push(info);
|
|
548
|
-
this.save();
|
|
549
|
-
return info;
|
|
544
|
+
return void 0;
|
|
545
|
+
}
|
|
546
|
+
function findPlaywrightManagedBrowser(chromiumRef) {
|
|
547
|
+
try {
|
|
548
|
+
const defaultPath = chromiumRef?.executablePath();
|
|
549
|
+
if (defaultPath && fs3.existsSync(defaultPath)) return defaultPath;
|
|
550
|
+
} catch {
|
|
550
551
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
552
|
+
for (const root of collectPlaywrightRoots()) {
|
|
553
|
+
if (!fs3.existsSync(root)) continue;
|
|
554
|
+
let entries = [];
|
|
555
|
+
try {
|
|
556
|
+
entries = fs3.readdirSync(root);
|
|
557
|
+
} catch {
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
for (const dir of entries.filter((d) => d.startsWith("chromium_headless_shell-") || d.startsWith("chromium-")).sort().reverse()) {
|
|
561
|
+
const cands = [
|
|
562
|
+
path3.join(root, dir, "chrome-headless-shell-linux64", "chrome-headless-shell"),
|
|
563
|
+
path3.join(root, dir, "chrome-linux", "headless_shell"),
|
|
564
|
+
path3.join(root, dir, "chrome-linux", "chrome"),
|
|
565
|
+
path3.join(root, dir, "chrome-linux64", "chrome"),
|
|
566
|
+
path3.join(root, dir, "chrome-headless-shell-mac-arm64", "chrome-headless-shell"),
|
|
567
|
+
path3.join(root, dir, "chrome-headless-shell-mac-x64", "chrome-headless-shell"),
|
|
568
|
+
path3.join(root, dir, "chrome-mac", "headless_shell"),
|
|
569
|
+
path3.join(root, dir, "chrome-mac-arm64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
570
|
+
path3.join(root, dir, "chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium")
|
|
571
|
+
];
|
|
572
|
+
for (const c of cands) {
|
|
573
|
+
if (fs3.existsSync(c)) return c;
|
|
574
|
+
}
|
|
561
575
|
}
|
|
562
|
-
const info = {
|
|
563
|
-
id: candidate,
|
|
564
|
-
name: cleanTitle,
|
|
565
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
566
|
-
};
|
|
567
|
-
this.desktops.push(info);
|
|
568
|
-
this.save();
|
|
569
|
-
return info;
|
|
570
|
-
}
|
|
571
|
-
renameDesktop(rawId, newName) {
|
|
572
|
-
const id = sanitizeDesktopId(rawId);
|
|
573
|
-
const item = this.desktops.find((d) => d.id === id);
|
|
574
|
-
if (!item) throw new Error("Masa\xFCst\xFC bulunamad\u0131.");
|
|
575
|
-
const trimmed = newName.trim();
|
|
576
|
-
if (!trimmed) throw new Error("Masa\xFCst\xFC ad\u0131 bo\u015F olamaz.");
|
|
577
|
-
item.name = trimmed;
|
|
578
|
-
this.save();
|
|
579
|
-
return item;
|
|
580
576
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
this.desktops.splice(idx, 1);
|
|
589
|
-
this.save();
|
|
590
|
-
const dir = path3.join(DESKTOPS_ROOT, id);
|
|
591
|
-
if (fs3.existsSync(dir)) {
|
|
592
|
-
fs3.rmSync(dir, { recursive: true, force: true });
|
|
593
|
-
}
|
|
594
|
-
return this.list();
|
|
577
|
+
return void 0;
|
|
578
|
+
}
|
|
579
|
+
function resolvePlaywrightCliPath() {
|
|
580
|
+
try {
|
|
581
|
+
return require2.resolve("playwright-core/cli.js");
|
|
582
|
+
} catch {
|
|
583
|
+
return null;
|
|
595
584
|
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
constructor(desktopId, hostRootOverride) {
|
|
605
|
-
this.desktopId = sanitizeDesktopId(desktopId);
|
|
606
|
-
this.instanceRoot = path3.join(DESKTOPS_ROOT, this.desktopId);
|
|
607
|
-
this.vfsRoot = hostRootOverride ? path3.resolve(hostRootOverride) : path3.join(this.instanceRoot, "vfs");
|
|
608
|
-
this.metaFile = path3.join(this.instanceRoot, "meta.json");
|
|
609
|
-
fs3.mkdirSync(this.instanceRoot, { recursive: true });
|
|
610
|
-
fs3.mkdirSync(this.vfsRoot, { recursive: true });
|
|
611
|
-
this.meta = this.loadMeta();
|
|
612
|
-
if (!hostRootOverride) {
|
|
613
|
-
this.ensureSeedWorkspace();
|
|
614
|
-
} else {
|
|
615
|
-
for (const dir of SYSTEM_DIRS) {
|
|
616
|
-
fs3.mkdirSync(this.resolveDiskPath(dir), { recursive: true });
|
|
617
|
-
}
|
|
585
|
+
}
|
|
586
|
+
function installPlaywrightBrowserSync(opts) {
|
|
587
|
+
const existing = findPlaywrightManagedBrowser();
|
|
588
|
+
if (existing) return true;
|
|
589
|
+
const cliPath = resolvePlaywrightCliPath();
|
|
590
|
+
if (!cliPath) {
|
|
591
|
+
if (!opts?.quiet) {
|
|
592
|
+
console.error("[TamgaVDesktop] playwright-core/cli.js bulunamad\u0131.");
|
|
618
593
|
}
|
|
594
|
+
return false;
|
|
619
595
|
}
|
|
620
|
-
|
|
621
|
-
|
|
596
|
+
const args = [cliPath, "install", "chromium-headless-shell"];
|
|
597
|
+
if (opts?.withDeps && process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0) {
|
|
598
|
+
args.push("--with-deps");
|
|
622
599
|
}
|
|
623
|
-
|
|
624
|
-
|
|
600
|
+
if (opts?.quiet) {
|
|
601
|
+
args.push("--no-progress");
|
|
625
602
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return () => this.changeListeners.delete(cb);
|
|
603
|
+
if (!opts?.quiet) {
|
|
604
|
+
console.log("[TamgaVDesktop] Yerle\u015Fik Playwright Chromium taray\u0131c\u0131s\u0131 kuruluyor...");
|
|
629
605
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
606
|
+
const res = spawnSync(process.execPath, args, {
|
|
607
|
+
stdio: opts?.quiet ? "ignore" : "inherit",
|
|
608
|
+
env: {
|
|
609
|
+
...process.env,
|
|
610
|
+
PLAYWRIGHT_SKIP_BROWSER_GC: "1"
|
|
636
611
|
}
|
|
612
|
+
});
|
|
613
|
+
if (res.status === 0 && findPlaywrightManagedBrowser()) {
|
|
614
|
+
return true;
|
|
637
615
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
theme: "dark",
|
|
664
|
-
iconSize: "md",
|
|
665
|
-
autoArrange: false,
|
|
666
|
-
sortBy: "name"
|
|
667
|
-
}
|
|
668
|
-
};
|
|
616
|
+
const fallbackArgs = [cliPath, "install", "--only-shell", "chromium"];
|
|
617
|
+
if (opts?.quiet) fallbackArgs.push("--no-progress");
|
|
618
|
+
const res2 = spawnSync(process.execPath, fallbackArgs, {
|
|
619
|
+
stdio: opts?.quiet ? "ignore" : "inherit"
|
|
620
|
+
});
|
|
621
|
+
return res2.status === 0 && Boolean(findPlaywrightManagedBrowser());
|
|
622
|
+
}
|
|
623
|
+
async function installPlaywrightBrowserAsync() {
|
|
624
|
+
if (findPlaywrightManagedBrowser()) return;
|
|
625
|
+
const cliPath = resolvePlaywrightCliPath();
|
|
626
|
+
if (!cliPath) return;
|
|
627
|
+
await new Promise((resolve) => {
|
|
628
|
+
const child = spawn2(
|
|
629
|
+
process.execPath,
|
|
630
|
+
[cliPath, "install", "chromium-headless-shell", "--no-progress"],
|
|
631
|
+
{ stdio: "ignore" }
|
|
632
|
+
);
|
|
633
|
+
child.on("exit", () => resolve());
|
|
634
|
+
child.on("error", () => resolve());
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
function normalizeUserUrl(rawInput) {
|
|
638
|
+
const trimmed = rawInput.trim();
|
|
639
|
+
if (!trimmed || trimmed === "compute://newtab" || trimmed === "about:blank") {
|
|
640
|
+
return { mode: "newtab", url: "compute://newtab" };
|
|
669
641
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
642
|
+
if (trimmed.startsWith("file://")) {
|
|
643
|
+
const rawPath = decodeURIComponent(trimmed.replace(/^file:\/\/\/?/, "/"));
|
|
644
|
+
const normPath = ("/" + rawPath).replace(/\/+/g, "/");
|
|
645
|
+
return { mode: "file", url: `file://${normPath}`, filePath: normPath };
|
|
673
646
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
return cleaned === "" ? "/" : cleaned;
|
|
647
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
648
|
+
return { mode: "web", url: trimmed };
|
|
677
649
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
return resolved;
|
|
650
|
+
if (/^(localhost(:\d+)?|(\d{1,3}\.){3}\d{1,3}(:\d+)?|([a-z0-9-]+\.)+[a-z]{2,})(\/.*)?$/i.test(
|
|
651
|
+
trimmed
|
|
652
|
+
) && !trimmed.includes(" ")) {
|
|
653
|
+
const proto = trimmed.startsWith("localhost") || /^\d+\.\d+/.test(trimmed) ? "http://" : "https://";
|
|
654
|
+
return { mode: "web", url: proto + trimmed };
|
|
685
655
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
)
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
656
|
+
return {
|
|
657
|
+
mode: "web",
|
|
658
|
+
url: `https://www.google.com/search?q=${encodeURIComponent(trimmed)}&hl=tr`
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
var PAGE_ENHANCEMENT_INIT_SCRIPT = `
|
|
662
|
+
(() => {
|
|
663
|
+
try {
|
|
664
|
+
Object.defineProperty(navigator, 'webdriver', { get: () => undefined });
|
|
665
|
+
} catch {}
|
|
666
|
+
|
|
667
|
+
if (!window.__rcCursorHooked) {
|
|
668
|
+
window.__rcCursorHooked = true;
|
|
669
|
+
let lastCursor = '';
|
|
670
|
+
let lastCheck = 0;
|
|
671
|
+
window.addEventListener('mousemove', (ev) => {
|
|
672
|
+
const now = performance.now();
|
|
673
|
+
if (now - lastCheck < 75) return;
|
|
674
|
+
lastCheck = now;
|
|
675
|
+
try {
|
|
676
|
+
const el = document.elementFromPoint(ev.clientX, ev.clientY);
|
|
677
|
+
const cur = el ? getComputedStyle(el).cursor || 'default' : 'default';
|
|
678
|
+
if (cur !== lastCursor && typeof window.__rcCursorChange === 'function') {
|
|
679
|
+
lastCursor = cur;
|
|
680
|
+
window.__rcCursorChange(cur).catch(() => {});
|
|
681
|
+
}
|
|
682
|
+
} catch {}
|
|
683
|
+
}, { passive: true, capture: true });
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (window.__rcAudioHooked) return;
|
|
687
|
+
window.__rcAudioHooked = true;
|
|
688
|
+
|
|
689
|
+
let mixCtx = null;
|
|
690
|
+
let mixGain = null;
|
|
691
|
+
let mixProcessor = null;
|
|
692
|
+
const retainedNodes = [];
|
|
693
|
+
const hookedElements = new WeakSet();
|
|
694
|
+
const hookedContexts = new WeakSet();
|
|
695
|
+
|
|
696
|
+
function sendFloatBufferAsPcm(ch0, ch1) {
|
|
697
|
+
if (typeof window.__rcPushAudioBase64 !== 'function') return;
|
|
698
|
+
const len = ch0.length;
|
|
699
|
+
let peak = 0;
|
|
700
|
+
for (let i = 0; i < len; i += 4) {
|
|
701
|
+
const a = Math.abs(ch0[i]);
|
|
702
|
+
if (a > peak) peak = a;
|
|
718
703
|
}
|
|
719
|
-
.
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
704
|
+
if (peak < 0.00035) return;
|
|
705
|
+
|
|
706
|
+
const pcm16 = new Int16Array(len);
|
|
707
|
+
for (let i = 0; i < len; i++) {
|
|
708
|
+
const mono = ch1 ? (ch0[i] + ch1[i]) * 0.5 : ch0[i];
|
|
709
|
+
const clamped = mono < -1 ? -1 : mono > 1 ? 1 : mono;
|
|
710
|
+
pcm16[i] = clamped * 32767;
|
|
726
711
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
<p>Bu sayfa sanal masa\xFCst\xFCn\xFCzdeki <code>/Desktop/baslangic.html</code> dosyas\u0131ndan \xE7al\u0131\u015F\u0131yor. \xDCst \xE7ubuktan kayna\u011F\u0131 d\xFCzenleyip kaydedebilirsiniz.</p>
|
|
735
|
-
</div>
|
|
736
|
-
</body>
|
|
737
|
-
</html>`,
|
|
738
|
-
"utf-8"
|
|
739
|
-
);
|
|
740
|
-
fs3.writeFileSync(
|
|
741
|
-
this.resolveDiskPath("/Desktop/Projeler/analiz.py"),
|
|
742
|
-
`def hesapla(veriler: list[float]) -> dict:
|
|
743
|
-
toplam = sum(veriler)
|
|
744
|
-
return {"adet": len(veriler), "ortalama": round(toplam / max(len(veriler), 1), 2)}
|
|
712
|
+
const bytes = new Uint8Array(pcm16.buffer);
|
|
713
|
+
let binary = '';
|
|
714
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
715
|
+
binary += String.fromCharCode(bytes[i]);
|
|
716
|
+
}
|
|
717
|
+
window.__rcPushAudioBase64(btoa(binary)).catch(() => {});
|
|
718
|
+
}
|
|
745
719
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
720
|
+
function ensurePipeline() {
|
|
721
|
+
if (mixCtx) {
|
|
722
|
+
if (mixCtx.state === 'suspended') mixCtx.resume().catch(() => {});
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const AC = window.AudioContext || window.webkitAudioContext;
|
|
726
|
+
if (!AC) return;
|
|
727
|
+
try {
|
|
728
|
+
mixCtx = new AC({ sampleRate: 24000 });
|
|
729
|
+
hookedContexts.add(mixCtx);
|
|
730
|
+
mixGain = mixCtx.createGain();
|
|
731
|
+
mixProcessor = mixCtx.createScriptProcessor(2048, 2, 2);
|
|
732
|
+
mixGain.connect(mixProcessor);
|
|
733
|
+
mixProcessor.connect(mixCtx.destination);
|
|
734
|
+
|
|
735
|
+
mixProcessor.onaudioprocess = (ev) => {
|
|
736
|
+
const ch0 = ev.inputBuffer.getChannelData(0);
|
|
737
|
+
const ch1 = ev.inputBuffer.numberOfChannels > 1 ? ev.inputBuffer.getChannelData(1) : null;
|
|
738
|
+
sendFloatBufferAsPcm(ch0, ch1);
|
|
739
|
+
};
|
|
740
|
+
} catch {}
|
|
760
741
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
742
|
+
|
|
743
|
+
function attachMediaElement(el) {
|
|
744
|
+
if (!el || hookedElements.has(el)) return;
|
|
745
|
+
ensurePipeline();
|
|
746
|
+
if (!mixCtx || !mixGain) return;
|
|
747
|
+
if (mixCtx.state === 'suspended') mixCtx.resume().catch(() => {});
|
|
748
|
+
|
|
749
|
+
try {
|
|
750
|
+
const src = mixCtx.createMediaElementSource(el);
|
|
751
|
+
const volGain = mixCtx.createGain();
|
|
752
|
+
const syncVol = () => {
|
|
753
|
+
volGain.gain.value = el.muted ? 0 : el.volume;
|
|
754
|
+
};
|
|
755
|
+
syncVol();
|
|
756
|
+
el.addEventListener('volumechange', syncVol);
|
|
757
|
+
src.connect(volGain);
|
|
758
|
+
volGain.connect(mixGain);
|
|
759
|
+
retainedNodes.push(src, volGain);
|
|
760
|
+
hookedElements.add(el);
|
|
761
|
+
} catch {}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
const origConnect = AudioNode.prototype.connect;
|
|
765
|
+
AudioNode.prototype.connect = function (dest, ...rest) {
|
|
766
|
+
const result = origConnect.call(this, dest, ...rest);
|
|
767
|
+
try {
|
|
768
|
+
if (
|
|
769
|
+
dest &&
|
|
770
|
+
this.context &&
|
|
771
|
+
dest === this.context.destination &&
|
|
772
|
+
!hookedContexts.has(this.context)
|
|
773
|
+
) {
|
|
774
|
+
hookedContexts.add(this.context);
|
|
775
|
+
const ctx = this.context;
|
|
776
|
+
const tap = ctx.createScriptProcessor(2048, 2, 2);
|
|
777
|
+
origConnect.call(this, tap);
|
|
778
|
+
origConnect.call(tap, ctx.destination);
|
|
779
|
+
const ratio = ctx.sampleRate / 24000;
|
|
780
|
+
tap.onaudioprocess = (ev) => {
|
|
781
|
+
const in0 = ev.inputBuffer.getChannelData(0);
|
|
782
|
+
const outLen = Math.floor(in0.length / ratio);
|
|
783
|
+
const resampled = new Float32Array(outLen);
|
|
784
|
+
for (let i = 0; i < outLen; i++) {
|
|
785
|
+
resampled[i] = in0[Math.min(in0.length - 1, Math.round(i * ratio))];
|
|
786
|
+
}
|
|
787
|
+
sendFloatBufferAsPcm(resampled, null);
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
} catch {}
|
|
791
|
+
return result;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const origPlay = HTMLMediaElement.prototype.play;
|
|
795
|
+
HTMLMediaElement.prototype.play = function (...args) {
|
|
796
|
+
attachMediaElement(this);
|
|
797
|
+
return origPlay.apply(this, args);
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
setInterval(() => {
|
|
801
|
+
const els = document.querySelectorAll('video, audio');
|
|
802
|
+
for (let i = 0; i < els.length; i++) {
|
|
803
|
+
const el = els[i];
|
|
804
|
+
if (!el.paused && !el.muted) {
|
|
805
|
+
attachMediaElement(el);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}, 600);
|
|
809
|
+
})();
|
|
810
|
+
`;
|
|
811
|
+
var ChromiumCluster = class {
|
|
812
|
+
browser = null;
|
|
813
|
+
launching = null;
|
|
814
|
+
sessions = /* @__PURE__ */ new Map();
|
|
815
|
+
executableUsed = "Chromium";
|
|
816
|
+
async getBrowser() {
|
|
817
|
+
if (this.browser && this.browser.isConnected()) {
|
|
818
|
+
return this.browser;
|
|
819
|
+
}
|
|
820
|
+
if (this.launching) {
|
|
821
|
+
return this.launching;
|
|
822
|
+
}
|
|
823
|
+
this.launching = (async () => {
|
|
824
|
+
const chromiumApi = await loadPlaywrightChromium();
|
|
825
|
+
let executablePath = findPlaywrightManagedBrowser(chromiumApi);
|
|
826
|
+
if (!executablePath) {
|
|
827
|
+
await installPlaywrightBrowserAsync();
|
|
828
|
+
executablePath = findChromiumExecutable(chromiumApi);
|
|
829
|
+
}
|
|
830
|
+
if (!executablePath) {
|
|
831
|
+
throw new Error(
|
|
832
|
+
"Playwright Chromium ikilisi bulunamad\u0131. Sunucuda 'tamga-vdesktop install-browser' \xE7al\u0131\u015Ft\u0131r\u0131n."
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
this.executableUsed = executablePath;
|
|
836
|
+
const launched = await chromiumApi.launch({
|
|
837
|
+
executablePath,
|
|
838
|
+
headless: true,
|
|
839
|
+
args: [
|
|
840
|
+
"--no-sandbox",
|
|
841
|
+
"--disable-setuid-sandbox",
|
|
842
|
+
"--disable-dev-shm-usage",
|
|
843
|
+
"--disable-blink-features=AutomationControlled",
|
|
844
|
+
"--autoplay-policy=no-user-gesture-required",
|
|
845
|
+
"--font-render-hinting=medium",
|
|
846
|
+
"--enable-font-antialiasing",
|
|
847
|
+
"--force-color-profile=srgb",
|
|
848
|
+
"--use-gl=angle",
|
|
849
|
+
"--use-angle=swiftshader-webgl",
|
|
850
|
+
"--enable-webgl",
|
|
851
|
+
"--ignore-gpu-blocklist"
|
|
852
|
+
]
|
|
853
|
+
});
|
|
854
|
+
this.browser = launched;
|
|
855
|
+
return launched;
|
|
856
|
+
})();
|
|
857
|
+
try {
|
|
858
|
+
return await this.launching;
|
|
859
|
+
} finally {
|
|
860
|
+
this.launching = null;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
getOrCreateSession(desktopId, vfs) {
|
|
864
|
+
let session = this.sessions.get(desktopId);
|
|
865
|
+
if (!session) {
|
|
866
|
+
session = new ChromiumDesktopSession(desktopId, vfs, this);
|
|
867
|
+
this.sessions.set(desktopId, session);
|
|
868
|
+
}
|
|
869
|
+
return session;
|
|
870
|
+
}
|
|
871
|
+
async destroySession(desktopId) {
|
|
872
|
+
const session = this.sessions.get(desktopId);
|
|
873
|
+
if (!session) return;
|
|
874
|
+
this.sessions.delete(desktopId);
|
|
875
|
+
await session.dispose();
|
|
876
|
+
}
|
|
877
|
+
getClusterInfo() {
|
|
878
|
+
let totalTabs = 0;
|
|
879
|
+
let totalWebPages = 0;
|
|
880
|
+
for (const s of this.sessions.values()) {
|
|
881
|
+
const info = s.getSessionStats();
|
|
882
|
+
totalTabs += info.activeTabs;
|
|
883
|
+
totalWebPages += info.webPagesCount;
|
|
774
884
|
}
|
|
775
885
|
return {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
886
|
+
ready: Boolean(this.browser?.isConnected()),
|
|
887
|
+
installed: Boolean(findChromiumExecutable()),
|
|
888
|
+
executable: path3.basename(this.executableUsed),
|
|
889
|
+
isolatedDesktopsLoaded: this.sessions.size,
|
|
890
|
+
totalTabs,
|
|
891
|
+
totalWebPages
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
var ChromiumDesktopSession = class {
|
|
896
|
+
desktopId;
|
|
897
|
+
vfs;
|
|
898
|
+
cluster;
|
|
899
|
+
context = null;
|
|
900
|
+
contextCreating = null;
|
|
901
|
+
tabs = /* @__PURE__ */ new Map();
|
|
902
|
+
tabOrder = [];
|
|
903
|
+
activeTabId = null;
|
|
904
|
+
viewport = { width: 1160, height: 700 };
|
|
905
|
+
dpr = 1;
|
|
906
|
+
jsonListeners = /* @__PURE__ */ new Set();
|
|
907
|
+
binaryListeners = /* @__PURE__ */ new Set();
|
|
908
|
+
internalPageCreating = 0;
|
|
909
|
+
frameCounter = 0;
|
|
910
|
+
lastFpsCheck = Date.now();
|
|
911
|
+
currentFps = 0;
|
|
912
|
+
constructor(desktopId, vfs, cluster) {
|
|
913
|
+
this.desktopId = desktopId;
|
|
914
|
+
this.vfs = vfs;
|
|
915
|
+
this.cluster = cluster;
|
|
916
|
+
this.createTabInternal("compute://newtab", true);
|
|
917
|
+
}
|
|
918
|
+
getSessionStats() {
|
|
919
|
+
return {
|
|
920
|
+
activeTabs: this.tabs.size,
|
|
921
|
+
webPagesCount: Array.from(this.tabs.values()).filter((t) => Boolean(t.page)).length,
|
|
922
|
+
fps: this.currentFps
|
|
786
923
|
};
|
|
787
924
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
} catch {
|
|
925
|
+
subscribe(onJson, onBinary) {
|
|
926
|
+
this.jsonListeners.add(onJson);
|
|
927
|
+
this.binaryListeners.add(onBinary);
|
|
928
|
+
onJson({
|
|
929
|
+
type: "tabs_state",
|
|
930
|
+
tabs: this.getTabsSummary(),
|
|
931
|
+
activeTabId: this.activeTabId
|
|
932
|
+
});
|
|
933
|
+
const active = this.activeTabId ? this.tabs.get(this.activeTabId) : void 0;
|
|
934
|
+
if (active?.mode === "web" && active.lastFrameBuffer) {
|
|
935
|
+
onBinary(active.lastFrameBuffer);
|
|
802
936
|
}
|
|
803
|
-
return
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const nodes = [];
|
|
807
|
-
const walk = (vDir) => {
|
|
808
|
-
const diskDir = this.resolveDiskPath(vDir);
|
|
809
|
-
if (!fs3.existsSync(diskDir)) return;
|
|
810
|
-
if (vDir !== "/") {
|
|
811
|
-
nodes.push(this.statNode(vDir));
|
|
812
|
-
}
|
|
813
|
-
const entries = fs3.readdirSync(diskDir).filter((e) => e !== ".DS_Store");
|
|
814
|
-
for (const entry of entries) {
|
|
815
|
-
const childVPath = vDir === "/" ? `/${entry}` : `${vDir}/${entry}`;
|
|
816
|
-
const childDisk = this.resolveDiskPath(childVPath);
|
|
817
|
-
const st = fs3.statSync(childDisk);
|
|
818
|
-
if (st.isDirectory()) {
|
|
819
|
-
walk(childVPath);
|
|
820
|
-
} else {
|
|
821
|
-
nodes.push(this.statNode(childVPath));
|
|
822
|
-
}
|
|
823
|
-
}
|
|
937
|
+
return () => {
|
|
938
|
+
this.jsonListeners.delete(onJson);
|
|
939
|
+
this.binaryListeners.delete(onBinary);
|
|
824
940
|
};
|
|
825
|
-
walk("/");
|
|
826
|
-
return { nodes, meta: this.meta };
|
|
827
941
|
}
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
return candidate;
|
|
834
|
-
}
|
|
835
|
-
const extIdx = cleanName.lastIndexOf(".");
|
|
836
|
-
const hasExt = extIdx > 0 && extIdx < cleanName.length - 1;
|
|
837
|
-
const stem = hasExt ? cleanName.slice(0, extIdx) : cleanName;
|
|
838
|
-
const ext = hasExt ? cleanName.slice(extIdx) : "";
|
|
839
|
-
let counter = 2;
|
|
840
|
-
while (true) {
|
|
841
|
-
const nextName = `${stem} (${counter})${ext}`;
|
|
842
|
-
candidate = normParent === "/" ? `/${nextName}` : `${normParent}/${nextName}`;
|
|
843
|
-
if (!fs3.existsSync(this.resolveDiskPath(candidate))) {
|
|
844
|
-
return candidate;
|
|
942
|
+
broadcastJson(msg) {
|
|
943
|
+
for (const cb of this.jsonListeners) {
|
|
944
|
+
try {
|
|
945
|
+
cb(msg);
|
|
946
|
+
} catch {
|
|
845
947
|
}
|
|
846
|
-
counter++;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
createFolder(parentPath, name, pos) {
|
|
850
|
-
const targetVPath = this.getUniquePath(parentPath, name || "Yeni Klas\xF6r");
|
|
851
|
-
fs3.mkdirSync(this.resolveDiskPath(targetVPath), { recursive: true });
|
|
852
|
-
if (pos) {
|
|
853
|
-
this.meta.positions[targetVPath] = pos;
|
|
854
|
-
this.saveMeta();
|
|
855
948
|
}
|
|
856
|
-
this.notifyChange();
|
|
857
|
-
return this.statNode(targetVPath);
|
|
858
949
|
}
|
|
859
|
-
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
if (pos) {
|
|
866
|
-
this.meta.positions[targetVPath] = pos;
|
|
867
|
-
this.saveMeta();
|
|
950
|
+
broadcastBinary(packet) {
|
|
951
|
+
for (const cb of this.binaryListeners) {
|
|
952
|
+
try {
|
|
953
|
+
cb(packet);
|
|
954
|
+
} catch {
|
|
955
|
+
}
|
|
868
956
|
}
|
|
869
|
-
this.notifyChange();
|
|
870
|
-
return this.statNode(targetVPath);
|
|
871
957
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
<html lang="tr">
|
|
879
|
-
<head>
|
|
880
|
-
<meta charset="UTF-8" />
|
|
881
|
-
<title>Sayfa</title>
|
|
882
|
-
</head>
|
|
883
|
-
<body style="font-family:-apple-system,sans-serif;padding:2rem;background:#141416;color:#f5f5f7;">
|
|
884
|
-
<h1>Merhaba</h1>
|
|
885
|
-
<p>Yeni HTML belgesi haz\u0131r.</p>
|
|
886
|
-
</body>
|
|
887
|
-
</html>
|
|
888
|
-
`;
|
|
889
|
-
case "json":
|
|
890
|
-
return `{
|
|
891
|
-
"ad": "kayit",
|
|
892
|
-
"aktif": true
|
|
893
|
-
}
|
|
894
|
-
`;
|
|
895
|
-
case "md":
|
|
896
|
-
return `# Ba\u015Fl\u0131k
|
|
897
|
-
|
|
898
|
-
Notlar\u0131n\u0131z\u0131 buraya yazabilirsiniz.
|
|
899
|
-
`;
|
|
900
|
-
case "py":
|
|
901
|
-
return `def main():
|
|
902
|
-
print("Merhaba!")
|
|
903
|
-
|
|
904
|
-
if __name__ == "__main__":
|
|
905
|
-
main()
|
|
906
|
-
`;
|
|
907
|
-
case "js":
|
|
908
|
-
case "ts":
|
|
909
|
-
return `console.log("Haz\u0131r");
|
|
910
|
-
`;
|
|
911
|
-
case "css":
|
|
912
|
-
return `body {
|
|
913
|
-
margin: 0;
|
|
914
|
-
background: #141416;
|
|
915
|
-
color: #f5f5f7;
|
|
916
|
-
}
|
|
917
|
-
`;
|
|
918
|
-
case "csv":
|
|
919
|
-
return `id,baslik,deger
|
|
920
|
-
1,Kalem A,100
|
|
921
|
-
2,Kalem B,250
|
|
922
|
-
`;
|
|
923
|
-
case "sql":
|
|
924
|
-
return `SELECT * FROM kayitlar LIMIT 10;
|
|
925
|
-
`;
|
|
926
|
-
case "svg":
|
|
927
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
|
|
928
|
-
<rect width="200" height="200" rx="24" fill="#1c1c1e"/>
|
|
929
|
-
<circle cx="100" cy="100" r="52" fill="#e5e5ea"/>
|
|
930
|
-
</svg>
|
|
931
|
-
`;
|
|
932
|
-
default:
|
|
933
|
-
return "";
|
|
934
|
-
}
|
|
958
|
+
broadcastTabs() {
|
|
959
|
+
this.broadcastJson({
|
|
960
|
+
type: "tabs_state",
|
|
961
|
+
tabs: this.getTabsSummary(),
|
|
962
|
+
activeTabId: this.activeTabId
|
|
963
|
+
});
|
|
935
964
|
}
|
|
936
|
-
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
throw new Error(`"${cleanName}" ad\u0131nda bir \xF6\u011Fe zaten mevcut.`);
|
|
952
|
-
}
|
|
953
|
-
fs3.renameSync(this.resolveDiskPath(norm), this.resolveDiskPath(nextVPath));
|
|
954
|
-
const updatedPositions = {};
|
|
955
|
-
for (const [k, v] of Object.entries(this.meta.positions)) {
|
|
956
|
-
if (k === norm) updatedPositions[nextVPath] = v;
|
|
957
|
-
else if (k.startsWith(norm + "/")) updatedPositions[nextVPath + k.slice(norm.length)] = v;
|
|
958
|
-
else updatedPositions[k] = v;
|
|
959
|
-
}
|
|
960
|
-
this.meta.positions = updatedPositions;
|
|
961
|
-
this.saveMeta();
|
|
962
|
-
this.notifyChange();
|
|
963
|
-
return this.statNode(nextVPath);
|
|
965
|
+
getTabsSummary() {
|
|
966
|
+
const now = Date.now();
|
|
967
|
+
return this.tabOrder.map((id) => this.tabs.get(id)).filter((t) => Boolean(t)).map((t) => ({
|
|
968
|
+
id: t.id,
|
|
969
|
+
url: t.url,
|
|
970
|
+
title: t.title,
|
|
971
|
+
favicon: t.favicon,
|
|
972
|
+
isLoading: t.isLoading,
|
|
973
|
+
canGoBack: t.canGoBack,
|
|
974
|
+
canGoForward: t.canGoForward,
|
|
975
|
+
isSecure: t.url.startsWith("https://") || t.url.startsWith("compute://") || t.url.startsWith("file://"),
|
|
976
|
+
isPlayingAudio: now - t.lastAudioAt < 1500,
|
|
977
|
+
mode: t.mode,
|
|
978
|
+
filePath: t.filePath
|
|
979
|
+
}));
|
|
964
980
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
981
|
+
async ensureContext() {
|
|
982
|
+
if (this.context) return this.context;
|
|
983
|
+
if (this.contextCreating) return this.contextCreating;
|
|
984
|
+
this.contextCreating = (async () => {
|
|
985
|
+
const browser = await this.cluster.getBrowser();
|
|
986
|
+
const majorVer = browser.version().split(".")[0] || "134";
|
|
987
|
+
const ctx = await browser.newContext({
|
|
988
|
+
viewport: this.viewport,
|
|
989
|
+
deviceScaleFactor: this.dpr,
|
|
990
|
+
locale: "tr-TR",
|
|
991
|
+
userAgent: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${majorVer}.0.0.0 Safari/537.36`,
|
|
992
|
+
acceptDownloads: true
|
|
993
|
+
});
|
|
994
|
+
await ctx.exposeBinding("__rcPushAudioBase64", (source, b64) => {
|
|
995
|
+
if (this.binaryListeners.size === 0 || !b64) return;
|
|
996
|
+
const matchingTab = Array.from(this.tabs.values()).find((t) => t.page === source.page);
|
|
997
|
+
if (!matchingTab) return;
|
|
998
|
+
matchingTab.lastAudioAt = Date.now();
|
|
999
|
+
if (matchingTab.id !== this.activeTabId || matchingTab.mode !== "web") return;
|
|
1000
|
+
const pcmBuf = Buffer.from(b64, "base64");
|
|
1001
|
+
const packet = Buffer.allocUnsafe(1 + pcmBuf.length);
|
|
1002
|
+
packet[0] = PACKET_AUDIO_PCM;
|
|
1003
|
+
pcmBuf.copy(packet, 1);
|
|
1004
|
+
this.broadcastBinary(packet);
|
|
1005
|
+
});
|
|
1006
|
+
await ctx.exposeBinding("__rcCursorChange", (source, cursor) => {
|
|
1007
|
+
const matchingTab = Array.from(this.tabs.values()).find((t) => t.page === source.page);
|
|
1008
|
+
if (!matchingTab || matchingTab.id !== this.activeTabId || matchingTab.mode !== "web") return;
|
|
1009
|
+
this.broadcastJson({ type: "browser_cursor", cursor: String(cursor || "default") });
|
|
1010
|
+
});
|
|
1011
|
+
await ctx.addInitScript(PAGE_ENHANCEMENT_INIT_SCRIPT);
|
|
1012
|
+
ctx.on("page", async (newPage) => {
|
|
1013
|
+
if (this.internalPageCreating > 0) return;
|
|
1014
|
+
const alreadyTracked = Array.from(this.tabs.values()).some((t) => t.page === newPage);
|
|
1015
|
+
if (alreadyTracked) return;
|
|
1016
|
+
const id = `tab-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
1017
|
+
const tab = {
|
|
1018
|
+
id,
|
|
1019
|
+
mode: "web",
|
|
1020
|
+
url: newPage.url() || "about:blank",
|
|
1021
|
+
title: "Yeni Sekme...",
|
|
1022
|
+
favicon: "",
|
|
1023
|
+
isLoading: true,
|
|
1024
|
+
canGoBack: false,
|
|
1025
|
+
canGoForward: false,
|
|
1026
|
+
lastAudioAt: 0,
|
|
1027
|
+
page: newPage,
|
|
1028
|
+
streaming: false
|
|
1029
|
+
};
|
|
1030
|
+
this.tabs.set(id, tab);
|
|
1031
|
+
this.tabOrder.push(id);
|
|
1032
|
+
await this.attachPageHandlers(tab, newPage);
|
|
1033
|
+
await this.activateTab(id);
|
|
1034
|
+
});
|
|
1035
|
+
this.context = ctx;
|
|
1036
|
+
return ctx;
|
|
1037
|
+
})();
|
|
1038
|
+
try {
|
|
1039
|
+
return await this.contextCreating;
|
|
1040
|
+
} finally {
|
|
1041
|
+
this.contextCreating = null;
|
|
970
1042
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1043
|
+
}
|
|
1044
|
+
createTabInternal(initialInput = "compute://newtab", makeActive = true) {
|
|
1045
|
+
const parsed = normalizeUserUrl(initialInput);
|
|
1046
|
+
const id = `tab-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
1047
|
+
const tab = {
|
|
1048
|
+
id,
|
|
1049
|
+
mode: parsed.mode,
|
|
1050
|
+
filePath: parsed.filePath,
|
|
1051
|
+
url: parsed.url,
|
|
1052
|
+
title: parsed.mode === "newtab" ? "Yeni Sekme" : parsed.mode === "file" ? path3.posix.basename(parsed.filePath || "Dosya") : parsed.url,
|
|
1053
|
+
favicon: "",
|
|
1054
|
+
isLoading: false,
|
|
1055
|
+
canGoBack: false,
|
|
1056
|
+
canGoForward: false,
|
|
1057
|
+
lastAudioAt: 0,
|
|
1058
|
+
streaming: false
|
|
1059
|
+
};
|
|
1060
|
+
this.tabs.set(id, tab);
|
|
1061
|
+
this.tabOrder.push(id);
|
|
1062
|
+
if (makeActive) this.activeTabId = id;
|
|
1063
|
+
return tab;
|
|
1064
|
+
}
|
|
1065
|
+
async createTab(initialUrl = "compute://newtab") {
|
|
1066
|
+
const tab = this.createTabInternal(initialUrl, false);
|
|
1067
|
+
await this.activateTab(tab.id);
|
|
1068
|
+
if (tab.mode === "web") {
|
|
1069
|
+
await this.navigate(tab.id, tab.url);
|
|
985
1070
|
}
|
|
986
|
-
this.
|
|
987
|
-
|
|
988
|
-
return moved;
|
|
1071
|
+
this.broadcastTabs();
|
|
1072
|
+
return tab.id;
|
|
989
1073
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1074
|
+
async applyTabMetrics(tab) {
|
|
1075
|
+
if (!tab.page || tab.page.isClosed()) return;
|
|
1076
|
+
try {
|
|
1077
|
+
await tab.page.setViewportSize(this.viewport);
|
|
1078
|
+
} catch {
|
|
1079
|
+
}
|
|
1080
|
+
if (tab.cdp) {
|
|
1081
|
+
try {
|
|
1082
|
+
await tab.cdp.send("Emulation.setDeviceMetricsOverride", {
|
|
1083
|
+
width: this.viewport.width,
|
|
1084
|
+
height: this.viewport.height,
|
|
1085
|
+
deviceScaleFactor: this.dpr,
|
|
1086
|
+
mobile: false
|
|
1087
|
+
});
|
|
1088
|
+
} catch {
|
|
998
1089
|
}
|
|
999
|
-
const base = path3.posix.basename(src);
|
|
1000
|
-
const desired = path3.posix.dirname(src) === normTarget ? this.makeCopyName(base) : base;
|
|
1001
|
-
const dest = this.getUniquePath(normTarget, desired);
|
|
1002
|
-
fs3.cpSync(this.resolveDiskPath(src), this.resolveDiskPath(dest), { recursive: true });
|
|
1003
|
-
copied.push(this.statNode(dest));
|
|
1004
1090
|
}
|
|
1005
|
-
this.notifyChange();
|
|
1006
|
-
return copied;
|
|
1007
1091
|
}
|
|
1008
|
-
|
|
1009
|
-
const
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1092
|
+
async activateTab(tabId) {
|
|
1093
|
+
const next = this.tabs.get(tabId);
|
|
1094
|
+
if (!next) return;
|
|
1095
|
+
if (this.activeTabId && this.activeTabId !== tabId) {
|
|
1096
|
+
const prev = this.tabs.get(this.activeTabId);
|
|
1097
|
+
if (prev) await this.stopScreencast(prev);
|
|
1012
1098
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
if (src.startsWith("/.trash/")) {
|
|
1020
|
-
fs3.rmSync(this.resolveDiskPath(src), { recursive: true, force: true });
|
|
1021
|
-
delete this.meta.trashOrigins[src];
|
|
1022
|
-
continue;
|
|
1099
|
+
this.activeTabId = tabId;
|
|
1100
|
+
this.broadcastTabs();
|
|
1101
|
+
if (next.mode === "web" && next.page) {
|
|
1102
|
+
await this.applyTabMetrics(next);
|
|
1103
|
+
if (next.lastFrameBuffer) {
|
|
1104
|
+
this.broadcastBinary(next.lastFrameBuffer);
|
|
1023
1105
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
this.meta.trashOrigins[dest] = src;
|
|
1027
|
-
delete this.meta.positions[src];
|
|
1106
|
+
await this.startScreencast(next);
|
|
1107
|
+
await this.captureImmediateFrame(next);
|
|
1028
1108
|
}
|
|
1029
|
-
this.saveMeta();
|
|
1030
|
-
this.notifyChange();
|
|
1031
1109
|
}
|
|
1032
|
-
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1110
|
+
async closeTab(tabId) {
|
|
1111
|
+
const tab = this.tabs.get(tabId);
|
|
1112
|
+
if (!tab) return;
|
|
1113
|
+
await this.cleanupTabPage(tab);
|
|
1114
|
+
this.tabs.delete(tabId);
|
|
1115
|
+
const idx = this.tabOrder.indexOf(tabId);
|
|
1116
|
+
if (idx !== -1) this.tabOrder.splice(idx, 1);
|
|
1117
|
+
if (this.tabOrder.length === 0) {
|
|
1118
|
+
const fresh = this.createTabInternal("compute://newtab", true);
|
|
1119
|
+
this.activeTabId = fresh.id;
|
|
1120
|
+
this.broadcastTabs();
|
|
1121
|
+
return;
|
|
1044
1122
|
}
|
|
1045
|
-
this.
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
for (const rawPath of paths) {
|
|
1051
|
-
const src = this.normalizeVirtualPath(rawPath);
|
|
1052
|
-
if (SYSTEM_DIRS.includes(src) || src === "/") continue;
|
|
1053
|
-
fs3.rmSync(this.resolveDiskPath(src), { recursive: true, force: true });
|
|
1054
|
-
delete this.meta.trashOrigins[src];
|
|
1055
|
-
delete this.meta.positions[src];
|
|
1123
|
+
if (this.activeTabId === tabId) {
|
|
1124
|
+
const nextIdx = Math.min(idx, this.tabOrder.length - 1);
|
|
1125
|
+
await this.activateTab(this.tabOrder[nextIdx]);
|
|
1126
|
+
} else {
|
|
1127
|
+
this.broadcastTabs();
|
|
1056
1128
|
}
|
|
1057
|
-
this.saveMeta();
|
|
1058
|
-
this.notifyChange();
|
|
1059
1129
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1130
|
+
async cleanupTabPage(tab) {
|
|
1131
|
+
if (tab.settleTimer) {
|
|
1132
|
+
clearTimeout(tab.settleTimer);
|
|
1133
|
+
tab.settleTimer = void 0;
|
|
1134
|
+
}
|
|
1135
|
+
await this.stopScreencast(tab);
|
|
1136
|
+
if (tab.cdp) {
|
|
1137
|
+
try {
|
|
1138
|
+
await tab.cdp.detach();
|
|
1139
|
+
} catch {
|
|
1065
1140
|
}
|
|
1141
|
+
tab.cdp = void 0;
|
|
1066
1142
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
compressToZip(paths, targetDir, zipName) {
|
|
1072
|
-
if (!paths.length) throw new Error("Ar\u015Fivlenecek \xF6\u011Fe se\xE7ilmedi.");
|
|
1073
|
-
const zip = new AdmZip();
|
|
1074
|
-
for (const rawPath of paths) {
|
|
1075
|
-
const src = this.normalizeVirtualPath(rawPath);
|
|
1076
|
-
const diskSrc = this.resolveDiskPath(src);
|
|
1077
|
-
if (!fs3.existsSync(diskSrc)) continue;
|
|
1078
|
-
const st = fs3.statSync(diskSrc);
|
|
1079
|
-
if (st.isDirectory()) {
|
|
1080
|
-
zip.addLocalFolder(diskSrc, path3.posix.basename(src));
|
|
1081
|
-
} else {
|
|
1082
|
-
zip.addLocalFile(diskSrc);
|
|
1143
|
+
if (tab.page && !tab.page.isClosed()) {
|
|
1144
|
+
try {
|
|
1145
|
+
await tab.page.close();
|
|
1146
|
+
} catch {
|
|
1083
1147
|
}
|
|
1084
1148
|
}
|
|
1085
|
-
|
|
1086
|
-
const finalName = baseName.toLowerCase().endsWith(".zip") ? baseName : `${baseName}.zip`;
|
|
1087
|
-
const destVPath = this.getUniquePath(targetDir, finalName);
|
|
1088
|
-
zip.writeZip(this.resolveDiskPath(destVPath));
|
|
1089
|
-
this.notifyChange();
|
|
1090
|
-
return this.statNode(destVPath);
|
|
1149
|
+
tab.page = void 0;
|
|
1091
1150
|
}
|
|
1092
|
-
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1151
|
+
async attachPageHandlers(tab, page) {
|
|
1152
|
+
const cdp = await page.context().newCDPSession(page);
|
|
1153
|
+
tab.cdp = cdp;
|
|
1154
|
+
await this.applyTabMetrics(tab);
|
|
1155
|
+
cdp.on("Page.screencastFrame", (payload) => {
|
|
1156
|
+
cdp.send("Page.screencastFrameAck", { sessionId: payload.sessionId }).catch(() => {
|
|
1157
|
+
});
|
|
1158
|
+
const jpegBuf = Buffer.from(payload.data, "base64");
|
|
1159
|
+
const packet = Buffer.allocUnsafe(1 + jpegBuf.length);
|
|
1160
|
+
packet[0] = PACKET_VIDEO_JPEG;
|
|
1161
|
+
jpegBuf.copy(packet, 1);
|
|
1162
|
+
tab.lastFrameBuffer = packet;
|
|
1163
|
+
this.recordFrameTick();
|
|
1164
|
+
if (this.activeTabId === tab.id && tab.mode === "web") {
|
|
1165
|
+
this.broadcastBinary(packet);
|
|
1166
|
+
if (Date.now() > (tab.suppressSettleUntil || 0)) {
|
|
1167
|
+
if (tab.settleTimer) clearTimeout(tab.settleTimer);
|
|
1168
|
+
tab.settleTimer = setTimeout(() => {
|
|
1169
|
+
if (this.activeTabId === tab.id && tab.mode === "web") {
|
|
1170
|
+
this.captureImmediateFrame(tab).catch(() => {
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
}, 220);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
const syncPageMeta = async () => {
|
|
1178
|
+
if (page.isClosed() || tab.mode !== "web") return;
|
|
1179
|
+
try {
|
|
1180
|
+
const currentUrl = page.url();
|
|
1181
|
+
if (currentUrl && currentUrl !== "about:blank") tab.url = currentUrl;
|
|
1182
|
+
const title = await page.title().catch(() => "");
|
|
1183
|
+
if (title) {
|
|
1184
|
+
tab.title = title;
|
|
1185
|
+
} else {
|
|
1186
|
+
try {
|
|
1187
|
+
tab.title = new URL(tab.url).hostname || tab.url;
|
|
1188
|
+
} catch {
|
|
1189
|
+
tab.title = tab.url;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
try {
|
|
1193
|
+
const u = new URL(tab.url);
|
|
1194
|
+
tab.favicon = `https://www.google.com/s2/favicons?domain=${u.hostname}&sz=64`;
|
|
1195
|
+
} catch {
|
|
1196
|
+
tab.favicon = "";
|
|
1197
|
+
}
|
|
1198
|
+
if (tab.cdp) {
|
|
1199
|
+
const hist = await tab.cdp.send("Page.getNavigationHistory").catch(() => null);
|
|
1200
|
+
if (hist) {
|
|
1201
|
+
tab.canGoBack = hist.currentIndex > 0;
|
|
1202
|
+
tab.canGoForward = hist.currentIndex < hist.entries.length - 1;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
} catch {
|
|
1206
|
+
}
|
|
1207
|
+
this.broadcastTabs();
|
|
1208
|
+
};
|
|
1209
|
+
page.on("framenavigated", (frame) => {
|
|
1210
|
+
if (frame === page.mainFrame()) syncPageMeta();
|
|
1211
|
+
});
|
|
1212
|
+
page.on("domcontentloaded", () => {
|
|
1213
|
+
tab.isLoading = false;
|
|
1214
|
+
syncPageMeta();
|
|
1215
|
+
this.captureImmediateFrame(tab).catch(() => {
|
|
1216
|
+
});
|
|
1217
|
+
});
|
|
1218
|
+
page.on("load", () => {
|
|
1219
|
+
tab.isLoading = false;
|
|
1220
|
+
syncPageMeta();
|
|
1221
|
+
this.captureImmediateFrame(tab).catch(() => {
|
|
1222
|
+
});
|
|
1223
|
+
});
|
|
1224
|
+
page.on("download", async (download) => {
|
|
1225
|
+
try {
|
|
1226
|
+
const suggested = download.suggestedFilename() || `indirilen-${Date.now()}`;
|
|
1227
|
+
const downloadsDir = this.vfs.resolveDiskPath("/Downloads");
|
|
1228
|
+
fs3.mkdirSync(downloadsDir, { recursive: true });
|
|
1229
|
+
let finalName = suggested;
|
|
1230
|
+
let counter = 2;
|
|
1231
|
+
while (fs3.existsSync(path3.join(downloadsDir, finalName))) {
|
|
1232
|
+
const extIdx = suggested.lastIndexOf(".");
|
|
1233
|
+
finalName = extIdx > 0 ? `${suggested.slice(0, extIdx)} (${counter})${suggested.slice(extIdx)}` : `${suggested} (${counter})`;
|
|
1234
|
+
counter++;
|
|
1235
|
+
}
|
|
1236
|
+
await download.saveAs(path3.join(downloadsDir, finalName));
|
|
1237
|
+
this.vfs.notifyChange();
|
|
1238
|
+
this.broadcastJson({
|
|
1239
|
+
type: "download_complete",
|
|
1240
|
+
fileName: finalName,
|
|
1241
|
+
virtualPath: `/Downloads/${finalName}`
|
|
1242
|
+
});
|
|
1243
|
+
} catch (err) {
|
|
1244
|
+
this.broadcastJson({
|
|
1245
|
+
type: "browser_error",
|
|
1246
|
+
message: `\u0130ndirme ba\u015Far\u0131s\u0131z oldu: ${err.message}`
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1105
1250
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
1251
|
+
recordFrameTick() {
|
|
1252
|
+
this.frameCounter++;
|
|
1253
|
+
const now = Date.now();
|
|
1254
|
+
const elapsed = now - this.lastFpsCheck;
|
|
1255
|
+
if (elapsed >= 1e3) {
|
|
1256
|
+
this.currentFps = Math.round(this.frameCounter * 1e3 / elapsed);
|
|
1257
|
+
this.frameCounter = 0;
|
|
1258
|
+
this.lastFpsCheck = now;
|
|
1111
1259
|
}
|
|
1112
|
-
const buf = fs3.readFileSync(disk);
|
|
1113
|
-
return {
|
|
1114
|
-
content: buf.toString("utf-8"),
|
|
1115
|
-
node: this.statNode(norm)
|
|
1116
|
-
};
|
|
1117
|
-
}
|
|
1118
|
-
writeTextFile(vPath, content) {
|
|
1119
|
-
const norm = this.normalizeVirtualPath(vPath);
|
|
1120
|
-
const disk = this.resolveDiskPath(norm);
|
|
1121
|
-
fs3.mkdirSync(path3.dirname(disk), { recursive: true });
|
|
1122
|
-
fs3.writeFileSync(disk, content, "utf-8");
|
|
1123
|
-
this.notifyChange();
|
|
1124
|
-
return this.statNode(norm);
|
|
1125
1260
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1261
|
+
async startScreencast(tab) {
|
|
1262
|
+
if (!tab.cdp || tab.streaming || tab.mode !== "web") return;
|
|
1263
|
+
try {
|
|
1264
|
+
await tab.cdp.send("Page.startScreencast", {
|
|
1265
|
+
format: "jpeg",
|
|
1266
|
+
quality: 92,
|
|
1267
|
+
maxWidth: Math.round(this.viewport.width * this.dpr),
|
|
1268
|
+
maxHeight: Math.round(this.viewport.height * this.dpr),
|
|
1269
|
+
everyNthFrame: 1
|
|
1270
|
+
});
|
|
1271
|
+
tab.streaming = true;
|
|
1272
|
+
} catch {
|
|
1273
|
+
tab.streaming = false;
|
|
1274
|
+
}
|
|
1133
1275
|
}
|
|
1134
|
-
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1276
|
+
async stopScreencast(tab) {
|
|
1277
|
+
if (tab.settleTimer) {
|
|
1278
|
+
clearTimeout(tab.settleTimer);
|
|
1279
|
+
tab.settleTimer = void 0;
|
|
1137
1280
|
}
|
|
1138
|
-
if (
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1281
|
+
if (!tab.cdp || !tab.streaming) return;
|
|
1282
|
+
try {
|
|
1283
|
+
await tab.cdp.send("Page.stopScreencast");
|
|
1284
|
+
} catch {
|
|
1143
1285
|
}
|
|
1144
|
-
|
|
1145
|
-
return this.meta;
|
|
1146
|
-
}
|
|
1147
|
-
saveCustomWallpaper(originalName, buffer) {
|
|
1148
|
-
const wpDir = path3.join(this.instanceRoot, "wallpapers");
|
|
1149
|
-
fs3.mkdirSync(wpDir, { recursive: true });
|
|
1150
|
-
const rawExt = path3.extname(originalName || "").toLowerCase().replace(/[^.a-z0-9]/g, "") || ".png";
|
|
1151
|
-
const fileName = `wp-${Date.now()}${rawExt}`;
|
|
1152
|
-
fs3.writeFileSync(path3.join(wpDir, fileName), buffer);
|
|
1153
|
-
this.meta.preferences.wallpaper = "custom";
|
|
1154
|
-
this.meta.preferences.customWallpaper = fileName;
|
|
1155
|
-
this.saveMeta();
|
|
1156
|
-
return this.meta;
|
|
1286
|
+
tab.streaming = false;
|
|
1157
1287
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1288
|
+
async captureImmediateFrame(tab) {
|
|
1289
|
+
if (!tab.page || tab.page.isClosed() || tab.mode !== "web") return;
|
|
1290
|
+
try {
|
|
1291
|
+
tab.suppressSettleUntil = Date.now() + 380;
|
|
1292
|
+
const pngBuf = await tab.page.screenshot({ type: "png" });
|
|
1293
|
+
const packet = Buffer.allocUnsafe(1 + pngBuf.length);
|
|
1294
|
+
packet[0] = PACKET_VIDEO_JPEG;
|
|
1295
|
+
pngBuf.copy(packet, 1);
|
|
1296
|
+
if (tab.lastFrameBuffer && tab.lastFrameBuffer.length === packet.length && tab.lastFrameBuffer.equals(packet)) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
tab.lastFrameBuffer = packet;
|
|
1300
|
+
if (this.activeTabId === tab.id) {
|
|
1301
|
+
this.broadcastBinary(packet);
|
|
1302
|
+
}
|
|
1303
|
+
} catch {
|
|
1162
1304
|
}
|
|
1163
|
-
const buf = fs3.readFileSync(disk);
|
|
1164
|
-
return this.saveCustomWallpaper(path3.basename(disk), buf);
|
|
1165
1305
|
}
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
|
|
1306
|
+
async navigate(tabId, rawInput) {
|
|
1307
|
+
const tab = this.tabs.get(tabId);
|
|
1308
|
+
if (!tab) return;
|
|
1309
|
+
const parsed = normalizeUserUrl(rawInput);
|
|
1310
|
+
tab.mode = parsed.mode;
|
|
1311
|
+
tab.filePath = parsed.filePath;
|
|
1312
|
+
tab.url = parsed.url;
|
|
1313
|
+
if (parsed.mode === "newtab") {
|
|
1314
|
+
await this.stopScreencast(tab);
|
|
1315
|
+
tab.title = "Yeni Sekme";
|
|
1316
|
+
tab.favicon = "";
|
|
1317
|
+
tab.isLoading = false;
|
|
1318
|
+
this.broadcastTabs();
|
|
1319
|
+
return;
|
|
1172
1320
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
// server/chromiumManager.ts
|
|
1183
|
-
import fs4 from "node:fs";
|
|
1184
|
-
import os3 from "node:os";
|
|
1185
|
-
import path4 from "node:path";
|
|
1186
|
-
async function loadPlaywrightChromium() {
|
|
1187
|
-
try {
|
|
1188
|
-
const pw = await import("playwright-core");
|
|
1189
|
-
return pw.chromium;
|
|
1190
|
-
} catch {
|
|
1191
|
-
throw new Error("Yerle\u015Fik Playwright Chromium y\xFCkl\xFC de\u011Fil. Linux sunucuda Firefox veya di\u011Fer yerel uygulamalar\u0131 kullan\u0131n.");
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
var PACKET_VIDEO_JPEG = 1;
|
|
1195
|
-
var PACKET_AUDIO_PCM = 2;
|
|
1196
|
-
function findChromiumExecutable(chromiumRef) {
|
|
1197
|
-
try {
|
|
1198
|
-
const defaultPath = chromiumRef?.executablePath();
|
|
1199
|
-
if (defaultPath && fs4.existsSync(defaultPath)) {
|
|
1200
|
-
return defaultPath;
|
|
1321
|
+
if (parsed.mode === "file") {
|
|
1322
|
+
await this.stopScreencast(tab);
|
|
1323
|
+
tab.title = path3.posix.basename(parsed.filePath || "Dosya");
|
|
1324
|
+
tab.favicon = "";
|
|
1325
|
+
tab.isLoading = false;
|
|
1326
|
+
this.broadcastTabs();
|
|
1327
|
+
return;
|
|
1201
1328
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1329
|
+
tab.isLoading = true;
|
|
1330
|
+
try {
|
|
1331
|
+
tab.title = new URL(parsed.url).hostname || parsed.url;
|
|
1332
|
+
} catch {
|
|
1333
|
+
tab.title = parsed.url;
|
|
1334
|
+
}
|
|
1335
|
+
this.broadcastTabs();
|
|
1336
|
+
try {
|
|
1337
|
+
const ctx = await this.ensureContext();
|
|
1338
|
+
if (!tab.page || tab.page.isClosed()) {
|
|
1339
|
+
this.internalPageCreating++;
|
|
1340
|
+
try {
|
|
1341
|
+
const page = await ctx.newPage();
|
|
1342
|
+
tab.page = page;
|
|
1343
|
+
await this.attachPageHandlers(tab, page);
|
|
1344
|
+
} finally {
|
|
1345
|
+
this.internalPageCreating--;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (this.activeTabId === tab.id) {
|
|
1349
|
+
await this.startScreencast(tab);
|
|
1222
1350
|
}
|
|
1351
|
+
await tab.page.goto(parsed.url, {
|
|
1352
|
+
waitUntil: "domcontentloaded",
|
|
1353
|
+
timeout: 25e3
|
|
1354
|
+
});
|
|
1355
|
+
tab.isLoading = false;
|
|
1356
|
+
this.broadcastTabs();
|
|
1357
|
+
await this.captureImmediateFrame(tab);
|
|
1358
|
+
} catch (err) {
|
|
1359
|
+
tab.isLoading = false;
|
|
1360
|
+
this.broadcastTabs();
|
|
1361
|
+
this.broadcastJson({
|
|
1362
|
+
type: "browser_error",
|
|
1363
|
+
tabId: tab.id,
|
|
1364
|
+
message: `Sayfa y\xFCklenemedi: ${err.message}`
|
|
1365
|
+
});
|
|
1223
1366
|
}
|
|
1224
1367
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
"
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
if (fs4.existsSync(candidate)) return candidate;
|
|
1236
|
-
}
|
|
1237
|
-
return void 0;
|
|
1238
|
-
}
|
|
1239
|
-
function normalizeUserUrl(rawInput) {
|
|
1240
|
-
const trimmed = rawInput.trim();
|
|
1241
|
-
if (!trimmed || trimmed === "compute://newtab" || trimmed === "about:blank") {
|
|
1242
|
-
return { mode: "newtab", url: "compute://newtab" };
|
|
1243
|
-
}
|
|
1244
|
-
if (trimmed.startsWith("file://")) {
|
|
1245
|
-
const rawPath = decodeURIComponent(trimmed.replace(/^file:\/\/\/?/, "/"));
|
|
1246
|
-
const normPath = ("/" + rawPath).replace(/\/+/g, "/");
|
|
1247
|
-
return { mode: "file", url: `file://${normPath}`, filePath: normPath };
|
|
1248
|
-
}
|
|
1249
|
-
if (/^https?:\/\//i.test(trimmed)) {
|
|
1250
|
-
return { mode: "web", url: trimmed };
|
|
1368
|
+
async goBack(tabId) {
|
|
1369
|
+
const tab = this.tabs.get(tabId);
|
|
1370
|
+
if (!tab?.page || tab.mode !== "web") return;
|
|
1371
|
+
tab.isLoading = true;
|
|
1372
|
+
this.broadcastTabs();
|
|
1373
|
+
await tab.page.goBack({ waitUntil: "domcontentloaded" }).catch(() => {
|
|
1374
|
+
});
|
|
1375
|
+
tab.isLoading = false;
|
|
1376
|
+
this.broadcastTabs();
|
|
1377
|
+
await this.captureImmediateFrame(tab);
|
|
1251
1378
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1379
|
+
async goForward(tabId) {
|
|
1380
|
+
const tab = this.tabs.get(tabId);
|
|
1381
|
+
if (!tab?.page || tab.mode !== "web") return;
|
|
1382
|
+
tab.isLoading = true;
|
|
1383
|
+
this.broadcastTabs();
|
|
1384
|
+
await tab.page.goForward({ waitUntil: "domcontentloaded" }).catch(() => {
|
|
1385
|
+
});
|
|
1386
|
+
tab.isLoading = false;
|
|
1387
|
+
this.broadcastTabs();
|
|
1388
|
+
await this.captureImmediateFrame(tab);
|
|
1257
1389
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
(() => {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
const retainedNodes = [];
|
|
1272
|
-
const hookedElements = new WeakSet();
|
|
1273
|
-
const hookedContexts = new WeakSet();
|
|
1274
|
-
|
|
1275
|
-
function sendFloatBufferAsPcm(ch0, ch1) {
|
|
1276
|
-
if (typeof window.__rcPushAudioBase64 !== 'function') return;
|
|
1277
|
-
const len = ch0.length;
|
|
1278
|
-
let peak = 0;
|
|
1279
|
-
for (let i = 0; i < len; i += 4) {
|
|
1280
|
-
const a = Math.abs(ch0[i]);
|
|
1281
|
-
if (a > peak) peak = a;
|
|
1282
|
-
}
|
|
1283
|
-
if (peak < 0.00035) return;
|
|
1284
|
-
|
|
1285
|
-
const pcm16 = new Int16Array(len);
|
|
1286
|
-
for (let i = 0; i < len; i++) {
|
|
1287
|
-
const mono = ch1 ? (ch0[i] + ch1[i]) * 0.5 : ch0[i];
|
|
1288
|
-
const clamped = mono < -1 ? -1 : mono > 1 ? 1 : mono;
|
|
1289
|
-
pcm16[i] = clamped * 32767;
|
|
1390
|
+
async reload(tabId) {
|
|
1391
|
+
const tab = this.tabs.get(tabId);
|
|
1392
|
+
if (!tab) return;
|
|
1393
|
+
if (tab.mode === "web" && tab.page) {
|
|
1394
|
+
tab.isLoading = true;
|
|
1395
|
+
this.broadcastTabs();
|
|
1396
|
+
await tab.page.reload({ waitUntil: "domcontentloaded" }).catch(() => {
|
|
1397
|
+
});
|
|
1398
|
+
tab.isLoading = false;
|
|
1399
|
+
this.broadcastTabs();
|
|
1400
|
+
await this.captureImmediateFrame(tab);
|
|
1401
|
+
} else {
|
|
1402
|
+
this.broadcastTabs();
|
|
1290
1403
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1404
|
+
}
|
|
1405
|
+
async setViewport(width, height, dpr) {
|
|
1406
|
+
const w = Math.max(360, Math.min(1920, Math.round(width)));
|
|
1407
|
+
const h = Math.max(260, Math.min(1200, Math.round(height)));
|
|
1408
|
+
const nextDpr = dpr && Number.isFinite(dpr) ? Math.max(1, Math.min(2, Number(dpr))) : this.dpr;
|
|
1409
|
+
const sizeChanged = Math.abs(this.viewport.width - w) >= 4 || Math.abs(this.viewport.height - h) >= 4;
|
|
1410
|
+
const dprChanged = Math.abs(this.dpr - nextDpr) >= 0.05;
|
|
1411
|
+
if (!sizeChanged && !dprChanged) return;
|
|
1412
|
+
this.viewport = { width: w, height: h };
|
|
1413
|
+
this.dpr = nextDpr;
|
|
1414
|
+
const active = this.activeTabId ? this.tabs.get(this.activeTabId) : void 0;
|
|
1415
|
+
if (active?.mode === "web" && active.page && !active.page.isClosed()) {
|
|
1416
|
+
try {
|
|
1417
|
+
await this.stopScreencast(active);
|
|
1418
|
+
await this.applyTabMetrics(active);
|
|
1419
|
+
await this.startScreencast(active);
|
|
1420
|
+
await this.captureImmediateFrame(active);
|
|
1421
|
+
} catch {
|
|
1422
|
+
}
|
|
1295
1423
|
}
|
|
1296
|
-
window.__rcPushAudioBase64(btoa(binary)).catch(() => {});
|
|
1297
1424
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
if (
|
|
1301
|
-
|
|
1425
|
+
handleInput(payload) {
|
|
1426
|
+
const tabId = payload.tabId || this.activeTabId;
|
|
1427
|
+
if (!tabId) return;
|
|
1428
|
+
const tab = this.tabs.get(tabId);
|
|
1429
|
+
if (!tab || tab.mode !== "web" || !tab.page || !tab.cdp || tab.page.isClosed()) return;
|
|
1430
|
+
const kind = payload.kind;
|
|
1431
|
+
if (kind === "mouse") {
|
|
1432
|
+
const eventType = payload.eventType;
|
|
1433
|
+
tab.cdp.send("Input.dispatchMouseEvent", {
|
|
1434
|
+
type: eventType,
|
|
1435
|
+
x: Number(payload.x) || 0,
|
|
1436
|
+
y: Number(payload.y) || 0,
|
|
1437
|
+
button: payload.button || "none",
|
|
1438
|
+
clickCount: Number(payload.clickCount) || 1,
|
|
1439
|
+
modifiers: Number(payload.modifiers) || 0,
|
|
1440
|
+
deltaX: Number(payload.deltaX) || 0,
|
|
1441
|
+
deltaY: Number(payload.deltaY) || 0
|
|
1442
|
+
}).catch(() => {
|
|
1443
|
+
});
|
|
1302
1444
|
return;
|
|
1303
1445
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
sendFloatBufferAsPcm(ch0, ch1);
|
|
1318
|
-
};
|
|
1319
|
-
} catch {}
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
function attachMediaElement(el) {
|
|
1323
|
-
if (!el || hookedElements.has(el)) return;
|
|
1324
|
-
ensurePipeline();
|
|
1325
|
-
if (!mixCtx || !mixGain) return;
|
|
1326
|
-
if (mixCtx.state === 'suspended') mixCtx.resume().catch(() => {});
|
|
1327
|
-
|
|
1328
|
-
try {
|
|
1329
|
-
const src = mixCtx.createMediaElementSource(el);
|
|
1330
|
-
const volGain = mixCtx.createGain();
|
|
1331
|
-
const syncVol = () => {
|
|
1332
|
-
volGain.gain.value = el.muted ? 0 : el.volume;
|
|
1333
|
-
};
|
|
1334
|
-
syncVol();
|
|
1335
|
-
el.addEventListener('volumechange', syncVol);
|
|
1336
|
-
src.connect(volGain);
|
|
1337
|
-
volGain.connect(mixGain);
|
|
1338
|
-
retainedNodes.push(src, volGain);
|
|
1339
|
-
hookedElements.add(el);
|
|
1340
|
-
} catch {}
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
// Also capture WebAudio API sounds (synths, games, web apps) connected to ctx.destination
|
|
1344
|
-
const origConnect = AudioNode.prototype.connect;
|
|
1345
|
-
AudioNode.prototype.connect = function (dest, ...rest) {
|
|
1346
|
-
const result = origConnect.call(this, dest, ...rest);
|
|
1347
|
-
try {
|
|
1348
|
-
if (
|
|
1349
|
-
dest &&
|
|
1350
|
-
this.context &&
|
|
1351
|
-
dest === this.context.destination &&
|
|
1352
|
-
!hookedContexts.has(this.context)
|
|
1353
|
-
) {
|
|
1354
|
-
hookedContexts.add(this.context);
|
|
1355
|
-
const ctx = this.context;
|
|
1356
|
-
const tap = ctx.createScriptProcessor(2048, 2, 2);
|
|
1357
|
-
origConnect.call(this, tap);
|
|
1358
|
-
origConnect.call(tap, ctx.destination);
|
|
1359
|
-
const ratio = ctx.sampleRate / 24000;
|
|
1360
|
-
tap.onaudioprocess = (ev) => {
|
|
1361
|
-
const in0 = ev.inputBuffer.getChannelData(0);
|
|
1362
|
-
const outLen = Math.floor(in0.length / ratio);
|
|
1363
|
-
const resampled = new Float32Array(outLen);
|
|
1364
|
-
for (let i = 0; i < outLen; i++) {
|
|
1365
|
-
resampled[i] = in0[Math.min(in0.length - 1, Math.round(i * ratio))];
|
|
1366
|
-
}
|
|
1367
|
-
sendFloatBufferAsPcm(resampled, null);
|
|
1368
|
-
};
|
|
1446
|
+
if (kind === "key") {
|
|
1447
|
+
const key = String(payload.key || "");
|
|
1448
|
+
const ctrlOrMeta = Boolean(payload.ctrlKey || payload.metaKey);
|
|
1449
|
+
const shiftKey = Boolean(payload.shiftKey);
|
|
1450
|
+
const altKey = Boolean(payload.altKey);
|
|
1451
|
+
const modPrefix = process.platform === "darwin" ? "Meta" : "Control";
|
|
1452
|
+
if (ctrlOrMeta && key.length === 1) {
|
|
1453
|
+
const lower = key.toLowerCase();
|
|
1454
|
+
if (["a", "c", "x", "z", "y", "f"].includes(lower)) {
|
|
1455
|
+
tab.page.keyboard.press(`${modPrefix}+${shiftKey ? "Shift+" : ""}${lower}`).catch(() => {
|
|
1456
|
+
});
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1369
1459
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1460
|
+
const specialKeys = /* @__PURE__ */ new Set([
|
|
1461
|
+
"Enter",
|
|
1462
|
+
"Backspace",
|
|
1463
|
+
"Tab",
|
|
1464
|
+
"Escape",
|
|
1465
|
+
"Delete",
|
|
1466
|
+
"ArrowLeft",
|
|
1467
|
+
"ArrowRight",
|
|
1468
|
+
"ArrowUp",
|
|
1469
|
+
"ArrowDown",
|
|
1470
|
+
"Home",
|
|
1471
|
+
"End",
|
|
1472
|
+
"PageUp",
|
|
1473
|
+
"PageDown",
|
|
1474
|
+
"F5"
|
|
1475
|
+
]);
|
|
1476
|
+
if (specialKeys.has(key)) {
|
|
1477
|
+
const mods = [];
|
|
1478
|
+
if (ctrlOrMeta) mods.push(modPrefix);
|
|
1479
|
+
if (altKey) mods.push("Alt");
|
|
1480
|
+
if (shiftKey) mods.push("Shift");
|
|
1481
|
+
tab.page.keyboard.press([...mods, key].join("+")).catch(() => {
|
|
1482
|
+
});
|
|
1483
|
+
} else if (key.length === 1 && !ctrlOrMeta) {
|
|
1484
|
+
tab.page.keyboard.insertText(key).catch(() => {
|
|
1485
|
+
});
|
|
1386
1486
|
}
|
|
1487
|
+
return;
|
|
1387
1488
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
browser = null;
|
|
1393
|
-
launching = null;
|
|
1394
|
-
sessions = /* @__PURE__ */ new Map();
|
|
1395
|
-
executableUsed = "Chromium";
|
|
1396
|
-
async getBrowser() {
|
|
1397
|
-
if (this.browser && this.browser.isConnected()) {
|
|
1398
|
-
return this.browser;
|
|
1489
|
+
if (kind === "paste") {
|
|
1490
|
+
const text = String(payload.text || "");
|
|
1491
|
+
if (text) tab.page.keyboard.insertText(text).catch(() => {
|
|
1492
|
+
});
|
|
1399
1493
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1494
|
+
}
|
|
1495
|
+
async dispose() {
|
|
1496
|
+
for (const tab of this.tabs.values()) {
|
|
1497
|
+
await this.cleanupTabPage(tab);
|
|
1402
1498
|
}
|
|
1403
|
-
this.
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
const launched = await chromiumApi.launch({
|
|
1408
|
-
executablePath,
|
|
1409
|
-
headless: true,
|
|
1410
|
-
args: [
|
|
1411
|
-
"--no-sandbox",
|
|
1412
|
-
"--disable-setuid-sandbox",
|
|
1413
|
-
"--disable-dev-shm-usage",
|
|
1414
|
-
"--disable-blink-features=AutomationControlled",
|
|
1415
|
-
"--autoplay-policy=no-user-gesture-required",
|
|
1416
|
-
"--font-render-hinting=none"
|
|
1417
|
-
]
|
|
1499
|
+
this.tabs.clear();
|
|
1500
|
+
this.tabOrder = [];
|
|
1501
|
+
if (this.context) {
|
|
1502
|
+
await this.context.close().catch(() => {
|
|
1418
1503
|
});
|
|
1419
|
-
this.
|
|
1420
|
-
return launched;
|
|
1421
|
-
})();
|
|
1422
|
-
try {
|
|
1423
|
-
return await this.launching;
|
|
1424
|
-
} finally {
|
|
1425
|
-
this.launching = null;
|
|
1504
|
+
this.context = null;
|
|
1426
1505
|
}
|
|
1427
1506
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
// server/index.ts
|
|
1510
|
+
import express from "express";
|
|
1511
|
+
import cors from "cors";
|
|
1512
|
+
import http2 from "node:http";
|
|
1513
|
+
import os5 from "node:os";
|
|
1514
|
+
import path8 from "node:path";
|
|
1515
|
+
import fs8 from "node:fs";
|
|
1516
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1517
|
+
import multer from "multer";
|
|
1518
|
+
import { WebSocketServer, WebSocket } from "ws";
|
|
1519
|
+
|
|
1520
|
+
// server/vfsManager.ts
|
|
1521
|
+
import fs4 from "node:fs";
|
|
1522
|
+
import path4 from "node:path";
|
|
1523
|
+
import AdmZip from "adm-zip";
|
|
1524
|
+
var STORAGE_ROOT = path4.resolve(process.cwd(), "storage");
|
|
1525
|
+
var DESKTOPS_ROOT = path4.join(STORAGE_ROOT, "desktops");
|
|
1526
|
+
var REGISTRY_FILE = path4.join(DESKTOPS_ROOT, "registry.json");
|
|
1527
|
+
function setStorageRoot(dir) {
|
|
1528
|
+
STORAGE_ROOT = path4.resolve(dir);
|
|
1529
|
+
DESKTOPS_ROOT = path4.join(STORAGE_ROOT, "desktops");
|
|
1530
|
+
REGISTRY_FILE = path4.join(DESKTOPS_ROOT, "registry.json");
|
|
1531
|
+
fs4.mkdirSync(DESKTOPS_ROOT, { recursive: true });
|
|
1532
|
+
}
|
|
1533
|
+
var SYSTEM_DIRS = ["/Desktop", "/Documents", "/Downloads", "/Projects", "/.trash"];
|
|
1534
|
+
function sanitizeDesktopId(raw) {
|
|
1535
|
+
const cleaned = (raw || "main").toLowerCase().replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
1536
|
+
return cleaned || "main";
|
|
1537
|
+
}
|
|
1538
|
+
function extractExtension(name, isDir) {
|
|
1539
|
+
if (isDir) return "";
|
|
1540
|
+
const lower = name.toLowerCase();
|
|
1541
|
+
if (lower.endsWith(".tar.gz")) return "tar.gz";
|
|
1542
|
+
if (lower.startsWith(".") && !lower.slice(1).includes(".")) {
|
|
1543
|
+
return lower.slice(1);
|
|
1544
|
+
}
|
|
1545
|
+
const idx = lower.lastIndexOf(".");
|
|
1546
|
+
if (idx <= 0 || idx === lower.length - 1) return "";
|
|
1547
|
+
return lower.slice(idx + 1);
|
|
1548
|
+
}
|
|
1549
|
+
var DesktopRegistry = class {
|
|
1550
|
+
desktops = [];
|
|
1551
|
+
constructor() {
|
|
1552
|
+
fs4.mkdirSync(DESKTOPS_ROOT, { recursive: true });
|
|
1553
|
+
this.migrateLegacyIfPresent();
|
|
1554
|
+
this.load();
|
|
1555
|
+
}
|
|
1556
|
+
migrateLegacyIfPresent() {
|
|
1557
|
+
const legacyVfs = path4.join(STORAGE_ROOT, "vfs");
|
|
1558
|
+
const mainDir = path4.join(DESKTOPS_ROOT, "main");
|
|
1559
|
+
if (fs4.existsSync(legacyVfs) && !fs4.existsSync(mainDir)) {
|
|
1560
|
+
fs4.mkdirSync(mainDir, { recursive: true });
|
|
1561
|
+
fs4.cpSync(legacyVfs, path4.join(mainDir, "vfs"), { recursive: true });
|
|
1562
|
+
const legacyMeta = path4.join(STORAGE_ROOT, "meta.json");
|
|
1563
|
+
if (fs4.existsSync(legacyMeta)) {
|
|
1564
|
+
fs4.cpSync(legacyMeta, path4.join(mainDir, "meta.json"));
|
|
1565
|
+
}
|
|
1566
|
+
fs4.writeFileSync(path4.join(mainDir, ".seeded"), (/* @__PURE__ */ new Date()).toISOString(), "utf-8");
|
|
1433
1567
|
}
|
|
1434
|
-
return session;
|
|
1435
|
-
}
|
|
1436
|
-
async destroySession(desktopId) {
|
|
1437
|
-
const session = this.sessions.get(desktopId);
|
|
1438
|
-
if (!session) return;
|
|
1439
|
-
this.sessions.delete(desktopId);
|
|
1440
|
-
await session.dispose();
|
|
1441
1568
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1569
|
+
load() {
|
|
1570
|
+
if (fs4.existsSync(REGISTRY_FILE)) {
|
|
1571
|
+
try {
|
|
1572
|
+
const parsed = JSON.parse(fs4.readFileSync(REGISTRY_FILE, "utf-8"));
|
|
1573
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
1574
|
+
this.desktops = parsed;
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
} catch {
|
|
1578
|
+
}
|
|
1449
1579
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1580
|
+
this.desktops = [
|
|
1581
|
+
{
|
|
1582
|
+
id: "main",
|
|
1583
|
+
name: "Masa\xFCst\xFC 1",
|
|
1584
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1585
|
+
}
|
|
1586
|
+
];
|
|
1587
|
+
this.save();
|
|
1457
1588
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
vfs;
|
|
1462
|
-
cluster;
|
|
1463
|
-
context = null;
|
|
1464
|
-
contextCreating = null;
|
|
1465
|
-
tabs = /* @__PURE__ */ new Map();
|
|
1466
|
-
tabOrder = [];
|
|
1467
|
-
activeTabId = null;
|
|
1468
|
-
viewport = { width: 1160, height: 700 };
|
|
1469
|
-
jsonListeners = /* @__PURE__ */ new Set();
|
|
1470
|
-
binaryListeners = /* @__PURE__ */ new Set();
|
|
1471
|
-
internalPageCreating = 0;
|
|
1472
|
-
frameCounter = 0;
|
|
1473
|
-
lastFpsCheck = Date.now();
|
|
1474
|
-
currentFps = 0;
|
|
1475
|
-
constructor(desktopId, vfs, cluster) {
|
|
1476
|
-
this.desktopId = desktopId;
|
|
1477
|
-
this.vfs = vfs;
|
|
1478
|
-
this.cluster = cluster;
|
|
1479
|
-
this.createTabInternal("compute://newtab", true);
|
|
1589
|
+
save() {
|
|
1590
|
+
fs4.mkdirSync(DESKTOPS_ROOT, { recursive: true });
|
|
1591
|
+
fs4.writeFileSync(REGISTRY_FILE, JSON.stringify(this.desktops, null, 2), "utf-8");
|
|
1480
1592
|
}
|
|
1481
|
-
|
|
1482
|
-
return
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1593
|
+
list() {
|
|
1594
|
+
return [...this.desktops];
|
|
1595
|
+
}
|
|
1596
|
+
ensureDesktop(rawId, desiredName) {
|
|
1597
|
+
const id = sanitizeDesktopId(rawId);
|
|
1598
|
+
const existing = this.desktops.find((d) => d.id === id);
|
|
1599
|
+
if (existing) return existing;
|
|
1600
|
+
const info = {
|
|
1601
|
+
id,
|
|
1602
|
+
name: desiredName?.trim() || `Masa\xFCst\xFC ${this.desktops.length + 1}`,
|
|
1603
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1486
1604
|
};
|
|
1605
|
+
this.desktops.push(info);
|
|
1606
|
+
this.save();
|
|
1607
|
+
return info;
|
|
1487
1608
|
}
|
|
1488
|
-
|
|
1489
|
-
this.
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
onBinary(active.lastFrameBuffer);
|
|
1609
|
+
createNewDesktop(name) {
|
|
1610
|
+
const nextNum = this.desktops.length + 1;
|
|
1611
|
+
const cleanTitle = name?.trim() || `Masa\xFCst\xFC ${nextNum}`;
|
|
1612
|
+
const baseSlug = sanitizeDesktopId(
|
|
1613
|
+
cleanTitle.replace(/ğ/gi, "g").replace(/ü/gi, "u").replace(/ş/gi, "s").replace(/ı/gi, "i").replace(/ö/gi, "o").replace(/ç/gi, "c")
|
|
1614
|
+
);
|
|
1615
|
+
let candidate = baseSlug || `masaustu-${nextNum}`;
|
|
1616
|
+
let counter = 2;
|
|
1617
|
+
while (this.desktops.some((d) => d.id === candidate)) {
|
|
1618
|
+
candidate = `${baseSlug}-${counter++}`;
|
|
1499
1619
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1620
|
+
const info = {
|
|
1621
|
+
id: candidate,
|
|
1622
|
+
name: cleanTitle,
|
|
1623
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1503
1624
|
};
|
|
1625
|
+
this.desktops.push(info);
|
|
1626
|
+
this.save();
|
|
1627
|
+
return info;
|
|
1504
1628
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1629
|
+
renameDesktop(rawId, newName) {
|
|
1630
|
+
const id = sanitizeDesktopId(rawId);
|
|
1631
|
+
const item = this.desktops.find((d) => d.id === id);
|
|
1632
|
+
if (!item) throw new Error("Masa\xFCst\xFC bulunamad\u0131.");
|
|
1633
|
+
const trimmed = newName.trim();
|
|
1634
|
+
if (!trimmed) throw new Error("Masa\xFCst\xFC ad\u0131 bo\u015F olamaz.");
|
|
1635
|
+
item.name = trimmed;
|
|
1636
|
+
this.save();
|
|
1637
|
+
return item;
|
|
1638
|
+
}
|
|
1639
|
+
deleteDesktop(rawId) {
|
|
1640
|
+
const id = sanitizeDesktopId(rawId);
|
|
1641
|
+
if (this.desktops.length <= 1) {
|
|
1642
|
+
throw new Error("En az bir sanal masa\xFCst\xFC aktif kalmal\u0131d\u0131r.");
|
|
1643
|
+
}
|
|
1644
|
+
const idx = this.desktops.findIndex((d) => d.id === id);
|
|
1645
|
+
if (idx === -1) return this.list();
|
|
1646
|
+
this.desktops.splice(idx, 1);
|
|
1647
|
+
this.save();
|
|
1648
|
+
const dir = path4.join(DESKTOPS_ROOT, id);
|
|
1649
|
+
if (fs4.existsSync(dir)) {
|
|
1650
|
+
fs4.rmSync(dir, { recursive: true, force: true });
|
|
1511
1651
|
}
|
|
1652
|
+
return this.list();
|
|
1512
1653
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1654
|
+
};
|
|
1655
|
+
var VFSManager = class {
|
|
1656
|
+
desktopId;
|
|
1657
|
+
instanceRoot;
|
|
1658
|
+
vfsRoot;
|
|
1659
|
+
metaFile;
|
|
1660
|
+
meta;
|
|
1661
|
+
changeListeners = /* @__PURE__ */ new Set();
|
|
1662
|
+
constructor(desktopId, hostRootOverride) {
|
|
1663
|
+
this.desktopId = sanitizeDesktopId(desktopId);
|
|
1664
|
+
this.instanceRoot = path4.join(DESKTOPS_ROOT, this.desktopId);
|
|
1665
|
+
this.vfsRoot = hostRootOverride ? path4.resolve(hostRootOverride) : path4.join(this.instanceRoot, "vfs");
|
|
1666
|
+
this.metaFile = path4.join(this.instanceRoot, "meta.json");
|
|
1667
|
+
fs4.mkdirSync(this.instanceRoot, { recursive: true });
|
|
1668
|
+
fs4.mkdirSync(this.vfsRoot, { recursive: true });
|
|
1669
|
+
this.meta = this.loadMeta();
|
|
1670
|
+
if (!hostRootOverride) {
|
|
1671
|
+
this.ensureSeedWorkspace();
|
|
1672
|
+
} else {
|
|
1673
|
+
for (const dir of SYSTEM_DIRS) {
|
|
1674
|
+
fs4.mkdirSync(this.resolveDiskPath(dir), { recursive: true });
|
|
1518
1675
|
}
|
|
1519
1676
|
}
|
|
1520
1677
|
}
|
|
1521
|
-
|
|
1522
|
-
this.
|
|
1523
|
-
type: "tabs_state",
|
|
1524
|
-
tabs: this.getTabsSummary(),
|
|
1525
|
-
activeTabId: this.activeTabId
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
getTabsSummary() {
|
|
1529
|
-
const now = Date.now();
|
|
1530
|
-
return this.tabOrder.map((id) => this.tabs.get(id)).filter((t) => Boolean(t)).map((t) => ({
|
|
1531
|
-
id: t.id,
|
|
1532
|
-
url: t.url,
|
|
1533
|
-
title: t.title,
|
|
1534
|
-
favicon: t.favicon,
|
|
1535
|
-
isLoading: t.isLoading,
|
|
1536
|
-
canGoBack: t.canGoBack,
|
|
1537
|
-
canGoForward: t.canGoForward,
|
|
1538
|
-
isSecure: t.url.startsWith("https://") || t.url.startsWith("compute://") || t.url.startsWith("file://"),
|
|
1539
|
-
isPlayingAudio: now - t.lastAudioAt < 1500,
|
|
1540
|
-
mode: t.mode,
|
|
1541
|
-
filePath: t.filePath
|
|
1542
|
-
}));
|
|
1678
|
+
getInstanceRoot() {
|
|
1679
|
+
return this.instanceRoot;
|
|
1543
1680
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
if (this.contextCreating) return this.contextCreating;
|
|
1547
|
-
this.contextCreating = (async () => {
|
|
1548
|
-
const browser = await this.cluster.getBrowser();
|
|
1549
|
-
const ctx = await browser.newContext({
|
|
1550
|
-
viewport: this.viewport,
|
|
1551
|
-
deviceScaleFactor: 1,
|
|
1552
|
-
locale: "tr-TR",
|
|
1553
|
-
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
|
1554
|
-
acceptDownloads: true
|
|
1555
|
-
});
|
|
1556
|
-
await ctx.exposeBinding("__rcPushAudioBase64", (source, b64) => {
|
|
1557
|
-
if (this.binaryListeners.size === 0 || !b64) return;
|
|
1558
|
-
const matchingTab = Array.from(this.tabs.values()).find((t) => t.page === source.page);
|
|
1559
|
-
if (!matchingTab) return;
|
|
1560
|
-
matchingTab.lastAudioAt = Date.now();
|
|
1561
|
-
if (matchingTab.id !== this.activeTabId || matchingTab.mode !== "web") return;
|
|
1562
|
-
const pcmBuf = Buffer.from(b64, "base64");
|
|
1563
|
-
const packet = Buffer.allocUnsafe(1 + pcmBuf.length);
|
|
1564
|
-
packet[0] = PACKET_AUDIO_PCM;
|
|
1565
|
-
pcmBuf.copy(packet, 1);
|
|
1566
|
-
this.broadcastBinary(packet);
|
|
1567
|
-
});
|
|
1568
|
-
await ctx.addInitScript(AUDIO_CAPTURE_INIT_SCRIPT);
|
|
1569
|
-
ctx.on("page", async (newPage) => {
|
|
1570
|
-
if (this.internalPageCreating > 0) return;
|
|
1571
|
-
const alreadyTracked = Array.from(this.tabs.values()).some((t) => t.page === newPage);
|
|
1572
|
-
if (alreadyTracked) return;
|
|
1573
|
-
const id = `tab-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
1574
|
-
const tab = {
|
|
1575
|
-
id,
|
|
1576
|
-
mode: "web",
|
|
1577
|
-
url: newPage.url() || "about:blank",
|
|
1578
|
-
title: "Yeni Sekme...",
|
|
1579
|
-
favicon: "",
|
|
1580
|
-
isLoading: true,
|
|
1581
|
-
canGoBack: false,
|
|
1582
|
-
canGoForward: false,
|
|
1583
|
-
lastAudioAt: 0,
|
|
1584
|
-
page: newPage,
|
|
1585
|
-
streaming: false
|
|
1586
|
-
};
|
|
1587
|
-
this.tabs.set(id, tab);
|
|
1588
|
-
this.tabOrder.push(id);
|
|
1589
|
-
await this.attachPageHandlers(tab, newPage);
|
|
1590
|
-
await this.activateTab(id);
|
|
1591
|
-
});
|
|
1592
|
-
this.context = ctx;
|
|
1593
|
-
return ctx;
|
|
1594
|
-
})();
|
|
1595
|
-
try {
|
|
1596
|
-
return await this.contextCreating;
|
|
1597
|
-
} finally {
|
|
1598
|
-
this.contextCreating = null;
|
|
1599
|
-
}
|
|
1681
|
+
getVfsRoot() {
|
|
1682
|
+
return this.vfsRoot;
|
|
1600
1683
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const tab = {
|
|
1605
|
-
id,
|
|
1606
|
-
mode: parsed.mode,
|
|
1607
|
-
filePath: parsed.filePath,
|
|
1608
|
-
url: parsed.url,
|
|
1609
|
-
title: parsed.mode === "newtab" ? "Yeni Sekme" : parsed.mode === "file" ? path4.posix.basename(parsed.filePath || "Dosya") : parsed.url,
|
|
1610
|
-
favicon: "",
|
|
1611
|
-
isLoading: false,
|
|
1612
|
-
canGoBack: false,
|
|
1613
|
-
canGoForward: false,
|
|
1614
|
-
lastAudioAt: 0,
|
|
1615
|
-
streaming: false
|
|
1616
|
-
};
|
|
1617
|
-
this.tabs.set(id, tab);
|
|
1618
|
-
this.tabOrder.push(id);
|
|
1619
|
-
if (makeActive) this.activeTabId = id;
|
|
1620
|
-
return tab;
|
|
1684
|
+
onChange(cb) {
|
|
1685
|
+
this.changeListeners.add(cb);
|
|
1686
|
+
return () => this.changeListeners.delete(cb);
|
|
1621
1687
|
}
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1688
|
+
notifyChange() {
|
|
1689
|
+
for (const cb of this.changeListeners) {
|
|
1690
|
+
try {
|
|
1691
|
+
cb();
|
|
1692
|
+
} catch {
|
|
1693
|
+
}
|
|
1627
1694
|
}
|
|
1628
|
-
this.broadcastTabs();
|
|
1629
|
-
return tab.id;
|
|
1630
1695
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
if (!next) return;
|
|
1634
|
-
if (this.activeTabId && this.activeTabId !== tabId) {
|
|
1635
|
-
const prev = this.tabs.get(this.activeTabId);
|
|
1636
|
-
if (prev) await this.stopScreencast(prev);
|
|
1637
|
-
}
|
|
1638
|
-
this.activeTabId = tabId;
|
|
1639
|
-
this.broadcastTabs();
|
|
1640
|
-
if (next.mode === "web" && next.page) {
|
|
1696
|
+
loadMeta() {
|
|
1697
|
+
if (fs4.existsSync(this.metaFile)) {
|
|
1641
1698
|
try {
|
|
1642
|
-
|
|
1699
|
+
const parsed = JSON.parse(fs4.readFileSync(this.metaFile, "utf-8"));
|
|
1700
|
+
const wp = parsed.preferences?.wallpaper === "nebula-compute" ? "mono-peaks" : parsed.preferences?.wallpaper || "mono-peaks";
|
|
1701
|
+
return {
|
|
1702
|
+
positions: parsed.positions || {},
|
|
1703
|
+
trashOrigins: parsed.trashOrigins || {},
|
|
1704
|
+
preferences: {
|
|
1705
|
+
wallpaper: wp,
|
|
1706
|
+
customWallpaper: parsed.preferences?.customWallpaper,
|
|
1707
|
+
theme: parsed.preferences?.theme === "light" ? "light" : "dark",
|
|
1708
|
+
iconSize: parsed.preferences?.iconSize || "md",
|
|
1709
|
+
autoArrange: parsed.preferences?.autoArrange ?? false,
|
|
1710
|
+
sortBy: parsed.preferences?.sortBy || "name"
|
|
1711
|
+
}
|
|
1712
|
+
};
|
|
1643
1713
|
} catch {
|
|
1644
1714
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1715
|
+
}
|
|
1716
|
+
return {
|
|
1717
|
+
positions: {},
|
|
1718
|
+
trashOrigins: {},
|
|
1719
|
+
preferences: {
|
|
1720
|
+
wallpaper: "mono-peaks",
|
|
1721
|
+
theme: "dark",
|
|
1722
|
+
iconSize: "md",
|
|
1723
|
+
autoArrange: false,
|
|
1724
|
+
sortBy: "name"
|
|
1647
1725
|
}
|
|
1648
|
-
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
saveMeta() {
|
|
1729
|
+
fs4.mkdirSync(this.instanceRoot, { recursive: true });
|
|
1730
|
+
fs4.writeFileSync(this.metaFile, JSON.stringify(this.meta, null, 2), "utf-8");
|
|
1731
|
+
}
|
|
1732
|
+
normalizeVirtualPath(vPath) {
|
|
1733
|
+
const cleaned = ("/" + (vPath || "").replace(/\\/g, "/")).replace(/\/+/g, "/").replace(/\/$/, "");
|
|
1734
|
+
return cleaned === "" ? "/" : cleaned;
|
|
1735
|
+
}
|
|
1736
|
+
resolveDiskPath(vPath) {
|
|
1737
|
+
const norm = this.normalizeVirtualPath(vPath);
|
|
1738
|
+
const resolved = path4.resolve(this.vfsRoot, "." + norm);
|
|
1739
|
+
if (!resolved.startsWith(this.vfsRoot)) {
|
|
1740
|
+
throw new Error("Ge\xE7ersiz dosya yolu eri\u015Fimi engellendi.");
|
|
1649
1741
|
}
|
|
1742
|
+
return resolved;
|
|
1650
1743
|
}
|
|
1651
|
-
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
this.tabs.delete(tabId);
|
|
1656
|
-
const idx = this.tabOrder.indexOf(tabId);
|
|
1657
|
-
if (idx !== -1) this.tabOrder.splice(idx, 1);
|
|
1658
|
-
if (this.tabOrder.length === 0) {
|
|
1659
|
-
const fresh = this.createTabInternal("compute://newtab", true);
|
|
1660
|
-
this.activeTabId = fresh.id;
|
|
1661
|
-
this.broadcastTabs();
|
|
1662
|
-
return;
|
|
1744
|
+
ensureSeedWorkspace() {
|
|
1745
|
+
const marker = path4.join(this.instanceRoot, ".seeded");
|
|
1746
|
+
for (const dir of SYSTEM_DIRS) {
|
|
1747
|
+
fs4.mkdirSync(this.resolveDiskPath(dir), { recursive: true });
|
|
1663
1748
|
}
|
|
1664
|
-
if (
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
this.
|
|
1749
|
+
if (fs4.existsSync(marker)) return;
|
|
1750
|
+
fs4.mkdirSync(this.resolveDiskPath("/Desktop/Projeler"), { recursive: true });
|
|
1751
|
+
fs4.writeFileSync(
|
|
1752
|
+
this.resolveDiskPath("/Desktop/notlar.txt"),
|
|
1753
|
+
`Sanal Masa\xFCst\xFC (${this.desktopId})
|
|
1754
|
+
=========================
|
|
1755
|
+
- Bu masa\xFCst\xFC di\u011Fer sanal masa\xFCstlerinden tamamen ba\u011F\u0131ms\u0131z bir disk ve taray\u0131c\u0131 oturumuna sahiptir.
|
|
1756
|
+
- Dosyalar\u0131 a\xE7\u0131k klas\xF6r pencerelerinin veya Chromium penceresinin \xFCst\xFCne do\u011Frudan s\xFCr\xFCkleyip b\u0131rakabilirsiniz.
|
|
1757
|
+
`,
|
|
1758
|
+
"utf-8"
|
|
1759
|
+
);
|
|
1760
|
+
fs4.writeFileSync(
|
|
1761
|
+
this.resolveDiskPath("/Desktop/baslangic.html"),
|
|
1762
|
+
`<!DOCTYPE html>
|
|
1763
|
+
<html lang="tr">
|
|
1764
|
+
<head>
|
|
1765
|
+
<meta charset="UTF-8" />
|
|
1766
|
+
<title>Yerel Web Sayfas\u0131</title>
|
|
1767
|
+
<style>
|
|
1768
|
+
body {
|
|
1769
|
+
margin: 0;
|
|
1770
|
+
min-height: 100vh;
|
|
1771
|
+
display: grid;
|
|
1772
|
+
place-items: center;
|
|
1773
|
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
|
1774
|
+
background: #141416;
|
|
1775
|
+
color: #f5f5f7;
|
|
1669
1776
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
}
|
|
1678
|
-
tab.cdp = void 0;
|
|
1777
|
+
.box {
|
|
1778
|
+
background: #1c1c1e;
|
|
1779
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
1780
|
+
border-radius: 18px;
|
|
1781
|
+
padding: 36px;
|
|
1782
|
+
max-width: 460px;
|
|
1783
|
+
text-align: center;
|
|
1679
1784
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1785
|
+
h1 { margin: 0 0 10px; font-size: 22px; font-weight: 600; }
|
|
1786
|
+
p { color: #a1a1a6; line-height: 1.6; font-size: 14px; }
|
|
1787
|
+
</style>
|
|
1788
|
+
</head>
|
|
1789
|
+
<body>
|
|
1790
|
+
<div class="box">
|
|
1791
|
+
<h1>Yerel HTML Dosyas\u0131</h1>
|
|
1792
|
+
<p>Bu sayfa sanal masa\xFCst\xFCn\xFCzdeki <code>/Desktop/baslangic.html</code> dosyas\u0131ndan \xE7al\u0131\u015F\u0131yor. \xDCst \xE7ubuktan kayna\u011F\u0131 d\xFCzenleyip kaydedebilirsiniz.</p>
|
|
1793
|
+
</div>
|
|
1794
|
+
</body>
|
|
1795
|
+
</html>`,
|
|
1796
|
+
"utf-8"
|
|
1797
|
+
);
|
|
1798
|
+
fs4.writeFileSync(
|
|
1799
|
+
this.resolveDiskPath("/Desktop/Projeler/analiz.py"),
|
|
1800
|
+
`def hesapla(veriler: list[float]) -> dict:
|
|
1801
|
+
toplam = sum(veriler)
|
|
1802
|
+
return {"adet": len(veriler), "ortalama": round(toplam / max(len(veriler), 1), 2)}
|
|
1803
|
+
|
|
1804
|
+
if __name__ == "__main__":
|
|
1805
|
+
print(hesapla([14.2, 19.8, 22.4]))
|
|
1806
|
+
`,
|
|
1807
|
+
"utf-8"
|
|
1808
|
+
);
|
|
1809
|
+
fs4.writeFileSync(
|
|
1810
|
+
this.resolveDiskPath("/Desktop/Projeler/ayarlar.json"),
|
|
1811
|
+
JSON.stringify({ desktop: this.desktopId, browser: "chromium", isolated: true }, null, 2),
|
|
1812
|
+
"utf-8"
|
|
1813
|
+
);
|
|
1814
|
+
const zip = new AdmZip();
|
|
1815
|
+
zip.addFile("bilgi.txt", Buffer.from("Sa\u011F t\u0131klay\u0131p Buraya Ay\u0131kla se\xE7ene\u011Fiyle \xE7\u0131kartabilirsiniz.\n", "utf-8"));
|
|
1816
|
+
zip.writeZip(this.resolveDiskPath("/Desktop/arsiv.zip"));
|
|
1817
|
+
fs4.writeFileSync(marker, (/* @__PURE__ */ new Date()).toISOString(), "utf-8");
|
|
1818
|
+
}
|
|
1819
|
+
statNode(vPath) {
|
|
1820
|
+
const norm = this.normalizeVirtualPath(vPath);
|
|
1821
|
+
const diskPath = this.resolveDiskPath(norm);
|
|
1822
|
+
const stat = fs4.statSync(diskPath);
|
|
1823
|
+
const isDir = stat.isDirectory();
|
|
1824
|
+
const name = norm === "/" ? "Disk" : path4.posix.basename(norm);
|
|
1825
|
+
const parentPath = norm === "/" ? "" : path4.posix.dirname(norm);
|
|
1826
|
+
let childCount = 0;
|
|
1827
|
+
let size = stat.size;
|
|
1828
|
+
if (isDir) {
|
|
1829
|
+
const entries = fs4.readdirSync(diskPath).filter((e) => e !== ".DS_Store");
|
|
1830
|
+
childCount = entries.length;
|
|
1831
|
+
size = this.computeDirSize(diskPath);
|
|
1685
1832
|
}
|
|
1686
|
-
|
|
1833
|
+
return {
|
|
1834
|
+
name,
|
|
1835
|
+
path: norm,
|
|
1836
|
+
parentPath,
|
|
1837
|
+
isDir,
|
|
1838
|
+
extension: extractExtension(name, isDir),
|
|
1839
|
+
size,
|
|
1840
|
+
childCount,
|
|
1841
|
+
createdAt: stat.birthtime.toISOString(),
|
|
1842
|
+
modifiedAt: stat.mtime.toISOString(),
|
|
1843
|
+
originalPath: this.meta.trashOrigins[norm]
|
|
1844
|
+
};
|
|
1687
1845
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
packet[0] = PACKET_VIDEO_JPEG;
|
|
1698
|
-
jpegBuf.copy(packet, 1);
|
|
1699
|
-
tab.lastFrameBuffer = packet;
|
|
1700
|
-
this.recordFrameTick();
|
|
1701
|
-
if (this.activeTabId === tab.id && tab.mode === "web") {
|
|
1702
|
-
this.broadcastBinary(packet);
|
|
1703
|
-
}
|
|
1704
|
-
});
|
|
1705
|
-
const syncPageMeta = async () => {
|
|
1706
|
-
if (page.isClosed() || tab.mode !== "web") return;
|
|
1707
|
-
try {
|
|
1708
|
-
const currentUrl = page.url();
|
|
1709
|
-
if (currentUrl && currentUrl !== "about:blank") tab.url = currentUrl;
|
|
1710
|
-
const title = await page.title().catch(() => "");
|
|
1711
|
-
if (title) {
|
|
1712
|
-
tab.title = title;
|
|
1846
|
+
computeDirSize(diskDir) {
|
|
1847
|
+
let total = 0;
|
|
1848
|
+
try {
|
|
1849
|
+
const entries = fs4.readdirSync(diskDir, { withFileTypes: true });
|
|
1850
|
+
for (const entry of entries) {
|
|
1851
|
+
if (entry.name === ".DS_Store") continue;
|
|
1852
|
+
const full = path4.join(diskDir, entry.name);
|
|
1853
|
+
if (entry.isDirectory()) {
|
|
1854
|
+
total += this.computeDirSize(full);
|
|
1713
1855
|
} else {
|
|
1714
|
-
|
|
1715
|
-
tab.title = new URL(tab.url).hostname || tab.url;
|
|
1716
|
-
} catch {
|
|
1717
|
-
tab.title = tab.url;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
try {
|
|
1721
|
-
const u = new URL(tab.url);
|
|
1722
|
-
tab.favicon = `https://www.google.com/s2/favicons?domain=${u.hostname}&sz=64`;
|
|
1723
|
-
} catch {
|
|
1724
|
-
tab.favicon = "";
|
|
1725
|
-
}
|
|
1726
|
-
if (tab.cdp) {
|
|
1727
|
-
const hist = await tab.cdp.send("Page.getNavigationHistory").catch(() => null);
|
|
1728
|
-
if (hist) {
|
|
1729
|
-
tab.canGoBack = hist.currentIndex > 0;
|
|
1730
|
-
tab.canGoForward = hist.currentIndex < hist.entries.length - 1;
|
|
1731
|
-
}
|
|
1856
|
+
total += fs4.statSync(full).size;
|
|
1732
1857
|
}
|
|
1733
|
-
} catch {
|
|
1734
1858
|
}
|
|
1735
|
-
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
const
|
|
1751
|
-
const
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
const extIdx = suggested.lastIndexOf(".");
|
|
1757
|
-
finalName = extIdx > 0 ? `${suggested.slice(0, extIdx)} (${counter})${suggested.slice(extIdx)}` : `${suggested} (${counter})`;
|
|
1758
|
-
counter++;
|
|
1859
|
+
} catch {
|
|
1860
|
+
}
|
|
1861
|
+
return total;
|
|
1862
|
+
}
|
|
1863
|
+
getSnapshot() {
|
|
1864
|
+
const nodes = [];
|
|
1865
|
+
const walk = (vDir) => {
|
|
1866
|
+
const diskDir = this.resolveDiskPath(vDir);
|
|
1867
|
+
if (!fs4.existsSync(diskDir)) return;
|
|
1868
|
+
if (vDir !== "/") {
|
|
1869
|
+
nodes.push(this.statNode(vDir));
|
|
1870
|
+
}
|
|
1871
|
+
const entries = fs4.readdirSync(diskDir).filter((e) => e !== ".DS_Store");
|
|
1872
|
+
for (const entry of entries) {
|
|
1873
|
+
const childVPath = vDir === "/" ? `/${entry}` : `${vDir}/${entry}`;
|
|
1874
|
+
const childDisk = this.resolveDiskPath(childVPath);
|
|
1875
|
+
const st = fs4.statSync(childDisk);
|
|
1876
|
+
if (st.isDirectory()) {
|
|
1877
|
+
walk(childVPath);
|
|
1878
|
+
} else {
|
|
1879
|
+
nodes.push(this.statNode(childVPath));
|
|
1759
1880
|
}
|
|
1760
|
-
await download.saveAs(path4.join(downloadsDir, finalName));
|
|
1761
|
-
this.vfs.notifyChange();
|
|
1762
|
-
this.broadcastJson({
|
|
1763
|
-
type: "download_complete",
|
|
1764
|
-
fileName: finalName,
|
|
1765
|
-
virtualPath: `/Downloads/${finalName}`
|
|
1766
|
-
});
|
|
1767
|
-
} catch (err) {
|
|
1768
|
-
this.broadcastJson({
|
|
1769
|
-
type: "browser_error",
|
|
1770
|
-
message: `\u0130ndirme ba\u015Far\u0131s\u0131z oldu: ${err.message}`
|
|
1771
|
-
});
|
|
1772
1881
|
}
|
|
1773
|
-
}
|
|
1882
|
+
};
|
|
1883
|
+
walk("/");
|
|
1884
|
+
return { nodes, meta: this.meta };
|
|
1774
1885
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
if (
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1886
|
+
getUniquePath(parentPath, desiredName) {
|
|
1887
|
+
const cleanName = desiredName.replace(/[\\/]/g, "").trim() || "Ads\u0131z";
|
|
1888
|
+
const normParent = this.normalizeVirtualPath(parentPath);
|
|
1889
|
+
let candidate = normParent === "/" ? `/${cleanName}` : `${normParent}/${cleanName}`;
|
|
1890
|
+
if (!fs4.existsSync(this.resolveDiskPath(candidate))) {
|
|
1891
|
+
return candidate;
|
|
1892
|
+
}
|
|
1893
|
+
const extIdx = cleanName.lastIndexOf(".");
|
|
1894
|
+
const hasExt = extIdx > 0 && extIdx < cleanName.length - 1;
|
|
1895
|
+
const stem = hasExt ? cleanName.slice(0, extIdx) : cleanName;
|
|
1896
|
+
const ext = hasExt ? cleanName.slice(extIdx) : "";
|
|
1897
|
+
let counter = 2;
|
|
1898
|
+
while (true) {
|
|
1899
|
+
const nextName = `${stem} (${counter})${ext}`;
|
|
1900
|
+
candidate = normParent === "/" ? `/${nextName}` : `${normParent}/${nextName}`;
|
|
1901
|
+
if (!fs4.existsSync(this.resolveDiskPath(candidate))) {
|
|
1902
|
+
return candidate;
|
|
1903
|
+
}
|
|
1904
|
+
counter++;
|
|
1783
1905
|
}
|
|
1784
1906
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
maxWidth: this.viewport.width,
|
|
1792
|
-
maxHeight: this.viewport.height,
|
|
1793
|
-
everyNthFrame: 1
|
|
1794
|
-
});
|
|
1795
|
-
tab.streaming = true;
|
|
1796
|
-
} catch {
|
|
1797
|
-
tab.streaming = false;
|
|
1907
|
+
createFolder(parentPath, name, pos) {
|
|
1908
|
+
const targetVPath = this.getUniquePath(parentPath, name || "Yeni Klas\xF6r");
|
|
1909
|
+
fs4.mkdirSync(this.resolveDiskPath(targetVPath), { recursive: true });
|
|
1910
|
+
if (pos) {
|
|
1911
|
+
this.meta.positions[targetVPath] = pos;
|
|
1912
|
+
this.saveMeta();
|
|
1798
1913
|
}
|
|
1914
|
+
this.notifyChange();
|
|
1915
|
+
return this.statNode(targetVPath);
|
|
1799
1916
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1917
|
+
createFile(parentPath, name, content, pos) {
|
|
1918
|
+
const targetVPath = this.getUniquePath(parentPath, name || "yeni-dosya.txt");
|
|
1919
|
+
const diskPath = this.resolveDiskPath(targetVPath);
|
|
1920
|
+
fs4.mkdirSync(path4.dirname(diskPath), { recursive: true });
|
|
1921
|
+
const finalContent = content !== void 0 ? content : this.getDefaultTemplate(targetVPath);
|
|
1922
|
+
fs4.writeFileSync(diskPath, finalContent, "utf-8");
|
|
1923
|
+
if (pos) {
|
|
1924
|
+
this.meta.positions[targetVPath] = pos;
|
|
1925
|
+
this.saveMeta();
|
|
1805
1926
|
}
|
|
1806
|
-
|
|
1927
|
+
this.notifyChange();
|
|
1928
|
+
return this.statNode(targetVPath);
|
|
1807
1929
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1930
|
+
getDefaultTemplate(vPath) {
|
|
1931
|
+
const ext = extractExtension(path4.posix.basename(vPath), false);
|
|
1932
|
+
switch (ext) {
|
|
1933
|
+
case "html":
|
|
1934
|
+
case "htm":
|
|
1935
|
+
return `<!DOCTYPE html>
|
|
1936
|
+
<html lang="tr">
|
|
1937
|
+
<head>
|
|
1938
|
+
<meta charset="UTF-8" />
|
|
1939
|
+
<title>Sayfa</title>
|
|
1940
|
+
</head>
|
|
1941
|
+
<body style="font-family:-apple-system,sans-serif;padding:2rem;background:#141416;color:#f5f5f7;">
|
|
1942
|
+
<h1>Merhaba</h1>
|
|
1943
|
+
<p>Yeni HTML belgesi haz\u0131r.</p>
|
|
1944
|
+
</body>
|
|
1945
|
+
</html>
|
|
1946
|
+
`;
|
|
1947
|
+
case "json":
|
|
1948
|
+
return `{
|
|
1949
|
+
"ad": "kayit",
|
|
1950
|
+
"aktif": true
|
|
1951
|
+
}
|
|
1952
|
+
`;
|
|
1953
|
+
case "md":
|
|
1954
|
+
return `# Ba\u015Fl\u0131k
|
|
1955
|
+
|
|
1956
|
+
Notlar\u0131n\u0131z\u0131 buraya yazabilirsiniz.
|
|
1957
|
+
`;
|
|
1958
|
+
case "py":
|
|
1959
|
+
return `def main():
|
|
1960
|
+
print("Merhaba!")
|
|
1961
|
+
|
|
1962
|
+
if __name__ == "__main__":
|
|
1963
|
+
main()
|
|
1964
|
+
`;
|
|
1965
|
+
case "js":
|
|
1966
|
+
case "ts":
|
|
1967
|
+
return `console.log("Haz\u0131r");
|
|
1968
|
+
`;
|
|
1969
|
+
case "css":
|
|
1970
|
+
return `body {
|
|
1971
|
+
margin: 0;
|
|
1972
|
+
background: #141416;
|
|
1973
|
+
color: #f5f5f7;
|
|
1974
|
+
}
|
|
1975
|
+
`;
|
|
1976
|
+
case "csv":
|
|
1977
|
+
return `id,baslik,deger
|
|
1978
|
+
1,Kalem A,100
|
|
1979
|
+
2,Kalem B,250
|
|
1980
|
+
`;
|
|
1981
|
+
case "sql":
|
|
1982
|
+
return `SELECT * FROM kayitlar LIMIT 10;
|
|
1983
|
+
`;
|
|
1984
|
+
case "svg":
|
|
1985
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
|
|
1986
|
+
<rect width="200" height="200" rx="24" fill="#1c1c1e"/>
|
|
1987
|
+
<circle cx="100" cy="100" r="52" fill="#e5e5ea"/>
|
|
1988
|
+
</svg>
|
|
1989
|
+
`;
|
|
1990
|
+
default:
|
|
1991
|
+
return "";
|
|
1820
1992
|
}
|
|
1821
1993
|
}
|
|
1822
|
-
|
|
1823
|
-
const
|
|
1824
|
-
if (
|
|
1825
|
-
|
|
1826
|
-
tab.mode = parsed.mode;
|
|
1827
|
-
tab.filePath = parsed.filePath;
|
|
1828
|
-
tab.url = parsed.url;
|
|
1829
|
-
if (parsed.mode === "newtab") {
|
|
1830
|
-
await this.stopScreencast(tab);
|
|
1831
|
-
tab.title = "Yeni Sekme";
|
|
1832
|
-
tab.favicon = "";
|
|
1833
|
-
tab.isLoading = false;
|
|
1834
|
-
this.broadcastTabs();
|
|
1835
|
-
return;
|
|
1994
|
+
renameNode(vPath, newName) {
|
|
1995
|
+
const norm = this.normalizeVirtualPath(vPath);
|
|
1996
|
+
if (SYSTEM_DIRS.includes(norm) || norm === "/") {
|
|
1997
|
+
throw new Error("Sistem ana dizinleri yeniden adland\u0131r\u0131lamaz.");
|
|
1836
1998
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
tab.favicon = "";
|
|
1841
|
-
tab.isLoading = false;
|
|
1842
|
-
this.broadcastTabs();
|
|
1843
|
-
return;
|
|
1999
|
+
const cleanName = newName.replace(/[\\/]/g, "").trim();
|
|
2000
|
+
if (!cleanName) {
|
|
2001
|
+
throw new Error("Dosya veya klas\xF6r ad\u0131 bo\u015F olamaz.");
|
|
1844
2002
|
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
tab.title = parsed.url;
|
|
2003
|
+
const parent = path4.posix.dirname(norm);
|
|
2004
|
+
const nextVPath = parent === "/" ? `/${cleanName}` : `${parent}/${cleanName}`;
|
|
2005
|
+
if (nextVPath === norm) {
|
|
2006
|
+
return this.statNode(norm);
|
|
1850
2007
|
}
|
|
1851
|
-
this.
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
2008
|
+
if (fs4.existsSync(this.resolveDiskPath(nextVPath))) {
|
|
2009
|
+
throw new Error(`"${cleanName}" ad\u0131nda bir \xF6\u011Fe zaten mevcut.`);
|
|
2010
|
+
}
|
|
2011
|
+
fs4.renameSync(this.resolveDiskPath(norm), this.resolveDiskPath(nextVPath));
|
|
2012
|
+
const updatedPositions = {};
|
|
2013
|
+
for (const [k, v] of Object.entries(this.meta.positions)) {
|
|
2014
|
+
if (k === norm) updatedPositions[nextVPath] = v;
|
|
2015
|
+
else if (k.startsWith(norm + "/")) updatedPositions[nextVPath + k.slice(norm.length)] = v;
|
|
2016
|
+
else updatedPositions[k] = v;
|
|
2017
|
+
}
|
|
2018
|
+
this.meta.positions = updatedPositions;
|
|
2019
|
+
this.saveMeta();
|
|
2020
|
+
this.notifyChange();
|
|
2021
|
+
return this.statNode(nextVPath);
|
|
2022
|
+
}
|
|
2023
|
+
moveNodes(paths, targetDir) {
|
|
2024
|
+
const normTarget = this.normalizeVirtualPath(targetDir);
|
|
2025
|
+
const targetDisk = this.resolveDiskPath(normTarget);
|
|
2026
|
+
if (!fs4.existsSync(targetDisk) || !fs4.statSync(targetDisk).isDirectory()) {
|
|
2027
|
+
throw new Error("Hedef klas\xF6r bulunamad\u0131.");
|
|
2028
|
+
}
|
|
2029
|
+
const moved = [];
|
|
2030
|
+
for (const rawPath of paths) {
|
|
2031
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2032
|
+
if (SYSTEM_DIRS.includes(src) || src === "/" || src === normTarget) continue;
|
|
2033
|
+
if (normTarget.startsWith(src + "/")) {
|
|
2034
|
+
throw new Error("Bir klas\xF6r kendi alt klas\xF6r\xFCn\xFCn i\xE7ine ta\u015F\u0131namaz.");
|
|
1863
2035
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
2036
|
+
const base = path4.posix.basename(src);
|
|
2037
|
+
const dest = path4.posix.dirname(src) === normTarget ? src : this.getUniquePath(normTarget, base);
|
|
2038
|
+
if (dest !== src) {
|
|
2039
|
+
fs4.renameSync(this.resolveDiskPath(src), this.resolveDiskPath(dest));
|
|
2040
|
+
delete this.meta.positions[src];
|
|
2041
|
+
}
|
|
2042
|
+
moved.push(this.statNode(dest));
|
|
2043
|
+
}
|
|
2044
|
+
this.saveMeta();
|
|
2045
|
+
this.notifyChange();
|
|
2046
|
+
return moved;
|
|
2047
|
+
}
|
|
2048
|
+
copyNodes(paths, targetDir) {
|
|
2049
|
+
const normTarget = this.normalizeVirtualPath(targetDir);
|
|
2050
|
+
const copied = [];
|
|
2051
|
+
for (const rawPath of paths) {
|
|
2052
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2053
|
+
if (src === "/") continue;
|
|
2054
|
+
if (normTarget.startsWith(src + "/")) {
|
|
2055
|
+
throw new Error("Bir klas\xF6r kendi alt klas\xF6r\xFCn\xFCn i\xE7ine kopyalanamaz.");
|
|
2056
|
+
}
|
|
2057
|
+
const base = path4.posix.basename(src);
|
|
2058
|
+
const desired = path4.posix.dirname(src) === normTarget ? this.makeCopyName(base) : base;
|
|
2059
|
+
const dest = this.getUniquePath(normTarget, desired);
|
|
2060
|
+
fs4.cpSync(this.resolveDiskPath(src), this.resolveDiskPath(dest), { recursive: true });
|
|
2061
|
+
copied.push(this.statNode(dest));
|
|
2062
|
+
}
|
|
2063
|
+
this.notifyChange();
|
|
2064
|
+
return copied;
|
|
2065
|
+
}
|
|
2066
|
+
makeCopyName(name) {
|
|
2067
|
+
const idx = name.lastIndexOf(".");
|
|
2068
|
+
if (idx > 0 && idx < name.length - 1) {
|
|
2069
|
+
return `${name.slice(0, idx)} kopyas\u0131${name.slice(idx)}`;
|
|
2070
|
+
}
|
|
2071
|
+
return `${name} kopyas\u0131`;
|
|
2072
|
+
}
|
|
2073
|
+
trashNodes(paths) {
|
|
2074
|
+
for (const rawPath of paths) {
|
|
2075
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2076
|
+
if (SYSTEM_DIRS.includes(src) || src === "/") continue;
|
|
2077
|
+
if (src.startsWith("/.trash/")) {
|
|
2078
|
+
fs4.rmSync(this.resolveDiskPath(src), { recursive: true, force: true });
|
|
2079
|
+
delete this.meta.trashOrigins[src];
|
|
2080
|
+
continue;
|
|
1866
2081
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
tab.isLoading = false;
|
|
1872
|
-
this.broadcastTabs();
|
|
1873
|
-
await this.captureImmediateFrame(tab);
|
|
1874
|
-
} catch (err) {
|
|
1875
|
-
tab.isLoading = false;
|
|
1876
|
-
this.broadcastTabs();
|
|
1877
|
-
this.broadcastJson({
|
|
1878
|
-
type: "browser_error",
|
|
1879
|
-
tabId: tab.id,
|
|
1880
|
-
message: `Sayfa y\xFCklenemedi: ${err.message}`
|
|
1881
|
-
});
|
|
2082
|
+
const dest = this.getUniquePath("/.trash", path4.posix.basename(src));
|
|
2083
|
+
fs4.renameSync(this.resolveDiskPath(src), this.resolveDiskPath(dest));
|
|
2084
|
+
this.meta.trashOrigins[dest] = src;
|
|
2085
|
+
delete this.meta.positions[src];
|
|
1882
2086
|
}
|
|
2087
|
+
this.saveMeta();
|
|
2088
|
+
this.notifyChange();
|
|
1883
2089
|
}
|
|
1884
|
-
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2090
|
+
restoreNodes(trashPaths) {
|
|
2091
|
+
const restored = [];
|
|
2092
|
+
for (const rawPath of trashPaths) {
|
|
2093
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2094
|
+
if (!src.startsWith("/.trash/")) continue;
|
|
2095
|
+
const origin = this.meta.trashOrigins[src] || `/Desktop/${path4.posix.basename(src)}`;
|
|
2096
|
+
const originParent = path4.posix.dirname(origin);
|
|
2097
|
+
fs4.mkdirSync(this.resolveDiskPath(originParent), { recursive: true });
|
|
2098
|
+
const finalDest = this.getUniquePath(originParent, path4.posix.basename(origin));
|
|
2099
|
+
fs4.renameSync(this.resolveDiskPath(src), this.resolveDiskPath(finalDest));
|
|
2100
|
+
delete this.meta.trashOrigins[src];
|
|
2101
|
+
restored.push(this.statNode(finalDest));
|
|
2102
|
+
}
|
|
2103
|
+
this.saveMeta();
|
|
2104
|
+
this.notifyChange();
|
|
2105
|
+
return restored;
|
|
1894
2106
|
}
|
|
1895
|
-
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
this.
|
|
1904
|
-
|
|
2107
|
+
deletePermanently(paths) {
|
|
2108
|
+
for (const rawPath of paths) {
|
|
2109
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2110
|
+
if (SYSTEM_DIRS.includes(src) || src === "/") continue;
|
|
2111
|
+
fs4.rmSync(this.resolveDiskPath(src), { recursive: true, force: true });
|
|
2112
|
+
delete this.meta.trashOrigins[src];
|
|
2113
|
+
delete this.meta.positions[src];
|
|
2114
|
+
}
|
|
2115
|
+
this.saveMeta();
|
|
2116
|
+
this.notifyChange();
|
|
1905
2117
|
}
|
|
1906
|
-
|
|
1907
|
-
const
|
|
1908
|
-
if (
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
await tab.page.reload({ waitUntil: "domcontentloaded" }).catch(() => {
|
|
1913
|
-
});
|
|
1914
|
-
tab.isLoading = false;
|
|
1915
|
-
this.broadcastTabs();
|
|
1916
|
-
await this.captureImmediateFrame(tab);
|
|
1917
|
-
} else {
|
|
1918
|
-
this.broadcastTabs();
|
|
2118
|
+
emptyTrash() {
|
|
2119
|
+
const trashDisk = this.resolveDiskPath("/.trash");
|
|
2120
|
+
if (fs4.existsSync(trashDisk)) {
|
|
2121
|
+
for (const item of fs4.readdirSync(trashDisk)) {
|
|
2122
|
+
fs4.rmSync(path4.join(trashDisk, item), { recursive: true, force: true });
|
|
2123
|
+
}
|
|
1919
2124
|
}
|
|
2125
|
+
this.meta.trashOrigins = {};
|
|
2126
|
+
this.saveMeta();
|
|
2127
|
+
this.notifyChange();
|
|
1920
2128
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
} catch {
|
|
2129
|
+
compressToZip(paths, targetDir, zipName) {
|
|
2130
|
+
if (!paths.length) throw new Error("Ar\u015Fivlenecek \xF6\u011Fe se\xE7ilmedi.");
|
|
2131
|
+
const zip = new AdmZip();
|
|
2132
|
+
for (const rawPath of paths) {
|
|
2133
|
+
const src = this.normalizeVirtualPath(rawPath);
|
|
2134
|
+
const diskSrc = this.resolveDiskPath(src);
|
|
2135
|
+
if (!fs4.existsSync(diskSrc)) continue;
|
|
2136
|
+
const st = fs4.statSync(diskSrc);
|
|
2137
|
+
if (st.isDirectory()) {
|
|
2138
|
+
zip.addLocalFolder(diskSrc, path4.posix.basename(src));
|
|
2139
|
+
} else {
|
|
2140
|
+
zip.addLocalFile(diskSrc);
|
|
1934
2141
|
}
|
|
1935
2142
|
}
|
|
2143
|
+
const baseName = zipName || (paths.length === 1 ? `${path4.posix.basename(paths[0]).replace(/\.[^.]+$/, "")}.zip` : "arsiv.zip");
|
|
2144
|
+
const finalName = baseName.toLowerCase().endsWith(".zip") ? baseName : `${baseName}.zip`;
|
|
2145
|
+
const destVPath = this.getUniquePath(targetDir, finalName);
|
|
2146
|
+
zip.writeZip(this.resolveDiskPath(destVPath));
|
|
2147
|
+
this.notifyChange();
|
|
2148
|
+
return this.statNode(destVPath);
|
|
1936
2149
|
}
|
|
1937
|
-
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
const
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
return;
|
|
2150
|
+
extractZip(zipVPath, targetDir) {
|
|
2151
|
+
const normZip = this.normalizeVirtualPath(zipVPath);
|
|
2152
|
+
const diskZip = this.resolveDiskPath(normZip);
|
|
2153
|
+
if (!fs4.existsSync(diskZip)) throw new Error("Ar\u015Fiv dosyas\u0131 bulunamad\u0131.");
|
|
2154
|
+
const parent = targetDir ? this.normalizeVirtualPath(targetDir) : path4.posix.dirname(normZip);
|
|
2155
|
+
const folderBase = path4.posix.basename(normZip).replace(/\.zip$/i, "") || "ayiklanan";
|
|
2156
|
+
const destFolderVPath = this.getUniquePath(parent, folderBase);
|
|
2157
|
+
const destDisk = this.resolveDiskPath(destFolderVPath);
|
|
2158
|
+
fs4.mkdirSync(destDisk, { recursive: true });
|
|
2159
|
+
const zip = new AdmZip(diskZip);
|
|
2160
|
+
zip.extractAllTo(destDisk, true);
|
|
2161
|
+
this.notifyChange();
|
|
2162
|
+
return this.statNode(destFolderVPath);
|
|
2163
|
+
}
|
|
2164
|
+
readTextFile(vPath) {
|
|
2165
|
+
const norm = this.normalizeVirtualPath(vPath);
|
|
2166
|
+
const disk = this.resolveDiskPath(norm);
|
|
2167
|
+
if (!fs4.existsSync(disk) || fs4.statSync(disk).isDirectory()) {
|
|
2168
|
+
throw new Error("Dosya okunamad\u0131.");
|
|
1957
2169
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
"End",
|
|
1984
|
-
"PageUp",
|
|
1985
|
-
"PageDown",
|
|
1986
|
-
"F5"
|
|
1987
|
-
]);
|
|
1988
|
-
if (specialKeys.has(key)) {
|
|
1989
|
-
const mods = [];
|
|
1990
|
-
if (ctrlOrMeta) mods.push(modPrefix);
|
|
1991
|
-
if (altKey) mods.push("Alt");
|
|
1992
|
-
if (shiftKey) mods.push("Shift");
|
|
1993
|
-
tab.page.keyboard.press([...mods, key].join("+")).catch(() => {
|
|
1994
|
-
});
|
|
1995
|
-
} else if (key.length === 1 && !ctrlOrMeta) {
|
|
1996
|
-
tab.page.keyboard.insertText(key).catch(() => {
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
return;
|
|
2170
|
+
const buf = fs4.readFileSync(disk);
|
|
2171
|
+
return {
|
|
2172
|
+
content: buf.toString("utf-8"),
|
|
2173
|
+
node: this.statNode(norm)
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
writeTextFile(vPath, content) {
|
|
2177
|
+
const norm = this.normalizeVirtualPath(vPath);
|
|
2178
|
+
const disk = this.resolveDiskPath(norm);
|
|
2179
|
+
fs4.mkdirSync(path4.dirname(disk), { recursive: true });
|
|
2180
|
+
fs4.writeFileSync(disk, content, "utf-8");
|
|
2181
|
+
this.notifyChange();
|
|
2182
|
+
return this.statNode(norm);
|
|
2183
|
+
}
|
|
2184
|
+
saveUploadedBuffer(parentPath, originalName, buffer) {
|
|
2185
|
+
const destVPath = this.getUniquePath(parentPath, originalName);
|
|
2186
|
+
const disk = this.resolveDiskPath(destVPath);
|
|
2187
|
+
fs4.mkdirSync(path4.dirname(disk), { recursive: true });
|
|
2188
|
+
fs4.writeFileSync(disk, buffer);
|
|
2189
|
+
this.notifyChange();
|
|
2190
|
+
return this.statNode(destVPath);
|
|
2191
|
+
}
|
|
2192
|
+
updateMeta(partial) {
|
|
2193
|
+
if (partial.positions) {
|
|
2194
|
+
this.meta.positions = { ...this.meta.positions, ...partial.positions };
|
|
2000
2195
|
}
|
|
2001
|
-
if (
|
|
2002
|
-
|
|
2003
|
-
if (
|
|
2004
|
-
|
|
2196
|
+
if (partial.preferences) {
|
|
2197
|
+
this.meta.preferences = { ...this.meta.preferences, ...partial.preferences };
|
|
2198
|
+
if (!this.meta.preferences.customWallpaper) {
|
|
2199
|
+
delete this.meta.preferences.customWallpaper;
|
|
2200
|
+
}
|
|
2005
2201
|
}
|
|
2202
|
+
this.saveMeta();
|
|
2203
|
+
return this.meta;
|
|
2006
2204
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2205
|
+
saveCustomWallpaper(originalName, buffer) {
|
|
2206
|
+
const wpDir = path4.join(this.instanceRoot, "wallpapers");
|
|
2207
|
+
fs4.mkdirSync(wpDir, { recursive: true });
|
|
2208
|
+
const rawExt = path4.extname(originalName || "").toLowerCase().replace(/[^.a-z0-9]/g, "") || ".png";
|
|
2209
|
+
const fileName = `wp-${Date.now()}${rawExt}`;
|
|
2210
|
+
fs4.writeFileSync(path4.join(wpDir, fileName), buffer);
|
|
2211
|
+
this.meta.preferences.wallpaper = "custom";
|
|
2212
|
+
this.meta.preferences.customWallpaper = fileName;
|
|
2213
|
+
this.saveMeta();
|
|
2214
|
+
return this.meta;
|
|
2215
|
+
}
|
|
2216
|
+
setWallpaperFromVfs(vPath) {
|
|
2217
|
+
const disk = this.resolveDiskPath(vPath);
|
|
2218
|
+
if (!fs4.existsSync(disk) || fs4.statSync(disk).isDirectory()) {
|
|
2219
|
+
throw new Error("Resim dosyas\u0131 bulunamad\u0131.");
|
|
2010
2220
|
}
|
|
2011
|
-
|
|
2012
|
-
this.
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2221
|
+
const buf = fs4.readFileSync(disk);
|
|
2222
|
+
return this.saveCustomWallpaper(path4.basename(disk), buf);
|
|
2223
|
+
}
|
|
2224
|
+
resolveWallpaperPath(fileName) {
|
|
2225
|
+
const safeName = path4.basename(fileName || "");
|
|
2226
|
+
const wpDir = path4.join(this.instanceRoot, "wallpapers");
|
|
2227
|
+
const resolved = path4.resolve(wpDir, safeName);
|
|
2228
|
+
if (!resolved.startsWith(wpDir)) {
|
|
2229
|
+
throw new Error("Ge\xE7ersiz arka plan yolu.");
|
|
2017
2230
|
}
|
|
2231
|
+
return resolved;
|
|
2232
|
+
}
|
|
2233
|
+
clearPositions() {
|
|
2234
|
+
this.meta.positions = {};
|
|
2235
|
+
this.saveMeta();
|
|
2236
|
+
return this.meta;
|
|
2018
2237
|
}
|
|
2019
2238
|
};
|
|
2020
2239
|
|
|
@@ -2142,7 +2361,7 @@ var AuthManager = class {
|
|
|
2142
2361
|
import fs5 from "node:fs";
|
|
2143
2362
|
import path5 from "node:path";
|
|
2144
2363
|
import { fileURLToPath } from "node:url";
|
|
2145
|
-
import { spawn as
|
|
2364
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
2146
2365
|
function resolveHelperPath(helperName) {
|
|
2147
2366
|
const here = path5.dirname(fileURLToPath(import.meta.url));
|
|
2148
2367
|
const candidates = [
|
|
@@ -2164,7 +2383,7 @@ var TerminalManager = class {
|
|
|
2164
2383
|
if (existing) return existing;
|
|
2165
2384
|
const scriptPath = resolveHelperPath("pty_bridge.py");
|
|
2166
2385
|
const safeCwd = fs5.existsSync(cwd) ? cwd : process.cwd();
|
|
2167
|
-
const proc =
|
|
2386
|
+
const proc = spawn3("python3", ["-u", scriptPath, safeCwd, String(cols), String(rows)], {
|
|
2168
2387
|
cwd: safeCwd,
|
|
2169
2388
|
env: {
|
|
2170
2389
|
...process.env,
|
|
@@ -2260,7 +2479,7 @@ var TerminalManager = class {
|
|
|
2260
2479
|
import fs6 from "node:fs";
|
|
2261
2480
|
import os4 from "node:os";
|
|
2262
2481
|
import path6 from "node:path";
|
|
2263
|
-
import { execSync as execSync2, spawn as
|
|
2482
|
+
import { execSync as execSync2, spawn as spawn4 } from "node:child_process";
|
|
2264
2483
|
var DEFAULT_SCREEN_W = 1440;
|
|
2265
2484
|
var DEFAULT_SCREEN_H = 840;
|
|
2266
2485
|
var PROFILE_LOCKED_APPS = /* @__PURE__ */ new Set([
|
|
@@ -2404,7 +2623,7 @@ var LinuxAppSession = class {
|
|
|
2404
2623
|
fs6.mkdirSync(this.tempDir, { recursive: true });
|
|
2405
2624
|
const obRcPath = path6.join(this.tempDir, "rc.xml");
|
|
2406
2625
|
fs6.writeFileSync(obRcPath, buildOpenboxRcXml(), "utf-8");
|
|
2407
|
-
this.xvfbProc =
|
|
2626
|
+
this.xvfbProc = spawn4(
|
|
2408
2627
|
"Xvfb",
|
|
2409
2628
|
[
|
|
2410
2629
|
this.displayStr,
|
|
@@ -2443,7 +2662,7 @@ var LinuxAppSession = class {
|
|
|
2443
2662
|
};
|
|
2444
2663
|
delete baseEnv.DBUS_SESSION_BUS_ADDRESS;
|
|
2445
2664
|
this.baseEnv = baseEnv;
|
|
2446
|
-
this.openboxProc =
|
|
2665
|
+
this.openboxProc = spawn4("openbox", ["--config-file", obRcPath], {
|
|
2447
2666
|
env: baseEnv,
|
|
2448
2667
|
stdio: "ignore"
|
|
2449
2668
|
});
|
|
@@ -2460,7 +2679,7 @@ var LinuxAppSession = class {
|
|
|
2460
2679
|
try {
|
|
2461
2680
|
execSync2("pactl info", { stdio: "ignore", timeout: 1200 });
|
|
2462
2681
|
} catch {
|
|
2463
|
-
|
|
2682
|
+
spawn4(
|
|
2464
2683
|
"pulseaudio",
|
|
2465
2684
|
["--daemonize=yes", "--exit-idle-time=-1", "--disallow-module-loading=0", "--no-cpu-limit"],
|
|
2466
2685
|
{ stdio: "ignore" }
|
|
@@ -2482,7 +2701,7 @@ var LinuxAppSession = class {
|
|
|
2482
2701
|
}
|
|
2483
2702
|
startAudioCapture(sinkName) {
|
|
2484
2703
|
try {
|
|
2485
|
-
const parec =
|
|
2704
|
+
const parec = spawn4(
|
|
2486
2705
|
"parec",
|
|
2487
2706
|
["-d", `${sinkName}.monitor`, "--rate=24000", "--channels=1", "--format=s16le", "--latency-msec=45"],
|
|
2488
2707
|
{ stdio: ["ignore", "pipe", "ignore"] }
|
|
@@ -2524,7 +2743,7 @@ var LinuxAppSession = class {
|
|
|
2524
2743
|
}
|
|
2525
2744
|
startX11Bridge(baseEnv) {
|
|
2526
2745
|
const scriptPath = resolveHelperPath("x11_bridge.py");
|
|
2527
|
-
const proc =
|
|
2746
|
+
const proc = spawn4(
|
|
2528
2747
|
"python3",
|
|
2529
2748
|
["-u", scriptPath, this.displayStr, String(this.screenWidth), String(this.screenHeight)],
|
|
2530
2749
|
{
|
|
@@ -2799,7 +3018,7 @@ var LinuxAppSession = class {
|
|
|
2799
3018
|
}
|
|
2800
3019
|
launchTargetApp(baseEnv) {
|
|
2801
3020
|
const { cmd, cwd } = this.buildLaunchCommand(false);
|
|
2802
|
-
this.appProc =
|
|
3021
|
+
this.appProc = spawn4("/bin/bash", ["-c", `exec ${cmd}`], {
|
|
2803
3022
|
cwd,
|
|
2804
3023
|
env: {
|
|
2805
3024
|
...baseEnv,
|
|
@@ -2839,7 +3058,7 @@ var LinuxAppSession = class {
|
|
|
2839
3058
|
spawnExtraWindow(customCommand) {
|
|
2840
3059
|
if (this.closed) return;
|
|
2841
3060
|
const { cmd, cwd } = customCommand ? { cmd: customCommand, cwd: path6.join(this.desktopDataRoot, "vfs", "Desktop") } : this.buildLaunchCommand(true);
|
|
2842
|
-
const child =
|
|
3061
|
+
const child = spawn4("/bin/bash", ["-c", cmd], {
|
|
2843
3062
|
cwd,
|
|
2844
3063
|
detached: true,
|
|
2845
3064
|
env: {
|
|
@@ -2863,7 +3082,7 @@ var LinuxAppSession = class {
|
|
|
2863
3082
|
const scriptPath = resolveHelperPath("x11_streamer.py");
|
|
2864
3083
|
const jpegQual = Math.max(60, Math.min(88, 92 - this.quality * 4));
|
|
2865
3084
|
const initTargetWid = view.targetMode === "pixmap" ? String(view.targetWid || 0) : "0";
|
|
2866
|
-
const proc =
|
|
3085
|
+
const proc = spawn4(
|
|
2867
3086
|
"python3",
|
|
2868
3087
|
[
|
|
2869
3088
|
"-u",
|
|
@@ -2984,7 +3203,7 @@ var LinuxAppSession = class {
|
|
|
2984
3203
|
String(this.quality + 1),
|
|
2985
3204
|
"-"
|
|
2986
3205
|
];
|
|
2987
|
-
const ff =
|
|
3206
|
+
const ff = spawn4("ffmpeg", args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
2988
3207
|
view.streamerProc = ff;
|
|
2989
3208
|
let acc = Buffer.alloc(0);
|
|
2990
3209
|
const SOI = Buffer.from([255, 216]);
|
|
@@ -3236,7 +3455,7 @@ import http from "node:http";
|
|
|
3236
3455
|
import net from "node:net";
|
|
3237
3456
|
import path7 from "node:path";
|
|
3238
3457
|
import zlib from "node:zlib";
|
|
3239
|
-
import { execSync as execSync3, spawn as
|
|
3458
|
+
import { execSync as execSync3, spawn as spawn5 } from "node:child_process";
|
|
3240
3459
|
function resolveCodeServeBinary() {
|
|
3241
3460
|
if (fs7.existsSync("/usr/share/code/bin/code-tunnel")) {
|
|
3242
3461
|
return "/usr/share/code/bin/code-tunnel";
|
|
@@ -3306,7 +3525,7 @@ var VSCodeServerManager = class {
|
|
|
3306
3525
|
}
|
|
3307
3526
|
this.ready = false;
|
|
3308
3527
|
this.statusMessage = "VS Code Web motoru ba\u015Flat\u0131l\u0131yor (ilk a\xE7\u0131l\u0131\u015Fta bile\u015Fenler indirilebilir)...";
|
|
3309
|
-
const proc =
|
|
3528
|
+
const proc = spawn5(
|
|
3310
3529
|
bin,
|
|
3311
3530
|
[
|
|
3312
3531
|
"serve-web",
|
|
@@ -3520,7 +3739,7 @@ var VSCodeServerManager = class {
|
|
|
3520
3739
|
};
|
|
3521
3740
|
|
|
3522
3741
|
// server/index.ts
|
|
3523
|
-
var TAMGA_VERSION = "1.
|
|
3742
|
+
var TAMGA_VERSION = "1.2.0";
|
|
3524
3743
|
var MIME_MAP = {
|
|
3525
3744
|
html: "text/html; charset=utf-8",
|
|
3526
3745
|
htm: "text/html; charset=utf-8",
|
|
@@ -4188,6 +4407,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
4188
4407
|
case "browser_new_tab":
|
|
4189
4408
|
await browserSession.createTab(msg.url);
|
|
4190
4409
|
break;
|
|
4410
|
+
case "browser_activate_tab":
|
|
4191
4411
|
case "browser_switch_tab":
|
|
4192
4412
|
await browserSession.activateTab(msg.tabId);
|
|
4193
4413
|
break;
|
|
@@ -4207,7 +4427,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
4207
4427
|
await browserSession.reload(msg.tabId);
|
|
4208
4428
|
break;
|
|
4209
4429
|
case "browser_viewport":
|
|
4210
|
-
await browserSession.setViewport(
|
|
4430
|
+
await browserSession.setViewport(
|
|
4431
|
+
Number(msg.width),
|
|
4432
|
+
Number(msg.height),
|
|
4433
|
+
typeof msg.devicePixelRatio === "number" ? msg.devicePixelRatio : void 0
|
|
4434
|
+
);
|
|
4211
4435
|
break;
|
|
4212
4436
|
case "browser_input":
|
|
4213
4437
|
browserSession.handleInput(msg);
|
|
@@ -4390,7 +4614,8 @@ TamgaVDesktop v${TAMGA_VERSION} \u2014 Linux Sanal Masa\xFCst\xFC Platformu
|
|
|
4390
4614
|
Kullan\u0131m:
|
|
4391
4615
|
tamga-vdesktop start [se\xE7enekler] Sunucuyu ba\u015Flat\u0131r
|
|
4392
4616
|
tamga-vdesktop init [se\xE7enekler] Yap\u0131land\u0131rma dosyas\u0131n\u0131 olu\u015Fturur
|
|
4393
|
-
tamga-vdesktop
|
|
4617
|
+
tamga-vdesktop install-browser Yerle\u015Fik Playwright Chromium taray\u0131c\u0131s\u0131n\u0131 kurar
|
|
4618
|
+
tamga-vdesktop setup-linux [se\xE7enekler] Linux GUI + Playwright Chromium ortam\u0131n\u0131 kurar
|
|
4394
4619
|
tamga-vdesktop service <komut> systemd servisini y\xF6netir (install|start|stop|restart|status|logs|uninstall)
|
|
4395
4620
|
tamga-vdesktop passwd <yeni-parola> Y\xF6netici parolas\u0131n\u0131 g\xFCnceller
|
|
4396
4621
|
tamga-vdesktop doctor Sistem ve ba\u011F\u0131ml\u0131l\u0131k te\u015Fhisi yapar
|
|
@@ -4458,6 +4683,19 @@ Ba\u015Flatmak i\xE7in: tamga-vdesktop start --config "${configPath}"`);
|
|
|
4458
4683
|
console.log(`7/24 servis i\xE7in: tamga-vdesktop service install --config "${configPath}"
|
|
4459
4684
|
`);
|
|
4460
4685
|
}
|
|
4686
|
+
function cmdInstallBrowser(flags) {
|
|
4687
|
+
const quiet = Boolean(flags.quiet);
|
|
4688
|
+
const withDeps = Boolean(flags["with-deps"]);
|
|
4689
|
+
const ok = installPlaywrightBrowserSync({ quiet, withDeps });
|
|
4690
|
+
if (!ok && !quiet) {
|
|
4691
|
+
console.error("\u2717 Playwright Chromium kurulumu tamamlanamad\u0131.");
|
|
4692
|
+
process.exit(1);
|
|
4693
|
+
}
|
|
4694
|
+
if (ok && !quiet) {
|
|
4695
|
+
const p = findPlaywrightManagedBrowser();
|
|
4696
|
+
console.log(`\u2713 Yerle\u015Fik Playwright Chromium haz\u0131r -> ${p || "ms-playwright"}`);
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4461
4699
|
function cmdSetupLinux(flags) {
|
|
4462
4700
|
if (process.platform !== "linux") {
|
|
4463
4701
|
console.error("setup-linux komutu yaln\u0131zca Ubuntu/Debian Linux sunucularda \xE7al\u0131\u015F\u0131r.");
|
|
@@ -4469,7 +4707,7 @@ function cmdSetupLinux(flags) {
|
|
|
4469
4707
|
"set -e",
|
|
4470
4708
|
"export DEBIAN_FRONTEND=noninteractive",
|
|
4471
4709
|
"apt-get update -y",
|
|
4472
|
-
"apt-get install -y --no-install-recommends xvfb openbox ffmpeg libturbojpeg libxdamage1 libxtst6 libx11-6 libxfixes3 libxext6 xclip xdotool wmctrl dbus-x11 x11-utils dmz-cursor-theme pulseaudio pulseaudio-utils fonts-dejavu-core fonts-liberation fonts-noto-color-emoji desktop-file-utils hicolor-icon-theme wget gnupg ca-certificates curl"
|
|
4710
|
+
"apt-get install -y --no-install-recommends xvfb openbox ffmpeg libturbojpeg libxdamage1 libxtst6 libx11-6 libxfixes3 libxext6 libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxrandr2 libgbm1 libasound2t64 xclip xdotool wmctrl dbus-x11 x11-utils dmz-cursor-theme pulseaudio pulseaudio-utils fonts-noto-core fonts-dejavu-core fonts-liberation fonts-noto-color-emoji desktop-file-utils hicolor-icon-theme wget gnupg ca-certificates curl || apt-get install -y --no-install-recommends xvfb openbox ffmpeg libturbojpeg libxdamage1 libxtst6 libx11-6 libxfixes3 libxext6 xclip xdotool wmctrl dbus-x11 x11-utils dmz-cursor-theme pulseaudio pulseaudio-utils fonts-dejavu-core fonts-liberation fonts-noto-color-emoji desktop-file-utils hicolor-icon-theme wget gnupg ca-certificates curl"
|
|
4473
4711
|
];
|
|
4474
4712
|
if (withFirefox) {
|
|
4475
4713
|
parts.push(`
|
|
@@ -4490,12 +4728,14 @@ if ! command -v code >/dev/null 2>&1; then
|
|
|
4490
4728
|
apt-get update -y && apt-get install -y code
|
|
4491
4729
|
fi`);
|
|
4492
4730
|
}
|
|
4493
|
-
|
|
4494
|
-
|
|
4731
|
+
parts.push("apt-get clean");
|
|
4732
|
+
console.log("TamgaVDesktop Linux GUI \xE7al\u0131\u015Fma ortam\u0131 ve Playwright Chromium kuruluyor...");
|
|
4733
|
+
const res = spawnSync2("/bin/bash", ["-c", parts.join("\n")], { stdio: "inherit" });
|
|
4495
4734
|
if (res.status !== 0) {
|
|
4496
4735
|
process.exit(res.status || 1);
|
|
4497
4736
|
}
|
|
4498
|
-
|
|
4737
|
+
installPlaywrightBrowserSync({ quiet: false, withDeps: true });
|
|
4738
|
+
console.log("\n\u2713 Linux GUI \xE7al\u0131\u015Fma ortam\u0131 ve yerle\u015Fik Chromium haz\u0131r!");
|
|
4499
4739
|
}
|
|
4500
4740
|
function cmdService(subCmd, flags) {
|
|
4501
4741
|
if (process.platform !== "linux") {
|
|
@@ -4551,10 +4791,10 @@ WantedBy=multi-user.target
|
|
|
4551
4791
|
execSync4(`systemctl ${subCmd} ${unitName}`, { stdio: "inherit" });
|
|
4552
4792
|
break;
|
|
4553
4793
|
case "status":
|
|
4554
|
-
|
|
4794
|
+
spawnSync2("systemctl", ["status", unitName, "--no-pager"], { stdio: "inherit" });
|
|
4555
4795
|
break;
|
|
4556
4796
|
case "logs":
|
|
4557
|
-
|
|
4797
|
+
spawnSync2("journalctl", ["-u", unitName, "-n", "80", "--no-pager"], { stdio: "inherit" });
|
|
4558
4798
|
break;
|
|
4559
4799
|
case "uninstall":
|
|
4560
4800
|
try {
|
|
@@ -4586,6 +4826,7 @@ function cmdDoctor(flags) {
|
|
|
4586
4826
|
const appMgr = new LinuxAppManager();
|
|
4587
4827
|
const status = appMgr.getRuntimeStatus();
|
|
4588
4828
|
const apps = appMgr.listApps().filter((a) => a.installed);
|
|
4829
|
+
const pwPath = findPlaywrightManagedBrowser() || findChromiumExecutable();
|
|
4589
4830
|
console.log(`
|
|
4590
4831
|
TamgaVDesktop v${TAMGA_VERSION} \u2014 Sistem Te\u015Fhisi`);
|
|
4591
4832
|
console.log(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
@@ -4595,6 +4836,7 @@ TamgaVDesktop v${TAMGA_VERSION} \u2014 Sistem Te\u015Fhisi`);
|
|
|
4595
4836
|
console.log(`Dinleme Adresi : ${config.host}:${config.port}`);
|
|
4596
4837
|
console.log(`Veri Dizini : ${config.dataDir}`);
|
|
4597
4838
|
console.log(`Giri\u015F Korumas\u0131 : ${config.auth.enabled ? `Aktif (${config.auth.username})` : "Kapal\u0131"}`);
|
|
4839
|
+
console.log(`Yerle\u015Fik Chromium: ${pwPath ? `HAZIR (${pwPath})` : "Eksik ('tamga-vdesktop install-browser' \xE7al\u0131\u015Ft\u0131r\u0131n)"}`);
|
|
4598
4840
|
console.log(`Linux GUI Motor : ${status.guiReady ? "HAZIR (Xvfb + Openbox + FFmpeg + X11)" : `Eksik: ${status.missingDeps.join(", ")}`}`);
|
|
4599
4841
|
console.log(`Linux Ses Motor : ${status.hasAudio ? "HAZIR (PulseAudio)" : "Devre D\u0131\u015F\u0131"}`);
|
|
4600
4842
|
console.log(`Kurulu Uygulama : ${apps.length > 0 ? apps.map((a) => a.name).join(", ") : "Yok"}`);
|
|
@@ -4625,6 +4867,9 @@ async function main() {
|
|
|
4625
4867
|
case "setup-linux":
|
|
4626
4868
|
cmdSetupLinux(flags);
|
|
4627
4869
|
break;
|
|
4870
|
+
case "install-browser":
|
|
4871
|
+
cmdInstallBrowser(flags);
|
|
4872
|
+
break;
|
|
4628
4873
|
case "service":
|
|
4629
4874
|
cmdService(positional[1], flags);
|
|
4630
4875
|
break;
|