refactor: Rename package from SwiftTUI to TUIKit

BREAKING CHANGE: Package name changed due to name collision with
existing rensbreur/SwiftTUI package.

Changes:
- Rename package from SwiftTUI to TUIKit in Package.swift
- Rename Sources/SwiftTUI to Sources/TUIKit
- Rename Sources/SwiftTUIExample to Sources/TUIKitExample
- Rename Tests/SwiftTUITests to Tests/TUIKitTests
- Rename SwiftTUI.swift to TUIKit.swift
- Update all imports: import SwiftTUI -> import TUIKit
- Update all code references: SwiftTUI.renderToBuffer -> TUIKit.renderToBuffer
- Update documentation comments
- Rename swiftTUIVersion to tuiKitVersion

All 181 tests passing.
This commit is contained in:
phranck
2026-01-28 19:32:09 +01:00
parent 44d9d4490e
commit 45e73faafb
65 changed files with 140 additions and 140 deletions
+10 -10
View File
@@ -4,7 +4,7 @@
import PackageDescription
let package = Package(
name: "SwiftTUI",
name: "TUIKit",
// Minimum deployment targets for Apple platforms
// Linux is automatically supported (no platform specification needed)
platforms: [
@@ -12,25 +12,25 @@ let package = Package(
],
products: [
.library(
name: "SwiftTUI",
targets: ["SwiftTUI"]
name: "TUIKit",
targets: ["TUIKit"]
),
.executable(
name: "SwiftTUIExample",
targets: ["SwiftTUIExample"]
name: "TUIKitExample",
targets: ["TUIKitExample"]
),
],
targets: [
.target(
name: "SwiftTUI"
name: "TUIKit"
),
.executableTarget(
name: "SwiftTUIExample",
dependencies: ["SwiftTUI"]
name: "TUIKitExample",
dependencies: ["TUIKit"]
),
.testTarget(
name: "SwiftTUITests",
dependencies: ["SwiftTUI"]
name: "TUIKitTests",
dependencies: ["TUIKit"]
),
]
)
@@ -1,17 +1,17 @@
//
// App.swift
// SwiftTUI
// TUIKit
//
// The base protocol for SwiftTUI applications.
// The base protocol for TUIKit applications.
//
import Foundation
// MARK: - App Protocol
/// The base protocol for SwiftTUI applications.
/// The base protocol for TUIKit applications.
///
/// `App` is the entry point for every SwiftTUI application,
/// `App` is the entry point for every TUIKit application,
/// similar to `App` in SwiftUI.
///
/// # Example
@@ -1,11 +1,11 @@
//
// Scene.swift
// SwiftTUI
// TUIKit
//
// Scene types for SwiftTUI applications.
// Scene types for TUIKit applications.
//
/// The base protocol for scenes in SwiftTUI.
/// The base protocol for scenes in TUIKit.
///
/// A scene represents a part of the app structure,
/// typically a window or a group of views.
@@ -1,6 +1,6 @@
//
// AppStorage.swift
// SwiftTUI
// TUIKit
//
// Persistent storage for app settings using @AppStorage property wrapper.
//
@@ -28,7 +28,7 @@ public protocol StorageBackend: Sendable {
/// A storage backend that persists data to a JSON file.
///
/// This is the default storage backend for SwiftTUI apps.
/// This is the default storage backend for TUIKit apps.
/// Data is stored in `~/.config/[appName]/settings.json`.
public final class JSONFileStorage: StorageBackend, @unchecked Sendable {
/// The shared instance.
@@ -1,6 +1,6 @@
//
// BorderStyle.swift
// SwiftTUI
// TUIKit
//
// Border styles and character sets for TUI borders.
//
@@ -1,11 +1,11 @@
//
// Color.swift
// SwiftTUI
// TUIKit
//
// Color definitions for terminal output with ANSI escape codes.
//
/// A color for use in SwiftTUI views.
/// A color for use in TUIKit views.
///
/// `Color` represents standard ANSI colors as well as
/// extended 256-color palette and True Color (24-bit RGB).
@@ -1,6 +1,6 @@
//
// Environment.swift
// SwiftTUI
// TUIKit
//
// Environment system for passing values down the view hierarchy.
// Similar to SwiftUI's @Environment property wrapper.
@@ -1,6 +1,6 @@
//
// Focus.swift
// SwiftTUI
// TUIKit
//
// Focus management system for interactive views.
//
@@ -1,8 +1,8 @@
//
// KeyEvent.swift
// SwiftTUI
// TUIKit
//
// Keyboard event handling for SwiftTUI.
// Keyboard event handling for TUIKit.
//
import Foundation
@@ -1,6 +1,6 @@
//
// Preferences.swift
// SwiftTUI
// TUIKit
//
// Preferences system for bottom-up data flow (child parent).
// Similar to SwiftUI's PreferenceKey system.
@@ -205,7 +205,7 @@ extension PreferenceModifier: Renderable {
PreferenceStorage.shared.setValue(value, forKey: K.self)
// Render content
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
@@ -234,7 +234,7 @@ extension OnPreferenceChangeModifier: Renderable {
PreferenceStorage.shared.push()
// Render content
let buffer = SwiftTUI.renderToBuffer(content, context: context)
let buffer = TUIKit.renderToBuffer(content, context: context)
// Pop and get collected preferences
let preferences = PreferenceStorage.shared.pop()
@@ -1,6 +1,6 @@
//
// PrimitiveViews.swift
// SwiftTUI
// TUIKit
//
// Primitive view types that serve as leaves in the view tree.
//
@@ -1,8 +1,8 @@
//
// State.swift
// SwiftTUI
// TUIKit
//
// State management for SwiftTUI views.
// State management for TUIKit views.
//
import Foundation
@@ -11,7 +11,7 @@ import Foundation
/// Global application state that triggers re-renders when modified.
///
/// Since SwiftTUI runs in a single-threaded event loop, we use a simple
/// Since TUIKit runs in a single-threaded event loop, we use a simple
/// observable pattern. The AppRunner subscribes to state changes and
/// re-renders when notified.
public final class AppState: @unchecked Sendable {
@@ -1,6 +1,6 @@
//
// Theme.swift
// SwiftTUI
// TUIKit
//
// Theming system with full 16M color support and predefined terminal themes.
//
@@ -9,10 +9,10 @@ import Foundation
// MARK: - Theme Protocol
/// A theme defines the color palette for a SwiftTUI application.
/// A theme defines the color palette for a TUIKit application.
///
/// Themes provide semantic colors that views use for consistent styling.
/// SwiftTUI includes several predefined themes inspired by classic terminals.
/// TUIKit includes several predefined themes inspired by classic terminals.
///
/// # Usage
///
@@ -1,6 +1,6 @@
//
// TupleViews.swift
// SwiftTUI
// TUIKit
//
// Container types for multiple views in ViewBuilder.
//
@@ -1,6 +1,6 @@
//
// UserDefaultsStorage.swift
// SwiftTUI
// TUIKit
//
// UserDefaults-compatible storage backend for all platforms.
//
@@ -1,13 +1,13 @@
//
// View.swift
// SwiftTUI
// TUIKit
//
// The base protocol for all SwiftTUI views.
// The base protocol for all TUIKit views.
//
/// The base protocol for all SwiftTUI views.
/// The base protocol for all TUIKit views.
///
/// `View` is the central protocol in SwiftTUI and works similarly to `View` in SwiftUI.
/// `View` is the central protocol in TUIKit and works similarly to `View` in SwiftUI.
/// It defines how components declare their structure and content.
///
/// Every View defines a `body` composed of other Views.
@@ -18,7 +18,7 @@
/// ```swift
/// struct MyView: View {
/// var body: some View {
/// Text("Hello, SwiftTUI!")
/// Text("Hello, TUIKit!")
/// }
/// }
/// ```
@@ -1,6 +1,6 @@
//
// ViewBuilder.swift
// SwiftTUI
// TUIKit
//
// Result builder for declarative view composition.
//
@@ -1,6 +1,6 @@
//
// ViewModifier.swift
// SwiftTUI
// TUIKit
//
// The view modifier system for transforming views.
//
@@ -53,7 +53,7 @@ public struct ModifiedView<Content: View, Modifier: ViewModifier>: View {
extension ModifiedView: Renderable {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
let childBuffer = SwiftTUI.renderToBuffer(content, context: context)
let childBuffer = TUIKit.renderToBuffer(content, context: context)
return modifier.modify(buffer: childBuffer, context: context)
}
}
@@ -1,6 +1,6 @@
//
// BackgroundModifier.swift
// SwiftTUI
// TUIKit
//
// The .background() modifier for adding background colors to views.
//
@@ -1,6 +1,6 @@
//
// BorderModifier.swift
// SwiftTUI
// TUIKit
//
// The .border() modifier for adding borders around views.
//
@@ -33,7 +33,7 @@ extension BorderedView: Renderable {
contentContext.availableWidth = max(1, context.availableWidth - 2)
// Render content with reduced width
let buffer = SwiftTUI.renderToBuffer(content, context: contentContext)
let buffer = TUIKit.renderToBuffer(content, context: contentContext)
guard !buffer.isEmpty else { return buffer }
@@ -1,6 +1,6 @@
//
// DimmedModifier.swift
// SwiftTUI
// TUIKit
//
// A modifier that applies a dimming effect to the entire view content.
//
@@ -22,7 +22,7 @@ public struct DimmedModifier<Content: View>: View {
extension DimmedModifier: Renderable {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
let contentBuffer = SwiftTUI.renderToBuffer(content, context: context)
let contentBuffer = TUIKit.renderToBuffer(content, context: context)
guard !contentBuffer.isEmpty else {
return contentBuffer
@@ -1,6 +1,6 @@
//
// FrameModifier.swift
// SwiftTUI
// TUIKit
//
// The .frame() modifier for setting explicit size constraints.
//
@@ -81,7 +81,7 @@ extension FlexibleFrameView: Renderable {
}
// Render content
let buffer = SwiftTUI.renderToBuffer(content, context: contentContext)
let buffer = TUIKit.renderToBuffer(content, context: contentContext)
// Apply minimum constraints
var finalWidth = buffer.width
@@ -1,6 +1,6 @@
//
// KeyPressModifier.swift
// SwiftTUI
// TUIKit
//
// A modifier for handling keyboard events.
//
@@ -43,7 +43,7 @@ extension KeyPressModifier: Renderable {
}
// Render the content
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
@@ -1,6 +1,6 @@
//
// LifecycleModifier.swift
// SwiftTUI
// TUIKit
//
// Lifecycle modifiers: .onAppear(), .onDisappear(), .task()
//
@@ -101,7 +101,7 @@ extension OnAppearModifier: Renderable {
_ = LifecycleTracker.shared.recordAppear(token: token, action: action)
// Render content
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
@@ -157,7 +157,7 @@ extension OnDisappearModifier: Renderable {
_ = LifecycleTracker.shared.recordAppear(token: token, action: {})
// Render content
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
@@ -234,7 +234,7 @@ extension TaskModifier: Renderable {
}
// Render content
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
@@ -1,6 +1,6 @@
//
// OverlayModifier.swift
// SwiftTUI
// TUIKit
//
// A modifier that renders an overlay on top of the base view.
//
@@ -30,8 +30,8 @@ public struct OverlayModifier<Base: View, Overlay: View>: View {
extension OverlayModifier: Renderable {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
// Render both contents
let baseBuffer = SwiftTUI.renderToBuffer(base, context: context)
let overlayBuffer = SwiftTUI.renderToBuffer(overlay, context: context)
let baseBuffer = TUIKit.renderToBuffer(base, context: context)
let overlayBuffer = TUIKit.renderToBuffer(overlay, context: context)
guard !baseBuffer.isEmpty else {
return overlayBuffer
@@ -1,6 +1,6 @@
//
// PaddingModifier.swift
// SwiftTUI
// TUIKit
//
// The .padding() modifier for adding space around a view.
//
@@ -1,6 +1,6 @@
//
// StatusBarItemsModifier.swift
// SwiftTUI
// TUIKit
//
// A modifier that sets status bar items for a view.
//
@@ -64,7 +64,7 @@ extension StatusBarItemsModifier: Renderable {
}
// Render the content
return SwiftTUI.renderToBuffer(content, context: renderContext)
return TUIKit.renderToBuffer(content, context: renderContext)
}
}
@@ -1,6 +1,6 @@
//
// ANSIRenderer.swift
// SwiftTUI
// TUIKit
//
// ANSI escape code generation for terminal output.
//
@@ -1,6 +1,6 @@
//
// FrameBuffer.swift
// SwiftTUI
// TUIKit
//
// A 2D text buffer for off-screen rendering before terminal output.
//
@@ -1,6 +1,6 @@
//
// Renderable.swift
// SwiftTUI
// TUIKit
//
// Protocol for views that can render themselves directly.
//
@@ -1,6 +1,6 @@
//
// Terminal.swift
// SwiftTUI
// TUIKit
//
// Terminal abstraction for input and output.
//
@@ -1,6 +1,6 @@
//
// ViewRenderer.swift
// SwiftTUI
// TUIKit
//
// Renders Views to terminal output via FrameBuffer.
//
@@ -351,9 +351,9 @@ extension ConditionalView: Renderable {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
switch self {
case .trueContent(let content):
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
case .falseContent(let content):
return SwiftTUI.renderToBuffer(content, context: context)
return TUIKit.renderToBuffer(content, context: context)
}
}
}
@@ -376,7 +376,7 @@ extension Optional: Renderable where Wrapped: View {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
switch self {
case .some(let view):
return SwiftTUI.renderToBuffer(view, context: context)
return TUIKit.renderToBuffer(view, context: context)
case .none:
return FrameBuffer()
}
@@ -1,15 +1,15 @@
//
// SwiftTUI.swift
// SwiftTUI
// TUIKit.swift
// TUIKit
//
// A SwiftUI-like framework for Terminal User Interfaces.
//
// SwiftTUI enables creating TUI applications with a declarative,
// TUIKit enables creating TUI applications with a declarative,
// SwiftUI-like syntax - without ncurses or other low-level libraries.
//
/// The current version of SwiftTUI.
public let swiftTUIVersion = "0.1.0"
/// The current version of TUIKit.
public let tuiKitVersion = "0.1.0"
/// Executes a view closure and renders it once.
///
@@ -20,11 +20,11 @@ public let swiftTUIVersion = "0.1.0"
/// ```swift
/// renderOnce {
/// VStack {
/// Text("Hello, SwiftTUI!")
/// Text("Hello, TUIKit!")
/// .bold()
/// .foregroundColor(.cyan)
/// Divider()
/// Text("Version \(swiftTUIVersion)")
/// Text("Version \(tuiKitVersion)")
/// .dim()
/// }
/// }
@@ -1,6 +1,6 @@
//
// Alert.swift
// SwiftTUI
// TUIKit
//
// A modal alert view with title, message, and optional actions.
//
@@ -1,6 +1,6 @@
//
// Box.swift
// SwiftTUI
// TUIKit
//
// A simple bordered container view.
//
@@ -1,6 +1,6 @@
//
// Button.swift
// SwiftTUI
// TUIKit
//
// An interactive button view that responds to keyboard input.
//
@@ -411,7 +411,7 @@ extension ButtonRow: Renderable {
// Render each button
var buttonBuffers: [FrameBuffer] = []
for button in buttons {
let buffer = SwiftTUI.renderToBuffer(button, context: context)
let buffer = TUIKit.renderToBuffer(button, context: context)
buttonBuffers.append(buffer)
}
@@ -1,6 +1,6 @@
//
// Card.swift
// SwiftTUI
// TUIKit
//
// A styled container view with border, background, and padding.
//
@@ -1,6 +1,6 @@
//
// Dialog.swift
// SwiftTUI
// TUIKit
//
// A modal dialog view with title and custom content.
//
@@ -1,6 +1,6 @@
//
// ForEach.swift
// SwiftTUI
// TUIKit
//
// Iteration over data collections for view generation.
//
@@ -1,6 +1,6 @@
//
// Menu.swift
// SwiftTUI
// TUIKit
//
// A menu view that displays a list of selectable items.
//
@@ -353,7 +353,7 @@ public struct AnyView: View {
/// Creates an AnyView wrapping the given view.
public init<V: View>(_ view: V) {
self._render = { context in
SwiftTUI.renderToBuffer(view, context: context)
TUIKit.renderToBuffer(view, context: context)
}
}
@@ -1,6 +1,6 @@
//
// Panel.swift
// SwiftTUI
// TUIKit
//
// A titled container view with a header.
//
@@ -78,7 +78,7 @@ extension Panel: Renderable {
public func renderToBuffer(context: RenderContext) -> FrameBuffer {
// Render the content first
let paddedContent = content.padding(padding)
let contentBuffer = SwiftTUI.renderToBuffer(paddedContent, context: context)
let contentBuffer = TUIKit.renderToBuffer(paddedContent, context: context)
guard !contentBuffer.isEmpty else {
return FrameBuffer()
@@ -1,6 +1,6 @@
//
// Spacer.swift
// SwiftTUI
// TUIKit
//
// Flexible spacing elements for layout.
//
@@ -1,6 +1,6 @@
//
// Stacks.swift
// SwiftTUI
// TUIKit
//
// Layout containers for vertical and horizontal arrangement.
//
@@ -1,6 +1,6 @@
//
// StatusBar.swift
// SwiftTUI
// TUIKit
//
// A status bar that displays keyboard shortcuts and context-sensitive actions.
// Always rendered at the bottom of the terminal, never dimmed by overlays.
@@ -1,13 +1,13 @@
//
// Text.swift
// SwiftTUI
// TUIKit
//
// A view for displaying text in the terminal.
//
/// A view that displays text in the terminal.
///
/// `Text` is one of the most fundamental views in SwiftTUI. It displays
/// `Text` is one of the most fundamental views in TUIKit. It displays
/// a string in the terminal and supports various formatting options.
///
/// # Example
@@ -1,11 +1,11 @@
//
// AppState.swift
// SwiftTUIExample
// TUIKitExample
//
// Global state management for the example app.
//
import SwiftTUI
import TUIKit
// MARK: - Demo Page Enum
@@ -1,11 +1,11 @@
//
// DemoSection.swift
// SwiftTUIExample
// TUIKitExample
//
// A reusable section component for organizing demo content.
//
import SwiftTUI
import TUIKit
/// A section with a styled title and content.
///
@@ -1,11 +1,11 @@
//
// HeaderView.swift
// SwiftTUIExample
// TUIKitExample
//
// A reusable header component for demo pages.
//
import SwiftTUI
import TUIKit
/// A styled header with title on the left and version on the right.
///
@@ -36,7 +36,7 @@ struct HeaderView: View {
.bold()
.foregroundColor(.cyan)
Spacer()
Text("SwiftTUI v\(swiftTUIVersion)")
Text("TUIKit v\(tuiKitVersion)")
.dim()
}
if let sub = subtitle {
@@ -1,11 +1,11 @@
//
// ContentView.swift
// SwiftTUIExample
// TUIKitExample
//
// The main content view that routes between demo pages.
//
import SwiftTUI
import TUIKit
// MARK: - Content View (Page Router)
@@ -1,11 +1,11 @@
//
// ButtonsPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates button and focus system capabilities.
//
import SwiftTUI
import TUIKit
/// Buttons and focus demo page.
///
@@ -1,11 +1,11 @@
//
// ColorsPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates color capabilities.
//
import SwiftTUI
import TUIKit
/// Colors demo page.
///
@@ -1,11 +1,11 @@
//
// ContainersPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates container view capabilities.
//
import SwiftTUI
import TUIKit
/// Container views demo page.
///
@@ -1,11 +1,11 @@
//
// LayoutPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates layout system capabilities.
//
import SwiftTUI
import TUIKit
/// Layout system demo page.
///
@@ -1,11 +1,11 @@
//
// MainMenuPage.swift
// SwiftTUIExample
// TUIKitExample
//
// The main menu page with navigation to all demos.
//
import SwiftTUI
import TUIKit
/// The main menu page.
///
@@ -17,7 +17,7 @@ struct MainMenuPage: View {
VStack(spacing: 1) {
HeaderView(
title: "SwiftTUI Example App",
title: "TUIKit Example App",
subtitle: "A SwiftUI-like framework for Terminal User Interfaces"
)
@@ -1,11 +1,11 @@
//
// OverlaysPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates overlay and modal capabilities.
//
import SwiftTUI
import TUIKit
/// Overlays and modals demo page.
///
@@ -1,11 +1,11 @@
//
// TextStylesPage.swift
// SwiftTUIExample
// TUIKitExample
//
// Demonstrates text styling capabilities.
//
import SwiftTUI
import TUIKit
/// Text styles demo page.
///
@@ -1,14 +1,14 @@
//
// main.swift
// SwiftTUIExample
// TUIKitExample
//
// Entry point for the SwiftTUI example application.
// Entry point for the TUIKit example application.
//
// This app demonstrates SwiftTUI capabilities through various demo pages.
// This app demonstrates TUIKit capabilities through various demo pages.
// Use the menu to navigate between demos.
//
import SwiftTUI
import TUIKit
// MARK: - Main App
@@ -1,12 +1,12 @@
//
// ButtonTests.swift
// SwiftTUI
// TUIKit
//
// Tests for Button, ButtonStyle, and ButtonRow views.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
// MARK: - Test Helpers
@@ -1,12 +1,12 @@
//
// ColorTests.swift
// SwiftTUI
// TUIKit
//
// Tests for the Color system and ANSI rendering.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
@Suite("Color Tests")
struct ColorTests {
@@ -1,12 +1,12 @@
//
// ContainerViewTests.swift
// SwiftTUI
// TUIKit
//
// Tests for container views: Alert, Dialog, Menu.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
@Suite("Alert Tests")
struct AlertTests {
@@ -1,13 +1,13 @@
//
// FocusTests.swift
// SwiftTUI
// TUIKit
//
// Tests for the focus management system.
//
import Foundation
import Testing
@testable import SwiftTUI
@testable import TUIKit
// MARK: - Mock Focusable
@@ -1,12 +1,12 @@
//
// FrameBufferTests.swift
// SwiftTUI
// TUIKit
//
// Tests for FrameBuffer operations and compositing.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
@Suite("FrameBuffer Tests")
struct FrameBufferTests {
@@ -1,12 +1,12 @@
//
// RenderingTests.swift
// SwiftTUI
// TUIKit
//
// Tests for view rendering and layout.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
@Suite("Rendering Tests")
struct RenderingTests {
@@ -1,12 +1,12 @@
//
// StatusBarTests.swift
// SwiftTUI
// TUIKit
//
// Tests for Shortcut constants, StatusBarItem, StatusBarManager, and StatusBar.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
// MARK: - Shortcut Constants Tests
@@ -1,12 +1,12 @@
//
// ViewTests.swift
// SwiftTUI
// TUIKit
//
// Tests for the View protocol, ViewBuilder, and basic views.
//
import Testing
@testable import SwiftTUI
@testable import TUIKit
@Suite("View Protocol Tests")
struct ViewTests {