Skip to content

feat(core): add actions/events hook infrastructure to plugin-loader#95

Closed
svallory wants to merge 1 commit intodocmd-io:mainfrom
svallory:feat/plugin-actions-hooks
Closed

feat(core): add actions/events hook infrastructure to plugin-loader#95
svallory wants to merge 1 commit intodocmd-io:mainfrom
svallory:feat/plugin-actions-hooks

Conversation

@svallory
Copy link
Copy Markdown
Contributor

@svallory svallory commented Apr 5, 2026

Summary

  • Adds actions (Record) and events (Record) hook types to the plugin-loader alongside existing array-based hooks
  • Plugins can now export actions and events objects for WebSocket RPC and fire-and-forget messaging
  • Defines PluginModule, ActionContext, ActionHandler, EventHandler, SourceTools, and related types in packages/core/src/types.ts
  • Exports all types from @docmd/core

Context

Part of the plugin API infrastructure discussed in #73. This enables plugins to register server-side action handlers that respond to browser RPC calls during development. The action dispatcher (separate PR) will consume these hooks.

Changes

File Change
packages/core/src/utils/plugin-loader.ts Add actions: {} and events: {} to hooks, update reset loop, add merge logic in registerPlugin()
packages/core/src/types.ts New file with all plugin API type definitions
packages/core/src/index.ts Re-export types

Test plan

  • Register a mock plugin with actions: { 'test:foo': handler } — verify hooks.actions['test:foo'] is callable
  • Verify existing plugins continue to load (no regression on array hooks)
  • Run pnpm test

Plugins can now export `actions` (for WebSocket RPC handlers) and
`events` (for fire-and-forget handlers) alongside existing build-time
hooks. Also defines PluginModule, ActionContext, and SourceTools types
for the plugin API contract.
@mgks
Copy link
Copy Markdown
Member

mgks commented Apr 9, 2026

Closing.
These changes are included in #97 which has been merged. Thank you for the clean PR chain! 🙏

@mgks mgks closed this Apr 9, 2026
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.

2 participants