Skip to content

Phase 4: Consolidate shared code#41

Merged
jamesainslie merged 4 commits intomainfrom
phase-4-consolidate-shared-code
Mar 20, 2026
Merged

Phase 4: Consolidate shared code#41
jamesainslie merged 4 commits intomainfrom
phase-4-consolidate-shared-code

Conversation

@jamesainslie
Copy link
Owner

Summary

  • Move shared content.css (~70KB) to @mdview/core/styles/ — eliminates duplication across chrome-ext and electron
  • Extract DEFAULT_STATE and DEFAULT_PREFERENCES to @mdview/core — single source of truth for both platforms
  • Consolidate 4 Chrome adapter classes (Storage, Messaging, File, Identity) from 5 scattered files into src/adapters/ barrel
  • Promote applyTheme() and watchSystemTheme() from Chrome shim to core ThemeEngine — Chrome shim reduced from 187 to 20 lines

Test plan

  • All 1282 tests pass (npm run test:ci)
  • npm -w @mdview/chrome-ext run build succeeds
  • npm -w @mdview/electron run build succeeds
  • content.css exists only in packages/core/styles/
  • DEFAULT_STATE defined only in packages/core/src/default-state.ts
  • No duplicate adapter classes in chrome-ext (ChromeStorageAdapter, ChromeMessagingAdapter each in one file only)

Both chrome-ext and electron had identical copies of content.css
(2684 lines, ~70KB). Consolidate into packages/core/styles/ as
the single source of truth. Both packages now import via the
@mdview/core/styles/content.css export.
…iew/core

Both chrome-ext and electron defined nearly identical default state
objects. Consolidate into packages/core/src/default-state.ts as the
single source of truth, including tocStyle: 'floating' for both
platforms. Adds 5 tests verifying structure and defaults.
Chrome adapter classes (StorageAdapter, MessagingAdapter, FileAdapter,
IdentityAdapter) were duplicated across 5 files. Extract into dedicated
adapter modules under src/adapters/ with a barrel export, mirroring
electron's adapter structure. All consumers now import from the
centralized location.
…Engine

The Chrome shim's applyTheme() used only standard DOM APIs and core
imports — nothing Chrome-specific. Move these methods into the core
ThemeEngine so both chrome-ext and electron share the same DOM theme
application logic. The Chrome shim is now a thin subclass that only
injects ChromeStorageAdapter.
@jamesainslie jamesainslie merged commit c33b99a into main Mar 20, 2026
0 of 2 checks passed
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@jamesainslie jamesainslie deleted the phase-4-consolidate-shared-code branch March 20, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant