diff --git a/README.md b/README.md index 25fb5fa..77219ee 100644 --- a/README.md +++ b/README.md @@ -1,71 +1,10 @@ -# Paravel [![version](https://badgen.net/npm/v/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 - -Some general-purpose utilities used elsewhere in paravel. - -- `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}) - } -} -``` +- [@welshman/lib](./tree/master/packages/lib) - generic utility functions. +- [@welshman/util](./tree/master/packages/util) - various nostr-specific utilities. +- [@welshman/net](./tree/master/packages/net) - framework for interacting with relays. +- [@welshman/feeds](./tree/master/packages/feeds) - an interpreter for custom nostr feeds. diff --git a/build_and_link.sh b/build_and_link.sh index 979c1e0..72a4c26 100755 --- a/build_and_link.sh +++ b/build_and_link.sh @@ -2,16 +2,16 @@ upstream=$1 -npm run build -w @coracle.social/$upstream +npm run build -w @welshman/$upstream for downstream in $(ls packages); do - n=@coracle.social/$upstream + n=@welshman/$upstream f=packages/$downstream/package.json v=$(jq '.dependencies["'$n'"] // empty' $f) if [[ ! -z $v ]]; then - mkdir -p packages/$downstream/node_modules/@coracle.social - cp -r packages/$upstream/build packages/$downstream/node_modules/@coracle.social/build - cp -r packages/$upstream/build node_modules/@coracle.social/build + mkdir -p packages/$downstream/node_modules/@welshman + cp -r packages/$upstream/build packages/$downstream/node_modules/@welshman/build + cp -r packages/$upstream/build node_modules/@welshman/build fi done diff --git a/install.sh b/install.sh index eac0aaa..d22dffe 100755 --- a/install.sh +++ b/install.sh @@ -4,14 +4,14 @@ for upstream in $(ls packages); do version=$(sed -nr 's/ +"version": "(.+)",/\1/p' packages/$upstream/package.json) for downstream in $(ls packages); do - n=@coracle.social/$upstream + n=@welshman/$upstream f=packages/$downstream/package.json v=$(jq '.dependencies["'$n'"] // empty' $f) if [[ ! -z $v ]]; then jq '.dependencies["'$n'"]="'$version'"' $f > $f.tmp mv $f.tmp $f - mkdir -p packages/$downstream/node_modules/@coracle.social + mkdir -p packages/$downstream/node_modules/@welshman fi done done diff --git a/package-lock.json b/package-lock.json index c0f6cfe..c6d3ca8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "paravel", + "name": "welshman", "lockfileVersion": 3, "requires": true, "packages": { @@ -114,22 +114,6 @@ "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": { "version": "4.4.0", "dev": true, @@ -550,6 +534,22 @@ "dev": true, "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": { "version": "8.11.3", "dev": true, @@ -3060,11 +3060,11 @@ } }, "packages/feeds": { - "name": "@coracle.social/feeds", - "version": "0.0.2", + "name": "@welshman/feeds", + "version": "0.0.1", "license": "MIT", "dependencies": { - "@coracle.social/util": "0.0.9" + "@welshman/util": "0.0.1" }, "devDependencies": { "gts": "^5.0.1", @@ -3073,8 +3073,8 @@ } }, "packages/lib": { - "name": "@coracle.social/lib", - "version": "0.0.6", + "name": "@welshman/lib", + "version": "0.0.1", "license": "MIT", "dependencies": { "@scure/base": "^1.1.6", @@ -3096,13 +3096,13 @@ "url": "https://paulmillr.com/funding/" } }, - "packages/network": { - "name": "@coracle.social/network", - "version": "0.0.8", + "packages/net": { + "name": "@welshman/net", + "version": "0.0.1", "license": "MIT", "dependencies": { - "@coracle.social/lib": "0.0.6", - "@coracle.social/util": "0.0.9", + "@welshman/lib": "0.0.1", + "@welshman/util": "0.0.1", "isomorphic-ws": "^5.0.0", "ws": "^8.16.0" }, @@ -3114,11 +3114,11 @@ } }, "packages/util": { - "name": "@coracle.social/util", - "version": "0.0.9", + "name": "@welshman/util", + "version": "0.0.1", "license": "MIT", "dependencies": { - "@coracle.social/lib": "0.0.6", + "@welshman/lib": "0.0.1", "nostr-tools": "^2.3.2" }, "devDependencies": { diff --git a/packages/feeds/README.md b/packages/feeds/README.md index 90a5729..ee8b294 100644 --- a/packages/feeds/README.md +++ b/packages/feeds/README.md @@ -1,4 +1,4 @@ -# @coracle.social/feeds +# @welshman/feeds [![version](https://badgen.feeds/npm/v/@welshman/feeds)](https://npmjs.com/package/@welshman/feeds) A custom feed compiler and loader for nostr. diff --git a/packages/feeds/compiler.ts b/packages/feeds/compiler.ts index 297e7ad..53c725a 100644 --- a/packages/feeds/compiler.ts +++ b/packages/feeds/compiler.ts @@ -1,6 +1,6 @@ -import {uniq, now, isNil} from '@coracle.social/lib' -import type {Rumor, Filter} from '@coracle.social/util' -import {Tags, getIdFilters, mergeFilters} from '@coracle.social/util' +import {uniq, now, isNil} from '@welshman/lib' +import type {Rumor, Filter} from '@welshman/util' +import {Tags, getIdFilters, mergeFilters} from '@welshman/util' import type {RequestItem, DVMItem, Scope, Feed, DynamicFilter, FeedOptions} from './core' import {FeedType, getSubFeeds} from './core' diff --git a/packages/feeds/core.ts b/packages/feeds/core.ts index 145cc4f..10c785c 100644 --- a/packages/feeds/core.ts +++ b/packages/feeds/core.ts @@ -1,4 +1,4 @@ -import type {Filter} from '@coracle.social/util' +import type {Filter} from '@welshman/util' export enum FeedType { Difference = "difference", diff --git a/packages/feeds/loader.ts b/packages/feeds/loader.ts index a6b2a65..8d0046e 100644 --- a/packages/feeds/loader.ts +++ b/packages/feeds/loader.ts @@ -1,6 +1,6 @@ -import {inc, max, min, now} from '@coracle.social/lib' -import type {Rumor, Filter} from '@coracle.social/util' -import {EPOCH, guessFilterDelta} from '@coracle.social/util' +import {inc, max, min, now} from '@welshman/lib' +import type {Rumor, Filter} from '@welshman/util' +import {EPOCH, guessFilterDelta} from '@welshman/util' import type {Feed, RequestItem, FeedOptions} from './core' import {FeedType} from './core' import {FeedCompiler} from './compiler' diff --git a/packages/feeds/package.json b/packages/feeds/package.json index f93411b..42857a2 100644 --- a/packages/feeds/package.json +++ b/packages/feeds/package.json @@ -1,6 +1,6 @@ { - "name": "@coracle.social/feeds", - "version": "0.0.3", + "name": "@welshman/feeds", + "version": "0.0.1", "author": "hodlbod", "license": "MIT", "description": "Utilities for building dynamic nostr feeds.", @@ -31,6 +31,6 @@ "typescript": "~5.1.6" }, "dependencies": { - "@coracle.social/util": "0.0.9" + "@welshman/util": "0.0.1" } } diff --git a/packages/lib/README.md b/packages/lib/README.md new file mode 100644 index 0000000..e319c7c --- /dev/null +++ b/packages/lib/README.md @@ -0,0 +1,11 @@ +# @welshman/lib [![version](https://badgen.net/npm/v/@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. diff --git a/packages/lib/package.json b/packages/lib/package.json index 8f096f4..42e8710 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { - "name": "@coracle.social/lib", - "version": "0.0.6", + "name": "@welshman/lib", + "version": "0.0.1", "author": "hodlbod", "license": "MIT", "description": "A collection of utilities.", diff --git a/packages/network/.eslintignore b/packages/net/.eslintignore similarity index 100% rename from packages/network/.eslintignore rename to packages/net/.eslintignore diff --git a/packages/network/Connection.ts b/packages/net/Connection.ts similarity index 98% rename from packages/network/Connection.ts rename to packages/net/Connection.ts index 6471eae..b43f022 100644 --- a/packages/network/Connection.ts +++ b/packages/net/Connection.ts @@ -1,4 +1,4 @@ -import {Emitter, Worker} from '@coracle.social/lib' +import {Emitter, Worker} from '@welshman/lib' import {AuthStatus, ConnectionMeta} from './ConnectionMeta' import {Socket, isMessage, asMessage} from './Socket' import type {SocketMessage} from './Socket' diff --git a/packages/network/ConnectionMeta.ts b/packages/net/ConnectionMeta.ts similarity index 98% rename from packages/network/ConnectionMeta.ts rename to packages/net/ConnectionMeta.ts index 1dbafbc..1108ca4 100644 --- a/packages/network/ConnectionMeta.ts +++ b/packages/net/ConnectionMeta.ts @@ -1,5 +1,5 @@ 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' export type PublishMeta = { diff --git a/packages/network/Context.ts b/packages/net/Context.ts similarity index 90% rename from packages/network/Context.ts rename to packages/net/Context.ts index 686e529..02115f4 100644 --- a/packages/network/Context.ts +++ b/packages/net/Context.ts @@ -1,6 +1,6 @@ import type {Event} from 'nostr-tools' -import {matchFilters, hasValidSignature} from '@coracle.social/util' -import type {Filter} from '@coracle.social/util' +import {matchFilters, hasValidSignature} from '@welshman/util' +import type {Filter} from '@welshman/util' import {Pool} from "./Pool" import {Executor} from "./Executor" import {Relays} from "./target/Relays" diff --git a/packages/network/Executor.ts b/packages/net/Executor.ts similarity index 96% rename from packages/network/Executor.ts rename to packages/net/Executor.ts index 65041dc..2fe7c64 100644 --- a/packages/network/Executor.ts +++ b/packages/net/Executor.ts @@ -1,6 +1,6 @@ import type {Event, Filter} from 'nostr-tools' -import type {Emitter} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import type {Emitter} from '@welshman/lib' +import type {Message} from '@welshman/util' import type {Connection} from './Connection' import {NetworkContext} from './Context' diff --git a/packages/network/Pool.ts b/packages/net/Pool.ts similarity index 96% rename from packages/network/Pool.ts rename to packages/net/Pool.ts index eca4711..5af5035 100644 --- a/packages/network/Pool.ts +++ b/packages/net/Pool.ts @@ -1,4 +1,4 @@ -import {Emitter} from '@coracle.social/lib' +import {Emitter} from '@welshman/lib' import {Connection} from "./Connection" export class Pool extends Emitter { diff --git a/packages/network/Publish.ts b/packages/net/Publish.ts similarity index 93% rename from packages/network/Publish.ts rename to packages/net/Publish.ts index dde1b16..13b18f7 100644 --- a/packages/network/Publish.ts +++ b/packages/net/Publish.ts @@ -1,7 +1,7 @@ import type {Event} from 'nostr-tools' -import {Emitter, now, randomId, defer} from '@coracle.social/lib' -import type {Deferred} from '@coracle.social/lib' -import {asEvent,} from '@coracle.social/util' +import {Emitter, now, randomId, defer} from '@welshman/lib' +import type {Deferred} from '@welshman/lib' +import {asEvent,} from '@welshman/util' import {NetworkContext} from './Context' export enum PublishStatus { diff --git a/packages/net/README.md b/packages/net/README.md new file mode 100644 index 0000000..9757f26 --- /dev/null +++ b/packages/net/README.md @@ -0,0 +1,20 @@ +# @welshman/net [![version](https://badgen.net/npm/v/@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. diff --git a/packages/network/Socket.ts b/packages/net/Socket.ts similarity index 95% rename from packages/network/Socket.ts rename to packages/net/Socket.ts index 61eb5cc..98780dc 100644 --- a/packages/network/Socket.ts +++ b/packages/net/Socket.ts @@ -1,6 +1,6 @@ import WebSocket from "isomorphic-ws" -import {Deferred, defer} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import {Deferred, defer} from '@welshman/lib' +import type {Message} from '@welshman/util' export type PlexMessage = [{relays: string[]}, Message] diff --git a/packages/network/Subscribe.ts b/packages/net/Subscribe.ts similarity index 97% rename from packages/network/Subscribe.ts rename to packages/net/Subscribe.ts index 80ca191..d53a908 100644 --- a/packages/network/Subscribe.ts +++ b/packages/net/Subscribe.ts @@ -1,8 +1,8 @@ import type {Event} from 'nostr-tools' -import {Emitter, randomId, groupBy, batch, defer, uniq, uniqBy} from '@coracle.social/lib' -import type {Deferred} from '@coracle.social/lib' -import {matchFilters, mergeFilters} from '@coracle.social/util' -import type {Filter} from '@coracle.social/util' +import {Emitter, randomId, groupBy, batch, defer, uniq, uniqBy} from '@welshman/lib' +import type {Deferred} from '@welshman/lib' +import {matchFilters, mergeFilters} from '@welshman/util' +import type {Filter} from '@welshman/util' import {Tracker} from "./Tracker" import {Connection} from './Connection' import {NetworkContext} from './Context' diff --git a/packages/network/Tracker.ts b/packages/net/Tracker.ts similarity index 95% rename from packages/network/Tracker.ts rename to packages/net/Tracker.ts index 7437a5d..36bfc76 100644 --- a/packages/network/Tracker.ts +++ b/packages/net/Tracker.ts @@ -1,4 +1,4 @@ -import {writable} from '@coracle.social/lib' +import {writable} from '@welshman/lib' export class Tracker { data = writable(new Map>()) diff --git a/packages/network/index.ts b/packages/net/index.ts similarity index 100% rename from packages/network/index.ts rename to packages/net/index.ts diff --git a/packages/network/package.json b/packages/net/package.json similarity index 85% rename from packages/network/package.json rename to packages/net/package.json index 414fc4f..0ab3294 100644 --- a/packages/network/package.json +++ b/packages/net/package.json @@ -1,6 +1,6 @@ { - "name": "@coracle.social/network", - "version": "0.0.9", + "name": "@welshman/net", + "version": "0.0.1", "author": "hodlbod", "license": "MIT", "description": "Utilities for connecting with nostr relays.", @@ -32,8 +32,8 @@ "typescript": "~5.1.6" }, "dependencies": { - "@coracle.social/lib": "0.0.6", - "@coracle.social/util": "0.0.9", + "@welshman/lib": "0.0.1", + "@welshman/util": "0.0.1", "isomorphic-ws": "^5.0.0", "ws": "^8.16.0" } diff --git a/packages/network/target/Multi.ts b/packages/net/target/Multi.ts similarity index 84% rename from packages/network/target/Multi.ts rename to packages/net/target/Multi.ts index 62ef835..5def7e2 100644 --- a/packages/network/target/Multi.ts +++ b/packages/net/target/Multi.ts @@ -1,5 +1,5 @@ -import {Emitter} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import {Emitter} from '@welshman/lib' +import type {Message} from '@welshman/util' import type {Target} from '../Executor' export class Multi extends Emitter { diff --git a/packages/network/target/Plex.ts b/packages/net/target/Plex.ts similarity index 87% rename from packages/network/target/Plex.ts rename to packages/net/target/Plex.ts index 891b6da..0d79758 100644 --- a/packages/network/target/Plex.ts +++ b/packages/net/target/Plex.ts @@ -1,5 +1,5 @@ -import {Emitter} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import {Emitter} from '@welshman/lib' +import type {Message} from '@welshman/util' import type {PlexMessage} from '../Socket' import type {Connection} from '../Connection' diff --git a/packages/network/target/Relay.ts b/packages/net/target/Relay.ts similarity index 85% rename from packages/network/target/Relay.ts rename to packages/net/target/Relay.ts index d7b6e4b..6a0d640 100644 --- a/packages/network/target/Relay.ts +++ b/packages/net/target/Relay.ts @@ -1,5 +1,5 @@ -import {Emitter} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import {Emitter} from '@welshman/lib' +import type {Message} from '@welshman/util' import type {Connection} from '../Connection' export class Relay extends Emitter { diff --git a/packages/network/target/Relays.ts b/packages/net/target/Relays.ts similarity index 87% rename from packages/network/target/Relays.ts rename to packages/net/target/Relays.ts index d0ba502..b6aba27 100644 --- a/packages/network/target/Relays.ts +++ b/packages/net/target/Relays.ts @@ -1,5 +1,5 @@ -import {Emitter} from '@coracle.social/lib' -import type {Message} from '@coracle.social/util' +import {Emitter} from '@welshman/lib' +import type {Message} from '@welshman/util' import type {Connection} from '../Connection' export class Relays extends Emitter { diff --git a/packages/network/tsc-multi.json b/packages/net/tsc-multi.json similarity index 100% rename from packages/network/tsc-multi.json rename to packages/net/tsc-multi.json diff --git a/packages/network/tsconfig.json b/packages/net/tsconfig.json similarity index 100% rename from packages/network/tsconfig.json rename to packages/net/tsconfig.json diff --git a/packages/util/Events.ts b/packages/util/Events.ts index f7cf618..9ef34ba 100644 --- a/packages/util/Events.ts +++ b/packages/util/Events.ts @@ -1,7 +1,7 @@ import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools' export type {Event, EventTemplate, UnsignedEvent} 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 {addressFromEvent, encodeAddress} from './Address' import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds' diff --git a/packages/util/Filters.ts b/packages/util/Filters.ts index 31d3b5b..0a8964a 100644 --- a/packages/util/Filters.ts +++ b/packages/util/Filters.ts @@ -1,6 +1,6 @@ import type {Event} 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 {decodeAddress, addressFromEvent, encodeAddress} from './Address' import {isReplaceableKind} from './Kinds' diff --git a/packages/util/Kinds.ts b/packages/util/Kinds.ts index 3e7e36e..5f18ee8 100644 --- a/packages/util/Kinds.ts +++ b/packages/util/Kinds.ts @@ -1,5 +1,4 @@ import {kinds} from 'nostr-tools' -import {between} from '@coracle.social/lib' export const isRegularKind = kinds.isRegularKind export const isEphemeralKind = kinds.isEphemeralKind diff --git a/packages/util/README.md b/packages/util/README.md new file mode 100644 index 0000000..844757d --- /dev/null +++ b/packages/util/README.md @@ -0,0 +1,14 @@ +# @welshman/util [![version](https://badgen.net/npm/v/@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. diff --git a/packages/util/Relay.ts b/packages/util/Relay.ts index c9b3aea..245e18f 100644 --- a/packages/util/Relay.ts +++ b/packages/util/Relay.ts @@ -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 {encodeAddress, addressFromEvent} from './Address' import {isReplaceable} from './Events' diff --git a/packages/util/Relays.ts b/packages/util/Relays.ts index 5a4c8bd..f014d3d 100644 --- a/packages/util/Relays.ts +++ b/packages/util/Relays.ts @@ -1,4 +1,4 @@ -import {normalizeUrl, stripProtocol} from '@coracle.social/lib' +import {normalizeUrl, stripProtocol} from '@welshman/lib' export const isShareableRelayUrl = (url: string) => Boolean( diff --git a/packages/util/Router.ts b/packages/util/Router.ts index 3ace7e2..7876f5a 100644 --- a/packages/util/Router.ts +++ b/packages/util/Router.ts @@ -1,5 +1,5 @@ -import {first, splitAt, identity, sortBy, uniq, shuffle, pushToMapKey} from '@coracle.social/lib' -import {Tags, Tag} from '@coracle.social/util' +import {first, splitAt, identity, sortBy, uniq, shuffle, pushToMapKey} from '@welshman/lib' +import {Tags, Tag} from '@welshman/util' import type {Rumor} from './Events' import {getAddress, isReplaceable} from './Events' import {isShareableRelayUrl} from './Relays' diff --git a/packages/util/Tags.ts b/packages/util/Tags.ts index b2ddbb4..24de60e 100644 --- a/packages/util/Tags.ts +++ b/packages/util/Tags.ts @@ -1,6 +1,6 @@ import {EventTemplate} from 'nostr-tools' -import type {OmitStatics} from '@coracle.social/lib' -import {Fluent, ensurePlural, last} from '@coracle.social/lib' +import type {OmitStatics} from '@welshman/lib' +import {Fluent, ensurePlural, last} from '@welshman/lib' import {isShareableRelayUrl, normalizeRelayUrl} from './Relays' import type {Address} from './Address' import {encodeAddress, decodeAddress} from './Address' diff --git a/packages/util/Zaps.ts b/packages/util/Zaps.ts index 81b7175..f38a064 100644 --- a/packages/util/Zaps.ts +++ b/packages/util/Zaps.ts @@ -1,5 +1,5 @@ import type {Event} from 'nostr-tools' -import {hexToBech32} from '@coracle.social/lib' +import {hexToBech32} from '@welshman/lib' import {Tags} from "./Tags" const DIVISORS = { diff --git a/packages/util/package.json b/packages/util/package.json index 71829ee..f4b5099 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,9 +1,9 @@ { - "name": "@coracle.social/util", - "version": "0.0.9", + "name": "@welshman/util", + "version": "0.0.1", "author": "hodlbod", "license": "MIT", - "description": "A collection of utilities.", + "description": "A collection of nostr-related utilities.", "publishConfig": { "access": "public" }, @@ -32,7 +32,7 @@ "typescript": "~5.1.6" }, "dependencies": { - "@coracle.social/lib": "0.0.6", + "@welshman/lib": "0.0.1", "nostr-tools": "^2.3.2" } }