Bump versions, move getAdapter to context

This commit is contained in:
Jon Staab
2025-04-01 14:24:32 -07:00
parent 540726531f
commit 1cbcb0ae4a
15 changed files with 91 additions and 126 deletions
+41 -76
View File
@@ -7600,6 +7600,7 @@
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz",
"integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
@@ -7672,18 +7673,18 @@
}, },
"packages/app": { "packages/app": {
"name": "@welshman/app", "name": "@welshman/app",
"version": "0.0.44", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"@welshman/dvm": "^0.0.15", "@welshman/dvm": "^0.1.1",
"@welshman/feeds": "^0.1.0", "@welshman/feeds": "^0.1.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"@welshman/signer": "^0.1.1", "@welshman/signer": "^0.1.3",
"@welshman/store": "^0.1.0", "@welshman/store": "^0.1.2",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"fuse.js": "^7.0.0", "fuse.js": "^7.0.0",
"idb": "^8.0.0", "idb": "^8.0.0",
"svelte": "^4.2.18", "svelte": "^4.2.18",
@@ -7702,18 +7703,6 @@
"events": "^3.3.0" "events": "^3.3.0"
} }
}, },
"packages/app/node_modules/@welshman/net": {
"version": "0.0.49",
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.49.tgz",
"integrity": "sha512-DvsBh+MGIZtRd08itpxM8H40tNB2CuEx1ayydnIjk/bX9J2SgfjoFcMhr0mJ8PdSYvwmfRV95T4gF19ni8ANeQ==",
"license": "MIT",
"dependencies": {
"@welshman/lib": "^0.1.0",
"@welshman/util": "^0.1.0",
"isomorphic-ws": "^5.0.0",
"ws": "^8.16.0"
}
},
"packages/app/node_modules/@welshman/signer/node_modules/@welshman/lib": { "packages/app/node_modules/@welshman/signer/node_modules/@welshman/lib": {
"version": "0.0.41", "version": "0.0.41",
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.41.tgz", "resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.41.tgz",
@@ -7752,11 +7741,11 @@
}, },
"packages/content": { "packages/content": {
"name": "@welshman/content", "name": "@welshman/content",
"version": "0.1.1", "version": "0.1.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@braintree/sanitize-url": "^7.0.2", "@braintree/sanitize-url": "^7.0.2",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"nostr-tools": "^2.7.2" "nostr-tools": "^2.7.2"
}, },
"engines": { "engines": {
@@ -7765,14 +7754,14 @@
}, },
"packages/dvm": { "packages/dvm": {
"name": "@welshman/dvm", "name": "@welshman/dvm",
"version": "0.0.15", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@noble/hashes": "^1.6.1", "@noble/hashes": "^1.6.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/signer": "^0.1.1", "@welshman/signer": "^0.1.3",
"@welshman/util": "^0.1.0" "@welshman/util": "^0.1.2"
} }
}, },
"packages/dvm/node_modules/@noble/hashes": { "packages/dvm/node_modules/@noble/hashes": {
@@ -7785,21 +7774,9 @@
"url": "https://paulmillr.com/funding/" "url": "https://paulmillr.com/funding/"
} }
}, },
"packages/dvm/node_modules/@welshman/net": {
"version": "0.0.49",
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.49.tgz",
"integrity": "sha512-DvsBh+MGIZtRd08itpxM8H40tNB2CuEx1ayydnIjk/bX9J2SgfjoFcMhr0mJ8PdSYvwmfRV95T4gF19ni8ANeQ==",
"license": "MIT",
"dependencies": {
"@welshman/lib": "^0.1.0",
"@welshman/util": "^0.1.0",
"isomorphic-ws": "^5.0.0",
"ws": "^8.16.0"
}
},
"packages/editor": { "packages/editor": {
"name": "@welshman/editor", "name": "@welshman/editor",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tiptap/core": "^2.11.5", "@tiptap/core": "^2.11.5",
@@ -7815,8 +7792,8 @@
"@tiptap/extension-text": "^2.11.5", "@tiptap/extension-text": "^2.11.5",
"@tiptap/pm": "^2.11.5", "@tiptap/pm": "^2.11.5",
"@tiptap/suggestion": "^2.11.5", "@tiptap/suggestion": "^2.11.5",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"nostr-editor": "^0.0.4-pre.13", "nostr-editor": "^0.0.4-pre.13",
"nostr-tools": "^2.10.4", "nostr-tools": "^2.10.4",
"tippy.js": "^6.3.7" "tippy.js": "^6.3.7"
@@ -7824,16 +7801,16 @@
}, },
"packages/feeds": { "packages/feeds": {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0" "@welshman/util": "^0.1.2"
} }
}, },
"packages/lib": { "packages/lib": {
"name": "@welshman/lib", "name": "@welshman/lib",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@scure/base": "^1.1.6", "@scure/base": "^1.1.6",
@@ -7853,12 +7830,12 @@
}, },
"packages/net": { "packages/net": {
"name": "@welshman/net", "name": "@welshman/net",
"version": "0.0.49", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"typed-emitter": "^2.1.0" "typed-emitter": "^2.1.0"
} }
@@ -7877,23 +7854,23 @@
}, },
"packages/relay": { "packages/relay": {
"name": "@welshman/relay", "name": "@welshman/relay",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0" "@welshman/util": "^0.1.2"
} }
}, },
"packages/signer": { "packages/signer": {
"name": "@welshman/signer", "name": "@welshman/signer",
"version": "0.1.1", "version": "0.1.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@noble/curves": "^1.7.0", "@noble/curves": "^1.7.0",
"@noble/hashes": "^1.6.1", "@noble/hashes": "^1.6.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"nostr-tools": "^2.7.2" "nostr-tools": "^2.7.2"
}, },
"engines": { "engines": {
@@ -7936,36 +7913,24 @@
"url": "https://paulmillr.com/funding/" "url": "https://paulmillr.com/funding/"
} }
}, },
"packages/signer/node_modules/@welshman/net": {
"version": "0.0.49",
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.49.tgz",
"integrity": "sha512-DvsBh+MGIZtRd08itpxM8H40tNB2CuEx1ayydnIjk/bX9J2SgfjoFcMhr0mJ8PdSYvwmfRV95T4gF19ni8ANeQ==",
"license": "MIT",
"dependencies": {
"@welshman/lib": "^0.1.0",
"@welshman/util": "^0.1.0",
"isomorphic-ws": "^5.0.0",
"ws": "^8.16.0"
}
},
"packages/store": { "packages/store": {
"name": "@welshman/store", "name": "@welshman/store",
"version": "0.1.0", "version": "0.1.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"svelte": "^4.2.18" "svelte": "^4.2.18"
} }
}, },
"packages/util": { "packages/util": {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.1.0", "version": "0.1.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/ws": "^8.5.13", "@types/ws": "^8.5.13",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"nostr-tools": "^2.7.2", "nostr-tools": "^2.7.2",
"nostr-wasm": "^0.1.0" "nostr-wasm": "^0.1.0"
}, },
+9 -9
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/app", "name": "@welshman/app",
"version": "0.1.0", "version": "0.1.1",
"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.",
@@ -27,14 +27,14 @@
}, },
"dependencies": { "dependencies": {
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"@welshman/dvm": "^0.0.15", "@welshman/dvm": "^0.1.1",
"@welshman/feeds": "^0.1.0", "@welshman/feeds": "^0.1.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/signer": "^0.1.1", "@welshman/signer": "^0.1.3",
"@welshman/store": "^0.1.0", "@welshman/store": "^0.1.2",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"fuse.js": "^7.0.0", "fuse.js": "^7.0.0",
"idb": "^8.0.0", "idb": "^8.0.0",
"svelte": "^4.2.18", "svelte": "^4.2.18",
+6 -6
View File
@@ -175,7 +175,7 @@ export const getPubkeyRelays = (pubkey: string, mode?: string) => {
} }
} }
export const globalRouterOptions: RouterOptions = { export const routerContext: RouterOptions = {
getRelayQuality, getRelayQuality,
getPubkeyRelays, getPubkeyRelays,
getFallbackRelays: () => ["wss://relay.damus.io/", "wss://nos.lol/"], getFallbackRelays: () => ["wss://relay.damus.io/", "wss://nos.lol/"],
@@ -191,15 +191,15 @@ export class Router {
readonly options: RouterOptions readonly options: RouterOptions
static configure(options: RouterOptions) { static configure(options: RouterOptions) {
Object.assign(globalRouterOptions, options) Object.assign(routerContext, options)
} }
static get() { static get() {
return new Router(globalRouterOptions) return new Router(routerContext)
} }
constructor(options: RouterOptions) { constructor(options: RouterOptions) {
this.options = mergeLeft(options, globalRouterOptions) this.options = mergeLeft(options, routerContext)
} }
// Utilities derived from options // Utilities derived from options
@@ -420,7 +420,7 @@ type FilterSelectionRule = (filter: Filter) => FilterScenario[]
export const getFilterSelectionsForSearch = (filter: Filter) => { export const getFilterSelectionsForSearch = (filter: Filter) => {
if (!filter.search) return [] if (!filter.search) return []
const relays = globalRouterOptions.getSearchRelays?.() || [] const relays = routerContext.getSearchRelays?.() || []
return [{filter, scenario: Router.get().FromRelays(relays).weight(10)}] return [{filter, scenario: Router.get().FromRelays(relays).weight(10)}]
} }
@@ -441,7 +441,7 @@ export const getFilterSelectionsForIndexedKinds = (filter: Filter) => {
if (kinds.length === 0) return [] if (kinds.length === 0) return []
const relays = globalRouterOptions.getIndexerRelays?.() || [] const relays = routerContext.getIndexerRelays?.() || []
return [ return [
{ {
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/content", "name": "@welshman/content",
"version": "0.1.1", "version": "0.1.2",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities for parsing nostr note content.", "description": "A collection of utilities for parsing nostr note content.",
@@ -30,7 +30,7 @@
}, },
"dependencies": { "dependencies": {
"@braintree/sanitize-url": "^7.0.2", "@braintree/sanitize-url": "^7.0.2",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"nostr-tools": "^2.7.2" "nostr-tools": "^2.7.2"
} }
} }
+5 -5
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/dvm", "name": "@welshman/dvm",
"version": "0.1.0", "version": "0.1.1",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities for building nostr DVMs.", "description": "A collection of utilities for building nostr DVMs.",
@@ -27,9 +27,9 @@
}, },
"dependencies": { "dependencies": {
"@noble/hashes": "^1.6.1", "@noble/hashes": "^1.6.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"@welshman/signer": "^0.1.1" "@welshman/signer": "^0.1.3"
} }
} }
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/editor", "name": "@welshman/editor",
"version": "0.1.0", "version": "0.1.1",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A batteries-included nostr editor.", "description": "A batteries-included nostr editor.",
@@ -40,8 +40,8 @@
"@tiptap/extension-text": "^2.11.5", "@tiptap/extension-text": "^2.11.5",
"@tiptap/pm": "^2.11.5", "@tiptap/pm": "^2.11.5",
"@tiptap/suggestion": "^2.11.5", "@tiptap/suggestion": "^2.11.5",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"nostr-editor": "^0.0.4-pre.13", "nostr-editor": "^0.0.4-pre.13",
"nostr-tools": "^2.10.4", "nostr-tools": "^2.10.4",
"tippy.js": "^6.3.7" "tippy.js": "^6.3.7"
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.1.0", "version": "0.1.1",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "Utilities for building dynamic nostr feeds.", "description": "Utilities for building dynamic nostr feeds.",
@@ -26,7 +26,7 @@
"fix": "gts fix" "fix": "gts fix"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0" "@welshman/util": "^0.1.2"
} }
} }
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/net", "name": "@welshman/net",
"version": "0.1.0", "version": "0.1.1",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "Utilities for connecting with nostr relays.", "description": "Utilities for connecting with nostr relays.",
@@ -26,9 +26,9 @@
"fix": "gts fix" "fix": "gts fix"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"typed-emitter": "^2.1.0" "typed-emitter": "^2.1.0"
} }
+1 -3
View File
@@ -99,9 +99,7 @@ export class MockAdapter extends AbstractAdapter {
} }
} }
export type AdapterContext = Partial<NetContext> & { export type AdapterContext = Partial<NetContext>
getAdapter?: (url: string, context: AdapterContext) => AbstractAdapter
}
export const getAdapter = (url: string, adapterContext: AdapterContext = {}) => { export const getAdapter = (url: string, adapterContext: AdapterContext = {}) => {
const context = mergeRight(netContext, adapterContext as any) const context = mergeRight(netContext, adapterContext as any)
+2
View File
@@ -1,5 +1,6 @@
import {Repository} from "@welshman/relay" import {Repository} from "@welshman/relay"
import {verifyEvent, TrustedEvent, SignedEvent} from "@welshman/util" import {verifyEvent, TrustedEvent, SignedEvent} from "@welshman/util"
import {AbstractAdapter} from "./adapter.js"
import {Pool} from "./pool.js" import {Pool} from "./pool.js"
export type NetContext = { export type NetContext = {
@@ -7,6 +8,7 @@ export type NetContext = {
repository: Repository repository: Repository
isEventValid: (event: TrustedEvent, url: string) => boolean isEventValid: (event: TrustedEvent, url: string) => boolean
isEventDeleted: (event: TrustedEvent, url: string) => boolean isEventDeleted: (event: TrustedEvent, url: string) => boolean
getAdapter?: (url: string, context: NetContext) => AbstractAdapter
} }
export const netContext: NetContext = { export const netContext: NetContext = {
+2 -2
View File
@@ -124,8 +124,8 @@ export class SingleRequest extends (EventEmitter as new () => TypedEmitter<Singl
} }
// Timeout our subscription // Timeout our subscription
if (this.options.timeout) { if (this.options.timeout || this.options.autoClose) {
setTimeout(() => this.close(), this.options.timeout) setTimeout(() => this.close(), this.options.timeout || 10000)
} }
// Start asynchronously so the caller can set up listeners // Start asynchronously so the caller can set up listeners
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/relay", "name": "@welshman/relay",
"version": "0.1.0", "version": "0.1.1",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "An in-memory nostr relay implementation.", "description": "An in-memory nostr relay implementation.",
@@ -26,7 +26,7 @@
"fix": "gts fix" "fix": "gts fix"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0" "@welshman/util": "^0.1.2"
} }
} }
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/signer", "name": "@welshman/signer",
"version": "0.1.2", "version": "0.1.3",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A nostr signer implemenation supporting several login methods.", "description": "A nostr signer implemenation supporting several login methods.",
@@ -31,9 +31,9 @@
"dependencies": { "dependencies": {
"@noble/curves": "^1.7.0", "@noble/curves": "^1.7.0",
"@noble/hashes": "^1.6.1", "@noble/hashes": "^1.6.1",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/net": "^0.0.49", "@welshman/net": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"nostr-tools": "^2.7.2" "nostr-tools": "^2.7.2"
}, },
"peerDependencies": { "peerDependencies": {
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/store", "name": "@welshman/store",
"version": "0.1.1", "version": "0.1.2",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities based on svelte/store for use with welshman", "description": "A collection of utilities based on svelte/store for use with welshman",
@@ -26,9 +26,9 @@
"fix": "gts fix" "fix": "gts fix"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"@welshman/util": "^0.1.0", "@welshman/util": "^0.1.2",
"@welshman/relay": "^0.1.0", "@welshman/relay": "^0.1.1",
"svelte": "^4.2.18" "svelte": "^4.2.18"
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.1.1", "version": "0.1.2",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of nostr-related utilities.", "description": "A collection of nostr-related utilities.",
@@ -30,7 +30,7 @@
}, },
"dependencies": { "dependencies": {
"@types/ws": "^8.5.13", "@types/ws": "^8.5.13",
"@welshman/lib": "^0.1.0", "@welshman/lib": "^0.1.1",
"nostr-tools": "^2.7.2", "nostr-tools": "^2.7.2",
"nostr-wasm": "^0.1.0" "nostr-wasm": "^0.1.0"
} }