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

co-share

v3.2.6

Published

A Javascript framework for easily building shared applications such as chats and games

Downloads

7

Readme

co-share

Build Status  Npm package version  GitHub license  Twitter

Javascript library for easily building shared applications such as chats and games

Transformable Example

A shared 3D Cube with "Alice" and "Bob" as simulated users.
The Example was built with co-share and react-three-fiber

npm i co-share

When to use

Building multiuser applications for the web is often challenging as asynchronous communication can drastically increase the system complexity. Writing robust and performant shared applications requires a structured and fitting architecture.

We propose the abstraction of shared stores to distribute logic and data between participating systems. By using Javascript & Node.js, the same code can be used on the client and the server to carry out the platform-independent communication.

How to use

The library is framework-independent as it runs on the Web and NodeJS. However, we provide react hooks out of the box to simplify the experience. Please help us to build tools for more web frameworks.

new Example extends Store {
    action = Action.create(this, "actionName", (origin, parameter) => {
        action.publishTo(
            origin == null ?
                { to: "all" } :
                { to: "all-except-one", except: origin },
            parameter
        )
    })
}

The Stores contain both, the platform-independent logic and the data. Platform independent logic is specified as Actions, which are methods that can be invoked on a remote client (similar to RPC/RMI). Above, we use publishTo to make the Store execute the given Action with the provided parameter on all nodes linked to this Store.

Tutorial

We will build a globally synchronized counter and display it using react. Every client can increase the counter.

Counter Example

Above, you can see a local simulation with the clients "Alice" and "Bob". Even though we can simulate the communication locally, this library is meant for networked communication using WebSocket or WebRTC.

Examples

The code for each example can be found on the respective pages

Simulated locally in your browser

  • Request - request response paradigma
  • Message - direct client to client messaging without any persistent storage in between
  • Lockable - advanced lock functionality to prevent editing by multiple people simultaneously
  • Optimistic Lockable - performance optimize lockable that allows for optimistic behaviour and error correction
  • Whiteboard - collaborative drawing on a shared whiteboard
  • Transformable - shared 3D transformation
  • Consistent - continous states with client-side prediction, lag-compensation and smoothing (using co-consistent)

An extra Project with a server/client architecture using SocketIO

Example Architecture

Sample Architecture Graph

In a multiuser scenario, stores are connected using StoreLinks. One Store can have 0-N StoreLinks to other participants.

In depth description

This framework revolves around the idea of Stores, which can represent any entity or information. A Store is a class that may contain a set of Actions which are methods that can be executed remotely. The communication for executing an action remotely is carried out by the connection of your choice, for instance, with socketio.

However, executing an Action requires an established StoreLink for a connection. This StoreLink uniquely identifies the relation between local Store and remote Store and vice versa. Setting up a StoreLink can be done manually or automatically by subscribing to a certain Store. When subscribing to a Store from a host, its Store will provide the initial parameters to create a local copy of that Store. A Subscriber provides the parameters running on every Store to determine if and what a requesting client should know about the Store. Subscribers can also deny a subscription request.

Supporting Packages