//! `Emotions.swift` — the emotion vocabulary, rendered ONCE for the whole//! Swift package.//!//! The declaration is `cotton_core::rules::emotions`, and a word is added//! THERE. This renderer exists for the same reason `retired.rs` does: the//! phone's mood composer draws a chip per word and the Mac's columns draw the//! same ones, so a hand-kept Swift copy would be a seam for the two halves of//! one vocabulary to drift through — and `gen:design:check` is the guard that//! a hand copy would need a second test to get.use cotton_core::rules::emotions::EMOTIONS;usecrate::swift::{generated_header, swift_str};pubfn render_emotions() -> String {let words = EMOTIONS .iter() .map(|word| format!(" {},", swift_str(word))) .collect::<Vec<_>>() .join("\n");let count = EMOTIONS.len();let header = generated_header("cotton-core — rules/emotions.rs"); format!(r#"{header}//// The emotion vocabulary — {count} words, alphabetical.//// Read from `crates/cotton-core/src/rules/emotions.rs`, which is where a word// is declared; a word is NEVER added here.//// A mood is a MOMENT: what the person said about how they are going, and the// emotions named in it. The slug IS the display word, so a chip, a filter and a// tool all say the same string and nothing has to map between a key and a// label.//// The order is alphabetical on purpose. A list running from bad to good would// rebuild the 1-to-5 scale this vocabulary replaced, and `awful`, `low`,// `okay`, `good` and `great` are in it only because the five faces the app used// to draw had exactly those words — migration 18 converts an old score into one// of them.//// English-only, by decision ([english-only-no-translations]): there is no// catalogue lookup here and there is not going to be one.import Foundationpublic enum Emotions {{ /// Every emotion a moment may name, alphabetical. public static let all: [String] = [{words} ] /// Is this exactly one of the declared words? Exact, like the Rust half: /// a chip that matched loosely would highlight a word the server will /// refuse. public static func isEmotion(_ word: String) -> Bool {{ all.contains(word) }} /// The declared word a caller meant, or nil — trimmed and lowercased, /// because a word typed into the composer and a chip tapped beside it /// arrive differently and mean the same thing. public static func normalise(_ word: String) -> String? {{ let wanted = word.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() return all.first {{ $0 == wanted }} }}}}"# )}#[cfg(test)]#[path = "emotions_tests.rs"]mod tests;