add pear interface (#143)

* add pear interface

* fix semi-colon spacing
This commit is contained in:
Vivek Singh
2024-09-25 15:48:40 +05:30
committed by GitHub
parent 15b52d79a5
commit 2ee7373e62
4 changed files with 25 additions and 1 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
assets/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -169,6 +169,14 @@ Running `pear run --dev .` should show
**Note**: Close the app before installing dependencies. If dependencies are installed while the app is running, an error is thrown.
Install the development dependencies using:
```
npm install
```
This will install the following:
- [pear-interface](https://github.com/holepunchto/pear-interface) for documentation and auto-completion inside editor.
- [brittle](https://github.com/holepunchto/brittle) a TAP framework for testing.
The app uses these modules:
- [hyperswarm](https://www.npmjs.com/package/hyperswarm) to connect peers on a "topic".
@@ -187,11 +195,15 @@ npm install hyperswarm hypercore-crypto b4a
Replace `app.js` with
``` js
// For interactive documentation and code auto-completion in editor
/** @typedef {import('pear-interface')} */
/* global Pear */
import Hyperswarm from 'hyperswarm' // Module for P2P networking and connecting peers
import crypto from 'hypercore-crypto' // Cryptographic functions for generating the key in app
import b4a from 'b4a' // Module for buffer-to-string and vice-versa conversions
const { teardown, updates } = Pear // Cleanup and updates function
const { teardown, updates } = Pear // Functions for cleanup and updates
const swarm = new Hyperswarm()

View File

@@ -8,6 +8,14 @@ It continues where [Starting a Pear Terminal Project](./starting-a-pear-terminal
## Step 1. Install modules
Install the development dependencies using:
```
npm install
```
This will install the following:
- [pear-interface](https://github.com/holepunchto/pear-interface) for documentation and auto-completion inside editors.
- [brittle](https://github.com/holepunchto/brittle) a TAP framework for testing.
For the chat part of the app, the same modules are needed as in [Making a Pear Desktop Application](./making-a-pear-desktop-app.md), `hyperswarm`, `b4a` and `hypercore-crypto`.
Pear runs on [`Bare`](https://github.com/holepunchto/bare), a lightweight JavaScript runtime which is similar to Node.js but comes with very few internal modules. Almost all Bare functionality comes from dependencies. Pear Terminal Applications are Bare applications so we will need `bare-readline` and `bare-tty` to read user input.
@@ -22,6 +30,10 @@ npm i bare-readline bare-tty bare-process hyperswarm b4a hypercore-crypto
Replace `index.js` with
``` js
// For interactive documentation and code auto-completion in editor
/** @typedef {import('pear-interface')} */
/* global Pear */
import Hyperswarm from 'hyperswarm' // Module for P2P networking and connecting peers
import b4a from 'b4a' // Module for buffer-to-string and vice-versa conversions