7e6b203a02
Bundle web bootstrap, icons, local font fallbacks and hosting instructions. Add optimized WebP/MP3 packaging, asset checks and a browser narration regression tool. Support browser audio handoff and ad-free explained hints. Refresh the responsive bookshelf and reduce unnecessary app, narration and paper repaint work. Preserve deliberate page swipes while tolerating small mouse movements during cell and navigation clicks. Validation: all 77 Flutter tests pass; shell, JavaScript and Python scripts parse; locale and web manifests are valid JSON; git diff --check passes.
50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Check all story/art/audio references in a deployable Flutter web bundle."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
root = Path(sys.argv[1] if len(sys.argv) > 1 else 'build/web')
|
|
missing = []
|
|
references = set()
|
|
|
|
|
|
def visit(value):
|
|
if isinstance(value, dict):
|
|
for item in value.values():
|
|
visit(item)
|
|
elif isinstance(value, list):
|
|
for item in value:
|
|
visit(item)
|
|
elif isinstance(value, str) and value.startswith('assets/'):
|
|
references.add(value)
|
|
path = root / 'assets' / value
|
|
if path.suffix in ('.png', '.wav'):
|
|
path = path.with_suffix('.webp' if path.suffix == '.png' else '.mp3')
|
|
if not path.is_file():
|
|
missing.append(value)
|
|
|
|
|
|
for name in ['index.html', 'flutter_bootstrap.js', 'main.dart.js',
|
|
'manifest.json', 'main.dart.wasm', 'main.dart.mjs', 'assets/AssetManifest.bin.json',
|
|
'assets/assets/fonts/DancingScript.ttf']:
|
|
if not (root / name).is_file():
|
|
missing.append(name)
|
|
|
|
font_manifest = root / 'assets/FontManifest.json'
|
|
if font_manifest.is_file():
|
|
visit(json.loads(font_manifest.read_text()))
|
|
|
|
for path in (root / 'assets/assets').rglob('*.json'):
|
|
data = json.loads(path.read_text())
|
|
visit(data)
|
|
# Mara's original manifest uses filenames instead of asset paths.
|
|
if path.name == 'narration_manifest.json':
|
|
for track in data.get('tracks', {}).values():
|
|
if 'file' in track and 'asset' not in track:
|
|
visit('assets/audio/' + track['file'])
|
|
|
|
if missing:
|
|
raise SystemExit('Missing bundled files:\n' + '\n'.join(sorted(set(missing))))
|
|
print(f'Web bundle verified: {len(references)} referenced assets present.')
|