mirror of
https://github.com/aljazceru/pear-docs.git
synced 2025-12-17 06:24:24 +01:00
add pear interface (#143)
* add pear interface * fix semi-colon spacing
This commit is contained in:
BIN
assets/.DS_Store
vendored
Normal file
BIN
assets/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -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.
|
**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:
|
The app uses these modules:
|
||||||
|
|
||||||
- [hyperswarm](https://www.npmjs.com/package/hyperswarm) to connect peers on a "topic".
|
- [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
|
Replace `app.js` with
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
|
|
||||||
|
// For interactive documentation and code auto-completion in editor
|
||||||
|
/** @typedef {import('pear-interface')} */
|
||||||
|
|
||||||
/* global Pear */
|
/* global Pear */
|
||||||
import Hyperswarm from 'hyperswarm' // Module for P2P networking and connecting peers
|
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 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
|
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()
|
const swarm = new Hyperswarm()
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ It continues where [Starting a Pear Terminal Project](./starting-a-pear-terminal
|
|||||||
|
|
||||||
## Step 1. Install modules
|
## 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`.
|
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.
|
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
|
Replace `index.js` with
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
|
|
||||||
|
// For interactive documentation and code auto-completion in editor
|
||||||
|
/** @typedef {import('pear-interface')} */
|
||||||
|
|
||||||
/* global Pear */
|
/* global Pear */
|
||||||
import Hyperswarm from 'hyperswarm' // Module for P2P networking and connecting peers
|
import Hyperswarm from 'hyperswarm' // Module for P2P networking and connecting peers
|
||||||
import b4a from 'b4a' // Module for buffer-to-string and vice-versa conversions
|
import b4a from 'b4a' // Module for buffer-to-string and vice-versa conversions
|
||||||
|
|||||||
Reference in New Issue
Block a user