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

@holochain/hc-web-client

v0.5.3

Published

Holochain Conductor connection helper for web based UIs and any Javascript client

Downloads

11

Readme

hc-web-client

Thin wrapper around rpc-websockets to enable calling zome functions in Holochain apps installed in a conductor. This module aims to fill a similar role to web3.js and allow for connecting to a holochain instance in a variety of scenarios.

Installation

The module can either be imported and used as part of a compiled web application or used in pure HTML. In the first case it is reccomended to download and install via npm npm install @holochain/hc-web-client. It can then be imported or required using

const { connect } = require('@holochain/hc-web-client')
// or
import { connect } from '@holochain/hc-web-client'

For the pure HTML case the hc-web-client.js file in the dist/ folder must be moved to your project directory and imported using

<script type="text/javascript" src="path/to/hc-web-client-0.0.1.browser.min.js"></script>

This will add a holochainclient field to the window object.

Usage

Scenario 1

A full URL including port to the holochain interface is known and will never change. This is ok for development or very specific applications. Usage:

connect({ url: "ws://localhost:3000" }).then(({callZome, close}) => {
    callZome('instanceId', 'zome', 'funcName')(params)
})

Scenario 2

UI is being served by the holochain conductor. This is the most commonly anticipated usage. Interface port is unknown but valid interface is defined in the conductor config. In this case no url parameter is required and it will automatically call the conductor to retrieve the correct port to make calls on. Usage:

connect().then(({callZome, close}) => {
    callZome('instanceId', 'zome', 'funcName')(params)
})

Conductor RPC calls

The holochain conductor exposes methods for each function of each zome of each running instance.

If the web client is connected to an admin interface there are also RPC methods to manage DNAs, UIs, interfaces and bridges. These can be called from the web client for exampe as:

connect().then(({call, close}) => {
    call('admin/dna/install_from_file')(params)
})

View the Holochain JSON-RPC API documentation.

Building

  • To build for node/babel use npm run build. This will build to ./lib
  • and to package for the web use npm run build:web. This will build to ./src

Contributing

Running tests

Tests can be run using npm run test

Publishing

To publish a new release to npm use the following steps. Ensure you are on the master branch then run

  • npm version patch
  • npm publish --access public

This will automatically build, lint, commit and push a new git tag before publishing. You can alternatively use npm version major|minor|patch to increment the correct version number. Please do not modify the version number in the package.json directly.

License

This project is licensed under the AGPL-3.0 License