-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
The server-side fingerprint-based refactor (livetemplate/livetemplate#86) eliminates the need for StaticsMap (sm) support in the client. Heterogeneous ranges (items with different templates) now use full replacement instead of per-item statics lookup.
This issue tracks the cleanup of ~35-50 lines of dead code that can be safely removed.
Background
Server Change: The server now uses structure fingerprints to determine when to send statics, replacing the complex registry-based path tracking. For heterogeneous ranges, instead of sending StaticsMap with per-item statics, the server sends a full tree replacement.
Client Impact: The StaticsMap (sm) field and _sk (statics key) handling code will never execute but won't cause errors. This is safe to remove for cleaner code.
Dead Code to Remove
1. RangeStateEntry.staticsMap field
File: state/tree-renderer.ts (line 7)
// Remove this field
interface RangeStateEntry {
items: any[];
statics: any[];
staticsMap?: Record<string, string[]>; // ← REMOVE
}2. sm destructuring and storage
File: state/tree-renderer.ts
| Line | Code | Action |
|---|---|---|
| 225 | staticsMap: rangeStructure.sm, |
Remove |
| 358 | staticsMap: rangeStructure.sm, |
Remove |
| 421 | staticsMap: value.sm, |
Remove |
| 493 | const { d: dynamics, s: statics, sm: staticsMap } = rangeNode; |
Simplify |
| 675 | staticsMap: rangeData.staticsMap, |
Remove |
| 681 | sm: rangeData.staticsMap, |
Remove |
| 702 | sm: this.rangeState[stateKey].staticsMap, |
Remove |
3. hasStaticsMap and _sk lookup logic
File: state/tree-renderer.ts
// Lines 509, 516-518 - REMOVE this block
const hasStaticsMap = staticsMap && typeof staticsMap === "object";
if (statics && Array.isArray(statics)) {
return dynamics.map((item: any, itemIdx: number) => {
let itemStatics = statics;
// REMOVE: This block is now dead code
if (hasStaticsMap && item._sk && staticsMap[item._sk]) {
itemStatics = staticsMap[item._sk];
}
// ... rest stays
});
}// Lines 728-735 - REMOVE staticsMap parameter and _sk lookup
private renderItemsWithStatics(
items: any[],
statics: string[],
staticsMap?: Record<string, string[]>, // ← REMOVE parameter
statePath?: string
): string {
// REMOVE: This check is now dead code
if (
staticsMap &&
typeof staticsMap === "object" &&
item._sk &&
staticsMap[item._sk]
) {
itemStatics = staticsMap[item._sk];
}
}Verification
Before removing this code, verify:
- Server v0.8.0 is released and stable
- No
smfields appear in WebSocket messages (can check via browser dev tools) - All existing tests pass after removal
- E2E tests in lvt repository pass
Estimated Impact
- Lines removed: ~35-50
- Risk: Low (dead code removal)
- Breaking changes: None (internal implementation detail)
Related
- Server PR: Analyze template parsing architecture for refactoring livetemplate#86
- Server docs:
docs/SIMPLIFIED_DIFF_PROPOSAL.md→ "Client Compatibility Analysis" section