Cotton code
82 lines · 3.6 KB · SwiftRaw
// Which physical object each tool in Home's directory is drawn as.//// The picture (05-home) draws the directory as the objects that did each job —// a clipboard for todos, a tear-off calendar, a rolodex for people — four// across on the plaster. Each object is ONE cut-out picture in `Media.xcassets`// (`tool-<name>.imageset`, written by `scripts/gen-tools/export_tool_objects.py`// from a generated sheet cut by `cut_sheet.py`); the tool's name and its figure// are set live under it, never baked in.//// The app ships no tool (owner's ruling, 21 Oct 2026: tools are records// only): a tool is a package record whose definition names its picture, and// these are the objects such a picture may name (architect, 14 Oct 2026:// generate every picture a design needs, never a placeholder). Every object// named here is an imageset on disk.//// Nothing in the table is keyed by position: a tool's order is its// database's.import CottonValuesimport Foundationpublic enum ToolObjects {    /// The objects the catalogue carries, by the name after `tool-`.    public static let objectNames: Set<String> = [        "todos", "calendar", "notes", "journal", "thoughts", "goals", "mood", "messages", "email",        "calls", "people", "locations", "news", "reader", "alarms", "money", "meetings",        // Ahead: a kraft bill file, envelopes standing in its pockets — the money still to come.        "ahead",        "documents", "photos", "videos", "passwords",        // The Camera: a cream point-and-shoot, its lens forward.        "camera",        "code", "assistants", "members", "devices", "bin", "feedback",        // The Domains tool a Cloudflare connection fills: a rolodex of web addresses.        "domains", "storage", "everything", "settings",        // The Outages log: a breaker switch thrown off.        "outages",        // Social: a twine-tied stack of postcards. Memory: a glass jar of folded slips.        "stories", "memory",        // AI usage: a brass meter. Import: an in-tray of arriving letters.        // Projects: a kraft accordion file.        "ai_usage", "imports", "projects",        // Food: a kraft takeaway bag sealed with a sticker.        "food",        // The tool box: the last entry on every database's Home (Spec 9.1),        // pinned there by `BoardLayout`, never in the person's order.        "tools",    ]    /// A tool whose SLUG is not its object's name. The Money tool's slug stays    /// `accounts` (a persisted tool key — `HomeData`), and    /// its object is the coins.    static let renamed: [String: String] = ["accounts": "money"]    /// The imageset a tool is drawn as, or `nil` for a typed name card.    public static func asset(for key: String) -> String? {        let name = renamed[key] ?? key        return objectNames.contains(name) ? "tool-\(name)" : nil    }    /// Whether this app ships the imageset `object` (`tool-todos`): a picture    /// naming any other is no object.    public static func ships(_ object: String) -> Bool {        object.hasPrefix("tool-") && objectNames.contains(String(object.dropFirst("tool-".count)))    }    /// `asset(for:)` as a tool picture — the default a definition's own    /// `picture` overrides.    public static func picture(for key: String) -> ToolPicture? {        asset(for: key).map(ToolPicture.asset)    }}/// The same photograph at app size or at small-tile size. A small tile draws/// the 192px export (`scripts/gen-tools/small-images.ts`) and never loads the/// master.public enum ToolImageVariant: Sendable {    case full, small    func asset(_ name: String) -> String {        self == .small ? "\(name)-small" : name    }}