Plugin System Architecture

EUIX is built around a micro-kernel architecture. The Lite Core runtime (euixjs/core) contains only the foundational XML parser, reactive state proxy, and DOM reconciler.

All additional capabilities—including REST data fetching, modal dialogs, animations, charts, maps, and WebMCP AI agents—are implemented as modular, tree-shakeable plugins.


🔌 Registering Plugins (.use()) #

Plugins are registered using the .use() method before mounting:

JAVASCRIPT
import { EUIXEngineCore } from 'euixjs/core';
import { EUIXApiPlugin } from 'euixjs/api';
import { EUIXStoragePlugin } from 'euixjs/storage';
import { EUIXDialogPlugin } from 'euixjs/dialog';

// Register plugins on Lite Core
EUIXEngineCore
  .use(EUIXApiPlugin)
  .use(EUIXStoragePlugin)
  .use(EUIXDialogPlugin);

// Mount your application
const engine = EUIXEngineCore.mount(xmlString, '#app');

🛠️ How EUIX Plugins Work #

An EUIX Plugin is an object implementing the plugin contract:

JAVASCRIPT
export const MyCustomPlugin = {
  name: 'my-custom-plugin',
  
  install(engine, options) {
    // 1. Register custom declarative actions
    engine.registerAction('NOTIFY', async (step, ctx) => {
      alert(step.message || 'Notification');
    });

    // 2. Intercept lifecycle hooks
    engine.on('mount', (instance) => {
      console.log('Component mounted:', instance);
    });

    // 3. Register custom tag renderers
    engine.registerTag('banner', (node, renderer) => {
      const el = document.createElement('div');
      el.className = 'app-banner';
      el.textContent = node.text;
      return el;
    });
  }
};

📦 Available Official Plugins #

PluginSubpath ImportDescription
SWR REST APIeuixjs/apiDeclarative HTTP client with caching and reactive status.
Storageeuixjs/storageLocalStorage and SessionStorage state persistence.
Dialogeuixjs/dialogAccessible modal dialog overlays with focus management.
Collapseeuixjs/collapseAccordion and collapsible body sections.
Animationeuixjs/animationCSS keyframe transitions with reduced-motion support.
Charteuixjs/chartDeclarative Chart.js charts with reactive dataset syncing.
Leaflet Mapseuixjs/leafletInteractive GIS maps, markers, and polygon rendering.
Date & Intleuixjs/dateInternationalization and date formatting helpers.
WebMCPeuixjs/webmcpExposes actions as tools to browser AI agents.
Navigatoreuixjs/navigatorHardware capabilities (battery, online status, geolocation).

🧭 Next Step #

Explore declarative HTTP endpoints in SWR REST API Plugin.

2 min read · Updated