This folder contains the Dart runtime intended for Flutter hosts.
Package identity: managedcode_tps
SDK/flutter is the Flutter-facing TPS runtime. It is implemented as a pure Dart package so it can be embedded into Flutter apps without owning the widget layer.
The package follows the same compile-and-play contract as the TypeScript, JavaScript, Swift, Java, and .NET runtimes.
TpsSpecTpsKeywordsvalidateTps(source)parseTps(source)compileTps(source)TpsPlayer: pure deterministic resolverTpsPlayer.enumerateStates(stepMs): deterministic sampling helperTpsPlaybackSession: timer-driven playback controller withplay,pause,stop,seek,advanceBy,nextWord,previousWord,nextBlock,previousBlock,increaseSpeed,decreaseSpeed, andsetSpeedOffsetWpmTpsPlaybackSession.snapshot: embeddable runtime snapshot for host widgetsTpsPlaybackSession.on(eventName, listener): runtime events includingsnapshotChangedandcompletedTpsStandalonePlayer.compile(source, options): compile-and-play wrapperTpsStandalonePlayer.fromCompiledScript(script, options): start from a compiled TPS state machineTpsStandalonePlayer.fromCompiledJson(json, options): restore from serialized compiled JSON
lib/src/managedcode_tps.dart: runtime implementationlib/managedcode_tps.dart: package export surfacetest/runtime_test.dart: parity, integration, timer, and large-script coverage
This SDK is intentionally UI-neutral. Flutter widgets should bind to runtime commands and rebuild from snapshot updates.
Recommended host flow:
- Create
TpsStandalonePlayer.compile(source)when the app starts from raw.tps. - Restore
TpsStandalonePlayer.fromCompiledJson(json)when the app already has compiled TPS JSON. - Bind buttons and gestures to
play,pause,seek,nextWord,previousWord,nextBlock,previousBlock,increaseSpeed, anddecreaseSpeed. - Render from the snapshot view-model instead of recomputing active-word state in the widget tree.
cd SDK/flutter && dart pub getcd SDK/flutter && dart analyzecd SDK/flutter && dart testcd SDK/flutter && ./coverage.sh
The tests cover:
- constants and keyword catalog parity
- canonical compiled transport JSON parity
- shared example snapshots for compile, player, session, and standalone playback
- invalid TPS diagnostics
- public parse/validate API behavior for title headers, front matter, punctuation, and malformed authoring
- compiled JSON restore guards and playback session control flow
- timed playback completion
- large generated-script performance smoke
- line coverage gate at 90% or higher for SDK source
Keep this package aligned with the root README.md specification and the shared fixtures under SDK/fixtures/.