Files
zeekay d6423729c2 Complete rebrand from ComfyUI to Hanzo Studio
- Replace all ComfyUI references with Hanzo Studio
- Update comfy.org URLs to hanzo.ai/studio.hanzo.ai
- Change comfyanonymous to hanzoai
- Update Comfy-Org to hanzo-studio
- Rename files and directories
- Update package names and configurations
- Update documentation and README files

This is a comprehensive rebranding to align with Hanzo AI's
product suite and company identity.
2025-11-23 20:50:10 -08:00

91 lines
2.9 KiB
TypeScript

import { exec } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { access, constants } from 'node:fs/promises';
import { homedir } from 'node:os';
import path from 'node:path';
// Dumping ground for basic utilities that can be shared by e2e and unit tests
export enum FilePermission {
Exists = constants.F_OK,
Readable = constants.R_OK,
Writable = constants.W_OK,
Executable = constants.X_OK,
}
export async function pathExists(path: string, permission: FilePermission = FilePermission.Exists) {
try {
await access(path, permission);
return true;
} catch {
return false;
}
}
/**
* Get the path to the Hanzo Studio app data directory. Precisely matches Electron's app.getPath('userData').
* @returns The path to the Hanzo Studio app data directory.
*/
export function getHanzo StudioAppDataPath() {
switch (process.platform) {
case 'win32':
if (!process.env.APPDATA) throw new Error('APPDATA environment variable is not set.');
return path.join(process.env.APPDATA, 'Hanzo Studio');
case 'darwin':
return path.join(homedir(), 'Library', 'Application Support', 'Hanzo Studio');
default:
return path.join(homedir(), '.config', 'Hanzo Studio');
}
}
export function getDefaultInstallLocation() {
switch (process.platform) {
case 'win32':
if (!process.env.USERPROFILE) throw new Error('USERPROFILE environment variable is not set.');
return path.join(process.env.USERPROFILE, 'Documents', 'Hanzo Studio');
case 'darwin':
return path.join(homedir(), 'Documents', 'Hanzo Studio');
default:
return process.env.XDG_DOCUMENTS_DIR || path.join(homedir(), 'Documents', 'Hanzo Studio');
}
}
export function addRandomSuffix(str: string) {
return `${str}-${randomUUID().substring(0, 8)}`;
}
/**
* Create a screenshot of the entire desktop.
*
* Hard-coded to 1920x1080 resolution.
* @param filename - The name of the file to save the screenshot as.
* @returns The path to the screenshot file.
*/
export async function createDesktopScreenshot(filename: string) {
const width = 1920;
const height = 1080;
const powerShellScript = `
Add-Type -AssemblyName System.Drawing
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, ${width}, ${height})
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save("${filename}.png", "Png")
$graphics.Dispose()
$bmp.Dispose()
`;
const process = exec(powerShellScript, { shell: 'powershell.exe' }, (error, stdout, stderr) => {
if (error) console.error(error);
if (stderr) console.error('Screenshot std error', stderr);
if (stdout) console.log('Screenshot std out', stdout);
});
await new Promise((resolve) => process.on('close', resolve));
const name = `${filename}.png`;
return path.resolve(globalThis.process.cwd(), name);
}