Switch to monorepo setup

This commit is contained in:
Jon Staab
2024-03-25 14:22:33 -07:00
parent 74b926e227
commit 54e0775453
49 changed files with 3677 additions and 2321 deletions
-2
View File
@@ -1,2 +0,0 @@
build/
src/util/normalize-url
+17 -9
View File
@@ -2,22 +2,32 @@
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.
## /util
This is a monorepo which is split into several different packages.
Some general-purpose utilities used in paravel.
## @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.
- `Kinds` contains kind constants and related utility functions.
- `LRUCache` is an implementation of an LRU cache.
- `Queue` is an implementation of an asynchronous queue.
- `Relays` contains utilities related to relays.
- `Router` is a utility for selecting relay urls based on user preferences and protocol hints.
- `Tags` and `Tag` extend `Fluent` to provide a convenient way to access and modify tags.
- `Tools` is a collection of general-purpose utility functions.
## /connect
## @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.
@@ -28,8 +38,6 @@ Utilities having to do with connection management and nostr messages.
- `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.
## /connect/target
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.
+3364
View File
File diff suppressed because it is too large Load Diff
+4 -42
View File
@@ -1,48 +1,10 @@
{
"name": "paravel",
"version": "0.5.7",
"description": "Yet another toolkit for nostr",
"author": "hodlbod",
"license": "MIT",
"keywords": [
"nostr"
"private": true,
"workspaces": [
"packages/*"
],
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/coracle-social/paravel.git"
},
"types": "./build/src/index.d.ts",
"exports": {
".": {
"types": "./build/src/index.d.ts",
"import": "./build/src/index.mjs",
"require": "./build/src/index.cjs"
}
},
"files": [
"build"
],
"scripts": {
"pub": "pnpm install && pnpm run lint && tsc-multi && pnpm publish",
"build": "tsc-multi",
"clean": "gts clean",
"lint": "gts lint",
"fix": "gts fix",
"prepare": "pnpm build",
"pretest": "pnpm build",
"posttest": "pnpm lint"
},
"dependencies": {
"isomorphic-ws": "^5.0.0",
"nostr-tools": "^2.1.2",
"ws": "^8.14.2"
},
"devDependencies": {
"@types/node": "20.4.6",
"@types/ws": "^8.5.5",
"gts": "^5.0.1",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
"url": "https://github.com/coracle-social/skiff.git"
}
}
+2
View File
@@ -0,0 +1,2 @@
build
normalize-url
@@ -1,7 +1,7 @@
import {EventEmitter} from 'events'
export class Emitter extends EventEmitter {
emit(type: string | symbol, ...args: any[]) {
emit(type: string | number, ...args: any[]) {
const a = super.emit(type, ...args)
const b = super.emit('*', type, ...args)
+2 -2
View File
@@ -1,5 +1,5 @@
export class Queue {
timeout?: NodeJS.Timeout
timeout?: number
messages: any[] = []
clear() {
@@ -48,7 +48,7 @@ export class Queue {
return
}
this.timeout = setTimeout(() => this.doWork(), 100) as NodeJS.Timeout
this.timeout = setTimeout(() => this.doWork(), 100)
}
stop() {
@@ -33,7 +33,3 @@ export type OmitAllStatics<T extends {new(...args: any[]): any, prototype: any}>
T extends {new(...args: infer A): infer R, prototype: infer P} ?
{new(...args: A): R, prototype: P} :
never;
export const fromNostrURI = (s: string) => s.replace(/^[\w+]+:\/?\/?/, "")
export const toNostrURI = (s: string) => `nostr:${s}`
@@ -281,76 +281,76 @@ export type Options = {
};
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
const DATA_URL_DEFAULT_MIME_TYPE = 'text/plain';
const DATA_URL_DEFAULT_CHARSET = 'us-ascii';
const DATA_URL_DEFAULT_MIME_TYPE = 'text/plain'
const DATA_URL_DEFAULT_CHARSET = 'us-ascii'
const testParameter = (name: string, filters: any[]) => filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
const testParameter = (name: string, filters: any[]) => filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name)
const supportedProtocols = new Set([
'https:',
'http:',
'file:',
]);
])
const hasCustomProtocol = (urlString: string) => {
try {
const {protocol} = new URL(urlString);
return protocol.endsWith(':') && !supportedProtocols.has(protocol);
const {protocol} = new URL(urlString)
return protocol.endsWith(':') && !supportedProtocols.has(protocol)
} catch {
return false;
return false
}
};
}
const normalizeDataURL = (urlString: string, {stripHash}: {stripHash: boolean}) => {
const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString)
if (!match) {
throw new Error(`Invalid URL: ${urlString}`);
throw new Error(`Invalid URL: ${urlString}`)
}
let {type, data, hash} = match.groups as any;
const mediaType = type.split(';');
hash = stripHash ? '' : hash;
let {type, data, hash} = match.groups as any
const mediaType = type.split(';')
hash = stripHash ? '' : hash
let isBase64 = false;
let isBase64 = false
if (mediaType[mediaType.length - 1] === 'base64') {
mediaType.pop();
isBase64 = true;
mediaType.pop()
isBase64 = true
}
// Lowercase MIME type
const mimeType = mediaType.shift()?.toLowerCase() ?? '';
const mimeType = mediaType.shift()?.toLowerCase() ?? ''
const attributes = mediaType
.map((attribute: string) => {
let [key, value = ''] = attribute.split('=').map((s: string) => s.trim());
let [key, value = ''] = attribute.split('=').map((s: string) => s.trim())
// Lowercase `charset`
if (key === 'charset') {
value = value.toLowerCase();
value = value.toLowerCase()
if (value === DATA_URL_DEFAULT_CHARSET) {
return '';
return ''
}
}
return `${key}${value ? `=${value}` : ''}`;
return `${key}${value ? `=${value}` : ''}`
})
.filter(Boolean);
.filter(Boolean)
const normalizedMediaType = [
...attributes,
];
]
if (isBase64) {
normalizedMediaType.push('base64');
normalizedMediaType.push('base64')
}
if (normalizedMediaType.length > 0 || (mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE)) {
normalizedMediaType.unshift(mimeType);
normalizedMediaType.unshift(mimeType)
}
return `data:${normalizedMediaType.join(';')},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ''}`;
};
return `data:${normalizedMediaType.join(';')},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ''}`
}
/**
[Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL.
@@ -392,53 +392,53 @@ export default function normalizeUrl(urlString: string, opts?: Options): string
// Legacy: Append `:` to the protocol if missing.
if (typeof options.defaultProtocol === 'string' && !options.defaultProtocol.endsWith(':')) {
options.defaultProtocol = `${options.defaultProtocol}:`;
options.defaultProtocol = `${options.defaultProtocol}:`
}
urlString = urlString.trim();
urlString = urlString.trim()
// Data URL
if (/^data:/i.test(urlString)) {
return normalizeDataURL(urlString, options);
return normalizeDataURL(urlString, options)
}
if (hasCustomProtocol(urlString)) {
return urlString;
return urlString
}
const hasRelativeProtocol = urlString.startsWith('//');
const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);
const hasRelativeProtocol = urlString.startsWith('//')
const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString)
// Prepend protocol
if (!isRelativeUrl) {
urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);
urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol)
}
const urlObject = new URL(urlString);
const urlObject = new URL(urlString)
if (options.forceHttp && options.forceHttps) {
throw new Error('The `forceHttp` and `forceHttps` options cannot be used together');
throw new Error('The `forceHttp` and `forceHttps` options cannot be used together')
}
if (options.forceHttp && urlObject.protocol === 'https:') {
urlObject.protocol = 'http:';
urlObject.protocol = 'http:'
}
if (options.forceHttps && urlObject.protocol === 'http:') {
urlObject.protocol = 'https:';
urlObject.protocol = 'https:'
}
// Remove auth
if (options.stripAuthentication) {
urlObject.username = '';
urlObject.password = '';
urlObject.username = ''
urlObject.password = ''
}
// Remove hash
if (options.stripHash) {
urlObject.hash = '';
urlObject.hash = ''
} else if (options.stripTextFragment) {
urlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, '');
urlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, '')
}
// Remove duplicate slashes if not preceded by a protocol
@@ -451,56 +451,56 @@ export default function normalizeUrl(urlString: string, opts?: Options): string
// Split the string by occurrences of this protocol regex, and perform
// duplicate-slash replacement on the strings between those occurrences
// (if any).
const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g;
const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g
let lastIndex = 0;
let result = '';
let lastIndex = 0
let result = ''
for (;;) {
const match = protocolRegex.exec(urlObject.pathname);
const match = protocolRegex.exec(urlObject.pathname)
if (!match) {
break;
break
}
const protocol = match[0];
const protocolAtIndex = match.index;
const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);
const protocol = match[0]
const protocolAtIndex = match.index
const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex)
result += intermediate.replace(/\/{2,}/g, '/');
result += protocol;
lastIndex = protocolAtIndex + protocol.length;
result += intermediate.replace(/\/{2,}/g, '/')
result += protocol
lastIndex = protocolAtIndex + protocol.length
}
const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);
result += remnant.replace(/\/{2,}/g, '/');
const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length)
result += remnant.replace(/\/{2,}/g, '/')
urlObject.pathname = result;
urlObject.pathname = result
}
// Decode URI octets
if (urlObject.pathname) {
try {
urlObject.pathname = decodeURI(urlObject.pathname);
urlObject.pathname = decodeURI(urlObject.pathname)
} catch {}
}
// Remove directory index
if (options.removeDirectoryIndex === true) {
options.removeDirectoryIndex = [/^index\.[a-z]+$/];
options.removeDirectoryIndex = [/^index\.[a-z]+$/]
}
if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
let pathComponents = urlObject.pathname.split('/');
const lastComponent = pathComponents[pathComponents.length - 1];
let pathComponents = urlObject.pathname.split('/')
const lastComponent = pathComponents[pathComponents.length - 1]
if (testParameter(lastComponent, options.removeDirectoryIndex)) {
pathComponents = pathComponents.slice(0, -1);
urlObject.pathname = pathComponents.slice(1).join('/') + '/';
pathComponents = pathComponents.slice(0, -1)
urlObject.pathname = pathComponents.slice(1).join('/') + '/'
}
}
if (urlObject.hostname) {
// Remove trailing dot
urlObject.hostname = urlObject.hostname.replace(/\.$/, '');
urlObject.hostname = urlObject.hostname.replace(/\.$/, '')
// Remove `www.`
if (options.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(urlObject.hostname)) {
@@ -508,7 +508,7 @@ export default function normalizeUrl(urlString: string, opts?: Options): string
// Source: https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
// Each TLD should be up to 63 characters long (min: 2).
// It is technically possible to have a single character TLD, but none currently exist.
urlObject.hostname = urlObject.hostname.replace(/^www\./, '');
urlObject.hostname = urlObject.hostname.replace(/^www\./, '')
}
}
@@ -517,13 +517,13 @@ export default function normalizeUrl(urlString: string, opts?: Options): string
// eslint-disable-next-line unicorn/no-useless-spread -- We are intentionally spreading to get a copy.
for (const key of [...urlObject.searchParams.keys()]) {
if (testParameter(key, options.removeQueryParameters)) {
urlObject.searchParams.delete(key);
urlObject.searchParams.delete(key)
}
}
}
if (!Array.isArray(options.keepQueryParameters) && options.removeQueryParameters === true) {
urlObject.search = '';
urlObject.search = ''
}
// Keep wanted query parameters
@@ -531,53 +531,53 @@ export default function normalizeUrl(urlString: string, opts?: Options): string
// eslint-disable-next-line unicorn/no-useless-spread -- We are intentionally spreading to get a copy.
for (const key of [...urlObject.searchParams.keys()]) {
if (!testParameter(key, options.keepQueryParameters)) {
urlObject.searchParams.delete(key);
urlObject.searchParams.delete(key)
}
}
}
// Sort query parameters
if (options.sortQueryParameters) {
urlObject.searchParams.sort();
urlObject.searchParams.sort()
// Calling `.sort()` encodes the search parameters, so we need to decode them again.
try {
urlObject.search = decodeURIComponent(urlObject.search);
urlObject.search = decodeURIComponent(urlObject.search)
} catch {}
}
if (options.removeTrailingSlash) {
urlObject.pathname = urlObject.pathname.replace(/\/$/, '');
urlObject.pathname = urlObject.pathname.replace(/\/$/, '')
}
// Remove an explicit port number, excluding a default port number, if applicable
if (options.removeExplicitPort && urlObject.port) {
urlObject.port = '';
urlObject.port = ''
}
const oldUrlString = urlString;
const oldUrlString = urlString
// Take advantage of many of the Node `url` normalizations
urlString = urlObject.toString();
urlString = urlObject.toString()
if (!options.removeSingleSlash && urlObject.pathname === '/' && !oldUrlString.endsWith('/') && urlObject.hash === '') {
urlString = urlString.replace(/\/$/, '');
urlString = urlString.replace(/\/$/, '')
}
// Remove ending `/` unless removeSingleSlash is false
if ((options.removeTrailingSlash || urlObject.pathname === '/') && urlObject.hash === '' && options.removeSingleSlash) {
urlString = urlString.replace(/\/$/, '');
urlString = urlString.replace(/\/$/, '')
}
// Restore relative protocol, if applicable
if (hasRelativeProtocol && !options.normalizeProtocol) {
urlString = urlString.replace(/^http:\/\//, '//');
urlString = urlString.replace(/^http:\/\//, '//')
}
// Remove http/https
if (options.stripProtocol) {
urlString = urlString.replace(/^(?:https?:)?\/\//, '');
urlString = urlString.replace(/^(?:https?:)?\/\//, '')
}
return urlString;
return urlString
}
+36
View File
@@ -0,0 +1,36 @@
{
"name": "@coracle.social/lib",
"version": "0.0.1",
"author": "hodlbod",
"license": "MIT",
"description": "A collection of utilities.",
"publishConfig": {
"access": "public"
},
"type": "module",
"files": [
"build"
],
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.mjs",
"require": "./build/index.cjs"
}
},
"scripts": {
"pub": "npm run lint && npm run rebuild && npm publish",
"rebuild": "npm run clean && npm run build",
"build": "tsc-multi",
"clean": "gts clean",
"lint": "gts lint",
"fix": "gts fix"
},
"devDependencies": {
"@types/events": "^3.0.3",
"gts": "^5.0.1",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
}
}
@@ -1,5 +1,6 @@
{
"targets": [
{"extname": ".cjs", "module": "commonjs"},
{"extname": ".mjs", "module": "esnext", "moduleResolution": "node"}
],
"projects": ["tsconfig.json"]
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "../../node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["es2019", "dom", "dom.iterable"]
},
"include": ["**/*.ts"]
}
+2
View File
@@ -0,0 +1,2 @@
build
normalize-url
@@ -1,5 +1,4 @@
import {Emitter} from '../util/Emitter'
import {Queue} from '../util/Queue'
import {Emitter, Queue} from '@coracle.social/lib'
import {AuthStatus, ConnectionMeta} from './ConnectionMeta'
import {Socket, isMessage, asMessage} from './Socket'
import type {SocketMessage} from './Socket'
@@ -1,5 +1,5 @@
import type {Event, Filter} from 'nostr-tools'
import type {Emitter} from '../util/Emitter'
import type {Emitter} from '@coracle.social/lib'
import type {Connection} from './Connection'
import type {Message} from './Socket'
@@ -1,5 +1,5 @@
import {Emitter} from '@coracle.social/lib'
import {Connection} from "./Connection"
import {Emitter} from '../util/Emitter'
export class Pool extends Emitter {
data: Map<string, Connection>
@@ -1,6 +1,5 @@
import type {MessageEvent} from 'isomorphic-ws'
import WebSocket from "isomorphic-ws"
import {Deferred, defer} from "../util/Deferred"
import {Deferred, defer} from '@coracle.social/lib'
export type Message = [string, ...any[]]
@@ -64,7 +63,7 @@ export class Socket {
this.disconnect()
}
onMessage = (event: MessageEvent) => {
onMessage = (event: {data: string}) => {
try {
const message = JSON.parse(event.data as string)
@@ -1,10 +1,9 @@
import EventEmitter from "events"
import {Emitter} from '@coracle.social/lib'
import type {Filter} from '@coracle.social/util'
import {matchFilters, hasValidSignature} from '@coracle.social/util'
import type {Event} from 'nostr-tools'
import type {Executor} from "./Executor"
import type {Connection} from './Connection'
import type {Filter} from '../protocol/Filters'
import {matchFilters} from "../protocol/Filters"
import {hasValidSignature} from "../protocol/Events"
export type SubscriptionOpts = {
executor: Executor
@@ -15,7 +14,7 @@ export type SubscriptionOpts = {
shouldValidate?: (e: Event, url: string) => boolean
}
export class Subscription extends EventEmitter {
export class Subscription extends Emitter {
unsubscribe: () => void
dead = new Set<string>()
seen = new Set<string>()
+10
View File
@@ -0,0 +1,10 @@
export * from "./Connection"
export * from "./ConnectionMeta"
export * from "./Executor"
export * from "./Pool"
export * from "./Socket"
export * from "./Subscription"
export * from "./target/Multi"
export * from "./target/Plex"
export * from "./target/Relay"
export * from "./target/Relays"
+41
View File
@@ -0,0 +1,41 @@
{
"name": "@coracle.social/network",
"version": "0.0.2",
"author": "hodlbod",
"license": "MIT",
"description": "Utilities for connecting with nostr relays.",
"publishConfig": {
"access": "public"
},
"type": "module",
"files": [
"build"
],
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.mjs",
"require": "./build/index.cjs"
}
},
"scripts": {
"pub": "npm run lint && npm run rebuild && npm publish",
"rebuild": "npm run clean && npm run build",
"build": "tsc-multi",
"clean": "gts clean",
"lint": "gts lint",
"fix": "gts fix"
},
"devDependencies": {
"@types/events": "^3.0.3",
"gts": "^5.0.1",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
},
"dependencies": {
"@coracle.social/util": "^0.0.2",
"isomorphic-ws": "^5.0.0",
"ws": "^8.16.0"
}
}
@@ -1,4 +1,4 @@
import {Emitter} from '../../util/Emitter'
import {Emitter} from '@coracle.social/lib'
import type {Target} from '../Executor'
import type {Message} from '../Socket'
@@ -1,4 +1,4 @@
import {Emitter} from '../../util/Emitter'
import {Emitter} from '@coracle.social/lib'
import type {PlexMessage, Message} from '../Socket'
import type {Connection} from '../Connection'
@@ -1,4 +1,4 @@
import {Emitter} from '../../util/Emitter'
import {Emitter} from '@coracle.social/lib'
import type {Message} from '../Socket'
import type {Connection} from '../Connection'
@@ -1,4 +1,4 @@
import {Emitter} from '../../util/Emitter'
import {Emitter} from '@coracle.social/lib'
import type {Message} from '../Socket'
import type {Connection} from '../Connection'
+7
View File
@@ -0,0 +1,7 @@
{
"targets": [
{"extname": ".cjs", "module": "commonjs"},
{"extname": ".mjs", "module": "esnext", "moduleResolution": "node"}
],
"projects": ["tsconfig.json"]
}
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "../../node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["es2019", "dom"]
},
"include": ["**/*.ts"]
}
+2
View File
@@ -0,0 +1,2 @@
build
normalize-url
@@ -1,6 +1,6 @@
import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
import {verifyEvent, getEventHash} from 'nostr-tools'
import {cached, now} from "../util"
import {cached, now} from '@coracle.social/lib'
import {Tags} from './Tags'
import {addressFromEvent, encodeAddress} from './Address'
import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds'
@@ -1,4 +1,4 @@
import {between} from '../util'
import {between} from '@coracle.social/lib'
export const isEphemeralKind = (kind: number) => between(19999, 29999, kind)
+3
View File
@@ -0,0 +1,3 @@
export const fromNostrURI = (s: string) => s.replace(/^[\w+]+:\/?\/?/, "")
export const toNostrURI = (s: string) => `nostr:${s}`
@@ -1,4 +1,4 @@
import {normalizeUrl, stripProtocol} from "../util"
import {normalizeUrl, stripProtocol} from '@coracle.social/lib'
export const isShareableRelayUrl = (url: string) =>
Boolean(
@@ -1,5 +1,5 @@
import type {EventTemplate, UnsignedEvent} from 'nostr-tools'
import {first, uniq, shuffle} from '../util'
import {first, uniq, shuffle} from '@coracle.social/lib'
import type {Rumor} from './Events'
import {getAddress, isReplaceable} from './Events'
import {Tag, Tags} from './Tags'
@@ -1,6 +1,6 @@
import {EventTemplate} from 'nostr-tools'
import type {OmitStatics} from '../util'
import {Fluent, last} from '../util'
import type {OmitStatics} from '@coracle.social/lib'
import {Fluent, last} from '@coracle.social/lib'
import {isShareableRelayUrl, normalizeRelayUrl} from './Relays'
import type {Address} from './Address'
import {encodeAddress, decodeAddress} from './Address'
+8
View File
@@ -0,0 +1,8 @@
export * from './Address'
export * from './Events'
export * from './Filters'
export * from './Kinds'
export * from './Links'
export * from './Relays'
export * from './Router'
export * from './Tags'
+40
View File
@@ -0,0 +1,40 @@
{
"name": "@coracle.social/util",
"version": "0.0.2",
"author": "hodlbod",
"license": "MIT",
"description": "A collection of utilities.",
"publishConfig": {
"access": "public"
},
"type": "module",
"files": [
"build"
],
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.mjs",
"require": "./build/index.cjs"
}
},
"scripts": {
"pub": "npm run lint && npm run rebuild && npm publish",
"rebuild": "npm run clean && npm run build",
"build": "tsc-multi",
"clean": "gts clean",
"lint": "gts lint",
"fix": "gts fix"
},
"devDependencies": {
"@types/events": "^3.0.3",
"gts": "^5.0.1",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
},
"dependencies": {
"@coracle.social/lib": "^0.0.1",
"nostr-tools": "^2.3.2"
}
}
+7
View File
@@ -0,0 +1,7 @@
{
"targets": [
{"extname": ".cjs", "module": "commonjs"},
{"extname": ".mjs", "module": "esnext", "moduleResolution": "node"}
],
"projects": ["tsconfig.json"]
}
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "../../node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["es2019"]
},
"include": ["**/*.ts"]
}
-2128
View File
File diff suppressed because it is too large Load Diff
-23
View File
@@ -1,23 +0,0 @@
export * from "./connect/Connection"
export * from "./connect/ConnectionMeta"
export * from "./connect/Executor"
export * from "./connect/Pool"
export * from "./connect/Socket"
export * from "./connect/Subscription"
export * from "./connect/target/Multi"
export * from "./connect/target/Plex"
export * from "./connect/target/Relay"
export * from "./connect/target/Relays"
export * from "./protocol/Address"
export * from "./util/Deferred"
export * from "./util/Emitter"
export * from "./protocol/Events"
export * from "./protocol/Filters"
export * from "./util/Fluent"
export * from "./protocol/Kinds"
export * from "./util/LRUCache"
export * from "./util/Queue"
export * from "./protocol/Relays"
export * from "./protocol/Router"
export * from "./protocol/Tags"
export * from "./util/Tools"
-10
View File
@@ -1,10 +0,0 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts"]
}