LifeMate — Personal, Family & Learning Companion

design/mobile-accessibility-v2
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
cjs 50 lines 4.69 KB
Raw
1 #!/usr/bin/env node
2 'use strict';
3 const {chromium}=require('playwright');
4 const fs=require('node:fs/promises'),path=require('node:path'),crypto=require('node:crypto');
5 const root=path.resolve(__dirname,'..'),out=path.join(root,'exports');
6 const base=new URL(process.env.DESIGN_BASE_URL || 'http://127.0.0.1:8772/LifeGuide-preview.html');
7 (async()=>{
8 if(!['127.0.0.1','localhost','[::1]'].includes(base.hostname))throw Error('Only a local design server is allowed');
9 await fs.mkdir(path.join(out,'screenshots'),{recursive:true});
10 const b=await chromium.launch({executablePath:process.env.CHROMIUM_PATH||'/usr/bin/chromium',args:['--no-sandbox']});
11 try{
12 const p=await b.newPage({viewport:{width:2200,height:1200},deviceScaleFactor:1});
13 await p.goto(base.href);await p.evaluate(()=>document.fonts.ready);
14 const {screens,boardFrames}=await p.evaluate(()=>({screens:window.LifeGuideDesign.screens,boardFrames:window.LifeGuideDesign.boardFrames}));
15 const images=[];
16 for(const frame of boardFrames){
17 const url=new URL(base);url.searchParams.set('board','1');url.searchParams.set('frame',frame.id);
18 await p.goto(url.href);await p.evaluate(()=>document.fonts.ready);
19 const file=`screenshots/${frame.id}.png`;
20 await p.locator('.board-panel').screenshot({path:path.join(out,file)});
21 images.push({...frame,file});
22 }
23 for(const theme of ['calm','bright']){
24 const url=new URL(base);url.searchParams.set('board','1');url.searchParams.set('direction',theme);
25 await p.goto(url.href);await p.evaluate(()=>document.fonts.ready);
26 await p.addStyleTag({content:'.board-grid{grid-template-columns:repeat(3,390px)}'});
27 await p.screenshot({path:path.join(out,`LifeGuide-${theme}-three-screens.png`),fullPage:true});
28 }
29 const boardURL=new URL(base);boardURL.searchParams.set('board','1');
30 await p.goto(boardURL.href);await p.evaluate(()=>document.fonts.ready);
31 const boardSize=await p.locator('.board-mode').boundingBox();
32 await p.screenshot({path:path.join(out,'LifeGuide-overview.png'),fullPage:true});
33 // PDF keeps searchable vector text. The oversized sheet is intentional:
34 // it is a zoomable board, not a document printed on A4.
35 await p.pdf({path:path.join(out,'LifeGuide-overview.pdf'),width:`${Math.ceil(boardSize.width)}px`,height:`${Math.ceil(boardSize.height)+16}px`,printBackground:true,margin:{top:'0',right:'0',bottom:'0',left:'0'}});
36 const tiles=images.map(i=>`<a href="${i.file}" aria-label="${i.title}"><img src="${i.file}" loading="lazy" alt="${i.title}؛ طرح تعاملی با داده ساختگی"><span>${i.title}</span></a>`).join('');
37 await fs.writeFile(path.join(out,'gallery.html'),`<!doctype html><html lang="fa" dir="rtl"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>LifeGuide · گالری طراحی v2</title><style>body{font:16px/1.8 sans-serif;margin:24px;background:#f2f5f0;color:#203a32}h1{font-size:26px}main{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:24px}a{color:#245c4c;background:white;padding:12px;border:1px solid #788b80;border-radius:16px;display:block;text-decoration:none}img{width:100%;height:420px;object-fit:contain;object-position:top}span{display:block;padding:12px}</style><h1>LifeGuide · گالری طراحی v2</h1><p>همهٔ داده‌ها ساختگی‌اند. تصویرها برای بزرگ‌نمایی باز می‌شوند؛ این گالری برنامهٔ عملیاتی نیست.</p><main>${tiles}</main></html>`);
38 // Actual browser view at mobile size, in addition to full-content board frames.
39 await p.setViewportSize({width:390,height:844});
40 for(const name of ['home','lesson','parent-home']){
41 const url=new URL(base);url.searchParams.set('screen',name);
42 await p.goto(url.href);await p.evaluate(()=>document.fonts.ready);
43 await p.screenshot({path:path.join(out,`screenshots/viewport-${name}-390.png`),fullPage:true});
44 }
45 const source=await fs.readFile(path.join(out,'LifeGuide-preview.html'));
46 const manifest={status:'VERIFIED_EXPORTS_ONLY',createdAt:new Date().toISOString(),browser:await b.version(),screenCount:screens.length,boardFrameCount:images.length,sourceSha256:crypto.createHash('sha256').update(source).digest('hex'),boardSize,images,unverified:['Safari','physical devices','Iran reachability','real video','student usability test']};
47 await fs.writeFile(path.join(out,'export-manifest.json'),JSON.stringify(manifest,null,2)+'\n');
48 console.log(JSON.stringify({status:manifest.status,screenCount:screens.length,boardFrameCount:images.length,boardSize,htmlSha256:manifest.sourceSha256}));
49 }finally{await b.close();}
50 })().catch(e=>{console.error(e.message);process.exitCode=1;});