Bump versions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/app",
|
||||
"version": "0.0.22",
|
||||
"version": "0.0.23",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of svelte stores for use in building nostr client applications.",
|
||||
@@ -32,7 +32,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@welshman/lib": "~0.0.24",
|
||||
"@welshman/feeds": "~0.0.22",
|
||||
"@welshman/feeds": "~0.0.23",
|
||||
"@welshman/dvm": "~0.0.10",
|
||||
"@welshman/net": "~0.0.33",
|
||||
"@welshman/signer": "~0.0.11",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {ctx, now} from '@welshman/lib'
|
||||
import {createEvent, getPubkeyTagValues} from '@welshman/util'
|
||||
import {Scope} from '@welshman/feeds'
|
||||
import type {RequestOpts, DVMOpts} from '@welshman/feeds'
|
||||
import {Scope, FeedController} from '@welshman/feeds'
|
||||
import type {RequestOpts, FeedOptions, DVMOpts, Feed} from '@welshman/feeds'
|
||||
import {makeDvmRequest} from '@welshman/dvm'
|
||||
import {makeSecret, Nip01Signer} from '@welshman/signer'
|
||||
import {pubkey, signer} from './session'
|
||||
@@ -68,3 +68,14 @@ export const getPubkeysForWOTRange = (min: number, max: number) => {
|
||||
|
||||
return pubkeys
|
||||
}
|
||||
|
||||
type _FeedOptions = Partial<Omit<FeedOptions, 'feed'>> & {feed: Feed}
|
||||
|
||||
export const createFeedController = (options: _FeedOptions) =>
|
||||
new FeedController({
|
||||
request,
|
||||
requestDVM,
|
||||
getPubkeysForScope,
|
||||
getPubkeysForWOTRange,
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -22,9 +22,9 @@ const feed = intersectionFeed(
|
||||
const controller = new FeedController({
|
||||
feed,
|
||||
request,
|
||||
requestDvm,
|
||||
requestDVM,
|
||||
getPubkeysForScope,
|
||||
getPubkeysForWotRange,
|
||||
getPubkeysForWOTRange,
|
||||
onEvent: event => console.log("Event", event),
|
||||
onExhausted: () => console.log("Exhausted"),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/feeds",
|
||||
"version": "0.0.22",
|
||||
"version": "0.0.23",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "Utilities for building dynamic nostr feeds.",
|
||||
|
||||
@@ -50,7 +50,7 @@ export class FeedController {
|
||||
onExhausted: () => exhausted.add(request),
|
||||
onEvent: e => {
|
||||
if (!seen.has(e.id)) {
|
||||
onEvent(e)
|
||||
onEvent?.(e)
|
||||
seen.add(e.id)
|
||||
}
|
||||
},
|
||||
@@ -62,7 +62,7 @@ export class FeedController {
|
||||
await Promise.all(loaders.map(loader => loader(limit)))
|
||||
|
||||
if (exhausted.size === requests.length) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ export class FeedController {
|
||||
.map((filter: Filter) => ({...filter, until, limit, since}))
|
||||
|
||||
if (requestFilters.length === 0) {
|
||||
return onExhausted()
|
||||
return onExhausted?.()
|
||||
}
|
||||
|
||||
let count = 0
|
||||
@@ -109,13 +109,13 @@ export class FeedController {
|
||||
onEvent: (event: TrustedEvent) => {
|
||||
count += 1
|
||||
until = Math.min(until, event.created_at - 1)
|
||||
onEvent(event)
|
||||
onEvent?.(event)
|
||||
},
|
||||
}))
|
||||
|
||||
if (useWindowing) {
|
||||
if (since === minSince) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
|
||||
// Relays can't be relied upon to return events in descending order, do exponential
|
||||
@@ -127,7 +127,7 @@ export class FeedController {
|
||||
|
||||
since = Math.max(minSince, until - delta)
|
||||
} else if (count === 0) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,13 +169,13 @@ export class FeedController {
|
||||
|
||||
for (const event of events.splice(0)) {
|
||||
if (!skip.has(event.id) && !seen.has(event.id)) {
|
||||
onEvent(event)
|
||||
onEvent?.(event)
|
||||
seen.add(event.id)
|
||||
}
|
||||
}
|
||||
|
||||
if (exhausted.size === controllers.length) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,13 +214,13 @@ export class FeedController {
|
||||
|
||||
for (const event of events.splice(0)) {
|
||||
if (counts.get(event.id) === controllers.length && !seen.has(event.id)) {
|
||||
onEvent(event)
|
||||
onEvent?.(event)
|
||||
seen.add(event.id)
|
||||
}
|
||||
}
|
||||
|
||||
if (exhausted.size === controllers.length) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ export class FeedController {
|
||||
onExhausted: () => exhausted.add(i),
|
||||
onEvent: (event: TrustedEvent) => {
|
||||
if (!seen.has(event.id)) {
|
||||
onEvent(event)
|
||||
onEvent?.(event)
|
||||
seen.add(event.id)
|
||||
}
|
||||
},
|
||||
@@ -258,7 +258,7 @@ export class FeedController {
|
||||
)
|
||||
|
||||
if (exhausted.size === controllers.length) {
|
||||
onExhausted()
|
||||
onExhausted?.()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export type FeedOptions = {
|
||||
requestDVM: (opts: DVMOpts) => Promise<void>
|
||||
getPubkeysForScope: (scope: Scope) => string[]
|
||||
getPubkeysForWOTRange: (minWOT: number, maxWOT: number) => string[]
|
||||
onEvent: (event: TrustedEvent) => void
|
||||
onExhausted: () => void
|
||||
onEvent?: (event: TrustedEvent) => void
|
||||
onExhausted?: () => void
|
||||
useWindowing?: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user