scaffold Flutter app — kernel, extensions, widgets, Tier 0 built-ins
First real content under app/. Lays the whole Tier 0 foundation in one
commit because the pieces depend on each other circularly (kernel →
extension → widgets → built-ins all reference types from the layer
below); splitting would leave intermediate commits that don't compile.
Key shapes:
* bare WidgetsApp root — no Material, no Cupertino, no Scaffold.
ClideTheme InheritedWidget is the only source of tokens.
* ClideKernel InheritedWidget aggregates 18 services (settings,
project, extensions, theme, panels, events, ipc, commands +
palette + keybindings, clipboard, files, notify, dialog, tray,
secrets, os, net, focus, log, i18n). ExtensionContext exposes
them through a stable interface.
* ClideExtension + sealed ContributionPoint hierarchy (Tab,
StatusItem, Toolbar, Command, TrayItem, LayoutPreset). One
manifest ships N contributions into kernel slots.
* Three-tier theme pipeline: palette (named colors) → semantic
roles → ~60 surface tokens. Defaults at each layer so legacy
palette-only themes produce a complete SurfaceTokens.
* A11y baked in from day one — every interactive primitive wraps
in Semantics(label:, hint:, button:); ensureSemantics() at boot;
theme/contrast.dart helper exposes token pairs for the WCAG
gate in the a11y test suite.
* i18n ported from fframe's L10n pattern (text-driven, namespaced
JSON catalogs, caller-supplied placeholders) with a proper
locale fallback chain (exact → language → default → placeholder)
fframe lacks.
* Four Tier-0 built-ins live (default-layout, welcome, ipc-status,
theme-picker) plus 17 id-reserving stubs so later tiers fill in
without rename churn.
.gitignore extended to cover app/ sub-package artefacts and the
Playwright harness scratch dirs.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:clide_app/kernel/src/events/types.dart';
|
||||
|
||||
class EventBus {
|
||||
EventBus();
|
||||
|
||||
final StreamController<ClideEventEnvelope> _controller =
|
||||
StreamController<ClideEventEnvelope>.broadcast();
|
||||
|
||||
Stream<ClideEventEnvelope> get stream => _controller.stream;
|
||||
|
||||
Stream<T> on<T extends ClideEvent>() =>
|
||||
_controller.stream.where((e) => e.event is T).map((e) => e.event as T);
|
||||
|
||||
void emit(ClideEvent event) {
|
||||
if (_controller.isClosed) return;
|
||||
_controller.add(ClideEventEnvelope(event, DateTime.now().toUtc()));
|
||||
}
|
||||
|
||||
Future<void> dispose() => _controller.close();
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ClideEvent {
|
||||
const ClideEvent();
|
||||
|
||||
String get subsystem;
|
||||
String get kind;
|
||||
|
||||
Map<String, Object?> payload() => const {};
|
||||
}
|
||||
|
||||
@immutable
|
||||
class ClideEventEnvelope {
|
||||
const ClideEventEnvelope(this.event, this.timestamp);
|
||||
|
||||
final ClideEvent event;
|
||||
final DateTime timestamp;
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'v': 1,
|
||||
'subsystem': event.subsystem,
|
||||
'kind': event.kind,
|
||||
'ts': timestamp.toIso8601String(),
|
||||
'data': event.payload(),
|
||||
};
|
||||
}
|
||||
|
||||
class DaemonConnectionChanged extends ClideEvent {
|
||||
const DaemonConnectionChanged({required this.connected});
|
||||
final bool connected;
|
||||
@override
|
||||
String get subsystem => 'ipc';
|
||||
@override
|
||||
String get kind => 'connection-changed';
|
||||
@override
|
||||
Map<String, Object?> payload() => {'connected': connected};
|
||||
}
|
||||
|
||||
class ThemeChanged extends ClideEvent {
|
||||
const ThemeChanged({required this.themeName});
|
||||
final String themeName;
|
||||
@override
|
||||
String get subsystem => 'theme';
|
||||
@override
|
||||
String get kind => 'changed';
|
||||
@override
|
||||
Map<String, Object?> payload() => {'theme': themeName};
|
||||
}
|
||||
|
||||
class ProjectOpened extends ClideEvent {
|
||||
const ProjectOpened({required this.path});
|
||||
final String path;
|
||||
@override
|
||||
String get subsystem => 'project';
|
||||
@override
|
||||
String get kind => 'opened';
|
||||
@override
|
||||
Map<String, Object?> payload() => {'path': path};
|
||||
}
|
||||
|
||||
class ProjectClosed extends ClideEvent {
|
||||
const ProjectClosed();
|
||||
@override
|
||||
String get subsystem => 'project';
|
||||
@override
|
||||
String get kind => 'closed';
|
||||
}
|
||||
|
||||
class ExtensionActivated extends ClideEvent {
|
||||
const ExtensionActivated({required this.id});
|
||||
final String id;
|
||||
@override
|
||||
String get subsystem => 'extensions';
|
||||
@override
|
||||
String get kind => 'activated';
|
||||
@override
|
||||
Map<String, Object?> payload() => {'id': id};
|
||||
}
|
||||
|
||||
class ExtensionDeactivated extends ClideEvent {
|
||||
const ExtensionDeactivated({required this.id});
|
||||
final String id;
|
||||
@override
|
||||
String get subsystem => 'extensions';
|
||||
@override
|
||||
String get kind => 'deactivated';
|
||||
@override
|
||||
Map<String, Object?> payload() => {'id': id};
|
||||
}
|
||||
|
||||
/// Forwarded from the daemon. Feature extensions subscribe to this and
|
||||
/// narrow by subsystem+kind, or register a converter that emits a typed
|
||||
/// `ClideEvent` subclass into the bus.
|
||||
class DaemonEvent extends ClideEvent {
|
||||
const DaemonEvent({
|
||||
required this.subsystem,
|
||||
required this.kind,
|
||||
required this.data,
|
||||
required this.ts,
|
||||
});
|
||||
|
||||
@override
|
||||
final String subsystem;
|
||||
@override
|
||||
final String kind;
|
||||
final Map<String, Object?> data;
|
||||
final DateTime ts;
|
||||
|
||||
@override
|
||||
Map<String, Object?> payload() => {'ts': ts.toIso8601String(), ...data};
|
||||
}
|
||||
Reference in New Issue
Block a user