Bump versions

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