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

@cidekar/window-rivet

v1.0.0

Published

Window Rivet is a zero-dependency module for transparent bidirectional communication across origins by fastening separate domains together using the Window object.

Downloads

9

Readme

Introduction

Window Rivet is a zero-dependency module for transparent bidirectional communication across origins by fastening separate domains together using the Window object.

Documentation

Usage

One-way messaging between a privileged and non-privileged domain:

Domain A

    const Rivet = require('@cidekar/rivet')

    // New-up an instance if rivet 
    const rivet = new rivet()
    
    // New-up the dispatcher
    const dispatcher = new rivet.dispatcher();

    // Dispatch single message from domain A.
    dispatcher.message({
        event: 'confirm', 
        message: 'Did you get my message?',
    });

Domain B

    const Rivet = require('@cidekar/rivet')

    // New-up an instance if rivet 
    const rivet = new rivet()

    // New-up the receiver
    const receiver = new rivet.receiver();

    // Receive a message on domain B.
    receiver.listen('confirm', function(event){
        //... Handle message 
        // event.messageEvent.data
    });

Bidirectional messaging between a privileged and non-privileged domain:

Domain A

    const Rivet = require('@cidekar/rivet')

    // New-up an instance if rivet 
    const rivet = new rivet()
    
    // New-up the dispatcher
    const dispatcher = new rivet.dispatcher();

    // Receive a message from domain B.
    dispatcher.listen('response', function (event) {
        //... handle the reply 
        // event.messageEvent.data
    })

    // Dispatch a message from domain A.
    dispatcher.message({
        event: 'confirm', 
        message: 'Did you get my message?',
    });

Domain B

    const Rivet = require('@cidekar/rivet')

    // New-up an instance of rivet 
    const rivet = new rivet()

    // New-up the receiver
    const receiver = new rivet.receiver();

    // A Simple reply function
    function reply(response, event) {
        receiver.message(response, event)
    }

    // Receive a message from domain A and reply.
    receiver.listen('confirm', function(event){
        reply({
            event: 'response',
            message: 'Yes. Thank you for asking!',
        })
    });

What version should a developer use?

Window Rivet is compiled for use in the browser and Node. To find the right version for your use case take a look at the build files definition table.

API

Configuration

| Name | Argument | Default | Description |
| ----------------- | -------- | ---------- | ------------- | | Dispatcher Origin | dispatcherOrigin | ["*"]| The origin of Dispatcher component. | | Receiver Origin | receiverOrigin | ["*"]| The origin of Receiver component. | | Warning Origin | warningOrigin | true | Display configuration waring in console | | Silent | silent | false | Display all cross-origin communication between Window objects in console. |

Components

| Type | Newable | Description | | ------------- | ------------- | -------- | | Dispatcher | X | Create, serialize, and transfer messages. | | Receiver | X |Listen, validate, and handel messages. |

Methods

| Name | Argument | Description | | ------------- | ---------- | ------------- | | Message | { event: string, message: string, array, or object } | Send a message to a component. | | Listen | { event: string, message: string, array, or object } | Listen for a message from a component. |

Hooks

| Type | Life Cycle | Description | | ------------- | ------------- | ------------- | | Created | Register and Ready | System startup, prepare to enter, record, and processed a configuration. | | Mounted | Register and Ready | System has completely processed the configuration and ready for communication. | | Dispatcher | Boot, Register, and Ready | The dispatcher is booted, registered into the system, and ready for communication. | | Receiver | Boot, Register, and Ready | The dispatcher is booted, registered into the system, and ready for communication. |

System Life Cycle

  • Kernel is loaded executing a thin bootloader layer initializing the system.
  • System hooks are created, components set into a ready state, and system is mounted to a domain.
  • A new instance of the Dispatcher and Receiver are created returning methods for bidirectional communication bound to each domain Window object.
  • A Dispatcher message is serialized and sent to a Receiver.
  • The Receiver receives the message and validates the origin and shape.
  • Authorized messages are synchronously dispatched to the Window firing a callback function with the message from the Dispatcher.
  • The Receiver sends a reply to the Dispatcher with a serialized message.

Documentation

View our documentation by running the TypeDoc generator:

    $ yarn docs

License

Copyright 2019 Cidekar, LLC. All rights reserved.

Apache License 2.0