Skip to content

Add plugin system for runtime-loaded framework providers#3

Merged
asklar merged 1 commit intomainfrom
plugin-system
Feb 24, 2026
Merged

Add plugin system for runtime-loaded framework providers#3
asklar merged 1 commit intomainfrom
plugin-system

Conversation

@asklar
Copy link
Owner

@asklar asklar commented Feb 24, 2026

Add a generic plugin architecture that allows external DLLs to extend lvt with additional UI framework support.

What this does

Plugins are DLLs placed in %USERPROFILE%/.lvt/plugins/\ and discovered at startup. Each plugin exports C ABI functions to detect frameworks and enrich the element tree with additional subtrees.

Core changes

  • plugin.h: C ABI plugin interface with versioning
  • plugin_loader.h/cpp: Plugin discovery, loading, framework detection delegation, and JSON-based tree grafting
  • framework_detector: Added \Framework::Plugin\ enum with string name field
  • tree_builder: Calls \�nrich_with_plugin()\ for plugin-detected frameworks
  • main.cpp: Plugin load/unload lifecycle

Plugin contract

Plugins export:

  • \lvt_plugin_info()\ — metadata (name, version, API version)
  • \lvt_detect_framework()\ — detect if the plugin's framework is present
  • \lvt_enrich_tree()\ — return JSON tree data to graft into the element tree
  • \lvt_plugin_free()\ — free allocated memory

JSON tree roots specify a \ arget_hwnd\ field to indicate which existing Win32 element to graft under.

Tests

11 new tests (44 total, all passing):

  • 8 PluginGraft tests (HWND matching, fallback, multiple roots, nested children, properties, error handling)
  • 3 FrameworkDisplayName tests

@asklar asklar force-pushed the plugin-system branch 4 times, most recently from eca7e6b to cdae23c Compare February 24, 2026 00:30
Add a generic plugin architecture that allows external DLLs to extend lvt
with additional UI framework support. Plugins are discovered at startup
from %USERPROFILE%/.lvt/plugins/ and loaded dynamically via a C ABI.

Core changes:
- src/plugin.h: C ABI plugin interface with versioning (LvtPluginInfo,
  LvtFrameworkDetection, LvtEnrichTreeFn, etc.)
- src/plugin_loader.h/cpp: Plugin discovery, loading, framework detection
  delegation, and JSON-based tree grafting. Plugins return JSON tree data
  which is grafted into the Win32 element tree by matching target_hwnd.
- framework_detector.h/cpp: Added Framework::Plugin enum value with string
  name field. Plugin-detected frameworks are appended after built-in ones.
- tree_builder.cpp: Calls enrich_with_plugin() for plugin-detected frameworks.
- main.cpp: Plugin load/unload lifecycle, framework_display_name() for output.
- CMakeLists.txt: Added plugin_loader.cpp to lvt and test targets.

TAP DLL cleanup:
- WPF TAP DLL now calls FreeLibraryAndExitThread to unload itself after
  collection, matching the convention for all injected DLLs. Removed the
  MonitorThread/trigger event mechanism (no longer needed since each run
  is a fresh injection).

Tests:
- 8 new PluginGraft tests: HWND matching, root fallback, multiple roots,
  nested children, properties, invalid JSON, deep matching.
- 3 new FrameworkDisplayName tests.
- All 44 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asklar asklar merged commit dd69d91 into main Feb 24, 2026
1 check passed
@asklar asklar deleted the plugin-system branch February 24, 2026 00:38
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