applesauce-core 0.0.0-next-20250130155410 → 0.0.0-next-20250131214149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NostrEvent } from "nostr-tools";
|
|
2
2
|
export declare const ContactsRelaysSymbol: unique symbol;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getRelaysFromContactsEvent(event: NostrEvent): Map<string, "all" | "inbox" | "outbox"> | null;
|
package/dist/helpers/contacts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOrComputeCachedValue } from "./cache.js";
|
|
2
2
|
import { safeRelayUrl } from "./relays.js";
|
|
3
3
|
export const ContactsRelaysSymbol = Symbol.for("contacts-relays");
|
|
4
|
-
export function
|
|
4
|
+
export function getRelaysFromContactsEvent(event) {
|
|
5
5
|
return getOrComputeCachedValue(event, ContactsRelaysSymbol, () => {
|
|
6
6
|
try {
|
|
7
7
|
const relayJson = JSON.parse(event.content);
|
package/dist/helpers/relays.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export declare function getSeenRelays(event: NostrEvent): Set<string> | undefine
|
|
|
10
10
|
export declare function validateRelayURL(relay: string | URL): URL;
|
|
11
11
|
export declare function safeRelayUrl(relayUrl: string | URL): string | null;
|
|
12
12
|
export declare function safeRelayUrls(urls: Iterable<string>): string[];
|
|
13
|
+
export declare function mergeRelaySets(...sources: (Iterable<string> | undefined)[]): string[];
|
package/dist/helpers/relays.js
CHANGED
|
@@ -29,3 +29,16 @@ export function safeRelayUrl(relayUrl) {
|
|
|
29
29
|
export function safeRelayUrls(urls) {
|
|
30
30
|
return Array.from(urls).map(safeRelayUrl).filter(Boolean);
|
|
31
31
|
}
|
|
32
|
+
export function mergeRelaySets(...sources) {
|
|
33
|
+
const set = new Set();
|
|
34
|
+
for (const src of sources) {
|
|
35
|
+
if (!src)
|
|
36
|
+
continue;
|
|
37
|
+
for (const url of src) {
|
|
38
|
+
const safe = safeRelayUrl(url);
|
|
39
|
+
if (safe)
|
|
40
|
+
set.add(safe);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Array.from(set);
|
|
44
|
+
}
|