feat: multi-package loading with base framework support

- Add RuntimeOptions.basePackages for loading framework packages before game package
- Add ScriptEngine.loadPackages() for multi-package module merging
- LuaDardoScriptEngine merges modules from all packages, game overrides framework
- PackageActivationController loads base packages first, then game package
- GamePackageManifest parses optional 'base' field
- Update docs: README, quick-start, lua-package-format, architecture
- Update all test mocks with loadPackages() implementation
This commit is contained in:
gem
2026-06-10 00:04:00 +08:00
parent 0d4fbd030c
commit 8ddc3be3a7
13 changed files with 255 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ It is designed for Flutter apps that want to host Lua-authored 2D games or inter
- Runtime commands for movement, fading, scaling, rotation, sequencing, audio, resources, toast, clipboard, and Spine animation.
- Shared Lua helper modules under `assets/runtime/lua/`.
- Configurable Runtime Lua asset root via `RuntimeOptions.runtimeLuaRoot`.
- Multi-package loading: shared framework packages loaded once, game packages loaded on top.
## Example
@@ -59,6 +60,18 @@ LuaGameWidget(
)
```
With a shared framework package:
```dart
LuaGameWidget(
gameId: 'ludo',
runtimeOptions: const RuntimeOptions(
runtimeLuaRoot: 'packages/flame_lua_runtime/assets/runtime/lua',
basePackages: ['_framework'],
),
)
```
Your app should provide game package assets such as:
```text
@@ -105,7 +118,7 @@ For AI agents and maintainers, start with:
- [`AGENTS.md`](AGENTS.md) — package boundaries, rules, public API, and validation commands.
- [`docs/quick-start.md`](docs/quick-start.md) — host app integration.
- [`docs/architecture.md`](docs/architecture.md) — Dart/Lua/Flame responsibilities.
- [`docs/lua-package-format.md`](docs/lua-package-format.md) — manifest and Lua package rules.
- [`docs/lua-package-format.md`](docs/lua-package-format.md) — manifest, Lua package rules, and multi-package loading.
- [`docs/protocol.md`](docs/protocol.md) — RuntimeEvent, GameDiff, RuntimeNode, RuntimeCommand boundary.
- [`docs/validation.md`](docs/validation.md) — checks, smoke tests, and release flow.