This commit is contained in:
Raven Scott
2026-02-19 18:15:15 -05:00
parent 44fd48c9cc
commit 41f9b6e2e2
5 changed files with 115 additions and 47 deletions
+20 -13
View File
@@ -4,22 +4,23 @@ Multiplayer Snake Pear app (workshop example).
## Overview
Sample Pear app demonstrating multiplayer gameplay and replication patterns.
`snake` is a Pear workshop example that demonstrates real-time multiplayer state sharing with Hyperswarm. It uses Pear Electron for UI.
## Usage
- `npm run dev` (runs `pear run -d .`)
## Examples
### Install and run
```sh
npm i
npm run dev
```
### Run with Pear CLI
## Configuration
- `pear.pre`: `pear-electron/pre`
- `pear.gui`: width/height and background color
## Examples
### Run in dev mode
```sh
pear run -d .
@@ -31,25 +32,31 @@ pear run -d .
npm test
```
### Inspect window size
```text
GUI size is configured in package.json under pear.gui.
```
## Best Practices
- Use as a reference for multiplayer app patterns.
- Use as a reference for realtime peer coordination.
## Performance
- Depends on replication strategy and network.
- Depends on swarm connectivity and update frequency.
## Security
- Treat peer updates as untrusted.
- Validate peer inputs before applying game state.
## Error Handling
- Check logs if the app fails to start.
- Use logs to inspect swarm connection issues.
## Integration
- Useful as a template for Pear games.
- Uses `hyperswarm`, `pear-bridge`, and `pear-electron`.
## License
+14 -14
View File
@@ -1,15 +1,16 @@
# speedrun
Pear app shell demonstrating updates/restart logic.
Pear app shell demonstrating update and restart flows.
## Overview
Sample Pear app with a simple UI and update/restart logic. Used as a development shell for testing updates.
`speedrun` is a minimal Pear desktop app that uses `pear-updates` to react to app updates. It rebuilds the UI bundle with esbuild and restarts on updates.
## Usage
## Scripts
- `npm run dev` (build + `pear run -d .`)
- `npm run build`
- `npm run build` bundles `src/main.jsx` to `dist/bundle.js`
- `npm run dev` builds in watch mode and runs `pear run -d .`
- `npm run prestage` installs, builds, and prunes dev deps
## Examples
@@ -25,32 +26,31 @@ npm run dev
npm run build
```
### Stage and run
### Restart on updates
```sh
pear stage
pear run pear://<link>
```text
App listens for updates and calls Pear.restart().
```
## Best Practices
- Use for testing update flows before production.
- Use `prestage` before staging to reduce package size.
## Performance
- Depends on build output size.
- Hot reload and update checks add minimal overhead.
## Security
- Do not embed sensitive values in the UI.
- Do not expose sensitive data in UI logs.
## Error Handling
- Check Pear logs if update restart fails.
- Handle update errors and show user feedback.
## Integration
- Useful in update pipeline validation.
- Uses `pear-electron`, `pear-bridge`, and `pear-updates`.
## License
+2 -2
View File
@@ -10,7 +10,7 @@ npm i tiny-paths
## Overview
Implements basic `path` helpers such as `join` for environments without Node's `path` module.
Implements basic `path` helpers for environments without Node's `path` module. Uses OS-specific separators.
## API
@@ -29,7 +29,7 @@ path.join('a', 'b', 'c')
### Normalize separators
```js
path.join('/a', 'b')
path.join('foo', 'bar') // foo/bar on posix, foo\\bar on windows
```
### Use in filesystem code
+3 -1
View File
@@ -10,7 +10,7 @@ npm i wasm-tools
## CLI
- `wasm-to-js`
- `wasm-to-js` (options: `--format`, `--platform`, `--sync`, `--minify`)
- `wasm-to-wat`
- `wat-to-js`
- `wat-to-wasm`
@@ -38,6 +38,7 @@ wat-to-wasm input.wat output.wasm
## Best Practices
- Validate output with wasm runtimes after conversion.
- Use `--sync` only when synchronous loading is required.
## Performance
@@ -54,6 +55,7 @@ wat-to-wasm input.wat output.wasm
## Integration
- Useful in build pipelines and bundlers.
- Pair with `esbuild` for JS bundling.
## License
+76 -17
View File
@@ -1,34 +1,93 @@
# blind-peer-muxer - Blind Peer Multiplexer (WIP)
# blind-peer-muxer
Protomux channel for blind-peer core metadata exchange.
## Install
```sh
npm i blind-peer-muxer
```
## Overview
blind-peer-muxer is a work-in-progress package intended to provide multiplexing for blind-peer services.
`blind-peer-muxer` defines a `blind-peer` Protomux protocol with a single message type for exchanging core lists. It uses Hyperschema-generated encodings.
### Status
## API
- **WIP**: No stable API yet
- **Placeholder**: Not production-ready
### `new BlindPeerChannel(stream, opts)`
## Installation
- **opts.oncores** handler for core list messages
- **opts.onopen** called when channel opens
- **opts.onclose** called when channel closes
```bash
npm install blind-peer-muxer
```
### Methods
## Usage
- `addCores(data)` sends a `cores` message
- `cork()` / `uncork()`
- `close()`
- `stream` getter
### Static
- `BlindPeerChannel.pair(stream, notify)`
## Message schema
`cores` payload includes:
- `referrer` (fixed32)
- `priority` (uint)
- `announce` (bool)
- `cores[]` with `{ key: fixed32, length: uint }`
## Examples
### Create a channel
```js
const muxer = require('blind-peer-muxer')
const BlindPeerChannel = require('blind-peer-muxer')
const chan = new BlindPeerChannel(stream, {
oncores: (msg) => console.log(msg)
})
```
## Notes
### Send core list
- Expect breaking changes
- Use only for experimentation
```js
chan.addCores({
priority: 1,
announce: true,
cores: [{ key, length: 10 }]
})
```
### Pair protocol
```js
BlindPeerChannel.pair(stream, (ch) => console.log('paired', ch))
```
## Best Practices
- Keep core lists small to reduce message size.
## Performance
- Protomux multiplexing avoids extra streams per peer.
## Security
- Validate incoming core lists before acting on them.
## Error Handling
- Handle stream errors on the underlying muxer.
## Integration
- Designed for blind-peer relay workflows.
## License
MIT
---
**Module Type**: Experimental | **Ecosystem Role**: Multiplexing | **Dependencies**: None