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

@precor/web-api-bridge

v2.1.5

Published

Provides api marshalling for React Native WebvViews and web page iframes.

Downloads

246

Readme

WebApiBridge

WebApiBridge provides a function call API interface between Javascript processes that pass MessageEvent objects such as a a web page and an iframe or a React Native application and a web app running in a react-native-webview.

Features

  • Provides support for API calls between JavaScript processes. Each process can support API calls in an array of JavaScript objects (inluding React components)
  • Marshalls plain JavaScript parameters and return values via JSON.stringify() to work with react-native-community/react-native-webview, including support of ReactNativeWebView.postMessage
  • Works for communication between a web page and iframe child window
  • Provides promise support for asynchronous API calls that need to return results
  • Marshalls exceptions thown in API calls to the caller
  • Validates the existance of API call and message delivery so reliability errors are reported
  • Supports origin and targetOrigin settings
  • A listener() function hook is provided for debugging that will be passed all messages sent/received

Installation

If you're using npm:

npm install --save @precor/web-api-bridge

or, if you're using yarn:

yarn add @precor/web-api-bridge

Type Checking

a Typescript definition file is included. The Proptype declaration for Message is included in types/shapes.js, i.e. to use it:

import { Message } from '@precor/web-api-bridge/types/shapes';

Documentation

WebApiBridge Class

Examples

react-iframe is a simple react implementation of an API between a parent and an iframe.

react-multi is a react implementation of an API between a parent and multiple iframes.

webapp-library extends the react-multi example by creating a functional library abstraction over the bridge for the web app iframes. It also demonstrates mulitiple apis per window and dynamic additions of apis after the iframe based web apps are loaded.

Gotchas

  • If you need to send a message from an app that loads a webview or an iframe, e.g. from a React Native app or a window parent, before receiving from that app then wait for the load to complete, e.g. onLoad callback to send that initial message.