This commit is contained in:
Jon Staab
2024-05-24 14:11:05 -07:00
parent 5ec54e3204
commit b7d5ce7ae2
6 changed files with 17 additions and 19 deletions
+7 -7
View File
@@ -3059,10 +3059,10 @@
}, },
"packages/feeds": { "packages/feeds": {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.0.8", "version": "0.0.9",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/util": "0.0.10" "@welshman/util": "0.0.11"
}, },
"devDependencies": { "devDependencies": {
"gts": "^5.0.1", "gts": "^5.0.1",
@@ -3072,7 +3072,7 @@
}, },
"packages/lib": { "packages/lib": {
"name": "@welshman/lib", "name": "@welshman/lib",
"version": "0.0.7", "version": "0.0.8",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@scure/base": "^1.1.6", "@scure/base": "^1.1.6",
@@ -3099,8 +3099,8 @@
"version": "0.0.10", "version": "0.0.10",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.7", "@welshman/lib": "0.0.8",
"@welshman/util": "0.0.10", "@welshman/util": "0.0.11",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"ws": "^8.16.0" "ws": "^8.16.0"
}, },
@@ -3112,10 +3112,10 @@
}, },
"packages/util": { "packages/util": {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.0.10", "version": "0.0.11",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.7", "@welshman/lib": "0.0.8",
"nostr-tools": "^2.3.2" "nostr-tools": "^2.3.2"
}, },
"devDependencies": { "devDependencies": {
+3 -5
View File
@@ -106,11 +106,9 @@ export class FeedCompiler<E extends TrustedEvent> {
this.options.requestDVM({ this.options.requestDVM({
...request, ...request,
onEvent: async (e: E) => { onEvent: async (e: E) => {
const tags = Tags.fromEvent(e) const tags = Tags.wrap(await tryCatch(() => JSON.parse(e.content)) || [])
const request = await tryCatch(() => JSON.parse(tags.get("request")?.value()))
const responseTags = tags.rejectByValue([request?.id, request?.pubkey])
for (const feed of feedsFromTags(responseTags, mappings)) { for (const feed of feedsFromTags(tags, mappings)) {
feeds.push(feed) feeds.push(feed)
} }
}, },
@@ -118,7 +116,7 @@ export class FeedCompiler<E extends TrustedEvent> {
) )
) )
return this._compileUnion(feeds) return await this._compileUnion(feeds)
} }
async _compileIntersection(feeds: Feed[]): Promise<RequestItem[]> { async _compileIntersection(feeds: Feed[]): Promise<RequestItem[]> {
+2 -2
View File
@@ -21,7 +21,7 @@ export class FeedLoader<E extends TrustedEvent> {
async getLoader([type, ...feed]: Feed, loadOpts: LoadOpts<E>) { async getLoader([type, ...feed]: Feed, loadOpts: LoadOpts<E>) {
if (this.compiler.canCompile([type, ...feed] as Feed)) { if (this.compiler.canCompile([type, ...feed] as Feed)) {
return this._getRequestsLoader(await this.compiler.compile([type, ...feed] as Feed), loadOpts) return this.getRequestsLoader(await this.compiler.compile([type, ...feed] as Feed), loadOpts)
} }
switch(type) { switch(type) {
@@ -38,7 +38,7 @@ export class FeedLoader<E extends TrustedEvent> {
} }
} }
async _getRequestsLoader(requests: RequestItem[], {onEvent, onExhausted}: LoadOpts<E>) { async getRequestsLoader(requests: RequestItem[], {onEvent, onExhausted}: LoadOpts<E>) {
const seen = new Set() const seen = new Set()
const exhausted = new Set() const exhausted = new Set()
const loaders = await Promise.all( const loaders = await Promise.all(
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.0.8", "version": "0.0.9",
"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": {
"@welshman/util": "0.0.10" "@welshman/util": "0.0.11"
} }
} }
+2 -2
View File
@@ -31,8 +31,8 @@
"typescript": "~5.1.6" "typescript": "~5.1.6"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.7", "@welshman/lib": "0.0.8",
"@welshman/util": "0.0.10", "@welshman/util": "0.0.11",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"ws": "^8.16.0" "ws": "^8.16.0"
} }
+1 -1
View File
@@ -31,7 +31,7 @@
"typescript": "~5.1.6" "typescript": "~5.1.6"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.7", "@welshman/lib": "0.0.8",
"nostr-tools": "^2.3.2" "nostr-tools": "^2.3.2"
} }
} }