The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { ProjectMonogramText } from "@t3tools/contracts"; |
| 2 | import * as Schema from "effect/Schema"; |
| 3 | import { msg } from "gt-react"; |
| 4 | import { lucideIconNames } from "./lib/lucideIconByName"; |
| 5 | export { PROJECT_ICON_COLORS, projectIconColorClassName } from "./projectIconColors"; |
| 6 | |
| 7 | const isProjectMonogramText = Schema.is(ProjectMonogramText); |
| 8 | |
| 9 | const POPULAR_PROJECT_ICONS: ReadonlyArray<string> = [ |
| 10 | "folder-code", |
| 11 | "code-2", |
| 12 | "terminal", |
| 13 | "globe-2", |
| 14 | "server", |
| 15 | "database", |
| 16 | "bot", |
| 17 | "sparkles", |
| 18 | "smartphone", |
| 19 | "monitor", |
| 20 | "cloud-cog", |
| 21 | "package", |
| 22 | "book-open", |
| 23 | "flask-conical", |
| 24 | "shield-check", |
| 25 | "rocket", |
| 26 | "gamepad-2", |
| 27 | "music", |
| 28 | "image", |
| 29 | "shopping-bag", |
| 30 | "git-branch", |
| 31 | "workflow", |
| 32 | "wrench", |
| 33 | "layers-3", |
| 34 | ]; |
| 35 | |
| 36 | export const PROJECT_EMOJIS: ReadonlyArray<{ readonly emoji: string; readonly label: string }> = [ |
| 37 | { emoji: "💻", label: msg("Computer", { $context: "emoji name, project icon" }) }, |
| 38 | { emoji: "🛠️", label: msg("Tools", { $context: "emoji name, project icon" }) }, |
| 39 | { emoji: "🚀", label: msg("Rocket", { $context: "emoji name, project icon" }) }, |
| 40 | { emoji: "🤖", label: msg("Robot", { $context: "emoji name, project icon" }) }, |
| 41 | { emoji: "✨", label: msg("Sparkles", { $context: "emoji name, project icon" }) }, |
| 42 | { emoji: "⚡", label: msg("Lightning", { $context: "emoji name, project icon" }) }, |
| 43 | { emoji: "🌐", label: msg("Web", { $context: "emoji name, project icon" }) }, |
| 44 | { emoji: "📱", label: msg("Mobile", { $context: "emoji name, project icon" }) }, |
| 45 | { emoji: "🖥️", label: msg("Desktop", { $context: "emoji name, project icon" }) }, |
| 46 | { emoji: "⌨️", label: msg("Keyboard", { $context: "emoji name, project icon" }) }, |
| 47 | { emoji: "⚙️", label: msg("Gear", { $context: "emoji name, project icon" }) }, |
| 48 | { emoji: "🗄️", label: msg("Database", { $context: "emoji name, project icon" }) }, |
| 49 | { emoji: "☁️", label: msg("Cloud", { $context: "emoji name, project icon" }) }, |
| 50 | { emoji: "📦", label: msg("Package", { $context: "emoji name, project icon" }) }, |
| 51 | { emoji: "📚", label: msg("Books", { $context: "emoji name, project icon" }) }, |
| 52 | { emoji: "🧪", label: msg("Test tube", { $context: "emoji name, project icon" }) }, |
| 53 | { emoji: "🔒", label: msg("Lock", { $context: "emoji name, project icon" }) }, |
| 54 | { emoji: "🎮", label: msg("Game", { $context: "emoji name, project icon" }) }, |
| 55 | { emoji: "🎵", label: msg("Music", { $context: "emoji name, project icon" }) }, |
| 56 | { emoji: "🎬", label: msg("Movie", { $context: "emoji name, project icon" }) }, |
| 57 | { emoji: "🖼️", label: msg("Picture", { $context: "emoji name, project icon" }) }, |
| 58 | { emoji: "🛍️", label: msg("Shopping", { $context: "emoji name, project icon" }) }, |
| 59 | { emoji: "🔥", label: msg("Fire", { $context: "emoji name, project icon" }) }, |
| 60 | { emoji: "💡", label: msg("Idea", { $context: "emoji name, project icon" }) }, |
| 61 | { emoji: "🧩", label: msg("Puzzle", { $context: "emoji name, project icon" }) }, |
| 62 | { emoji: "📊", label: msg("Chart", { $context: "emoji name, project icon" }) }, |
| 63 | { emoji: "🧠", label: msg("Brain", { $context: "emoji name, project icon" }) }, |
| 64 | { emoji: "🦄", label: msg("Unicorn", { $context: "emoji name, project icon" }) }, |
| 65 | { emoji: "🐙", label: msg("Octopus", { $context: "emoji name, project icon" }) }, |
| 66 | { emoji: "🌱", label: msg("Seedling", { $context: "emoji name, project icon" }) }, |
| 67 | ]; |
| 68 | |
| 69 | export function filterProjectIconNames(query: string): ReadonlyArray<string> { |
| 70 | const normalized = query.trim().toLowerCase().replaceAll(/\s+/g, "-"); |
| 71 | if (!normalized) return POPULAR_PROJECT_ICONS; |
| 72 | return lucideIconNames.filter((name) => name.includes(normalized)).slice(0, 60); |
| 73 | } |
| 74 | |
| 75 | // The server also rejects monograms longer than two graphemes (ProjectCommands.ts). |
| 76 | export function isValidProjectMonogram(text: string): boolean { |
| 77 | if (!isProjectMonogramText(text)) return false; |
| 78 | const segments = new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text); |
| 79 | return Array.from(segments).length <= 2; |
| 80 | } |
| 81 | |
| 82 | export function firstEmoji(value: string): string | null { |
| 83 | const trimmed = value.trim(); |
| 84 | if (!trimmed) return null; |
| 85 | const segments = new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(trimmed); |
| 86 | const segment = segments[Symbol.iterator]().next().value?.segment; |
| 87 | const isFlag = /^\p{Regional_Indicator}{2}$/u.test(segment ?? ""); |
| 88 | const isKeycap = /^[#*0-9]\uFE0F?\u20E3$/u.test(segment ?? ""); |
| 89 | if (!segment || (!/\p{Extended_Pictographic}/u.test(segment) && !isFlag && !isKeycap)) { |
| 90 | return null; |
| 91 | } |
| 92 | return segment; |
| 93 | } |