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 🙏

© 2024 – Pkg Stats / Ryan Hefner

trainmanjs

v0.5.1

Published

TrainmanJS - Cross-Origin Communication Library

Downloads

20

Readme

version dependencies dev dependencies

TrainmanJS

TrainmanJS is Cross-Origin Communication Library. It's a wrapper for the native postMessage API.

It allows you to send bidirectional Topics and Messages between the iframes and wrapper (parent) window.

Trainman

The Trainman is an exile who created and operates Mobil Avenue and is a servant of another exile program known as the Merovingian.

source: http://matrix.wikia.com/wiki/The_Trainman

Features

  • Topics and messages

    You can listen to different kind of topics and message to it. You have control to which frame you would like to send a message. What is also important, the parent frame knows exactly which child frame did send the message. Thanks to that you can omit some topics from particular recipients inside your topic listener.

  • Lazy loading

    Thanks to the queuing mechanism and buffer you can start sending messages immediately. You can send a message from the wrapper (parent) window to the child iframe even it's still loading. Queued messages will be delivered once the connection is established.

  • Reconnection

    When the child frame will reload itself, Trainman will try to reconnect with it. During the reconnection, Trainman will queue messages inside his buffer. Queued messages will be delivered once the connection is established again.

  • Bulk operation (upcoming)

    Post a message to all child frames at once. Don't need to specify an exact recipient. You can use the '*' symbol for sending a message to all of the connect children frames.

  • Debug mode

    Easily turn on and off logging mechanism. Thanks to that you can debug your code and application in a much more simple way. You can track and check whole Trainman and Passenger communication.

  • F2F (upcoming)

    Frame-to-frame direct communication. Allow to send and proxy messages directly between the child frames.

How to install

NPM and Yarn

You can install the library using NPM:

npm install trainmanjs -S
// or
yarn add trainmanjs

Next, you can import TrainmanJS module into your app:

import Trainman from 'trainmnanjs';

For the child pages (frames) you should import Passenger class:

import { Passenger } from 'trainmnanjs';

Using CDN

You can also use the CDN service ex. unpkg.com or npm-cdn.herrokuapp.com

<script src="https://unpkg.com/trainmanjs"></script>

<!-- or -->

<script src="http://npm-cdn.herokuapp.com/[email protected]/lib/trainmanjs.js"></script>

Then you can access the Trainman and Passenger from the injected module:

(function(module) {
  const Trainman = module.Trainman;
  const Passenger = module.Passenger;
})(window.trainmanjs);

How to use it

TBA

Examples

Simple Example

  1. Check simple example how to use Trainman
  2. Here you can find the source code for the above example

Re-connection and Debug Mode

  1. Reconnection example
  2. Here you can find the source code for the above example