Skip to content

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:

PrioritySourceNotes
1../lh-ui-core/dist/harmonyLocal link: token edits take effect immediately
2node_modules/@lh-ui/core/dist/harmonynpm 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 ​

SymptomCauseFix
Compile error Cannot find module 'LhTokens'Tokens not syncedpnpm link:tokens
Token values look wrongcore repo not re-run through codegenRun pnpm codegen in the core repo, then link again
link:tokens reports "token artifacts not found"Sibling repo absent and no npm package installedCheck the family layout, or pnpm i -D @lh-ui/core
Dark colors look wrongLight primary changed but dark precomputation not updatedUpdate color-dark.json and re-run (R-n6)
Component colors are all lightEntry never called LhTheme.applyCall it once after the EntryAbility window is created

lh-ui native bloodline · HarmonyOS (ArkTS + ArkUI)