Local Linking
Family layout convention
lh-ui/ # family parent directory (not a repo)
├── lh-ui-core/ # token source of truth + codegen
├── lh-ui-android/ # sibling repos
├── lh-ui-ios/
├── lh-ui-harmony/ # this repo
└── lh-ui-windows/When every repo shares the same parent directory, tokens are linked locally; when sibling repos are absent (a CI single-repo clone), it falls back to the npm package automatically. This is structurally the same as the web bloodline's vite alias guard mechanism (master plan D18).
Three-level guard
scripts/link-tokens.mjs resolves token artifacts by priority:
| Priority | Source | Notes |
|---|---|---|
| 1 | ../lh-ui-core/dist/harmony | Local link: token edits take effect immediately |
| 2 | node_modules/@lh-ui/core/dist/harmony | npm fallback: @lh-ui/core's files:["dist"] ships all four platform artifacts |
| 3 | — | Exits with an error — without tokens there is nothing to build |
Daily workflow
bash
# 1. Edit tokens (in the core repo)
cd ../lh-ui-core
vim tokens/color.json # or spacing / typography / ...
# 2. Regenerate and verify
pnpm codegen # generates dist/ artifacts for all four platforms
pnpm verify # schema + references + WCAG contrast + spec consistency
# 3. Sync back to this repo
cd ../lh-ui-harmony
pnpm link:tokens # overwrites lib/tokens/
# 4. Regression (DevEco)
# Right-click tests → Run Tests (hypium golden cases)CI gate
bash
pnpm link:tokens:check # checks whether tokens are in sync (file-count comparison; exit code 1 if not)Forbidden actions
- ❌ Hand-editing
lib/tokens/(generated artifacts, gitignored) - ❌ Committing generated token files to the repo
- ❌ Writing color or spacing literals inside components (e.g.
'#FF2B4C7C',vp(40), raw font-size numbers) - ❌ Copying artifacts by hand, bypassing
link:tokens
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Compile error Cannot find module 'LhTokens' | Tokens not synced | pnpm link:tokens |
| Token values look wrong | core repo not re-run through codegen | Run pnpm codegen in the core repo, then link again |
link:tokens reports "token artifacts not found" | Sibling repo absent and no npm package installed | Check the family layout, or pnpm i -D @lh-ui/core |
| Dark colors look wrong | Light primary changed but dark precomputation not updated | Update color-dark.json and re-run (R-n6) |
| Component colors are all light | Entry never called LhTheme.apply | Call it once after the EntryAbility window is created |

