mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
`:commons` is on the CLI classpath, yet it declared Compose UI, Coil, Compose resources, markdown and desktop Compose as dependencies, dragging ~40 MB of UI/Skiko jars into every `amy` distribution. This moves every Compose-dependent file into a new KMP module, `:commonsUI`, that `api`-depends on `:commons`; `:commons` keeps only the Compose runtime (stability annotations + snapshot state) and lifecycle-viewmodel. Files keep their `com.vitorpamplona.amethyst.commons.*` packages, so the split is a build-graph boundary and no consumer import changed. 236 files were `git mv`'d (composables, icons, robohash, theme, Coil fetchers, the `@Composable` relay-client entry points, `composeResources`, and the tests that exercise them). Two headless files needed surgery instead of a move: `GalleryParser` lost a vestigial foundation `@OptIn`, and the `LocalPrivacyLockState`/`lockStateFor` CompositionLocal accessor moved out of `PrivacyLockState` into its own commonsUI file. The feed DAL under `ui/feeds` and `ui/note/ParentNote`+`ReplyContext` stay in `commons` because ViewModels depend on them. `amethyst`, `desktopApp`, `nappletHost` (NappletWebContract serves the shell from composeResources) and `benchmark` now depend on `:commonsUI`; `cli`, `geode` and `marmotBench` do not. commons' androidMain gains an explicit androidx.core KTX dep it previously got transitively through Compose UI. CI, crowdin, the icon-font tools and the escaping hook point at the new composeResources location; CLAUDE.md, commons/ARCHITECTURE.md, a new commonsUI/ARCHITECTURE.md, CONTRIBUTING, BUILDING and the affected skills document the boundary. A plan doc under commons/plans records the classification method and follow-ups. Verified: JVM compiles for commons, commonsUI, cli, desktopApp; Android debug compiles for nappletHost and amethyst; commons/commonsUI/cli JVM test suites; both verifyKmpPurity gates; the cli runtime classpath no longer resolves Compose UI, material3, Skiko or Coil. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N56KzPSYiN5edMRamvKEgD
67 lines
2.4 KiB
Bash
Executable File
67 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Subset commonsUI/.../material_symbols_outlined.ttf to only the codepoints
|
|
# referenced from MaterialSymbols.kt. The full Google variable font is ~11 MB
|
|
# (≈3500 glyphs); the subset is ~410 KB.
|
|
#
|
|
# Run this whenever MaterialSymbols.kt gains or loses a codepoint, or when
|
|
# pulling a newer upstream font release.
|
|
#
|
|
# Inputs:
|
|
# $1 (optional) — path to a full upstream MaterialSymbolsOutlined-Regular.ttf
|
|
# to subset. If omitted, the script downloads the variable
|
|
# font from Google Fonts.
|
|
#
|
|
# Output:
|
|
# Overwrites commonsUI/src/commonMain/composeResources/font/material_symbols_outlined.ttf
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
SYMBOLS_KT="$REPO_ROOT/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/icons/symbols/MaterialSymbols.kt"
|
|
TARGET="$REPO_ROOT/commonsUI/src/commonMain/composeResources/font/material_symbols_outlined.ttf"
|
|
|
|
if ! command -v pyftsubset >/dev/null 2>&1; then
|
|
echo "pyftsubset not found. Install with: pip install fonttools brotli" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${1:-}" ]; then
|
|
SOURCE_TTF="$1"
|
|
else
|
|
SOURCE_TTF="$(mktemp -t material_symbols.XXXXXX.ttf)"
|
|
trap 'rm -f "$SOURCE_TTF"' EXIT
|
|
echo "Downloading upstream Material Symbols Outlined variable font..."
|
|
curl -fsSL -o "$SOURCE_TTF" \
|
|
"https://github.com/google/material-design-icons/raw/master/variablefont/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf"
|
|
fi
|
|
|
|
CODEPOINTS_FILE="$(mktemp -t material_symbols_cp.XXXXXX.txt)"
|
|
trap 'rm -f "$CODEPOINTS_FILE" ${SOURCE_TTF:+}' EXIT
|
|
|
|
# Pull every \uXXXX literal out of MaterialSymbols.kt as U+XXXX, deduplicated.
|
|
grep -oE '\\u[A-Fa-f0-9]{4}' "$SYMBOLS_KT" | sort -u | sed 's/\\u/U+/' > "$CODEPOINTS_FILE"
|
|
|
|
count=$(wc -l < "$CODEPOINTS_FILE")
|
|
echo "Subsetting to $count codepoints from MaterialSymbols.kt"
|
|
|
|
pyftsubset "$SOURCE_TTF" \
|
|
--unicodes-file="$CODEPOINTS_FILE" \
|
|
--output-file="$TARGET" \
|
|
--layout-features='*' \
|
|
--no-hinting \
|
|
--desubroutinize \
|
|
--notdef-outline \
|
|
--recommended-glyphs \
|
|
--name-IDs='*' \
|
|
--name-legacy \
|
|
--name-languages='*' \
|
|
--glyph-names \
|
|
--symbol-cmap
|
|
|
|
# Bake in the custom (non-Material) glyphs from custom/ — third-party logos
|
|
# like OpenTimestamps that the upstream font will never carry.
|
|
python3 "$REPO_ROOT/tools/material-symbols-subset/add_custom_glyphs.py" "$TARGET"
|
|
|
|
echo "Wrote $TARGET ($(du -h "$TARGET" | cut -f1))"
|