import { gzipSync } from 'node:zlib';
import { stat, readFile } from 'node:fs/promises';

const files = [
  'public/vendor/opencascade/opencascade.js',
  'public/vendor/opencascade/opencascade.wasm',
  'public/vendor/opencascade/opencascade.worker.js',
  'public/step_worker_loader.js',
  'public/step_worker.js',
];

for (const file of files) {
  try {
    const info = await stat(file);
    const bytes = await readFile(file);
    console.log(`${file}\traw=${info.size}\tgzip=${gzipSync(bytes, { level: 9 }).byteLength}`);
  } catch (error) {
    if (error?.code !== 'ENOENT') {
      throw error;
    }
    console.log(`${file}\tmissing`);
  }
}
