Rename everything to welshman
This commit is contained in:
@@ -1,71 +1,10 @@
|
|||||||
# Paravel [](https://npmjs.com/package/paravel)
|
# Welshman
|
||||||
|
|
||||||
A nostr toolkit focused on creating highly a configurable client system. What paravel provides is less a library of code than a library of abstractions. Odds are you will end up creating a custom implementation of every component to suit your needs, but if you start with paravel that will be much easier than if you pile on parameters over time.
|
A nostr toolkit focused on creating highly a configurable client system, extracted from the [Coracle](https://github.com/coracle-social/coracle) nostr client.
|
||||||
|
|
||||||
This is a monorepo which is split into several different packages.
|
This is a monorepo which is split into several different packages:
|
||||||
|
|
||||||
## @coracle.social/lib
|
- [@welshman/lib](./tree/master/packages/lib) - generic utility functions.
|
||||||
|
- [@welshman/util](./tree/master/packages/util) - various nostr-specific utilities.
|
||||||
Some general-purpose utilities used elsewhere in paravel.
|
- [@welshman/net](./tree/master/packages/net) - framework for interacting with relays.
|
||||||
|
- [@welshman/feeds](./tree/master/packages/feeds) - an interpreter for custom nostr feeds.
|
||||||
- `Deferred` is just a promise with `resolve` and `reject` methods.
|
|
||||||
- `Emitter` extends EventEmitter to support `emitter.on('*', ...)`.
|
|
||||||
- `Fluent` is a wrapper around arrays with chained methods that modify and copy the underlying array.
|
|
||||||
- `LRUCache` is an implementation of an LRU cache.
|
|
||||||
- `Worker` is an implementation of an asynchronous queue.
|
|
||||||
- `Tools` is a collection of general-purpose utility functions.
|
|
||||||
- `Store` is an implementation of svelte-like subscribable stores with extra features.
|
|
||||||
|
|
||||||
## @coracle.social/util
|
|
||||||
|
|
||||||
Some nostr-specific utilities. For the most part, these will not have side effects or manage state.
|
|
||||||
|
|
||||||
- `Address` contains utilities for dealing with nostr addresses.
|
|
||||||
- `Events` contains utilities for dealing with nostr events.
|
|
||||||
- `Filters` contains utilities for dealing with nostr filters.
|
|
||||||
- `Kinds` contains kind constants and related utility functions.
|
|
||||||
- `Relays` contains utilities related to relay urls.
|
|
||||||
- `Router` is a utility for selecting relay urls based on user preferences and protocol hints.
|
|
||||||
- `Tags` provides a convenient way to access and modify tags.
|
|
||||||
|
|
||||||
## @coracle.social/network
|
|
||||||
|
|
||||||
Utilities having to do with connection management and nostr messages.
|
|
||||||
|
|
||||||
- `ConnectionMeta` tracks stats for a given `Connection`.
|
|
||||||
- `Connection` is a wrapper for `Socket` with send and receive queues, and a `ConnectionMeta` instance.
|
|
||||||
- `Executor` implements common nostr flows on `target`
|
|
||||||
- `Pool` is a thin wrapper around `Map` for use with `Relay`s.
|
|
||||||
- `Socket` is a wrapper around isomorphic-ws that handles json parsing/serialization.
|
|
||||||
- `Subscription` is a higher-level utility for making requests against multiple nostr relays.
|
|
||||||
|
|
||||||
Executor targets extend `Emitter`, and have a `send` method, a `cleanup` method, and a `connections` getter. They are intended to be passed to an `Executor` for use.
|
|
||||||
|
|
||||||
- `Multi` allows you to compose multiple targets together.
|
|
||||||
- `Plex` takes an array of urls and a `Connection` and sends and receives wrapped nostr messages over that connection.
|
|
||||||
- `Relay` takes a `Connection` and provides listeners for different verbs.
|
|
||||||
- `Relays` takes an array of `Connection`s and provides listeners for different verbs, merging all events into a single stream.
|
|
||||||
|
|
||||||
# Example
|
|
||||||
|
|
||||||
Functionality is split into small chunks to allow for changing out implementations as needed. This is useful when attempting to support novel use cases. Here's a simple implementation of an agent that can use a multiplexer if enabled, or can fall back to communicating directly with all relays.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
class Agent {
|
|
||||||
pool = new Pool()
|
|
||||||
|
|
||||||
constructor(readonly multiplexerUrl: string) {}
|
|
||||||
|
|
||||||
getTarget(urls) {
|
|
||||||
return this.multiplexerUrl
|
|
||||||
? new Plex(urls, this.pool.get(this.multiplexerUrl))
|
|
||||||
: new Relays(urls.map(url => this.pool.get(url)))
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribe(urls, filters, id, {onEvent, onEose}) {
|
|
||||||
const executor = new Executor(this.getTarget(urls))
|
|
||||||
|
|
||||||
return executor.subscribe(filters, id, {onEvent, onEose})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
+5
-5
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
upstream=$1
|
upstream=$1
|
||||||
|
|
||||||
npm run build -w @coracle.social/$upstream
|
npm run build -w @welshman/$upstream
|
||||||
|
|
||||||
for downstream in $(ls packages); do
|
for downstream in $(ls packages); do
|
||||||
n=@coracle.social/$upstream
|
n=@welshman/$upstream
|
||||||
f=packages/$downstream/package.json
|
f=packages/$downstream/package.json
|
||||||
v=$(jq '.dependencies["'$n'"] // empty' $f)
|
v=$(jq '.dependencies["'$n'"] // empty' $f)
|
||||||
|
|
||||||
if [[ ! -z $v ]]; then
|
if [[ ! -z $v ]]; then
|
||||||
mkdir -p packages/$downstream/node_modules/@coracle.social
|
mkdir -p packages/$downstream/node_modules/@welshman
|
||||||
cp -r packages/$upstream/build packages/$downstream/node_modules/@coracle.social/build
|
cp -r packages/$upstream/build packages/$downstream/node_modules/@welshman/build
|
||||||
cp -r packages/$upstream/build node_modules/@coracle.social/build
|
cp -r packages/$upstream/build node_modules/@welshman/build
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
+2
-2
@@ -4,14 +4,14 @@ for upstream in $(ls packages); do
|
|||||||
version=$(sed -nr 's/ +"version": "(.+)",/\1/p' packages/$upstream/package.json)
|
version=$(sed -nr 's/ +"version": "(.+)",/\1/p' packages/$upstream/package.json)
|
||||||
|
|
||||||
for downstream in $(ls packages); do
|
for downstream in $(ls packages); do
|
||||||
n=@coracle.social/$upstream
|
n=@welshman/$upstream
|
||||||
f=packages/$downstream/package.json
|
f=packages/$downstream/package.json
|
||||||
v=$(jq '.dependencies["'$n'"] // empty' $f)
|
v=$(jq '.dependencies["'$n'"] // empty' $f)
|
||||||
|
|
||||||
if [[ ! -z $v ]]; then
|
if [[ ! -z $v ]]; then
|
||||||
jq '.dependencies["'$n'"]="'$version'"' $f > $f.tmp
|
jq '.dependencies["'$n'"]="'$version'"' $f > $f.tmp
|
||||||
mv $f.tmp $f
|
mv $f.tmp $f
|
||||||
mkdir -p packages/$downstream/node_modules/@coracle.social
|
mkdir -p packages/$downstream/node_modules/@welshman
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
Generated
+30
-30
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "paravel",
|
"name": "welshman",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -114,22 +114,6 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@coracle.social/feeds": {
|
|
||||||
"resolved": "packages/feeds",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/@coracle.social/lib": {
|
|
||||||
"resolved": "packages/lib",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/@coracle.social/network": {
|
|
||||||
"resolved": "packages/network",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/@coracle.social/util": {
|
|
||||||
"resolved": "packages/util",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/@eslint-community/eslint-utils": {
|
"node_modules/@eslint-community/eslint-utils": {
|
||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@@ -550,6 +534,22 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/@welshman/feeds": {
|
||||||
|
"resolved": "packages/feeds",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
|
"node_modules/@welshman/lib": {
|
||||||
|
"resolved": "packages/lib",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
|
"node_modules/@welshman/net": {
|
||||||
|
"resolved": "packages/net",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
|
"node_modules/@welshman/util": {
|
||||||
|
"resolved": "packages/util",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.11.3",
|
"version": "8.11.3",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@@ -3060,11 +3060,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/feeds": {
|
"packages/feeds": {
|
||||||
"name": "@coracle.social/feeds",
|
"name": "@welshman/feeds",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/util": "0.0.9"
|
"@welshman/util": "0.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gts": "^5.0.1",
|
"gts": "^5.0.1",
|
||||||
@@ -3073,8 +3073,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/lib": {
|
"packages/lib": {
|
||||||
"name": "@coracle.social/lib",
|
"name": "@welshman/lib",
|
||||||
"version": "0.0.6",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scure/base": "^1.1.6",
|
"@scure/base": "^1.1.6",
|
||||||
@@ -3096,13 +3096,13 @@
|
|||||||
"url": "https://paulmillr.com/funding/"
|
"url": "https://paulmillr.com/funding/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/network": {
|
"packages/net": {
|
||||||
"name": "@coracle.social/network",
|
"name": "@welshman/net",
|
||||||
"version": "0.0.8",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/lib": "0.0.6",
|
"@welshman/lib": "0.0.1",
|
||||||
"@coracle.social/util": "0.0.9",
|
"@welshman/util": "0.0.1",
|
||||||
"isomorphic-ws": "^5.0.0",
|
"isomorphic-ws": "^5.0.0",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
},
|
},
|
||||||
@@ -3114,11 +3114,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/util": {
|
"packages/util": {
|
||||||
"name": "@coracle.social/util",
|
"name": "@welshman/util",
|
||||||
"version": "0.0.9",
|
"version": "0.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/lib": "0.0.6",
|
"@welshman/lib": "0.0.1",
|
||||||
"nostr-tools": "^2.3.2"
|
"nostr-tools": "^2.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# @coracle.social/feeds
|
# @welshman/feeds [](https://npmjs.com/package/@welshman/feeds)
|
||||||
|
|
||||||
A custom feed compiler and loader for nostr.
|
A custom feed compiler and loader for nostr.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {uniq, now, isNil} from '@coracle.social/lib'
|
import {uniq, now, isNil} from '@welshman/lib'
|
||||||
import type {Rumor, Filter} from '@coracle.social/util'
|
import type {Rumor, Filter} from '@welshman/util'
|
||||||
import {Tags, getIdFilters, mergeFilters} from '@coracle.social/util'
|
import {Tags, getIdFilters, mergeFilters} from '@welshman/util'
|
||||||
import type {RequestItem, DVMItem, Scope, Feed, DynamicFilter, FeedOptions} from './core'
|
import type {RequestItem, DVMItem, Scope, Feed, DynamicFilter, FeedOptions} from './core'
|
||||||
import {FeedType, getSubFeeds} from './core'
|
import {FeedType, getSubFeeds} from './core'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type {Filter} from '@coracle.social/util'
|
import type {Filter} from '@welshman/util'
|
||||||
|
|
||||||
export enum FeedType {
|
export enum FeedType {
|
||||||
Difference = "difference",
|
Difference = "difference",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {inc, max, min, now} from '@coracle.social/lib'
|
import {inc, max, min, now} from '@welshman/lib'
|
||||||
import type {Rumor, Filter} from '@coracle.social/util'
|
import type {Rumor, Filter} from '@welshman/util'
|
||||||
import {EPOCH, guessFilterDelta} from '@coracle.social/util'
|
import {EPOCH, guessFilterDelta} from '@welshman/util'
|
||||||
import type {Feed, RequestItem, FeedOptions} from './core'
|
import type {Feed, RequestItem, FeedOptions} from './core'
|
||||||
import {FeedType} from './core'
|
import {FeedType} from './core'
|
||||||
import {FeedCompiler} from './compiler'
|
import {FeedCompiler} from './compiler'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@coracle.social/feeds",
|
"name": "@welshman/feeds",
|
||||||
"version": "0.0.3",
|
"version": "0.0.1",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Utilities for building dynamic nostr feeds.",
|
"description": "Utilities for building dynamic nostr feeds.",
|
||||||
@@ -31,6 +31,6 @@
|
|||||||
"typescript": "~5.1.6"
|
"typescript": "~5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/util": "0.0.9"
|
"@welshman/util": "0.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# @welshman/lib [](https://npmjs.com/package/@welshman/lib)
|
||||||
|
|
||||||
|
Some general-purpose utilities used elsewhere in @welshman.
|
||||||
|
|
||||||
|
- `Deferred` is just a promise with `resolve` and `reject` methods.
|
||||||
|
- `Emitter` extends EventEmitter to support `emitter.on('*', ...)`.
|
||||||
|
- `Fluent` is a wrapper around arrays with chained methods that modify and copy the underlying array.
|
||||||
|
- `LRUCache` is an implementation of an LRU cache.
|
||||||
|
- `Worker` is an implementation of an asynchronous queue.
|
||||||
|
- `Tools` is a collection of general-purpose utility functions.
|
||||||
|
- `Store` is an implementation of svelte-like subscribable stores with extra features.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@coracle.social/lib",
|
"name": "@welshman/lib",
|
||||||
"version": "0.0.6",
|
"version": "0.0.1",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "A collection of utilities.",
|
"description": "A collection of utilities.",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Emitter, Worker} from '@coracle.social/lib'
|
import {Emitter, Worker} from '@welshman/lib'
|
||||||
import {AuthStatus, ConnectionMeta} from './ConnectionMeta'
|
import {AuthStatus, ConnectionMeta} from './ConnectionMeta'
|
||||||
import {Socket, isMessage, asMessage} from './Socket'
|
import {Socket, isMessage, asMessage} from './Socket'
|
||||||
import type {SocketMessage} from './Socket'
|
import type {SocketMessage} from './Socket'
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type {Event, Filter} from 'nostr-tools'
|
import type {Event, Filter} from 'nostr-tools'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {Connection} from './Connection'
|
import type {Connection} from './Connection'
|
||||||
|
|
||||||
export type PublishMeta = {
|
export type PublishMeta = {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Event} from 'nostr-tools'
|
import type {Event} from 'nostr-tools'
|
||||||
import {matchFilters, hasValidSignature} from '@coracle.social/util'
|
import {matchFilters, hasValidSignature} from '@welshman/util'
|
||||||
import type {Filter} from '@coracle.social/util'
|
import type {Filter} from '@welshman/util'
|
||||||
import {Pool} from "./Pool"
|
import {Pool} from "./Pool"
|
||||||
import {Executor} from "./Executor"
|
import {Executor} from "./Executor"
|
||||||
import {Relays} from "./target/Relays"
|
import {Relays} from "./target/Relays"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Event, Filter} from 'nostr-tools'
|
import type {Event, Filter} from 'nostr-tools'
|
||||||
import type {Emitter} from '@coracle.social/lib'
|
import type {Emitter} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {Connection} from './Connection'
|
import type {Connection} from './Connection'
|
||||||
import {NetworkContext} from './Context'
|
import {NetworkContext} from './Context'
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Emitter} from '@coracle.social/lib'
|
import {Emitter} from '@welshman/lib'
|
||||||
import {Connection} from "./Connection"
|
import {Connection} from "./Connection"
|
||||||
|
|
||||||
export class Pool extends Emitter {
|
export class Pool extends Emitter {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import type {Event} from 'nostr-tools'
|
import type {Event} from 'nostr-tools'
|
||||||
import {Emitter, now, randomId, defer} from '@coracle.social/lib'
|
import {Emitter, now, randomId, defer} from '@welshman/lib'
|
||||||
import type {Deferred} from '@coracle.social/lib'
|
import type {Deferred} from '@welshman/lib'
|
||||||
import {asEvent,} from '@coracle.social/util'
|
import {asEvent,} from '@welshman/util'
|
||||||
import {NetworkContext} from './Context'
|
import {NetworkContext} from './Context'
|
||||||
|
|
||||||
export enum PublishStatus {
|
export enum PublishStatus {
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# @welshman/net [](https://npmjs.com/package/@welshman/net)
|
||||||
|
|
||||||
|
Utilities having to do with connection management and nostr messages.
|
||||||
|
|
||||||
|
- `Connection` - a wrapper for `Socket` with send and receive queues, and a `ConnectionMeta` instance.
|
||||||
|
- `ConnectionMeta` - tracks stats for a given `Connection`.
|
||||||
|
- `Context` - an object containing a default `Pool` and global configuration options.
|
||||||
|
- `Executor` - implements common nostr flows on a given `target`
|
||||||
|
- `Pool` - a thin wrapper around `Map` which stores `Connection`s.
|
||||||
|
- `Publish` - utilities for publishing events.
|
||||||
|
- `Socket` - a wrapper around isomorphic-ws that handles json parsing/serialization.
|
||||||
|
- `Subscribe` - utilities for making requests against nostr relays.
|
||||||
|
- `Tracker` - tracks which relays a given event was seen on.
|
||||||
|
|
||||||
|
Executor `target`s extend `Emitter`, and have a `send` method, a `cleanup` method, and a `connections` getter. They are intended to be passed to an `Executor` for use.
|
||||||
|
|
||||||
|
- `targets/Multi` allows you to compose multiple targets together.
|
||||||
|
- `targets/Plex` takes an array of urls and a `Connection` and sends and receives wrapped nostr messages over that connection.
|
||||||
|
- `targets/Relay` takes a `Connection` and provides listeners for different verbs.
|
||||||
|
- `targets/Relays` takes an array of `Connection`s and provides listeners for different verbs, merging all events into a single stream.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import WebSocket from "isomorphic-ws"
|
import WebSocket from "isomorphic-ws"
|
||||||
import {Deferred, defer} from '@coracle.social/lib'
|
import {Deferred, defer} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
|
|
||||||
export type PlexMessage = [{relays: string[]}, Message]
|
export type PlexMessage = [{relays: string[]}, Message]
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import type {Event} from 'nostr-tools'
|
import type {Event} from 'nostr-tools'
|
||||||
import {Emitter, randomId, groupBy, batch, defer, uniq, uniqBy} from '@coracle.social/lib'
|
import {Emitter, randomId, groupBy, batch, defer, uniq, uniqBy} from '@welshman/lib'
|
||||||
import type {Deferred} from '@coracle.social/lib'
|
import type {Deferred} from '@welshman/lib'
|
||||||
import {matchFilters, mergeFilters} from '@coracle.social/util'
|
import {matchFilters, mergeFilters} from '@welshman/util'
|
||||||
import type {Filter} from '@coracle.social/util'
|
import type {Filter} from '@welshman/util'
|
||||||
import {Tracker} from "./Tracker"
|
import {Tracker} from "./Tracker"
|
||||||
import {Connection} from './Connection'
|
import {Connection} from './Connection'
|
||||||
import {NetworkContext} from './Context'
|
import {NetworkContext} from './Context'
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {writable} from '@coracle.social/lib'
|
import {writable} from '@welshman/lib'
|
||||||
|
|
||||||
export class Tracker {
|
export class Tracker {
|
||||||
data = writable(new Map<string, Set<string>>())
|
data = writable(new Map<string, Set<string>>())
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@coracle.social/network",
|
"name": "@welshman/net",
|
||||||
"version": "0.0.9",
|
"version": "0.0.1",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Utilities for connecting with nostr relays.",
|
"description": "Utilities for connecting with nostr relays.",
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
"typescript": "~5.1.6"
|
"typescript": "~5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/lib": "0.0.6",
|
"@welshman/lib": "0.0.1",
|
||||||
"@coracle.social/util": "0.0.9",
|
"@welshman/util": "0.0.1",
|
||||||
"isomorphic-ws": "^5.0.0",
|
"isomorphic-ws": "^5.0.0",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Emitter} from '@coracle.social/lib'
|
import {Emitter} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {Target} from '../Executor'
|
import type {Target} from '../Executor'
|
||||||
|
|
||||||
export class Multi extends Emitter {
|
export class Multi extends Emitter {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Emitter} from '@coracle.social/lib'
|
import {Emitter} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {PlexMessage} from '../Socket'
|
import type {PlexMessage} from '../Socket'
|
||||||
import type {Connection} from '../Connection'
|
import type {Connection} from '../Connection'
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Emitter} from '@coracle.social/lib'
|
import {Emitter} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {Connection} from '../Connection'
|
import type {Connection} from '../Connection'
|
||||||
|
|
||||||
export class Relay extends Emitter {
|
export class Relay extends Emitter {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Emitter} from '@coracle.social/lib'
|
import {Emitter} from '@welshman/lib'
|
||||||
import type {Message} from '@coracle.social/util'
|
import type {Message} from '@welshman/util'
|
||||||
import type {Connection} from '../Connection'
|
import type {Connection} from '../Connection'
|
||||||
|
|
||||||
export class Relays extends Emitter {
|
export class Relays extends Emitter {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
|
import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
|
||||||
export type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
|
export type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
|
||||||
import {verifyEvent, getEventHash} from 'nostr-tools'
|
import {verifyEvent, getEventHash} from 'nostr-tools'
|
||||||
import {cached, now} from '@coracle.social/lib'
|
import {cached, now} from '@welshman/lib'
|
||||||
import {Tags} from './Tags'
|
import {Tags} from './Tags'
|
||||||
import {addressFromEvent, encodeAddress} from './Address'
|
import {addressFromEvent, encodeAddress} from './Address'
|
||||||
import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds'
|
import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Event} from 'nostr-tools'
|
import type {Event} from 'nostr-tools'
|
||||||
import {matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
|
import {matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
|
||||||
import {prop, avg, hash, groupBy, randomId, uniq} from '@coracle.social/lib'
|
import {prop, avg, hash, groupBy, randomId, uniq} from '@welshman/lib'
|
||||||
import type {Rumor} from './Events'
|
import type {Rumor} from './Events'
|
||||||
import {decodeAddress, addressFromEvent, encodeAddress} from './Address'
|
import {decodeAddress, addressFromEvent, encodeAddress} from './Address'
|
||||||
import {isReplaceableKind} from './Kinds'
|
import {isReplaceableKind} from './Kinds'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {kinds} from 'nostr-tools'
|
import {kinds} from 'nostr-tools'
|
||||||
import {between} from '@coracle.social/lib'
|
|
||||||
|
|
||||||
export const isRegularKind = kinds.isRegularKind
|
export const isRegularKind = kinds.isRegularKind
|
||||||
export const isEphemeralKind = kinds.isEphemeralKind
|
export const isEphemeralKind = kinds.isEphemeralKind
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# @welshman/util [](https://npmjs.com/package/@welshman/util)
|
||||||
|
|
||||||
|
Some nostr-specific utilities. For the most part, these will not have side effects or manage state.
|
||||||
|
|
||||||
|
- `Address` utilities for dealing with nostr addresses.
|
||||||
|
- `Events` utilities for dealing with nostr events.
|
||||||
|
- `Filters` utilities for dealing with nostr filters.
|
||||||
|
- `Kinds` kind constants and related utility functions.
|
||||||
|
- `Links` utilities for encoding and decoding nostr links.
|
||||||
|
- `Relay` an implementation of an in-memory nostr relay.
|
||||||
|
- `Relays` utilities related to relay urls.
|
||||||
|
- `Router` is a utility for selecting relay urls based on user preferences and protocol hints.
|
||||||
|
- `Tags` convenient way to access and modify tags.
|
||||||
|
- `Zaps` utilities related to zaps.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Emitter, uniq, omit, now, range, identity, pushToMapKey} from '@coracle.social/lib'
|
import {Emitter, uniq, omit, now, range, identity} from '@welshman/lib'
|
||||||
import {matchFilters, matchFilter} from './Filters'
|
import {matchFilters, matchFilter} from './Filters'
|
||||||
import {encodeAddress, addressFromEvent} from './Address'
|
import {encodeAddress, addressFromEvent} from './Address'
|
||||||
import {isReplaceable} from './Events'
|
import {isReplaceable} from './Events'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {normalizeUrl, stripProtocol} from '@coracle.social/lib'
|
import {normalizeUrl, stripProtocol} from '@welshman/lib'
|
||||||
|
|
||||||
export const isShareableRelayUrl = (url: string) =>
|
export const isShareableRelayUrl = (url: string) =>
|
||||||
Boolean(
|
Boolean(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {first, splitAt, identity, sortBy, uniq, shuffle, pushToMapKey} from '@coracle.social/lib'
|
import {first, splitAt, identity, sortBy, uniq, shuffle, pushToMapKey} from '@welshman/lib'
|
||||||
import {Tags, Tag} from '@coracle.social/util'
|
import {Tags, Tag} from '@welshman/util'
|
||||||
import type {Rumor} from './Events'
|
import type {Rumor} from './Events'
|
||||||
import {getAddress, isReplaceable} from './Events'
|
import {getAddress, isReplaceable} from './Events'
|
||||||
import {isShareableRelayUrl} from './Relays'
|
import {isShareableRelayUrl} from './Relays'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {EventTemplate} from 'nostr-tools'
|
import {EventTemplate} from 'nostr-tools'
|
||||||
import type {OmitStatics} from '@coracle.social/lib'
|
import type {OmitStatics} from '@welshman/lib'
|
||||||
import {Fluent, ensurePlural, last} from '@coracle.social/lib'
|
import {Fluent, ensurePlural, last} from '@welshman/lib'
|
||||||
import {isShareableRelayUrl, normalizeRelayUrl} from './Relays'
|
import {isShareableRelayUrl, normalizeRelayUrl} from './Relays'
|
||||||
import type {Address} from './Address'
|
import type {Address} from './Address'
|
||||||
import {encodeAddress, decodeAddress} from './Address'
|
import {encodeAddress, decodeAddress} from './Address'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type {Event} from 'nostr-tools'
|
import type {Event} from 'nostr-tools'
|
||||||
import {hexToBech32} from '@coracle.social/lib'
|
import {hexToBech32} from '@welshman/lib'
|
||||||
import {Tags} from "./Tags"
|
import {Tags} from "./Tags"
|
||||||
|
|
||||||
const DIVISORS = {
|
const DIVISORS = {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@coracle.social/util",
|
"name": "@welshman/util",
|
||||||
"version": "0.0.9",
|
"version": "0.0.1",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "A collection of utilities.",
|
"description": "A collection of nostr-related utilities.",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"typescript": "~5.1.6"
|
"typescript": "~5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coracle.social/lib": "0.0.6",
|
"@welshman/lib": "0.0.1",
|
||||||
"nostr-tools": "^2.3.2"
|
"nostr-tools": "^2.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user