File size: 976 Bytes
1bfa806
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Packaged visual assets owned by the FCC desktop shell."""

from importlib.resources import files
from pathlib import Path

_ICON_FILES = {
    ".icns": "app-icon.icns",
    ".ico": "app-icon.ico",
    ".png": "app-icon.png",
}


def app_icon_bytes(suffix: str) -> bytes:
    """Read the packaged app icon matching a native file suffix."""

    normalized_suffix = suffix.lower()
    try:
        filename = _ICON_FILES[normalized_suffix]
    except KeyError as exc:
        supported = ", ".join(sorted(_ICON_FILES))
        raise ValueError(
            f"Unsupported app icon format {suffix!r}; expected one of: {supported}"
        ) from exc
    return files("free_claude_code").joinpath("assets", filename).read_bytes()


def export_app_icon(destination: Path) -> None:
    """Copy the packaged native icon to an installer-owned destination."""

    destination.parent.mkdir(parents=True, exist_ok=True)
    destination.write_bytes(app_icon_bytes(destination.suffix))