mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
d0627bafdc
- Extract View system foundation into new TUIkitView module (Layer 1) - View, ViewBuilder, TupleViews, ViewModifier, PrimitiveViews, EquatableView - Renderable, RenderContext, RenderCache, ChildInfo, SpacerProtocol - State, StateStorage, StateRegistration, HydrationContext - EnvironmentValues, EnvironmentModifier, ViewServiceEnvironment - Introduce SpacerProtocol to decouple ChildInfo from concrete Spacer type - Split ServiceEnvironment.swift (StateStorageKey/RenderCacheKey to TUIkitView) - Add @_exported import TUIkitView in Exports.swift for backward compatibility - Make internal types public for cross-module visibility (Renderable, Layoutable, renderToBuffer, ChildView, ChildInfo, ModifiedView, StateStorage, RenderCache) - Organize TUIkitCore into Rendering/, Environment/, Input/, Extensions/, Concurrency/ - Organize TUIkitStyling into Color/, Theme/, Styles/
39 lines
1016 B
Swift
39 lines
1016 B
Swift
// 🖥️ TUIKit — Terminal UI Kit for Swift
|
||
// ViewServiceEnvironment.swift
|
||
//
|
||
// Created by LAYERED.work
|
||
// License: MIT
|
||
|
||
import TUIkitCore
|
||
|
||
// MARK: - State Storage
|
||
|
||
/// EnvironmentKey for the persistent `@State` value storage.
|
||
private struct StateStorageKey: EnvironmentKey {
|
||
static let defaultValue: StateStorage? = nil
|
||
}
|
||
|
||
// MARK: - Render Cache
|
||
|
||
/// EnvironmentKey for memoized subtree rendering results.
|
||
private struct RenderCacheKey: EnvironmentKey {
|
||
static let defaultValue: RenderCache? = nil
|
||
}
|
||
|
||
// MARK: - EnvironmentValues Extensions
|
||
|
||
extension EnvironmentValues {
|
||
|
||
/// The persistent `@State` value storage indexed by `ViewIdentity`.
|
||
public var stateStorage: StateStorage? {
|
||
get { self[StateStorageKey.self] }
|
||
set { self[StateStorageKey.self] = newValue }
|
||
}
|
||
|
||
/// Cache for memoized subtree rendering results.
|
||
public var renderCache: RenderCache? {
|
||
get { self[RenderCacheKey.self] }
|
||
set { self[RenderCacheKey.self] = newValue }
|
||
}
|
||
}
|