autoclaw 1.0.28 → 1.0.30
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 +11 -4
- package/package.json +1 -1
package/dist/tools/screenshot.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chromium } from 'playwright';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as os from 'os';
|
|
4
|
+
import * as child_process from 'child_process';
|
|
4
5
|
// Helper to check for common CJK and Emoji font paths on Linux
|
|
5
6
|
const checkLinuxFonts = () => {
|
|
6
7
|
if (os.platform() !== 'linux')
|
|
@@ -21,7 +22,6 @@ const checkLinuxFonts = () => {
|
|
|
21
22
|
const hasEmoji = commonEmojiFontFiles.some(path => fs.existsSync(path));
|
|
22
23
|
// Also check if fc-list finds fonts (if available) - secondary check
|
|
23
24
|
try {
|
|
24
|
-
const child_process = require('child_process');
|
|
25
25
|
const cjkOutput = child_process.execSync('fc-list :lang=zh', { stdio: 'pipe' }).toString();
|
|
26
26
|
const emojiOutput = child_process.execSync('fc-list :family=Emoji', { stdio: 'pipe' }).toString(); // Approximate check
|
|
27
27
|
return {
|
|
@@ -35,7 +35,6 @@ const checkLinuxFonts = () => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const installFonts = (missing) => {
|
|
38
|
-
const child_process = require('child_process');
|
|
39
38
|
try {
|
|
40
39
|
let installCmd = '';
|
|
41
40
|
if (fs.existsSync('/etc/alpine-release')) {
|
|
@@ -97,6 +96,10 @@ export const ScreenshotTool = {
|
|
|
97
96
|
fullPage: {
|
|
98
97
|
type: "boolean",
|
|
99
98
|
description: "If true (default), takes a screenshot of the full scrollable page. Set to false for viewport only."
|
|
99
|
+
},
|
|
100
|
+
waitTime: {
|
|
101
|
+
type: "number",
|
|
102
|
+
description: "Optional delay in seconds to wait for page resources to load before capturing (default: 1)."
|
|
100
103
|
}
|
|
101
104
|
},
|
|
102
105
|
required: ["url", "outputPath"]
|
|
@@ -156,8 +159,12 @@ export const ScreenshotTool = {
|
|
|
156
159
|
});
|
|
157
160
|
// Wait for fonts to be ready
|
|
158
161
|
await page.evaluate(() => document.fonts.ready);
|
|
159
|
-
// Additional
|
|
160
|
-
|
|
162
|
+
// Additional delay for dynamic content (user specified or default 1s)
|
|
163
|
+
const waitTimeMs = (args.waitTime || 1) * 1000;
|
|
164
|
+
if (waitTimeMs > 0) {
|
|
165
|
+
console.log(`Waiting for ${waitTimeMs}ms...`);
|
|
166
|
+
await page.waitForTimeout(waitTimeMs);
|
|
167
|
+
}
|
|
161
168
|
await page.screenshot({
|
|
162
169
|
path: args.outputPath,
|
|
163
170
|
fullPage: args.fullPage !== false // Default to true if undefined
|