Add browser playtest and improve library, media and input

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.
This commit is contained in:
Hadrian Burkhardt
2026-11-06 03:33:26 +01:00
parent 7855aafade
commit 7e6b203a02
34 changed files with 1370 additions and 269 deletions
+37
View File
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/ui/paper.dart';
void main() {
testWidgets('paper raster layer stays within the viewport on large screens', (
tester,
) async {
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
for (final viewport in [
const Size(1920, 1080),
const Size(3840, 2160),
const Size(390, 844),
]) {
tester.view.physicalSize = viewport;
await tester.pumpWidget(
const MaterialApp(home: Paper(child: SizedBox.expand())),
);
await tester.pumpAndSettle();
final image = find.image(
const AssetImage('assets/artwork/mara-single-page-v2.png'),
);
final bounds = tester.getRect(image);
expect(bounds.left, greaterThanOrEqualTo(0));
expect(bounds.top, greaterThanOrEqualTo(0));
expect(bounds.right, lessThanOrEqualTo(viewport.width));
expect(bounds.bottom, lessThanOrEqualTo(viewport.height));
if (viewport.width > viewport.height) {
expect(bounds.size, viewport);
expect(tester.widget<Image>(image).fit, BoxFit.cover);
} else {
expect(bounds.size, const Size(390, 585));
}
}
});
}
+72
View File
@@ -0,0 +1,72 @@
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/progress.dart';
void main() {
testWidgets('rapid mouse clicks tolerate small movement and cycle to X', (
tester,
) async {
final book = (await tester.runAsync(Book.load))!;
final game = Game(book, Progress.memory())..showStory(2);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
final cell = List.generate(
game.cells.length,
(i) => i,
).firstWhere((i) => !game.puzzle!.given[i]);
final center = tester.getCenter(find.byKey(ValueKey('cell-$cell')));
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: center);
await mouse.down(center);
await mouse.up();
await tester.pump(const Duration(milliseconds: 30));
expect(game.cells[cell], 1);
await mouse.down(center);
await mouse.moveTo(center + const Offset(4, 1));
await mouse.up();
await tester.pump();
expect(
game.cells[cell],
2,
reason: 'Minor mouse drift must not become a swipe',
);
await mouse.down(center);
await mouse.moveTo(center + const Offset(80, 0));
await mouse.up();
await tester.pump();
expect(game.cells[cell], 2, reason: 'A deliberate grid drag must not mark');
expect(game.storyIndex, 2, reason: 'A grid drag must not turn the page');
await mouse.removePointer();
await tester.pumpWidget(const SizedBox());
});
testWidgets('next-leaf mouse click tolerates small movement', (tester) async {
final book = (await tester.runAsync(Book.load))!;
final game = Game(book, Progress.memory())..showStory(0);
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
await tester.pumpAndSettle();
final next = find.text('Next leaf →');
await tester.ensureVisible(next);
await tester.pumpAndSettle();
final center = tester.getCenter(next);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: center);
await mouse.down(center);
await mouse.moveTo(center + const Offset(5, 1));
await mouse.up();
await tester.pump();
expect(game.storyIndex, 1);
await mouse.down(const Offset(30, 300));
await mouse.moveTo(const Offset(110, 300));
await mouse.up();
await tester.pump();
expect(game.storyIndex, 0, reason: 'A deliberate margin swipe still turns');
await mouse.removePointer();
await tester.pumpWidget(const SizedBox());
});
}