npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@morgan-stanley/composeui-messaging-client

v0.1.0-alpha.13

Published

JavaScript client for ComposeUI's Message Router

Readme

@morgan-stanley/composeui-messaging-client

This package provides a JavaScript/TypeScript client for connecting to the ComposeUI MessageRouter from web modules. It enables publish/subscribe messaging and service invocation between web applications and the ComposeUI messaging infrastructure.

Features

  • Connect to the ComposeUI MessageRouter from browser or Electron environments
  • Publish and subscribe to topics
  • Register and invoke services
  • Promise-based async API
  • TypeScript typings included

Setup

Install the package:

npm install @morgan-stanley/composeui-messaging-client

Import and create a client:

import { createMessageRouter } from "@morgan-stanley/composeui-messaging-client";

let client = createMessageRouter();
await client.connect();

Usage

Subscribe to a topic

client.subscribe('exampleTopic', (message) => {
    const payload = JSON.parse(message.payload);
    console.log(payload);
});

Publish a message

await client.publish('exampleTopic', JSON.stringify({ foo: "bar" }));

Register a service

await client.registerService('myService', async (endpoint, payload, context) => {
    // handle the request and return a response string
    return "response";
});

Invoke a service

const response = await client.invoke('myService', "request payload");
console.log(response); // response string from the service

Unsubscribe from a topic

const subscription = client.subscribe('exampleTopic', handler);
// Later, to unsubscribe:
subscription.unsubscribe();

API Reference

createMessageRouter(options?)

Creates a new MessageRouter client instance.

  • options (optional): Configuration object for the client.

client.connect() => Promise<void>

Establishes a connection to the MessageRouter.

  • Returns: Promise<void>

client.close() => Promise<void>

Closes the connection to the MessageRouter.

  • Returns: Promise<void>

client.subscribe(topic: string, subscriber: TopicSubscriber) => Promise<Unsubscribable>

Subscribes to a topic and registers a handler for incoming messages.

  • topic: The topic string to subscribe to.
  • handler: Function called with each message received: PartialObserver<TopicMessage> | ((message: TopicMessage) => void).
  • Returns: Unsubscribable (call unsubscribe() to remove the handler)

client.publish(topic: string, payload: MessageBuffer, options?: PublishOptions) => Promise<void>

Publishes a message to a topic.

  • topic: The topic string to publish to.
  • payload: The message payload as a string.
  • options: Additional publish options (correlationId).
  • Returns: Promise<void>

client.invoke(service: string, payload: MessageBuffer, options?: InvokeOptions) => Promise<MessageBuffer | undefined>

Invokes a service and returns the response.

  • service: The service name to invoke.
  • payload: The request payload as a string.
  • options: Additional invoke options (correlationId).
  • Returns: Promise<string | undefined> (the response payload)

client.registerService(service: string, handler: MessageHandler, descriptor?: EndpointDescriptor | undefined) => Promise<void>)

Registers a service handler for a given service name.

  • service: The service name to register.
  • handler: Async function that receives the endpoint, request payload, and context, and returns a response payload. (endpoint: string, payload: MessageBuffer | undefined, context: MessageContext) => (MessageBuffer | Promise<MessageBuffer> | void | Promise<void>)
  • descriptor: Additional description for the endpoint
  • Returns: Promise<void>

client.unregisterService(service: string) => Promise<void>

Unregisters a previously registered service.

  • service: The service name to unregister.
  • Returns: Promise<void>

client.registerEndpoint(endpoint: string, handler: MessageHandler, descriptor?: EndpointDescriptor | undefined) => Promise<void>

Registers a local endpoint handler that is not advertised to other clients.

  • endpoint: The endpoint name to register.
  • handler: Async function that receives the endpoint, request payload, and context, and returns a response payload. (endpoint: string, payload: MessageBuffer | undefined, context: MessageContext) => (MessageBuffer | Promise<MessageBuffer> | void | Promise<void>).
  • descriptor (optional): Endpoint descriptor object containing additional description for the endpoint.
  • Returns: Promise<void>

client.unregisterEndpoint(endpoint: string) => Promise<void>

Unregisters a previously registered local endpoint.

  • endpoint: The endpoint name to unregister.
  • Returns: Promise<void>

client.state()

Returns the current connection state of the client.

  • Type: ClientState (Created, Connecting, Connected, Closing, Closed)
  • Usage example:
    if (client.state === ClientState.Connected) {
        // Client is connected
    }

© Morgan Stanley. See NOTICE file for additional information.