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