Bump welshman

This commit is contained in:
Jon Staab
2024-09-10 20:19:57 -07:00
parent 618049c4af
commit ed365f7e38
5 changed files with 73 additions and 127 deletions

76
package-lock.json generated
View File

@@ -23,12 +23,12 @@
"@tiptap/extension-text": "^2.6.6",
"@tiptap/suggestion": "^2.6.4",
"@types/throttle-debounce": "^5.0.2",
"@welshman/app": "^0.0.1",
"@welshman/lib": "^0.0.15",
"@welshman/net": "^0.0.20",
"@welshman/signer": "^0.0.4",
"@welshman/store": "^0.0.4",
"@welshman/util": "^0.0.28",
"@welshman/app": "^0.0.4",
"@welshman/lib": "^0.0.17",
"@welshman/net": "^0.0.21",
"@welshman/signer": "^0.0.5",
"@welshman/store": "^0.0.5",
"@welshman/util": "^0.0.30",
"daisyui": "^4.12.10",
"fuse.js": "^7.0.0",
"idb": "^8.0.0",
@@ -1654,19 +1654,25 @@
}
},
"node_modules/@welshman/app": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.1.tgz",
"integrity": "sha512-3vvbfOwMhY6iSyswhTlmL1TCkHVF7nlpxUVvbNpgS4KD2gIs4YFr9WqAlSL4x1Ebjdm0EE3KakCr3YodP5kIOg==",
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.4.tgz",
"integrity": "sha512-Xouy66xz1tnMjlDAlxtKF+1lHVJyM2sRiC6RONDmt75HXUnuvMX19sssRy4AFwb8jychBr8EMjYanVX2EV1Sow==",
"dependencies": {
"@welshman/lib": "0.0.15",
"@welshman/util": "0.0.28",
"svelte": "^4.2.18"
"@welshman/lib": "0.0.17",
"@welshman/net": "0.0.21",
"@welshman/signer": "0.0.5",
"@welshman/store": "0.0.5",
"@welshman/util": "0.0.30",
"fuse.js": "^7.0.0",
"idb": "^8.0.0",
"svelte": "^4.2.18",
"throttle-debounce": "^5.0.2"
}
},
"node_modules/@welshman/lib": {
"version": "0.0.15",
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.15.tgz",
"integrity": "sha512-3sKbLHq+G57Cc1E9rRx1QeaNo+Oy/rE+bko7SJBq+p9L65xOxXal8rfrlCoiyKWiJLIkDMwSWtitCWjYR2DP8w==",
"version": "0.0.17",
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.17.tgz",
"integrity": "sha512-C0yelgMD6F5hgIcDjflJ+1Qg9/yvodtxSE00p1DZgkTn0s/7znvxraYpQInQdhqp8vJ8r+3coR3YagrRdm9+LA==",
"dependencies": {
"@scure/base": "^1.1.6",
"@types/events": "^3.0.3",
@@ -1676,43 +1682,43 @@
}
},
"node_modules/@welshman/net": {
"version": "0.0.20",
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.20.tgz",
"integrity": "sha512-GPoQ3cuPV5t9gqhRoKQ2xxyVejdbQLqyXY6OxwXwtuSikbWt4Y9QWw/CwENn2doQ2JnE1lVkIoO7xwHJxPcPlQ==",
"version": "0.0.21",
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.21.tgz",
"integrity": "sha512-BOWRevNJjyNHshxr0eFn/yBjjVIuvofyy/Q+eYuLLTRwolFkqmaiN8xuG3wFndPi5z2uuC87Ay4PmRTzp+kCSg==",
"dependencies": {
"@welshman/lib": "0.0.15",
"@welshman/util": "0.0.28",
"@welshman/lib": "0.0.17",
"@welshman/util": "0.0.30",
"isomorphic-ws": "^5.0.0",
"ws": "^8.16.0"
}
},
"node_modules/@welshman/signer": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/@welshman/signer/-/signer-0.0.4.tgz",
"integrity": "sha512-CX6mdLDkbtOQ8jXo0RNhAmBflZ52j896BPZJRbMXk0B9yC8L7df//gPOimAYy+ffZV7NOb495LaBsrwfvJhKcw==",
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/@welshman/signer/-/signer-0.0.5.tgz",
"integrity": "sha512-i3SUEF4yAb8up2qk6hdLyRytnkRt5W+5KyrbN1RmFcQpDC/foa3nYO+Q0mydwXIX3h6HAV7MzO8vi9tHWJ30Ww==",
"dependencies": {
"@welshman/lib": "0.0.15",
"@welshman/net": "0.0.20",
"@welshman/util": "0.0.28",
"@welshman/lib": "0.0.17",
"@welshman/net": "0.0.21",
"@welshman/util": "0.0.30",
"nostr-tools": "^2.7.2"
}
},
"node_modules/@welshman/store": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/@welshman/store/-/store-0.0.4.tgz",
"integrity": "sha512-bdI89bONcJugBS7rqoLxxZfWPSHaJVOH11ohnA8uhZX7PwuWtNwUHAwwsl3YTBUMyB1Vfp5P4rsdC7LEmAQloA==",
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/@welshman/store/-/store-0.0.5.tgz",
"integrity": "sha512-AH8TsaZ63s4ln4NBO2/DjtmBFPZlxXnDiyV3wScj6Ts0vahZCinlrL8pAIfLzvZ2QvjcnFiPf081kghhr3Baaw==",
"dependencies": {
"@welshman/lib": "0.0.15",
"@welshman/util": "0.0.28",
"@welshman/lib": "0.0.17",
"@welshman/util": "0.0.30",
"svelte": "^4.2.18"
}
},
"node_modules/@welshman/util": {
"version": "0.0.28",
"resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.28.tgz",
"integrity": "sha512-2U77yGM1cc9UeM8L8YQvqxSClv9x1q9u94rJYajGV0LJx3O0Iog4gRlb8aPei8fSHst92JemcqF45ghrFTCeeQ==",
"version": "0.0.30",
"resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.30.tgz",
"integrity": "sha512-CYLtaXfCod5Xo/OCXPUGYKwT+fRwm5DU7ASqcGwPuB/vadDodT/OJPSmrMH9Pq63VY9xK4gX/I2ma/rKRokdpg==",
"dependencies": {
"@welshman/lib": "0.0.15",
"@welshman/lib": "0.0.17",
"nostr-tools": "^2.7.2"
}
},

