refactor: migrate shared infrastructure, home and industries features

This commit is contained in:
2026-08-03 17:19:08 +05:30
parent ab7540c757
commit e664f6e307
42 changed files with 25 additions and 2641 deletions

24
scripts/probe.mjs Normal file
View File

@@ -0,0 +1,24 @@
import { chromium } from 'playwright';
const browser = await chromium.launch();
for (const w of [1600, 1440, 1366, 1280, 1180, 1024, 992, 900, 768, 640, 480, 390]) {
const page = await browser.newPage({ viewport: { width: w, height: 900 }, deviceScaleFactor: 1 });
await page.goto('http://localhost:3000/miletruth', { waitUntil: 'load', timeout: 90000 });
await page.waitForTimeout(1200);
const r = await page.evaluate(() => {
const copy = document.querySelector('#solution-miletruth-ai .sw-mt-copy');
const flow = document.querySelector('#solution-miletruth-ai .sw-mt-flow');
const labels = [...flow.querySelectorAll('.sw-mt-step-label')];
return {
copyW: Math.round(copy.getBoundingClientRect().width),
// widest single unbreakable label vs the track it was given
worst: labels.map(e => {
const track = e.parentElement.getBoundingClientRect().width;
return { txt: e.textContent, need: Math.round(e.scrollWidth), track: Math.round(track) };
}).filter(x => x.need > x.track + 1),
};
});
console.log(`${String(w).padStart(4)} copy=${String(r.copyW).padStart(3)} overflow=${r.worst.length ? JSON.stringify(r.worst) : 'none'}`);
await page.close();
}
await browser.close();

View File

@@ -0,0 +1,49 @@
import { chromium } from 'playwright';
const shots = [
{ name: 'desktop-1440', w: 1440, h: 1000 },
{ name: 'laptop-1280', w: 1280, h: 900 },
{ name: 'tablet-1024', w: 1024, h: 950 },
{ name: 'mobile-390', w: 390, h: 844 },
];
for (const s of shots) {
// fresh browser each time: reusing one exhausts software WebGL contexts
const browser = await chromium.launch({
args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader'],
});
const page = await browser.newPage({ viewport: { width: s.w, height: s.h }, deviceScaleFactor: 1 });
const errs = [];
page.on('pageerror', e => errs.push('pageerror: ' + e.message));
await page.goto('http://localhost:3000/miletruth', { waitUntil: 'load', timeout: 90000 });
const toSec = () => page.evaluate(() => {
const el = document.querySelector('#solution-miletruth-ai');
if (el) window.scrollTo(0, window.scrollY + el.getBoundingClientRect().top - 8);
});
await toSec();
await page.waitForTimeout(18000);
await toSec();
await page.waitForTimeout(2500);
const info = await page.evaluate(() => {
const sec = document.querySelector('#solution-miletruth-ai');
const scene = sec.querySelector('.mtn-scene');
const sb = scene.getBoundingClientRect();
return {
canvas: sec.querySelectorAll('canvas').length,
labels: [...scene.querySelectorAll('.mtn-lbl')].map(e => {
const r = e.getBoundingClientRect();
const clip = r.left < sb.left || r.right > sb.right || r.top < sb.top || r.bottom > sb.bottom;
return e.querySelector('.mtn-lbl-n').textContent + (clip ? ' CLIPPED' : '');
}),
stepRows: new Set([...sec.querySelectorAll('.sw-mt-step')].map(e => Math.round(e.getBoundingClientRect().top))).size,
overflowX: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
});
console.log(`${s.name}: ` + JSON.stringify(info));
if (errs.length) console.log(' ERRORS:', errs.slice(0, 3));
await page.screenshot({ path: `/tmp/mt-${s.name}.png`, timeout: 90000 });
await browser.close();
}

22
scripts/v.mjs Normal file
View File

@@ -0,0 +1,22 @@
import { chromium } from 'playwright-core';
const exe = process.env.HOME + '/Library/Caches/ms-playwright/chromium-1223/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing';
const browser = await chromium.launch({ executablePath: exe });
const page = await browser.newPage({ viewport: { width: 390, height: 760 }, deviceScaleFactor: 2 });
// keep the loader on screen long enough: throttle nothing, just capture during initial window
const resp = page.goto('http://localhost:3000/contact', { waitUntil: 'commit' }).catch(()=>{});
// poll quickly for the loader + logo box while visible
let measured = null;
for (let i=0;i<40;i++){
try {
const m = await page.evaluate(()=>{
const loader=document.querySelector('.dm-loader'); const logo=document.querySelector('.dm-loader__logo');
if(!loader||!logo) return null;
const r=logo.getBoundingClientRect();
return { vw:innerWidth, logoLeft:Math.round(r.left), logoRight:Math.round(r.right), logoW:Math.round(r.width), centerOffset:Math.round((r.left+r.width/2)-(innerWidth/2)) };
});
if(m){ measured=m; if(i===2){ await page.screenshot({path:'/tmp/loader.png'}); } }
} catch(e){}
await page.waitForTimeout(40);
}
console.log(JSON.stringify(measured));
await browser.close();