(feat): migrate bun to pnpm
(feat): some mtp stuff (wip): electron app tray
This commit is contained in:
parent
69149b73bd
commit
82a483d7ab
39 changed files with 10109 additions and 2429 deletions
|
|
@ -10,22 +10,22 @@
|
|||
"scripts": {
|
||||
"clean": "rm -rf dist release",
|
||||
"lint": "eslint src",
|
||||
"build:web": "cd ../.. && bun run build:web",
|
||||
"build:web": "cd ../.. && pnpm run build:web",
|
||||
"build": "tsc -p tsconfig.json && esbuild src/preload/preload.ts --bundle --platform=node --format=cjs --external:electron --outfile=dist/preload/preload.cjs",
|
||||
"dev:raw": "cd ../.. && bun run build:web && cd apps/electron && bun run build && electron . --verbose",
|
||||
"dev": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run dev:raw; else bun run dev:raw; fi",
|
||||
"start:raw": "bun run build && electron .",
|
||||
"start": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run start:raw; else bun run start:raw; fi",
|
||||
"package:raw": "cd ../.. && bun run build:web && cd apps/electron && bun run build && electron-builder --publish never",
|
||||
"package": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run package:raw; else bun run package:raw; fi",
|
||||
"package:linux:raw": "cd ../.. && bun run build:web && cd apps/electron && bun run build && electron-builder --linux --publish never",
|
||||
"package:linux": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run package:linux:raw; else bun run package:linux:raw; fi",
|
||||
"package:windows:raw": "cd ../.. && bun run build:web && cd apps/electron && bun run build && electron-builder --win --publish never",
|
||||
"package:windows": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run package:windows:raw; else bun run package:windows:raw; fi",
|
||||
"checksum": "bun scripts/generate-release-metadata.ts",
|
||||
"generate-signing-key": "bun scripts/generate-signing-key.ts",
|
||||
"validate:raw": "bun run build && bun run package:linux:raw",
|
||||
"validate": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command bun run validate:raw; else bun run validate:raw; fi"
|
||||
"dev:raw": "cd ../.. && pnpm run build:web && cd apps/electron && pnpm run build && electron . --verbose",
|
||||
"dev": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run dev:raw; else pnpm run dev:raw; fi",
|
||||
"start:raw": "pnpm run build && electron .",
|
||||
"start": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run start:raw; else pnpm run start:raw; fi",
|
||||
"package:raw": "cd ../.. && pnpm run build:web && cd apps/electron && pnpm run build && electron-builder --publish never",
|
||||
"package": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run package:raw; else pnpm run package:raw; fi",
|
||||
"package:linux:raw": "cd ../.. && pnpm run build:web && cd apps/electron && pnpm run build && electron-builder --linux --publish never",
|
||||
"package:linux": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run package:linux:raw; else pnpm run package:linux:raw; fi",
|
||||
"package:windows:raw": "cd ../.. && pnpm run build:web && cd apps/electron && pnpm run build && electron-builder --win --publish never",
|
||||
"package:windows": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run package:windows:raw; else pnpm run package:windows:raw; fi",
|
||||
"checksum": "node scripts/generate-release-metadata.ts",
|
||||
"generate-signing-key": "node scripts/generate-signing-key.ts",
|
||||
"validate:raw": "pnpm run build && pnpm run package:linux:raw",
|
||||
"validate": "if command -v nix >/dev/null 2>&1 && [ -z \"$IN_NIX_SHELL\" ]; then nix develop ../..#electron --command pnpm run validate:raw; else pnpm run validate:raw; fi"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import {
|
|||
type DesktopScreenShareAudioOutput,
|
||||
type DesktopScreenShareCapabilities,
|
||||
} from "../shared/ipc.js";
|
||||
import { initTray } from "./tray.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const verbose = process.argv.includes("--verbose");
|
||||
|
|
@ -310,6 +311,7 @@ async function start() {
|
|||
verboseLog("app ready");
|
||||
registerIpc();
|
||||
registerDisplayMediaHandler();
|
||||
initTray();
|
||||
await createWindow();
|
||||
}
|
||||
|
||||
|
|
|
|||
25
apps/electron/src/main/tray.ts
Normal file
25
apps/electron/src/main/tray.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Tray, Menu } from "electron";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
let tray: Tray | null = null;
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export function initTray() {
|
||||
const iconPath = path.join(__dirname, "../../build/icons/32x32.png");
|
||||
|
||||
tray = new Tray(iconPath); // keep reference alive
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: "Restart", type: "normal" },
|
||||
{ label: "Quit", type: "normal" },
|
||||
]);
|
||||
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
tray.on("click", (event) => {
|
||||
console.log(event);
|
||||
})
|
||||
}
|
||||
|
|
@ -21,11 +21,11 @@
|
|||
"dev:mobile:raw": "tauri android dev --host ${TAURI_DEV_HOST:-127.0.0.1}",
|
||||
"start-adb:mobile:raw": "adb devices",
|
||||
"build:mobile:raw": "tauri android build",
|
||||
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command bun dev:mobile:raw; else bun dev:mobile:raw; fi",
|
||||
"start-adb:mobile": "if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command bun start-adb:mobile:raw; else bun start-adb:mobile:raw; fi",
|
||||
"build:mobile": "bun run render-version.ts && if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command bun build:mobile:raw; else bun build:mobile:raw; fi && bun run render-version.ts --unrender",
|
||||
"gen-icons": "tauri icon ./logo.json && bun scripts/sync-electron-icons.ts",
|
||||
"format": "bunx prettier --write .",
|
||||
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command pnpm run dev:mobile:raw; else pnpm run dev:mobile:raw; fi",
|
||||
"start-adb:mobile": "if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command pnpm run start-adb:mobile:raw; else pnpm run start-adb:mobile:raw; fi",
|
||||
"build:mobile": "node render-version.ts && if command -v nix >/dev/null 2>&1; then nix develop ../..#tauri --command pnpm run build:mobile:raw; else pnpm run build:mobile:raw; fi && node render-version.ts --unrender",
|
||||
"gen-icons": "tauri icon ./logo.json && node scripts/sync-electron-icons.ts",
|
||||
"format": "pnpm exec prettier --write .",
|
||||
"lint": "eslint src"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
"mainBinaryName": "tensamin",
|
||||
"identifier": "net.tensamin.client",
|
||||
"build": {
|
||||
"beforeDevCommand": "cd ../web && bun run dev && cd ../tauri",
|
||||
"beforeDevCommand": "cd ../web && pnpm run dev && cd ../tauri",
|
||||
"devUrl": "http://localhost:3000",
|
||||
"beforeBuildCommand": "cd ../.. && bun run build:web && cd apps/tauri",
|
||||
"beforeBuildCommand": "cd ../.. && pnpm run build:web && cd apps/tauri",
|
||||
"frontendDist": "../../web/dist"
|
||||
},
|
||||
"app": {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"format": "bunx prettier --write .",
|
||||
"format": "pnpm exec prettier --write .",
|
||||
"lint": "eslint src",
|
||||
"dev": "vite --port 3000 --host 0.0.0.0",
|
||||
"test": "bun test --pass-with-no-tests",
|
||||
"build": "bun run test && tsc -b && vite build",
|
||||
"test": "vitest run --passWithNoTests",
|
||||
"build": "pnpm run test && tsc -b && vite build",
|
||||
"preview": "cd dist && nix-shell -p python3 --run 'python3 -m http.server 3000' && cd .."
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -61,14 +61,9 @@ function parseTuFileContent(rawFileContent: string): {
|
|||
? Number(userIdString.split("@")[0])
|
||||
: Number(userIdString);
|
||||
|
||||
const rawDomain = userIdString.includes("@")
|
||||
const domain = userIdString.includes("@")
|
||||
? userIdString.split("@")[1]
|
||||
: null;
|
||||
const domain = rawDomain
|
||||
? rawDomain.includes(":")
|
||||
? rawDomain
|
||||
: rawDomain + ":1984"
|
||||
: null;
|
||||
|
||||
if (!userId || !privateKey) {
|
||||
throw new Error("Invalid file");
|
||||
|
|
@ -76,7 +71,6 @@ function parseTuFileContent(rawFileContent: string): {
|
|||
|
||||
console.log({
|
||||
domain,
|
||||
rawDomain,
|
||||
userId,
|
||||
});
|
||||
|
||||
|
|
@ -220,14 +214,9 @@ export default function Form() {
|
|||
const actualUsername = inputUsername.includes("@")
|
||||
? inputUsername.split("@")[0]
|
||||
: inputUsername;
|
||||
const rawDomain = inputUsername.includes("@")
|
||||
const domain = inputUsername.includes("@")
|
||||
? inputUsername.split("@")[1]
|
||||
: null;
|
||||
const domain = rawDomain
|
||||
? rawDomain.includes(":")
|
||||
? rawDomain
|
||||
: rawDomain + ":1984"
|
||||
: null;
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
|
|
|
|||
Loading…
Reference in a new issue