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

@contentstack/studio-messenger

v1.1.4

Published

This package handles communication between the Studio platform and the iframe webpage.

Readme

Studio Messenger

A communication package that handles messaging between the Studio platform and iframe webpages using postMessage API.

Overview

This package provides a robust messaging system for communication between different parts of the Studio ecosystem:

  • Studio - The main editing interface
  • Visual Builder - The visual editing interface
  • Built-in Canvas - Embedded canvas components
  • Popup Windows - Modal dialogs and popups

Features

  • Bidirectional Communication - Send and receive messages between iframes and parent windows
  • Multiple Channels - Separate communication channels for different contexts
  • Type Safety - Full TypeScript support with typed event data
  • Event Management - Built on @contentstack/advanced-post-message for reliable messaging
  • Debug Support - Optional debug mode for development

Installation

npm install @contentstack/studio-messenger

Usage

Basic Setup

The package automatically initializes event managers when loaded in a browser environment:

import {
  composableStudioEventManager,
  visualBuilderEventManager,
  composableStudioPopupEventManager,
  composableStudioBuiltInCanvasEventManager
} from '@contentstack/studio-messenger';

Available Event Managers

  • composableStudioEventManager - Main Studio communication
  • visualBuilderEventManager - Visual Builder communication
  • composableStudioPopupEventManager - Popup window communication
  • composableStudioBuiltInCanvasEventManager - Built-in canvas communication

Sending Messages

import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';

// Send a highlight node event
composableStudioEventManager?.emit(POST_MESSAGE_EVENTS.HIGHLIGHT_NODE, {
  nodeId: 'my-node-id',
  highlight: true
});

// Send a transform operation
composableStudioEventManager?.emit(POST_MESSAGE_EVENTS.TRANSFORM_OPERATION, {
  operation: 'insert-node',
  data: { /* operation data */ }
});

Listening for Messages

import { visualBuilderEventManager, VISUAL_BUILDER_POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';

// Listen for composition saved events
visualBuilderEventManager?.on(VISUAL_BUILDER_POST_MESSAGE_EVENTS.COMPOSITION_SAVED, (data) => {
  console.log('Composition saved:', data);
  // Handle the saved composition
});

API Reference

Constants

Channel IDs

  • COMPOSABLE_STUDIO_CHANNEL_ID - Main Studio channel
  • VISUAL_BUILDER_CHANNEL_ID - Visual Builder channel
  • COMPOSABLE_STUDIO_POPUP_CHANNEL_ID - Popup channel
  • COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID - Built-in canvas channel

Query Parameters

  • COMPOSABLE_STUDIO_QUERY_PARAM - Available query parameters for configuration

Event Types

Studio Events (POST_MESSAGE_EVENTS)

  • HIGHLIGHT_NODE - Highlight/unhighlight nodes
  • SET_ACTIVE_NODE - Set the currently active node
  • TRANSFORM_OPERATION - Apply transformations to nodes
  • REGISTER_COMPONENTS - Register new components
  • GET_NODE_STYLE - Retrieve node styles
  • UPDATE_DATA_SOURCE - Update data sources
  • APPLY_OPERATION - Apply operations
  • GET_ACTIVE_BREAKPOINT - Get current breakpoint
  • REGISTER_BREAKPOINTS - Register breakpoint definitions
  • SET_CURSOR_TYPE - Set cursor type
  • HIGHLIGHT_SLOT_NODE - Highlight slot nodes
  • UPDATE_BINDING_ERRORS - Update binding validation errors
  • HIDDEN_COMPONENT_NOTIFICATION - Notify about hidden components

Visual Builder Events (VISUAL_BUILDER_POST_MESSAGE_EVENTS)

  • REFETCH_SPEC - Request spec refetch
  • COMPOSITION_SAVED - Composition save notification
  • OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE - Open in Studio

Built-in Canvas Events (COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS)

  • REQUEST_FOR_COMPOSITION_CONFIG - Request composition configuration

Event Data Types

interface OpenComposableStudioFromVBEventData {
  compositionEntryUid: string;
  windowFeatures?: string;
  fetchCompositionData: FetchCompositionData | null;
}

interface CompositionSavedEventData {
  entryUid: string;
  contentTypeUid: string;
  locale: string;
}

interface HiddenElementNotificationEventData {
  action: "open" | "close";
  uid: "__all__" | string;
}

Development

Building

npm run build

Development Mode

npm run dev

Linting

npm run lint
npm run lint:fix

Architecture

The package uses a singleton pattern to manage event managers across the application. Each manager is stored in window.__csMessengerListeners__ to ensure consistent communication channels.

Channel Flow

Studio ↔ Visual Builder
        ↕
   Built-in Canvas
        ↕
    Popup Windows