-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-preview.js
More file actions
52 lines (44 loc) · 1.79 KB
/
Copy pathdebug-preview.js
File metadata and controls
52 lines (44 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Debug script to test preview generation for a specific map
* Run with: node --experimental-modules debug-preview.js
*/
import { readFile } from 'fs/promises';
import { W3XMapLoader } from './src/formats/maps/w3x/W3XMapLoader.js';
import { MapPreviewExtractor } from './src/engine/rendering/MapPreviewExtractor.js';
async function testPreview() {
const mapPath = './maps/3P Sentinel 01 v3.06.w3x';
console.log(`\n=== Testing Preview for: ${mapPath} ===\n`);
try {
// Load map file
console.log('1. Loading map file...');
const buffer = await readFile(mapPath);
console.log(` ✅ Loaded ${buffer.length} bytes`);
// Parse map
console.log('\n2. Parsing map...');
const loader = new W3XMapLoader();
const mapData = await loader.parse(buffer);
console.log(' ✅ Map parsed successfully');
console.log(' - Format:', mapData.format);
console.log(' - Name:', mapData.info?.name || 'Unknown');
console.log(' - Terrain size:', mapData.terrain?.width, 'x', mapData.terrain?.height);
// Extract preview
console.log('\n3. Extracting/generating preview...');
const extractor = new MapPreviewExtractor();
const file = new File([buffer], '3P Sentinel 01 v3.06.w3x');
const result = await extractor.extract(file, mapData);
console.log(' Result:', result.source);
console.log(' Success:', result.success);
console.log(' Time:', result.extractTimeMs, 'ms');
if (result.error) {
console.log(' ❌ Error:', result.error);
}
if (result.dataUrl) {
console.log(' ✅ Data URL:', result.dataUrl.substring(0, 100) + '...');
console.log(' Data URL length:', result.dataUrl.length);
}
} catch (err) {
console.error('\n❌ Error:', err.message);
console.error(err.stack);
}
}
testPreview();