LifeMate — Personal, Family & Learning Companion

feat/aparat-learning-library
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
mjs 38 lines 1.49 KB
Raw
1 import assert from 'node:assert/strict';
2 import {readFile} from 'node:fs/promises';
3 import vm from 'node:vm';
4
5 const script = (await readFile(new URL('../web/flutter_bootstrap.js', import.meta.url), 'utf8'))
6 .replace('{{flutter_js}}', '').replace('{{flutter_build_config}}', '');
7 let engineConfig;
8 let removed = false;
9 const status = {remove() { removed = true; }};
10 let ready;
11 const started = new Promise(resolve => { ready = resolve; });
12 const window = {isSecureContext:true,addEventListener() {}};
13 vm.runInNewContext(script, {
14 URL,
15 window,
16 navigator: {locks: {request(name, options, callback) {
17 assert.equal(name,'lifeguide.active-instance.v1');
18 assert.equal(options.mode,'exclusive');
19 assert.equal(options.ifAvailable,true);
20 callback({name});
21 return new Promise(() => {});
22 }}},
23 document: {baseURI: 'https://family.example.test/',
24 getElementById: id => id === 'startup-status' ? status : null},
25 _flutter: {loader: {async load(options) {
26 assert.equal(options.config.canvasKitBaseUrl, 'https://family.example.test/canvaskit/');
27 await options.onEntrypointLoaded({async initializeEngine(config) {
28 engineConfig = config;
29 return {async runApp() {}};
30 }});
31 ready();
32 }}},
33 });
34 await started;
35 assert.equal(window.lifeguideInstanceOwned,true);
36 assert.equal(engineConfig?.fontFallbackBaseUrl, 'https://family.example.test/assets/fonts/fallback/');
37 assert.equal(removed, true);
38 console.log('Custom bootstrap passes the local font configuration to the Flutter engine.');