build 6, watchdog
This commit is contained in:
+36
-17
@@ -215,11 +215,19 @@ async function importLocale(app) {
|
||||
|
||||
const fontDir = pathToFileURL(join(ROOT, 'wasm/frontend/node_modules/@fontsource/barlow/files')).href
|
||||
|
||||
function frameHtml({ raw, caption, rtl, tabs }) {
|
||||
const W = 1290, H = 2796, scale = 0.79
|
||||
// App Store: 1290×2796 with an iPhone frame. Play: 1440×2560 (9:16; Play rejects
|
||||
// images longer than 2:1) with a generic phone outline and no Dynamic Island.
|
||||
const FRAME = {
|
||||
appstore: { W: 1290, H: 2796, scale: 0.79, bottom: 60, h1Top: 150, h1Size: 92, island: true },
|
||||
play: { W: 1440, H: 2560, scale: 0.68, bottom: 70, h1Top: 120, h1Size: 84, island: false },
|
||||
}
|
||||
|
||||
function frameHtml({ raw, caption, rtl, tabs, kind = 'appstore' }) {
|
||||
const { W, H, scale, bottom, h1Top, h1Size, island } = FRAME[kind]
|
||||
const sw = Math.round(1290 * scale), sh = Math.round(2796 * scale)
|
||||
const left = Math.round((W - sw) / 2), top = H - sh - 60
|
||||
const left = Math.round((W - sw) / 2), top = H - sh - bottom
|
||||
const px = (v) => Math.round(v * 3 * scale) // app points → frame pixels
|
||||
const r = (v) => Math.round(v * scale / 0.79) // radii tuned for the App Store frame
|
||||
const tabBar = tabs ? `
|
||||
<div class="tabbar" style="height:${px(83)}px">
|
||||
${tabs.map((t, i) => `<div class="tab${i === 0 ? ' on' : ''}">
|
||||
@@ -235,12 +243,13 @@ function frameHtml({ raw, caption, rtl, tabs }) {
|
||||
radial-gradient(2px 2px at 120px 160px, #fff8, transparent), radial-gradient(2px 2px at 980px 90px, #fff9, transparent),
|
||||
radial-gradient(1.5px 1.5px at 400px 320px, #fff6, transparent), radial-gradient(2px 2px at 1180px 420px, #fff7, transparent),
|
||||
radial-gradient(1.5px 1.5px at 760px 250px, #fff5, transparent), radial-gradient(2.5px 2.5px at 230px 470px, #FFE9C7aa, transparent); }
|
||||
h1 { position: absolute; left: 90px; right: 90px; top: 150px; margin: 0; color: #E8ECF2; font-weight: 700;
|
||||
font-size: 92px; line-height: 1.12; text-align: center; letter-spacing: -0.01em; }
|
||||
h1 { position: absolute; left: 90px; right: 90px; top: ${h1Top}px; margin: 0; color: #E8ECF2; font-weight: 700;
|
||||
font-size: ${h1Size}px; line-height: 1.12; text-align: center; letter-spacing: -0.01em; }
|
||||
h1 em { color: #F5B544; font-style: normal; }
|
||||
${kind === 'play' ? `h1 { top: 0; height: ${top - 18}px; display: flex; align-items: center; justify-content: center; }` : ''}
|
||||
.device { position: absolute; left: ${left - 18}px; top: ${top - 18}px; width: ${sw + 36}px; height: ${sh + 36}px;
|
||||
border-radius: 120px; background: #1A2130; box-shadow: 0 40px 120px #000a, inset 0 0 0 3px #2B3446; }
|
||||
.screen { position: absolute; left: ${left}px; top: ${top}px; width: ${sw}px; height: ${sh}px; border-radius: 104px; overflow: hidden; background: #000; }
|
||||
border-radius: ${r(120)}px; background: #1A2130; box-shadow: 0 40px 120px #000a, inset 0 0 0 3px #2B3446; }
|
||||
.screen { position: absolute; left: ${left}px; top: ${top}px; width: ${sw}px; height: ${sh}px; border-radius: ${r(104)}px; overflow: hidden; background: #000; }
|
||||
.screen img { width: 100%; height: 100%; display: block; }
|
||||
.status { position: absolute; left: 0; right: 0; top: 0; height: ${px(54)}px; display: flex; align-items: center;
|
||||
justify-content: space-between; padding: 0 ${px(34)}px; color: #fff; font: 600 ${px(17)}px -apple-system, system-ui, sans-serif; direction: ltr; }
|
||||
@@ -260,7 +269,7 @@ function frameHtml({ raw, caption, rtl, tabs }) {
|
||||
<svg width="${px(16)}" height="${px(12)}" viewBox="0 0 16 12"><path d="M8 11.5 5.6 9a3.4 3.4 0 0 1 4.8 0zM3.4 6.8a6.6 6.6 0 0 1 9.2 0l-1.4 1.4a4.6 4.6 0 0 0-6.4 0zM1 4.4a10 10 0 0 1 14 0l-1.4 1.4a8 8 0 0 0-11.2 0z" fill="#fff"/></svg>
|
||||
<svg width="${px(27)}" height="${px(13)}" viewBox="0 0 27 13"><rect x=".5" y=".5" width="23" height="12" rx="3.5" fill="none" stroke="#fff" opacity=".45"/><rect x="2" y="2" width="20" height="9" rx="2" fill="#fff"/><rect x="24.5" y="4" width="2" height="5" rx="1" fill="#fff" opacity=".45"/></svg>
|
||||
</span></div>
|
||||
<div class="island"></div>
|
||||
${island ? '<div class="island"></div>' : ''}
|
||||
${tabBar}
|
||||
<div class="home"></div>
|
||||
</div></body></html>`
|
||||
@@ -285,21 +294,31 @@ async function frames(locale) {
|
||||
? ['sites', 'new', 'settings'].map((k, j) => ({ label: msgs[`tab.${k}`], icon: TAB_ICONS[j] }))
|
||||
: null
|
||||
const tabsOrdered = tabs && rtl ? [...tabs] : tabs // dir=rtl on <html> mirrors the flex row
|
||||
const html = join(out, `frame-${name}.html`)
|
||||
writeFileSync(html, frameHtml({ raw: pathToFileURL(raw).href, caption: m.captions[i], rtl, tabs: tabsOrdered }))
|
||||
const png = join(out, `${String(i + 1).padStart(2, '0')}-${name}.png`)
|
||||
await new Promise((res, rej) => {
|
||||
const p = spawn(CHROME, ['--headless=new', '--hide-scrollbars', '--allow-file-access-from-files',
|
||||
'--force-device-scale-factor=1', '--window-size=1290,2796', `--screenshot=${png}`, pathToFileURL(html).href], { stdio: 'ignore' })
|
||||
p.on('exit', (c) => (c === 0 ? res() : rej(new Error(`frame render failed: ${png}`))))
|
||||
})
|
||||
// App Store images in <locale>/, Google Play images in <locale>/play/.
|
||||
for (const kind of ['appstore', 'play']) {
|
||||
const dir = kind === 'play' ? join(out, 'play') : out
|
||||
mkdirSync(dir, { recursive: true })
|
||||
const html = join(dir, `frame-${name}.html`)
|
||||
writeFileSync(html, frameHtml({ raw: pathToFileURL(raw).href, caption: m.captions[i], rtl, tabs: tabsOrdered, kind }))
|
||||
const png = join(dir, `${String(i + 1).padStart(2, '0')}-${name}.png`)
|
||||
const { W, H } = FRAME[kind]
|
||||
const render = () => new Promise((res) => {
|
||||
const p = spawn(CHROME, ['--headless=new', '--hide-scrollbars', '--allow-file-access-from-files',
|
||||
'--force-device-scale-factor=1', `--window-size=${W},${H}`, `--screenshot=${png}`, pathToFileURL(html).href], { stdio: 'ignore' })
|
||||
p.on('exit', (c) => res(c === 0))
|
||||
})
|
||||
let ok = false
|
||||
for (let attempt = 0; attempt < 3 && !ok; attempt++) ok = await render() // headless Chrome occasionally exits non-zero
|
||||
if (!ok) throw new Error(`frame render failed: ${png}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FRAMES_ONLY=1 re-frames existing raw-*.png without re-running the app.
|
||||
let port = 9400
|
||||
for (const locale of locales) {
|
||||
process.stdout.write(`${locale}: screens… `)
|
||||
await rawScreens(locale, port++)
|
||||
if (!process.env.FRAMES_ONLY) await rawScreens(locale, port++)
|
||||
process.stdout.write('frames… ')
|
||||
await frames(locale)
|
||||
console.log('done')
|
||||
|
||||
Reference in New Issue
Block a user