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

@superleapai/iframe-sdk

v1.0.2

Published

SuperleapCRM iframe SDK - Enables bidirectional communication between embedded websites (in iframe) and parent CRM through global window custom events

Readme

@superleapai/iframe-sdk

A powerful iframe SDK that enables bidirectional communication between embedded websites (in iframe) and parent CRM applications through global window custom events and postMessage API.

Features

  • 🔄 Bidirectional Communication: Send and receive events between iframe and parent window
  • 🌐 Cross-Origin Support: Works seamlessly with cross-origin iframes using postMessage fallback
  • 🎯 Event-Driven Architecture: Simple event-based API for clean integration
  • 🔧 Configurable: Customizable event prefixes and debug modes
  • 📱 Toast Notifications: Built-in toast notification system
  • Loading States: Easy loading state management
  • 🔍 TypeScript Support: Full TypeScript declarations included

Installation

npm install @superleapai/iframe-sdk

Quick Start

In your embedded website (iframe content):

// Import the SDK
import SuperleapCRM from '@superleapai/iframe-sdk';

// Or use via script tag
// <script src="path/to/index.js"></script>
// The SDK will be available as window.SuperleapCRM

// Show a success toast
SuperleapCRM.toast('Operation completed successfully!', 'success');

// Set loading state
SuperleapCRM.setIsLoading(true, 'Processing...');

// Close the form/modal
SuperleapCRM.closeForm({ reason: 'completed', data: { id: 123 } });

// Send custom events
SuperleapCRM.sendCustomEvent('userAction', { 
  action: 'click', 
  element: 'submit-button' 
});

// Listen for events from parent CRM
const cleanup = SuperleapCRM.listen('configUpdate', (detail) => {
  console.log('Received config update:', detail);
});

// Listen for all events
const cleanupAll = SuperleapCRM.listen((event) => {
  console.log('Received event:', event.type, event);
});

// Clean up listeners when done
cleanup();
cleanupAll();

In your parent CRM application:

// Listen for events from iframe
window.addEventListener('superleapCRM:closeForm', function(event) {
  console.log('Close form requested:', event.detail);
  // Handle close logic - hide modal, navigate away, etc.
});

window.addEventListener('superleapCRM:setLoading', function(event) {
  const { isLoading, message } = event.detail.payload;
  // Update your loading UI
  if (isLoading) {
    showLoadingSpinner(message);
  } else {
    hideLoadingSpinner();
  }
});

window.addEventListener('superleapCRM:showToast', function(event) {
  const { message, type, duration } = event.detail.payload;
  // Show toast in your CRM UI
  showToast(message, type, duration);
});

// For cross-origin iframes, also listen to postMessage
window.addEventListener('message', function(event) {
  if (event.data && event.data.type === 'SUPERLEAP_CRM_EVENT') {
    // Re-dispatch as custom event for consistent handling
    const customEvent = new CustomEvent(event.data.eventName, {
      detail: event.data.detail
    });
    window.dispatchEvent(customEvent);
  }
});

// Send events TO the iframe
window.dispatchEvent(new CustomEvent('superleapCRM:configUpdate', {
  detail: {
    payload: { theme: 'dark', language: 'en' }
  }
}));

API Reference

Methods

closeForm(data?: any): boolean

Sends an event to close the form/modal.

SuperleapCRM.closeForm({ reason: 'user_cancelled' });

setIsLoading(isLoading: boolean, message?: string): boolean

Sets the loading state in the parent CRM.

SuperleapCRM.setIsLoading(true, 'Saving data...');
SuperleapCRM.setIsLoading(false); // Hide loading

toast(message: string, type?: string, duration?: number): boolean

Shows a toast notification. Types: 'success', 'error', 'warning', 'info'.

SuperleapCRM.toast('Success!', 'success', 3000);
SuperleapCRM.toast('Something went wrong', 'error');

sendCustomEvent(eventType: string, data: any): boolean

Sends a custom event to the parent CRM.

SuperleapCRM.sendCustomEvent('formSubmit', { 
  formId: 'contact-form',
  data: { name: 'John', email: '[email protected]' }
});

listen(eventType: string, callback: Function): Function

Listens for specific events from the parent CRM. Returns cleanup function.

const cleanup = SuperleapCRM.listen('themeChange', (detail) => {
  document.body.className = detail.payload.theme;
});

// Clean up when done
cleanup();

listen(callback: Function): Function

Listens for all events from the parent CRM.

const cleanup = SuperleapCRM.listen((event) => {
  console.log(`Received ${event.type}:`, event);
});

configure(options: object): void

Configures the SDK.

SuperleapCRM.configure({
  debug: true, // Enable debug logging
  eventPrefix: 'myApp:' // Change event prefix
});

isInIframe(): boolean

Utility to check if running inside an iframe.

if (SuperleapCRM.isInIframe()) {
  console.log('Running in iframe');
}

version(): object

Returns version and API information.

console.log(SuperleapCRM.version());
// { version: "1.0.0", api: [...], eventPrefix: "superleapCRM:" }

Event Structure

All events follow this structure:

{
  detail: {
    payload: any, // Your event data
    timestamp: string, // ISO timestamp
    source: "embedded-site",
    isFromIframe: boolean
  }
}

Cross-Origin Support

The SDK automatically handles cross-origin scenarios:

  1. Same-origin: Uses direct custom events on window.top
  2. Cross-origin: Falls back to postMessage API
  3. Parent CRM: Should listen for both custom events AND postMessage

TypeScript Support

The package includes full TypeScript declarations:

import SuperleapCRM, { SuperleapCRMConfig } from '@superleapai/iframe-sdk';

const config: SuperleapCRMConfig = {
  debug: true,
  eventPrefix: 'myApp:'
};

SuperleapCRM.configure(config);

Browser Support

  • Modern browsers with ES6+ support
  • IE11+ (with polyfills for CustomEvent if needed)
  • All mobile browsers

License

ISC