@open-matrix/core
v0.1.2
Published
Matrix runtime SDK — actors, Web Components, transports, serialization, and LISP-on-Protocol
Maintainers
Readme
@matrix/core
Matrix runtime SDK — actors, Web Components, transports, serialization, and LISP-on-Protocol.
Install
npm install @matrix/coreUsage
Headless Actor (daemon-side)
import { MatrixActor } from '@matrix/core';
class PingActor extends MatrixActor {
static accepts = {
ping: { message: 'string' },
};
static emits = {
pong: { echo: 'string', ts: 'number' },
};
onPing(payload: { message: string }) {
this.emit('pong', { echo: payload.message, ts: Date.now() });
}
}Browser Web Component
import { MatrixActorHtmlElement } from '@matrix/core';
class StatusPanel extends MatrixActorHtmlElement {
static accepts = { showStatus: { text: 'string' } };
static template = `<div id="status"></div>`;
static styles = `#status { font-family: monospace; padding: 8px; }`;
onShowStatus(payload: { text: string }) {
this.shadowRoot!.querySelector('#status')!.textContent = payload.text;
}
}
customElements.define('status-panel', StatusPanel);Programmatic Runtime
import { MatrixRuntime, InMemoryBroker } from '@matrix/core';
const broker = new InMemoryBroker();
const runtime = new MatrixRuntime({ broker });
await runtime.start();What's Included
| Category | Key Exports |
|----------|------------|
| Core | MatrixActor, Supervisor, HeadlessComponentRegistry |
| Framework | MatrixActorHtmlElement, MxContract, MxInterface, MxProxy |
| Runtime | MatrixRuntime, HeadlessHost, ConsoleLogger |
| Transports | InMemoryBroker, MqttTransport, FederationTransportAdapter |
| Messaging | TopicRouter, SubscriptionBag, RequestReply |
| LISP | Interpreter, EvalContext, parseSExpr |
| Serialization | serialize, parse, 5-format parity |
| Flow | FlowBuilder, FlowEngine, FlowContext |
135 named exports total. Full type declarations included.
Requirements
- Node.js >= 20
- TypeScript >= 5.0 (for type checking)
License
MIT