View File

@@ -48,12 +48,12 @@
"@tiptap/extension-text": "^2.6.6",
"@tiptap/suggestion": "^2.6.4",
"@types/throttle-debounce": "^5.0.2",
"@welshman/app": "^0.0.1",
"@welshman/lib": "^0.0.15",
"@welshman/net": "^0.0.20",
"@welshman/signer": "^0.0.4",
"@welshman/store": "^0.0.4",
"@welshman/util": "^0.0.28",
"@welshman/lib": "^0.0.17",
"@welshman/util": "^0.0.30",
"@welshman/store": "^0.0.5",
"@welshman/net": "^0.0.21",
"@welshman/signer": "^0.0.5",
"@welshman/app": "^0.0.4",
"daisyui": "^4.12.10",
"fuse.js": "^7.0.0",
"idb": "^8.0.0",

View File

@@ -11,7 +11,7 @@ import {PublishStatus} from "@welshman/net"
import {
pubkey,
repository,
loadOne,
load,
makeThunk,
publishThunk,
loadProfile,
@@ -56,26 +56,12 @@ export const makeIMeta = (url: string, data: Record<string, string>) => [
// Loaders
export const loadUserData = async (pubkey: string, hints: string[] = []) => {
const relaySelections = await loadRelaySelections(pubkey, INDEXER_RELAYS)
const relays = uniq([
...getRelayTagValues(relaySelections?.tags || []),
...INDEXER_RELAYS,
...hints,
export const loadUserData = (pubkey: string, hints: string[] = []) =>
Promise.all([
loadProfile(pubkey),
loadFollows(pubkey),
loadMutes(pubkey),
])
const membership = await loadGroupMembership(pubkey, relays)
const promises = [
loadProfile(pubkey, relays),
loadFollows(pubkey, relays),
loadMutes(pubkey, relays),
]
for (const [_, nom, url] of getGroupTags(membership?.event.tags || [])) {
promises.push(loadGroup(nom, [url]))
}
await Promise.all(promises)
}
// Updates
@@ -110,7 +96,7 @@ export const sendJoinRequest = async (nom: string, url: string): Promise<[boolea
if (message.includes("already a member")) return [true, ""]
if (status !== PublishStatus.Success) return [false, message]
if (await loadOne({filters, relays})) return [true, ""]
if (await load({filters, relays})) return [true, ""]
return [
false,

View File

@@ -1,7 +1,7 @@
import type {FuseResult} from "fuse.js"
import {get, derived} from "svelte/store"
import type {Maybe} from "@welshman/lib"
import {max, between, groupBy, pushToMapKey, nthEq, stripProtocol, indexBy} from "@welshman/lib"
import {setContext, max, between, groupBy, pushToMapKey, nthEq, stripProtocol, indexBy} from "@welshman/lib"
import {
getIdFilters,
getIdentifier,
@@ -16,7 +16,6 @@ import {
} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
import {
env,
pubkey,
repository,
createSearch,
@@ -28,6 +27,9 @@ import {
profilesByPubkey,
loadRelaySelections,
getWriteRelayUrls,
getDefaultAppContext,
getDefaultNetContext,
makeRouter,
} from "@welshman/app"
import type {Relay} from "@welshman/app"
import type {SubscribeRequest} from "@welshman/net"
@@ -46,7 +48,16 @@ export const DUFFLEPUD_URL = "https://dufflepud.onrender.com"
export const REACTION_KINDS = [REACTION, ZAP_RESPONSE]
Object.assign(env, {DUFFLEPUD_URL})
setContext({
net: getDefaultNetContext(),
app: getDefaultAppContext({
dufflepudUrl: DUFFLEPUD_URL,
indexerRelays: INDEXER_RELAYS,
requestTimeout: 5000,
router: makeRouter(),
}),
})
export const deriveEvent = (idOrAddress: string, hints: string[] = []) => {
let attempted = false

View File

@@ -17,6 +17,7 @@
publishStatusData,
plaintext,
freshness,
storageAdapters,
} from "@welshman/app"
import type {PublishStatusData, PublishStatusDataByUrlById} from "@welshman/app"
import {createEventStore, adapter} from "@welshman/store"
@@ -59,7 +60,7 @@
onMount(() => {
Object.assign(window, {get, state})
ready = initStorage(3, {
ready = initStorage('flotilla', 3, {
events: {
keyPath: "id",
store: createEventStore(repository),
@@ -72,67 +73,9 @@
keyPath: "nip05",
store: handles,
},
publishStatus: {
keyPath: "id",
store: adapter({
store: publishStatusData,
forward: ($psd: PublishStatusDataByUrlById) => {
const data = []
for (const itemsByUrl of Object.values($psd)) {
for (const item of Object.values(itemsByUrl)) {
data.push(item)
}
}
return data
},
backward: (data: PublishStatusData[]) => {
const result: PublishStatusDataByUrlById = {}
for (const item of data) {
result[item.id] = result[item.id] || {}
result[item.id][item.url] = item
}
return result
},
}),
},
freshness: {
keyPath: "key",
store: adapter({
store: freshness,
forward: ($freshness: Record<string, number>) =>
Object.entries($freshness).map(([key, ts]) => ({key, ts})),
backward: (data: any[]) => {
const result: Record<string, number> = {}
for (const {key, ts} of data) {
result[key] = ts
}
return result
},
}),
},
plaintext: {
keyPath: "id",
store: adapter({
store: plaintext,
forward: ($plaintext: Record<string, string>) =>
Object.entries($plaintext).map(([id, plaintext]) => ({id, plaintext})),
backward: (data: any[]) => {
const result: Record<string, string> = {}
for (const {id, plaintext} of data) {
result[id] = plaintext
}
return result
},
}),
},
publishStatus: storageAdapters.fromObjectStore(publishStatusData),
freshness: storageAdapters.fromObjectStore(freshness),
plaintext: storageAdapters.fromObjectStore(plaintext),
}).then(() => sleep(300)) // Wait an extra few ms because of repository throttle
dialog.addEventListener("close", () => {