autoclaw 1.0.27 → 1.0.28
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/tools/screenshot.js +44 -7
- package/package.json +1 -1
package/dist/tools/screenshot.js
CHANGED
|
@@ -34,6 +34,47 @@ const checkLinuxFonts = () => {
|
|
|
34
34
|
return { cjk: hasCJK, emoji: hasEmoji };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
const installFonts = (missing) => {
|
|
38
|
+
const child_process = require('child_process');
|
|
39
|
+
try {
|
|
40
|
+
let installCmd = '';
|
|
41
|
+
if (fs.existsSync('/etc/alpine-release')) {
|
|
42
|
+
// Alpine
|
|
43
|
+
const pkgs = [];
|
|
44
|
+
if (!missing.cjk)
|
|
45
|
+
pkgs.push('font-noto-cjk');
|
|
46
|
+
if (!missing.emoji)
|
|
47
|
+
pkgs.push('font-noto-emoji');
|
|
48
|
+
if (pkgs.length > 0) {
|
|
49
|
+
installCmd = `apk add --no-cache ${pkgs.join(' ')}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (fs.existsSync('/etc/debian_version')) {
|
|
53
|
+
// Debian/Ubuntu
|
|
54
|
+
const pkgs = [];
|
|
55
|
+
if (!missing.cjk)
|
|
56
|
+
pkgs.push('fonts-noto-cjk', 'fonts-wqy-zenhei');
|
|
57
|
+
if (!missing.emoji)
|
|
58
|
+
pkgs.push('fonts-noto-color-emoji');
|
|
59
|
+
if (pkgs.length > 0) {
|
|
60
|
+
// apt-get update is often needed first in clean containers
|
|
61
|
+
installCmd = `apt-get update && apt-get install -y ${pkgs.join(' ')}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (installCmd) {
|
|
65
|
+
console.log(`Creating font environment... (${installCmd})`);
|
|
66
|
+
console.log("This may take a few moments...");
|
|
67
|
+
child_process.execSync(installCmd, { stdio: 'inherit' });
|
|
68
|
+
console.log('✅ Fonts installed successfully.');
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.warn(`⚠️ Failed to auto-install fonts: ${e.message}`);
|
|
74
|
+
console.warn('Please install them manually to fix "tofu" characters.');
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
37
78
|
export const ScreenshotTool = {
|
|
38
79
|
name: "Screenshot Tool",
|
|
39
80
|
configKeys: [],
|
|
@@ -66,13 +107,9 @@ export const ScreenshotTool = {
|
|
|
66
107
|
// Check for fonts on Linux to prevent "tofu" characters
|
|
67
108
|
if (os.platform() === 'linux') {
|
|
68
109
|
const fonts = checkLinuxFonts();
|
|
69
|
-
if (!fonts.cjk) {
|
|
70
|
-
console.
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
if (!fonts.emoji) {
|
|
74
|
-
console.warn("⚠️ Warning: No Emoji fonts detected. Emojis may appear as squares.");
|
|
75
|
-
console.warn(" Run 'apk add font-noto-emoji' (Alpine) or 'apt-get install fonts-noto-color-emoji' (Debian/Ubuntu).");
|
|
110
|
+
if (!fonts.cjk || !fonts.emoji) {
|
|
111
|
+
console.log("Missing fonts detected. Attempting to fix environment...");
|
|
112
|
+
installFonts(fonts);
|
|
76
113
|
}
|
|
77
114
|
}
|
|
78
115
|
let browser;
|