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

@holo-host/comb

v0.3.2

Published

Cross-origin message bus (COMB) facilitates communication between a hApp UI and Holo Chaperone

Downloads

64

Readme

Cross-origin Message Bus (COMB)

COMB is a library that facilitates the calls between the parent window (hApp UI) and the iframe (Chaperone).

Used between Holo Chaperone and Holo Hosting Web SDK.

Architecture

COMB is designed to make an iFrame feel like a script. With this in mind, the expectation is that the parent window wants to operate the iFrame, not vice-versa. The purpose of using an iFrame instead of a script will usually be for isolation and/or security. The iFrame does not trust the parent window, but requires input from the parent window to know what to do.

Features

  • Parent/Child communication line
  • Promise wrappers
  • Round trip method request
  • Restrict domains

API

API Reference

Example Usage

Both the parent window and iFrame must load COMB.

<script type="text/javascript" src="./holo_hosting_comb.js"></script>
<script type="text/javascript">
(async () => {
    const child = await comb.connect( url, document.body, 5000, signal => console.log('comb got signal', signal) );

    await child.set("development_mode", true );
    await child.set("welcome_greeting", "Hello" );

    let response = await child.run("isDevelopmentMode");
    // true
    let response = await child.run("sayWelcome", "world", true );
    // "HELLO WORLD!"
})();
</script>
<script type="text/javascript" src="./holo_hosting_comb.js"></script>
<script type="text/javascript">
(async () => {
    const parent = comb.listen({
        "isDevelopmentMode": function () {
            return this.development_mode;
        },
        "sayWelcome": async function ( name, uppercase ) {
            let message = `${this.welcome_greeting}, ${name}!`;
            return uppercase === true ? message.toUpperCase() : message;
        },
    });
})();
</script>

Contributors

We use Postmate to set up a message tunnel between the parent and child frames.

Postmate provided a call child method in its API, but it did not return the result. COMB's Parent and Child classes wrap the communication tunnel in a more useful request/response type API.

Development environment as of 2019/11

  • Node.js 12

Project employs

  • Typescript
  • Webpack
  • JSDoc

Setup

Nix shell will provide packages listed in ../default.nix nativeBuildInputs

nix-shell ../shell.nix

Inside the nix shell

yarn install

Compile (Typescript)

The source is written in Typescript. Run yarn run compile or make build.

Bundler (Webpack)

The web distribution is bundled with Webpack. Run yarn run bundle or make dist.

NOTE: yarn run bundle will not automatically compile

Testing

yarn test

Unit tests

Unit tests are not written because nearly all the complexity is in the integration tests.

Integration tests

Integration tests use puppeteer to simulate a real browser experience.

Required setup

  • HTTP Server for parent window (hApp UI)
  • HTTP Server for child window (Holo Chaperon)
  • Call methods from parent, mock responses from external systems (Resolver, Envoy)