diff --git a/demo/lib/main.dart b/demo/lib/main.dart index 196b14ce..21be3074 100644 --- a/demo/lib/main.dart +++ b/demo/lib/main.dart @@ -22,10 +22,7 @@ void main() async { SuperDeckApp( options: DeckOptions( baseStyle: borderedStyle(), - widgets: { - ...demoWidgets, - 'twitter': const _TwitterWidgetDefinition(), - }, + widgets: {...demoWidgets, 'twitter': const _TwitterWidgetDefinition()}, // debug: true, styles: { 'announcement': announcementStyle(), @@ -37,6 +34,7 @@ void main() async { footer: FooterPart(), background: BackgroundPart(), ), + watchForChanges: true, ), ), ); diff --git a/packages/builder/lib/src/parsers/raw_slide_schema.g.dart b/packages/builder/lib/src/parsers/raw_slide_schema.g.dart index a3c0de4b..580f07ad 100644 --- a/packages/builder/lib/src/parsers/raw_slide_schema.g.dart +++ b/packages/builder/lib/src/parsers/raw_slide_schema.g.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // AckSchemaGenerator diff --git a/packages/superdeck/lib/src/deck/deck_controller_builder.dart b/packages/superdeck/lib/src/deck/deck_controller_builder.dart index 228aba9e..65492fa4 100644 --- a/packages/superdeck/lib/src/deck/deck_controller_builder.dart +++ b/packages/superdeck/lib/src/deck/deck_controller_builder.dart @@ -47,8 +47,8 @@ class _DeckControllerBuilderState extends State { options: widget.options, ); - // Start CLI watcher in debug mode for auto-rebuild - if (kCanRunProcess) { + // Start CLI watcher in debug mode for auto-rebuild (if enabled) + if (kCanRunProcess && widget.options.watchForChanges) { try { _cliWatcher = CliWatcher( projectRoot: Directory.current, @@ -65,6 +65,8 @@ class _DeckControllerBuilderState extends State { } catch (e) { _logger.warning('CLI watcher failed to start: $e'); } + } else if (!widget.options.watchForChanges) { + _logger.info('CLI watcher disabled via DeckOptions.watchForChanges'); } } diff --git a/packages/superdeck/lib/src/deck/deck_options.dart b/packages/superdeck/lib/src/deck/deck_options.dart index 878a0274..805dae6f 100644 --- a/packages/superdeck/lib/src/deck/deck_options.dart +++ b/packages/superdeck/lib/src/deck/deck_options.dart @@ -9,12 +9,20 @@ class DeckOptions { final SlideParts parts; final bool debug; + /// Whether to watch for file changes and auto-rebuild the deck. + /// + /// When `true` (default), starts a CLI watcher process that monitors + /// the slides file and rebuilds automatically on changes. + /// Set to `false` to disable file watching. + final bool watchForChanges; + const DeckOptions({ this.baseStyle, this.styles = const {}, this.widgets = const {}, this.parts = const SlideParts(), this.debug = false, + this.watchForChanges = false, }); DeckOptions copyWith({ @@ -23,6 +31,7 @@ class DeckOptions { Map? widgets, SlideParts? parts, bool? debug, + bool? watchForChanges, }) { return DeckOptions( baseStyle: baseStyle ?? this.baseStyle, @@ -30,6 +39,7 @@ class DeckOptions { widgets: widgets ?? this.widgets, parts: parts ?? this.parts, debug: debug ?? this.debug, + watchForChanges: watchForChanges ?? this.watchForChanges, ); } @@ -42,8 +52,10 @@ class DeckOptions { styles == other.styles && widgets == other.widgets && parts == other.parts && - debug == other.debug; + debug == other.debug && + watchForChanges == other.watchForChanges; @override - int get hashCode => Object.hash(baseStyle, styles, widgets, parts, debug); + int get hashCode => + Object.hash(baseStyle, styles, widgets, parts, debug, watchForChanges); } diff --git a/packages/superdeck/test/styling/schema/style_schemas_test.dart b/packages/superdeck/test/styling/schema/style_schemas_test.dart index 3fb68b92..afb0600d 100644 --- a/packages/superdeck/test/styling/schema/style_schemas_test.dart +++ b/packages/superdeck/test/styling/schema/style_schemas_test.dart @@ -1359,12 +1359,11 @@ void main() { group('Edge Cases', () { test('handles null values gracefully', () { - final result = StyleSchemas.styleConfigSchema.safeParse({ + // Schema should handle nulls gracefully without throwing + StyleSchemas.styleConfigSchema.safeParse({ 'base': null, 'styles': null, }); - // Depending on schema, this might pass or fail - // The schema should handle nulls gracefully }); test('handles very large font sizes', () { @@ -1566,7 +1565,7 @@ void main() { final result = StyleSchemas.colorSchema.safeParse('#ABCDEF'); final color = result.getOrThrow()!; expect(color.a, 1.0); // Full alpha - expect((color.value & 0x00FFFFFF), 0xABCDEF); + expect((color.toARGB32() & 0x00FFFFFF), 0xABCDEF); }); test('colorSchema transforms 8-digit hex correctly', () {