import 'source.dart'; /// Compile-time source gate: `--dart-define=SOURCES=comicland,mangaread,mangatown` /// or `--dart-define=SOURCES=all`. /// /// Unset / invalid → ComicLand only. Default is **not** all sources. const String kSourcesDefine = String.fromEnvironment( 'SOURCES', defaultValue: 'comicland', ); /// Parses [raw] into enabled [SourceId]s. /// /// - Token `all` (case-insensitive) enables every [SourceId]. /// - Unknown tokens ignored. /// - Empty result falls back to `{SourceId.comicland}`. Set parseEnabledSourceIds([String raw = kSourcesDefine]) { final parts = raw.split(',').map((p) => p.trim().toLowerCase()).where( (p) => p.isNotEmpty, ); for (final part in parts) { if (part == 'all') { return SourceId.values.toSet(); } } final out = {}; for (final part in parts) { final id = SourceId.tryParse(part); if (id != null) out.add(id); } if (out.isEmpty) { return {SourceId.comicland}; } return out; } Set enabledSourceIds() => parseEnabledSourceIds();