A desktop browser with x402 built in: when a page asks for payment, it pays in stablecoins and shows the content.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-browser.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-browser.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-browser.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 site icons (favicons) in tabs, address bar suggestions and the bookmarks panel 7249579 15 hours, 50 minutes ago History
launch.mjs · 3.3 KB · 65 lines
1#!/usr/bin/env node
2/**
3 * Launch the built app (dist/main.js) with proper branding.
4 *
5 * Why this exists: on macOS the Dock label, the app-menu title and the Dock icon come
6 * from the .app BUNDLE, not from our code — so running plain `electron dist/main.js`
7 * always shows "Electron" and the Electron logo. In dev we therefore make a branded copy
8 * of Electron.app (name, bundle id, icon), re-sign it ad hoc, and run the app inside it.
9 * The copy is cached in .bundle/ (gitignored) and rebuilt only when Electron or the icon
10 * changes. A packaged release would use electron-builder instead; this is the dev path.
11 *
12 * Other platforms: window/taskbar icon is set in main.ts, so we just run electron.
13 */
14import { execFileSync, spawn } from "node:child_process";
15import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
16import { createRequire } from "node:module";
17import { dirname, join } from "node:path";
18import { fileURLToPath } from "node:url";
19
20const here = dirname(fileURLToPath(import.meta.url));
21const root = join(here, "..");
22const NAME = "dbbasic-browser";
23const BUNDLE_ID = "com.askrobots.dbbasic-browser";
24const electronPath = createRequire(import.meta.url)("electron"); // path to the electron binary
25
26let exe = electronPath;
27
28if (process.platform === "darwin") {
29 const srcApp = join(dirname(electronPath), "..", ".."); // …/Electron.app
30 const icon = join(root, "assets", "icon.icns");
31 const outDir = join(root, ".bundle");
32 const app = join(outDir, `${NAME}.app`);
33 const stampFile = join(outDir, "stamp");
34 const electronVersion = readFileSync(join(srcApp, "..", "version"), "utf8").trim();
35 const stamp = `${electronVersion}|${existsSync(icon) ? statSync(icon).mtimeMs : "noicon"}|${NAME}|${BUNDLE_ID}`;
36
37 const upToDate = existsSync(app) && existsSync(stampFile) && readFileSync(stampFile, "utf8") === stamp;
38 if (!upToDate) {
39 console.error(`[launch] building branded ${NAME}.app …`);
40 rmSync(outDir, { recursive: true, force: true });
41 mkdirSync(outDir, { recursive: true });
42 try {
43 execFileSync("cp", ["-cR", srcApp, app]); // APFS clone: near-instant, no extra disk
44 } catch {
45 cpSync(srcApp, app, { recursive: true, verbatimSymlinks: true });
46 }
47 const plist = join(app, "Contents", "Info.plist");
48 const pb = (cmd) => { try { execFileSync("/usr/libexec/PlistBuddy", ["-c", cmd, plist]); } catch { /* key may not exist */ } };
49 for (const [k, v] of [["CFBundleName", NAME], ["CFBundleDisplayName", NAME], ["CFBundleIdentifier", BUNDLE_ID]]) {
50 pb(`Delete :${k}`);
51 pb(`Add :${k} string ${v}`);
52 }
53 if (existsSync(icon)) {
54 execFileSync("cp", [icon, join(app, "Contents", "Resources", "electron.icns")]); // CFBundleIconFile points here
55 }
56 // Editing Info.plist breaks the bundle's signature; macOS (esp. Apple Silicon) wants a valid one.
57 execFileSync("codesign", ["--force", "--deep", "--sign", "-", app], { stdio: "ignore" });
58 writeFileSync(stampFile, stamp);
59 }
60 exe = join(app, "Contents", "MacOS", "Electron");
61}
62
63const child = spawn(exe, [join(root, "dist", "main.js"), ...process.argv.slice(2)], { stdio: "inherit" });
64for (const sig of ["SIGINT", "SIGTERM"]) process.on(sig, () => child.kill(sig));
65child.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));