@welshman/app 0.0.1 → 0.0.2
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.
- package/build/src/collection.cjs +40 -0
- package/build/src/collection.cjs.map +1 -0
- package/build/src/collection.d.ts +15 -0
- package/build/src/collection.mjs +36 -0
- package/build/src/collection.mjs.map +1 -0
- package/build/src/core.cjs +32 -0
- package/build/src/core.cjs.map +1 -0
- package/build/src/core.d.ts +16 -0
- package/build/src/core.mjs +26 -0
- package/build/src/core.mjs.map +1 -0
- package/build/src/follows.cjs +31 -0
- package/build/src/follows.cjs.map +1 -0
- package/build/src/follows.d.ts +9 -0
- package/build/src/follows.mjs +27 -0
- package/build/src/follows.mjs.map +1 -0
- package/build/src/freshness.cjs +21 -0
- package/build/src/freshness.cjs.map +1 -0
- package/build/src/freshness.d.ts +8 -0
- package/build/src/freshness.mjs +14 -0
- package/build/src/freshness.mjs.map +1 -0
- package/build/src/handles.cjs +43 -0
- package/build/src/handles.cjs.map +1 -0
- package/build/src/handles.d.ts +16 -0
- package/build/src/handles.mjs +37 -0
- package/build/src/handles.mjs.map +1 -0
- package/build/src/index.cjs +23 -2
- package/build/src/index.cjs.map +1 -1
- package/build/src/index.d.ts +15 -2
- package/build/src/index.mjs +23 -2
- package/build/src/index.mjs.map +1 -1
- package/build/src/mutes.cjs +31 -0
- package/build/src/mutes.cjs.map +1 -0
- package/build/src/mutes.d.ts +9 -0
- package/build/src/mutes.mjs +27 -0
- package/build/src/mutes.mjs.map +1 -0
- package/build/src/plaintext.cjs +24 -0
- package/build/src/plaintext.cjs.map +1 -0
- package/build/src/plaintext.d.ts +8 -0
- package/build/src/plaintext.mjs +18 -0
- package/build/src/plaintext.mjs.map +1 -0
- package/build/src/profiles.cjs +40 -0
- package/build/src/profiles.cjs.map +1 -0
- package/build/src/profiles.d.ts +13 -0
- package/build/src/profiles.mjs +34 -0
- package/build/src/profiles.mjs.map +1 -0
- package/build/src/relaySelections.cjs +28 -0
- package/build/src/relaySelections.cjs.map +1 -0
- package/build/src/relaySelections.d.ts +12 -0
- package/build/src/relaySelections.mjs +22 -0
- package/build/src/relaySelections.mjs.map +1 -0
- package/build/src/relays.cjs +122 -0
- package/build/src/relays.cjs.map +1 -0
- package/build/src/relays.d.ts +28 -0
- package/build/src/relays.mjs +115 -0
- package/build/src/relays.mjs.map +1 -0
- package/build/src/session.cjs +27 -18
- package/build/src/session.cjs.map +1 -1
- package/build/src/session.d.ts +13 -1
- package/build/src/session.mjs +23 -18
- package/build/src/session.mjs.map +1 -1
- package/build/src/storage.cjs +91 -0
- package/build/src/storage.cjs.map +1 -0
- package/build/src/storage.d.ts +21 -0
- package/build/src/storage.mjs +82 -0
- package/build/src/storage.mjs.map +1 -0
- package/build/src/thunk.cjs +44 -0
- package/build/src/thunk.cjs.map +1 -0
- package/build/src/thunk.d.ts +37 -0
- package/build/src/thunk.mjs +39 -0
- package/build/src/thunk.mjs.map +1 -0
- package/build/src/topics.cjs +30 -0
- package/build/src/topics.cjs.map +1 -0
- package/build/src/topics.d.ts +10 -0
- package/build/src/topics.mjs +27 -0
- package/build/src/topics.mjs.map +1 -0
- package/build/src/util.cjs +62 -0
- package/build/src/util.cjs.map +1 -0
- package/build/src/util.d.ts +22 -0
- package/build/src/util.mjs +47 -0
- package/build/src/util.mjs.map +1 -0
- package/build/src/zappers.cjs +43 -0
- package/build/src/zappers.cjs.map +1 -0
- package/build/src/zappers.d.ts +10 -0
- package/build/src/zappers.mjs +38 -0
- package/build/src/zappers.mjs.map +1 -0
- package/package.json +10 -4
- package/build/src/relay.cjs +0 -13
- package/build/src/relay.cjs.map +0 -1
- package/build/src/relay.d.ts +0 -6
- package/build/src/relay.mjs +0 -10
- package/build/src/relay.mjs.map +0 -1
- package/build/src/types.cjs +0 -3
- package/build/src/types.cjs.map +0 -1
- package/build/src/types.d.ts +0 -15
- package/build/src/types.mjs +0 -2
- package/build/src/types.mjs.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collection = void 0;
|
|
4
|
+
const store_1 = require("svelte/store");
|
|
5
|
+
const lib_1 = require("@welshman/lib");
|
|
6
|
+
const store_2 = require("@welshman/store");
|
|
7
|
+
const freshness_1 = require("./freshness.cjs");
|
|
8
|
+
const collection = ({ name, store, getKey, load, }) => {
|
|
9
|
+
const indexStore = (0, store_2.withGetter)((0, store_1.derived)(store, $items => (0, lib_1.indexBy)(getKey, $items)));
|
|
10
|
+
const getItem = (key) => indexStore.get().get(key);
|
|
11
|
+
const pending = new Map();
|
|
12
|
+
const loadItem = async (key, ...args) => {
|
|
13
|
+
if ((0, freshness_1.getFreshness)(name, key) > (0, lib_1.now)() - 3600) {
|
|
14
|
+
return indexStore.get().get(key);
|
|
15
|
+
}
|
|
16
|
+
if (pending.has(key)) {
|
|
17
|
+
await pending.get(key);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
(0, freshness_1.setFreshness)(name, key, (0, lib_1.now)());
|
|
21
|
+
const promise = load(key, ...args);
|
|
22
|
+
pending.set(key, promise);
|
|
23
|
+
await promise;
|
|
24
|
+
pending.delete(key);
|
|
25
|
+
}
|
|
26
|
+
return indexStore.get().get(key);
|
|
27
|
+
};
|
|
28
|
+
const deriveItem = (key, ...args) => {
|
|
29
|
+
if (!key) {
|
|
30
|
+
return (0, store_1.readable)(undefined);
|
|
31
|
+
}
|
|
32
|
+
// If we don't yet have the item, or it's stale, trigger a request for it. The derived
|
|
33
|
+
// store will update when it arrives
|
|
34
|
+
load(key, ...args);
|
|
35
|
+
return (0, store_1.derived)(indexStore, $index => $index.get(key));
|
|
36
|
+
};
|
|
37
|
+
return { indexStore, deriveItem, loadItem, getItem };
|
|
38
|
+
};
|
|
39
|
+
exports.collection = collection;
|
|
40
|
+
//# sourceMappingURL=collection.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.c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,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAG,IAAc,EAAE,EAAE;QAC3D,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAA;SAC3B;QAED,sFAAsF;QACtF,oCAAoC;QACpC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;QAElB,OAAO,IAAA,eAAO,EAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,CAAC,CAAA;IAED,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAA;AACpD,CAAC,CAAA;AAlDY,QAAA,UAAU,cAkDtB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Readable } from 'svelte/store';
|
|
2
|
+
import { type Maybe } from '@welshman/lib';
|
|
3
|
+
export declare const collection: <T, LoadArgs extends any[]>({ name, store, getKey, load, }: {
|
|
4
|
+
name: string;
|
|
5
|
+
store: Readable<T[]>;
|
|
6
|
+
getKey: (item: T) => string;
|
|
7
|
+
load: (key: string, ...args: LoadArgs) => Promise<any>;
|
|
8
|
+
}) => {
|
|
9
|
+
indexStore: Readable<Map<string, T>> & {
|
|
10
|
+
get: () => Map<string, T>;
|
|
11
|
+
};
|
|
12
|
+
deriveItem: (key: Maybe<string>, ...args: LoadArgs) => Readable<T | undefined>;
|
|
13
|
+
loadItem: (key: string, ...args: LoadArgs) => Promise<T | undefined>;
|
|
14
|
+
getItem: (key: string) => T | undefined;
|
|
15
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readable, derived } from 'svelte/store';
|
|
2
|
+
import { indexBy, now } from '@welshman/lib';
|
|
3
|
+
import { withGetter } from '@welshman/store';
|
|
4
|
+
import { getFreshness, setFreshness } from "./freshness.mjs";
|
|
5
|
+
export const collection = ({ name, store, getKey, load, }) => {
|
|
6
|
+
const indexStore = withGetter(derived(store, $items => indexBy(getKey, $items)));
|
|
7
|
+
const getItem = (key) => indexStore.get().get(key);
|
|
8
|
+
const pending = new Map();
|
|
9
|
+
const loadItem = async (key, ...args) => {
|
|
10
|
+
if (getFreshness(name, key) > now() - 3600) {
|
|
11
|
+
return indexStore.get().get(key);
|
|
12
|
+
}
|
|
13
|
+
if (pending.has(key)) {
|
|
14
|
+
await pending.get(key);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
setFreshness(name, key, now());
|
|
18
|
+
const promise = load(key, ...args);
|
|
19
|
+
pending.set(key, promise);
|
|
20
|
+
await promise;
|
|
21
|
+
pending.delete(key);
|
|
22
|
+
}
|
|
23
|
+
return indexStore.get().get(key);
|
|
24
|
+
};
|
|
25
|
+
const deriveItem = (key, ...args) => {
|
|
26
|
+
if (!key) {
|
|
27
|
+
return readable(undefined);
|
|
28
|
+
}
|
|
29
|
+
// If we don't yet have the item, or it's stale, trigger a request for it. The derived
|
|
30
|
+
// store will update when it arrives
|
|
31
|
+
load(key, ...args);
|
|
32
|
+
return derived(indexStore, $index => $index.get(key));
|
|
33
|
+
};
|
|
34
|
+
return { indexStore, deriveItem, loadItem, getItem };
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=collection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.mjs","sourceRoot":"","sources":["../../src/collection.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAE,OAAO,EAAgB,MAAM,cAAc;OACtD,EAAC,OAAO,EAAc,GAAG,EAAC,MAAM,eAAe;OAC/C,EAAC,UAAU,EAAC,MAAM,iBAAiB;OACnC,EAAC,YAAY,EAAE,YAAY,EAAC;AAEnC,MAAM,CAAC,MAAM,UAAU,GAAG,CAA4B,EACpD,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,GAML,EAAE,EAAE;IACH,MA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AI,CAAC,CAAA;QAElB,OAAO,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,CAAC,CAAA;IAED,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAA;AACpD,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadOne = exports.load = exports.subscribe = exports.tracker = exports.relay = exports.events = exports.repository = exports.env = void 0;
|
|
4
|
+
const lib_1 = require("@welshman/lib");
|
|
5
|
+
const util_1 = require("@welshman/util");
|
|
6
|
+
const net_1 = require("@welshman/net");
|
|
7
|
+
const store_1 = require("@welshman/store");
|
|
8
|
+
exports.env = {
|
|
9
|
+
DUFFLEPUD_URL: undefined,
|
|
10
|
+
};
|
|
11
|
+
exports.repository = new util_1.Repository();
|
|
12
|
+
exports.events = (0, store_1.createEventStore)(exports.repository);
|
|
13
|
+
exports.relay = new util_1.Relay(exports.repository);
|
|
14
|
+
exports.tracker = new net_1.Tracker();
|
|
15
|
+
const subscribe = (request) => {
|
|
16
|
+
const sub = (0, net_1.subscribe)({ delay: 50, authTimeout: 3000, ...request });
|
|
17
|
+
sub.emitter.on("event", (url, e) => {
|
|
18
|
+
exports.repository.publish(e);
|
|
19
|
+
});
|
|
20
|
+
return sub;
|
|
21
|
+
};
|
|
22
|
+
exports.subscribe = subscribe;
|
|
23
|
+
const load = (request) => new Promise(resolve => {
|
|
24
|
+
const sub = (0, exports.subscribe)({ closeOnEose: true, timeout: 3000, ...request });
|
|
25
|
+
const events = [];
|
|
26
|
+
sub.emitter.on("event", (url, e) => events.push(e));
|
|
27
|
+
sub.emitter.on("complete", () => resolve(events));
|
|
28
|
+
});
|
|
29
|
+
exports.load = load;
|
|
30
|
+
const loadOne = async (request) => (0, lib_1.first)(await (0, exports.load)(request));
|
|
31
|
+
exports.loadOne = loadOne;
|
|
32
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.cjs","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,yCAAgD;AAEhD,uCAAiE;AAEjE,2CAAgD;AAEnC,QAAA,GAAG,GAGZ;IACF,aAAa,EAAE,SAAS;CACzB,CAAA;AAEY,QAAA,UAAU,GAAG,IAAI,iBAAU,EAAgB,CAAA;AAE3C,QAAA,MAAM,GAAG,IAAA,wBAAgB,EAAC,kBAAU,CAAC,CAAA;AAErC,QAAA,KAAK,GAAG,IAAI,YAAK,CAAC,kBAAU,CAAC,CAAA;AAE7B,QAAA,OAAO,GAAG,IAAI,aAAO,EAAE,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAC,OAAyB,EAAE,EAAE;IACrD,MAAM,GAAG,GAAG,IAAA,eAAa,EAAC,EAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC,CAAA;IAErE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,CAAe,EAAE,EAAE;QACvD,kBAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AARY,QAAA,SAAS,aAQrB;AAEM,MAAM,IAAI,GAAG,CAAC,OAAyB,EAAE,EAAE,CAChD,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;IACpC,MAAM,GAAG,GAAG,IAAA,iBAAS,EAAC,EAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC,CAAA;IACrE,MAAM,MAAM,GAAmB,EAAE,CAAA;IAEjC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,CAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACzE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AACnD,CAAC,CAAC,CAAA;AAPS,QAAA,IAAI,QAOb;AAEG,MAAM,OAAO,GAAG,KAAK,EAAE,OAAyB,EAAE,EAAE,CAAC,IAAA,WAAK,EAAC,MAAM,IAAA,YAAI,EAAC,OAAO,CAAC,CAAC,CAAA;AAAzE,QAAA,OAAO,WAAkE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import { Repository, Relay } from "@welshman/util";
|
|
3
|
+
import type { TrustedEvent } from "@welshman/util";
|
|
4
|
+
import { Tracker } from "@welshman/net";
|
|
5
|
+
import type { SubscribeRequest } from "@welshman/net";
|
|
6
|
+
export declare const env: {
|
|
7
|
+
DUFFLEPUD_URL?: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
export declare const repository: Repository<TrustedEvent>;
|
|
11
|
+
export declare const events: import("svelte/store").Writable<TrustedEvent[]>;
|
|
12
|
+
export declare const relay: Relay<TrustedEvent>;
|
|
13
|
+
export declare const tracker: Tracker;
|
|
14
|
+
export declare const subscribe: (request: SubscribeRequest) => import("@welshman/net").Subscription;
|
|
15
|
+
export declare const load: (request: SubscribeRequest) => Promise<TrustedEvent[]>;
|
|
16
|
+
export declare const loadOne: (request: SubscribeRequest) => Promise<TrustedEvent>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { first } from "@welshman/lib";
|
|
2
|
+
import { Repository, Relay } from "@welshman/util";
|
|
3
|
+
import { Tracker, subscribe as baseSubscribe } from "@welshman/net";
|
|
4
|
+
import { createEventStore } from "@welshman/store";
|
|
5
|
+
export const env = {
|
|
6
|
+
DUFFLEPUD_URL: undefined,
|
|
7
|
+
};
|
|
8
|
+
export const repository = new Repository();
|
|
9
|
+
export const events = createEventStore(repository);
|
|
10
|
+
export const relay = new Relay(repository);
|
|
11
|
+
export const tracker = new Tracker();
|
|
12
|
+
export const subscribe = (request) => {
|
|
13
|
+
const sub = baseSubscribe({ delay: 50, authTimeout: 3000, ...request });
|
|
14
|
+
sub.emitter.on("event", (url, e) => {
|
|
15
|
+
repository.publish(e);
|
|
16
|
+
});
|
|
17
|
+
return sub;
|
|
18
|
+
};
|
|
19
|
+
export const load = (request) => new Promise(resolve => {
|
|
20
|
+
const sub = subscribe({ closeOnEose: true, timeout: 3000, ...request });
|
|
21
|
+
const events = [];
|
|
22
|
+
sub.emitter.on("event", (url, e) => events.push(e));
|
|
23
|
+
sub.emitter.on("complete", () => resolve(events));
|
|
24
|
+
});
|
|
25
|
+
export const loadOne = async (request) => first(await load(request));
|
|
26
|
+
//# sourceMappingURL=core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.mjs","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"OAAO,EAAC,KAAK,EAAC,MAAM,eAAe;OAC5B,EAAC,UAAU,EAAE,KAAK,EAAC,MAAM,gBAAgB;OAEzC,EAAC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAC,MAAM,eAAe;OAE1D,EAAC,gBAAgB,EAAC,MAAM,iBAAiB;AAEhD,MAAM,CAAC,MAAM,GAAG,GAGZ;IACF,aAAa,EAAE,SAAS;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAgB,CAAA;AAExD,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAA;AAElD,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;AAE1C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAEpC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAyB,EAAE,EAAE;IACrD,MAAM,GAAG,GAAG,aAAa,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC,CAAA;IAErE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,CAAe,EAAE,EAAE;QACvD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAyB,EAAE,EAAE,CAChD,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;IACpC,MAAM,GAAG,GAAG,SAAS,CAAC,EAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC,CAAA;IACrE,MAAM,MAAM,GAAmB,EAAE,CAAA;IAEjC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,CAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACzE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AACnD,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAyB,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.loadFollows = exports.deriveFollows = exports.followsByPubkey = exports.follows = void 0;
|
|
5
|
+
const util_1 = require("@welshman/util");
|
|
6
|
+
const store_1 = require("@welshman/store");
|
|
7
|
+
const core_1 = require("./core.cjs");
|
|
8
|
+
const collection_1 = require("./collection.cjs");
|
|
9
|
+
const plaintext_1 = require("./plaintext.cjs");
|
|
10
|
+
const relaySelections_1 = require("./relaySelections.cjs");
|
|
11
|
+
exports.follows = (0, store_1.withGetter)((0, store_1.deriveEventsMapped)(core_1.repository, {
|
|
12
|
+
filters: [{ kinds: [util_1.FOLLOWS] }],
|
|
13
|
+
itemToEvent: item => item.event,
|
|
14
|
+
eventToItem: async (event) => (0, util_1.readList)((0, util_1.asDecryptedEvent)(event, {
|
|
15
|
+
content: await (0, plaintext_1.ensurePlaintext)(event),
|
|
16
|
+
})),
|
|
17
|
+
}));
|
|
18
|
+
_a = (0, collection_1.collection)({
|
|
19
|
+
name: "follows",
|
|
20
|
+
store: exports.follows,
|
|
21
|
+
getKey: follows => follows.event.pubkey,
|
|
22
|
+
load: async (pubkey, hints = [], request = {}) => {
|
|
23
|
+
const relays = (0, relaySelections_1.getWriteRelayUrls)(await (0, relaySelections_1.loadRelaySelections)(pubkey, hints));
|
|
24
|
+
return (0, core_1.load)({
|
|
25
|
+
...request,
|
|
26
|
+
relays: [...relays, ...hints],
|
|
27
|
+
filters: [{ kinds: [util_1.FOLLOWS], authors: [pubkey] }],
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
}), exports.followsByPubkey = _a.indexStore, exports.deriveFollows = _a.deriveItem, exports.loadFollows = _a.loadItem;
|
|
31
|
+
//# sourceMappingURL=follows.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follows.cjs","sourceRoot":"","sources":["../../src/follows.ts"],"names":[],"mappings":";;;;AAAA,yCAAkE;AAGlE,2CAA8D;AAC9D,qCAAuC;AACvC,iDAAuC;AACvC,+CAA2C;AAC3C,2DAAwE;AAE3D,QAAA,OAAO,GAAG,IAAA,kBAAU,EAC/B,IAAA,0BAAkB,EAAgB,iBAAU,EAAE;IAC5C,OAAO,EAAE,CAAC,EAAC,KAAK,EAAE,CAAC,cAAO,CAAC,EAAC,CAAC;IAC7B,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK;IAC/B,WAAW,EAAE,KAAK,EAAE,KAAmB,EAAE,EAAE,CACzC,IAAA,eAAQ,EACN,IAAA,uBAAgB,EAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,IAAA,2BAAe,EAAC,KAAK,CAAC;KACtC,CAAC,CACH;CACJ,CAAC,CACH,CAAA;AAEY,KAIT,IAAA,uBAAU,EAAC;IACb,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,eAAO;IACd,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM;IACvC,IAAI,EAAE,KAAK,EAAE,MAAc,EAAE,KAAK,GAAG,EAAE,EAAE,UAAqC,EAAE,EAAE,EAAE;QAClF,MAAM,MAAM,GAAG,IAAA,mCAAiB,EAAC,MAAM,IAAA,qCAAmB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;QAE1E,OAAO,IAAA,WAAI,EAAC;YACV,GAAG,OAAO;YACV,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;YAC7B,OAAO,EAAE,CAAC,EAAC,KAAK,EAAE,CAAC,cAAO,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAC,CAAC;SACjD,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,EAhBY,uBAAe,kBACf,qBAAa,kBACf,mBAAW,eAcrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import { type PublishedList } from '@welshman/util';
|
|
3
|
+
import { type SubscribeRequest } from "@welshman/net";
|
|
4
|
+
export declare const follows: import("svelte/store").Readable<PublishedList[]> & {
|
|
5
|
+
get: () => PublishedList[];
|
|
6
|
+
};
|
|
7
|
+
export declare const followsByPubkey: import("svelte/store").Readable<Map<string, PublishedList>> & {
|
|
8
|
+
get: () => Map<string, PublishedList>;
|
|
9
|
+
}, deriveFollows: (key: import("@welshman/lib").Maybe<string>, hints?: any, request?: Partial<SubscribeRequest> | undefined) => import("svelte/store").Readable<PublishedList | undefined>, loadFollows: (key: string, hints?: any, request?: Partial<SubscribeRequest> | undefined) => Promise<PublishedList | undefined>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FOLLOWS, asDecryptedEvent, readList } from '@welshman/util';
|
|
2
|
+
import { deriveEventsMapped, withGetter } from '@welshman/store';
|
|
3
|
+
import { repository, load } from "./core.mjs";
|
|
4
|
+
import { collection } from "./collection.mjs";
|
|
5
|
+
import { ensurePlaintext } from "./plaintext.mjs";
|
|
6
|
+
import { getWriteRelayUrls, loadRelaySelections } from "./relaySelections.mjs";
|
|
7
|
+
export const follows = withGetter(deriveEventsMapped(repository, {
|
|
8
|
+
filters: [{ kinds: [FOLLOWS] }],
|
|
9
|
+
itemToEvent: item => item.event,
|
|
10
|
+
eventToItem: async (event) => readList(asDecryptedEvent(event, {
|
|
11
|
+
content: await ensurePlaintext(event),
|
|
12
|
+
})),
|
|
13
|
+
}));
|
|
14
|
+
export const { indexStore: followsByPubkey, deriveItem: deriveFollows, loadItem: loadFollows, } = collection({
|
|
15
|
+
name: "follows",
|
|
16
|
+
store: follows,
|
|
17
|
+
getKey: follows => follows.event.pubkey,
|
|
18
|
+
load: async (pubkey, hints = [], request = {}) => {
|
|
19
|
+
const relays = getWriteRelayUrls(await loadRelaySelections(pubkey, hints));
|
|
20
|
+
return load({
|
|
21
|
+
...request,
|
|
22
|
+
relays: [...relays, ...hints],
|
|
23
|
+
filters: [{ kinds: [FOLLOWS], authors: [pubkey] }],
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=follows.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follows.mjs","sourceR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C,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAC,CAAC;SACjD,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setFreshnessBulk = exports.setFreshness = exports.getFreshness = exports.getFreshnessKey = exports.freshness = void 0;
|
|
4
|
+
const store_1 = require("svelte/store");
|
|
5
|
+
const lib_1 = require("@welshman/lib");
|
|
6
|
+
const store_2 = require("@welshman/store");
|
|
7
|
+
exports.freshness = (0, store_2.withGetter)((0, store_1.writable)({}));
|
|
8
|
+
const getFreshnessKey = (ns, key) => `${ns}:${key}`;
|
|
9
|
+
exports.getFreshnessKey = getFreshnessKey;
|
|
10
|
+
const getFreshness = (ns, key) => exports.freshness.get()[(0, exports.getFreshnessKey)(ns, key)] || 0;
|
|
11
|
+
exports.getFreshness = getFreshness;
|
|
12
|
+
const setFreshness = (ns, key, ts) => exports.freshness.update((0, lib_1.assoc)((0, exports.getFreshnessKey)(ns, key), ts));
|
|
13
|
+
exports.setFreshness = setFreshness;
|
|
14
|
+
const setFreshnessBulk = (ns, updates) => exports.freshness.update($freshness => {
|
|
15
|
+
for (const [key, ts] of Object.entries(updates)) {
|
|
16
|
+
$freshness[key] = ts;
|
|
17
|
+
}
|
|
18
|
+
return $freshness;
|
|
19
|
+
});
|
|
20
|
+
exports.setFreshnessBulk = setFreshnessBulk;
|
|
21
|
+
//# sourceMappingURL=freshness.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.cjs","sourceRoot":"","sources":["../../src/freshness.ts"],"names":[],"mappings":";;;AAAA,wCAAqC;AACrC,uCAAmC;AACnC,2CAA0C;AAE7B,QAAA,SAAS,GAAG,IAAA,kBAAU,EAAC,IAAA,gBAAQ,EAAyB,EAAE,CAAC,CAAC,CAAA;AAElE,MAAM,eAAe,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAA;AAA7D,QAAA,eAAe,mBAA8C;AAEnE,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAE,CACtD,iBAAS,CAAC,GAAG,EAAE,CAAC,IAAA,uBAAe,EAAC,EAAE,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;AADnC,QAAA,YAAY,gBACuB;AAEzC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAU,EAAE,EAAE,CAClE,iBAAS,CAAC,MAAM,CAAC,IAAA,WAAK,EAAC,IAAA,uBAAe,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAD1C,QAAA,YAAY,gBAC8B;AAEhD,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAE,OAA+B,EAAE,EAAE,CAC9E,iBAAS,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;IAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC/C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;KACrB;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAC,CAAA;AAPS,QAAA,gBAAgB,oBAOzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
export declare const freshness: import("svelte/store").Writable<Record<string, number>> & {
|
|
3
|
+
get: () => Record<string, number>;
|
|
4
|
+
};
|
|
5
|
+
export declare const getFreshnessKey: (ns: string, key: string) => string;
|
|
6
|
+
export declare const getFreshness: (ns: string, key: string) => number;
|
|
7
|
+
export declare const setFreshness: (ns: string, key: string, ts: number) => void;
|
|
8
|
+
export declare const setFreshnessBulk: (ns: string, updates: Record<string, number>) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
import { assoc } from '@welshman/lib';
|
|
3
|
+
import { withGetter } from '@welshman/store';
|
|
4
|
+
export const freshness = withGetter(writable({}));
|
|
5
|
+
export const getFreshnessKey = (ns, key) => `${ns}:${key}`;
|
|
6
|
+
export const getFreshness = (ns, key) => freshness.get()[getFreshnessKey(ns, key)] || 0;
|
|
7
|
+
export const setFreshness = (ns, key, ts) => freshness.update(assoc(getFreshnessKey(ns, key), ts));
|
|
8
|
+
export const setFreshnessBulk = (ns, updates) => freshness.update($freshness => {
|
|
9
|
+
for (const [key, ts] of Object.entries(updates)) {
|
|
10
|
+
$freshness[key] = ts;
|
|
11
|
+
}
|
|
12
|
+
return $freshness;
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=freshness.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.mjs","sourceRoot":"","sources":["../../src/freshness.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc;OAC9B,EAAC,KAAK,EAAC,MAAM,eAAe;OAC5B,EAAC,UAAU,EAAC,MAAM,iBAAiB;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAyB,EAAE,CAAC,CAAC,CAAA;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAA;AAE1E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAE,CACtD,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,GAAW,EAAE,EAAU,EAAE,EAAE,CAClE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAE,OAA+B,EAAE,EAAE,CAC9E,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;IAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC/C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;KACrB;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.displayHandle = exports.loadHandle = exports.deriveHandle = exports.handlesByNip05 = exports.fetchHandles = exports.handlesByPubkey = exports.handles = void 0;
|
|
5
|
+
const store_1 = require("svelte/store");
|
|
6
|
+
const store_2 = require("@welshman/store");
|
|
7
|
+
const lib_1 = require("@welshman/lib");
|
|
8
|
+
const core_1 = require("./core.cjs");
|
|
9
|
+
const collection_1 = require("./collection.cjs");
|
|
10
|
+
const profiles_1 = require("./profiles.cjs");
|
|
11
|
+
exports.handles = (0, store_2.withGetter)((0, store_1.writable)([]));
|
|
12
|
+
exports.handlesByPubkey = (0, store_1.derived)([profiles_1.profilesByPubkey, exports.handles], ([$profilesByPubkey, $handles]) => (0, lib_1.indexBy)($handle => $handle.pubkey, $handles.filter($handle => { var _a; return $handle.pubkey && ((_a = $profilesByPubkey.get($handle.pubkey)) === null || _a === void 0 ? void 0 : _a.nip05) === $handle.nip05; })));
|
|
13
|
+
const fetchHandles = (handles) => {
|
|
14
|
+
const base = core_1.env.DUFFLEPUD_URL;
|
|
15
|
+
if (!base) {
|
|
16
|
+
throw new Error("DUFFLEPUD_URL is required to fetch nip05 info");
|
|
17
|
+
}
|
|
18
|
+
const res = (0, lib_1.postJson)(`${base}/handle/info`, { handles });
|
|
19
|
+
const handlesByNip05 = new Map();
|
|
20
|
+
for (const { handle, info } of (res === null || res === void 0 ? void 0 : res.data) || []) {
|
|
21
|
+
handlesByNip05.set(handle, info);
|
|
22
|
+
}
|
|
23
|
+
return handlesByNip05;
|
|
24
|
+
};
|
|
25
|
+
exports.fetchHandles = fetchHandles;
|
|
26
|
+
_a = (0, collection_1.collection)({
|
|
27
|
+
name: "handles",
|
|
28
|
+
store: exports.handles,
|
|
29
|
+
getKey: (handle) => handle.nip05,
|
|
30
|
+
load: (0, lib_1.batcher)(800, async (nip05s) => {
|
|
31
|
+
const fresh = await (0, exports.fetchHandles)((0, lib_1.uniq)(nip05s));
|
|
32
|
+
const stale = exports.handlesByNip05.get();
|
|
33
|
+
const items = nip05s.map(nip05 => {
|
|
34
|
+
const handle = fresh.get(nip05) || stale.get(nip05) || {};
|
|
35
|
+
return { ...handle, nip05 };
|
|
36
|
+
});
|
|
37
|
+
exports.handles.update($handles => (0, lib_1.uniqBy)($handle => $handle.nip05, [...$handles, ...items]));
|
|
38
|
+
return items;
|
|
39
|
+
}),
|
|
40
|
+
}), exports.handlesByNip05 = _a.indexStore, exports.deriveHandle = _a.deriveItem, exports.loadHandle = _a.loadItem;
|
|
41
|
+
const displayHandle = (handle) => handle.nip05.startsWith("_@") ? (0, lib_1.last)(handle.nip05.split("@")) : handle.nip05;
|
|
42
|
+
exports.displayHandle = displayHandle;
|
|
43
|
+
//# sourceMappingURL=handles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handles.cjs","sourceRoot":"","sources":["../../src/handles.ts"],"names":[],"mappings":";;;;AAAA,wCAA8C;AAC9C,2CAA0C;AAC1C,uCAA4E;AAC5E,qCAA0B;AAC1B,iDAAuC;AACvC,6CAA2C;AAS9B,QAAA,OAAO,GAAG,IAAA,kBAAU,EAAC,IAAA,gBAAQ,EAAW,EAAE,CAAC,CAA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EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,IAAA,oBAAY,EAAC,IAAA,UAAI,EAAC,MAAM,CAAC,CAAC,CAAA;QAC9C,MAAM,KAAK,GAAG,sBAAc,CAAC,GAAG,EAAE,CAAA;QAClC,MAAM,KAAK,GAAa,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACzC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;YAEzD,OAAO,EAAC,GAAG,MAAM,EAAE,KAAK,EAAC,CAAA;QAC3B,CAAC,CAAC,CAAA;QAEF,eAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAA,YAAM,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAErF,OAAO,KAAK,CAAA;IACd,CAAC,CAAC;CACH,CAAC,EApBY,sBAAc,kBACd,oBAAY,kBACd,kBAAU,eAkBpB;AAEK,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAC9C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,UAAI,EAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA;AADjE,QAAA,aAAa,iBACoD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
export type Handle = {
|
|
3
|
+
nip05: string;
|
|
4
|
+
pubkey?: string;
|
|
5
|
+
nip46?: string[];
|
|
6
|
+
relays?: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare const handles: import("svelte/store").Writable<Handle[]> & {
|
|
9
|
+
get: () => Handle[];
|
|
10
|
+
};
|
|
11
|
+
export declare const handlesByPubkey: import("svelte/store").Readable<Map<string | undefined, Handle>>;
|
|
12
|
+
export declare const fetchHandles: (handles: string[]) => Map<string, Handle>;
|
|
13
|
+
export declare const handlesByNip05: import("svelte/store").Readable<Map<string, Handle>> & {
|
|
14
|
+
get: () => Map<string, Handle>;
|
|
15
|
+
}, deriveHandle: (key: import("@welshman/lib").Maybe<string>) => import("svelte/store").Readable<Handle | undefined>, loadHandle: (key: string) => Promise<Handle | undefined>;
|
|
16
|
+
export declare const displayHandle: (handle: Handle) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { writable, derived } from 'svelte/store';
|
|
2
|
+
import { withGetter } from '@welshman/store';
|
|
3
|
+
import { uniq, indexBy, uniqBy, batcher, postJson, last } from '@welshman/lib';
|
|
4
|
+
import { env } from "./core.mjs";
|
|
5
|
+
import { collection } from "./collection.mjs";
|
|
6
|
+
import { profilesByPubkey } from "./profiles.mjs";
|
|
7
|
+
export const handles = withGetter(writable([]));
|
|
8
|
+
export const handlesByPubkey = derived([profilesByPubkey, handles], ([$profilesByPubkey, $handles]) => indexBy($handle => $handle.pubkey, $handles.filter($handle => { var _a; return $handle.pubkey && ((_a = $profilesByPubkey.get($handle.pubkey)) === null || _a === void 0 ? void 0 : _a.nip05) === $handle.nip05; })));
|
|
9
|
+
export const fetchHandles = (handles) => {
|
|
10
|
+
const base = env.DUFFLEPUD_URL;
|
|
11
|
+
if (!base) {
|
|
12
|
+
throw new Error("DUFFLEPUD_URL is required to fetch nip05 info");
|
|
13
|
+
}
|
|
14
|
+
const res = postJson(`${base}/handle/info`, { handles });
|
|
15
|
+
const handlesByNip05 = new Map();
|
|
16
|
+
for (const { handle, info } of (res === null || res === void 0 ? void 0 : res.data) || []) {
|
|
17
|
+
handlesByNip05.set(handle, info);
|
|
18
|
+
}
|
|
19
|
+
return handlesByNip05;
|
|
20
|
+
};
|
|
21
|
+
export const { indexStore: handlesByNip05, deriveItem: deriveHandle, loadItem: loadHandle, } = collection({
|
|
22
|
+
name: "handles",
|
|
23
|
+
store: handles,
|
|
24
|
+
getKey: (handle) => handle.nip05,
|
|
25
|
+
load: batcher(800, async (nip05s) => {
|
|
26
|
+
const fresh = await fetchHandles(uniq(nip05s));
|
|
27
|
+
const stale = handlesByNip05.get();
|
|
28
|
+
const items = nip05s.map(nip05 => {
|
|
29
|
+
const handle = fresh.get(nip05) || stale.get(nip05) || {};
|
|
30
|
+
return { ...handle, nip05 };
|
|
31
|
+
});
|
|
32
|
+
handles.update($handles => uniqBy($handle => $handle.nip05, [...$handles, ...items]));
|
|
33
|
+
return items;
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
export const displayHandle = (handle) => handle.nip05.startsWith("_@") ? last(handle.nip05.split("@")) : handle.nip05;
|
|
37
|
+
//# sourceMappingURL=handles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handles.mjs","sourceRoot":"","sources":["../../src/handles.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,cAAc;OACvC,EAAC,UAAU,EAAC,MAAM,iBAAiB;OACnC,EAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,eAAe;OACrE,EAAC,GAAG,EAAC;OACL,EAAC,UAAU,EAAC;OACZ,EAAC,gBAAgB,EAAC;AASzB,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAW,EAAE,CAAC,CAAC,CAAA;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,iBAAiB,EAAE,QAAQ,CAAC,EAAE,EAAE,CACpG,OAAO,CACL,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EACzB,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAC,OAAA,OAAO,CAA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AM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;YAEzD,OAAO,EAAC,GAAG,MAAM,EAAE,KAAK,EAAC,CAAA;QAC3B,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAErF,OAAO,KAAK,CAAA;IACd,CAAC,CAAC;CACH,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAC9C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA"}
|
package/build/src/index.cjs
CHANGED
|
@@ -14,7 +14,28 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./core.cjs"), exports);
|
|
18
|
+
__exportStar(require("./collection.cjs"), exports);
|
|
19
|
+
__exportStar(require("./freshness.cjs"), exports);
|
|
20
|
+
__exportStar(require("./follows.cjs"), exports);
|
|
21
|
+
__exportStar(require("./handles.cjs"), exports);
|
|
22
|
+
__exportStar(require("./mutes.cjs"), exports);
|
|
23
|
+
__exportStar(require("./plaintext.cjs"), exports);
|
|
24
|
+
__exportStar(require("./profiles.cjs"), exports);
|
|
25
|
+
__exportStar(require("./relays.cjs"), exports);
|
|
26
|
+
__exportStar(require("./relaySelections.cjs"), exports);
|
|
19
27
|
__exportStar(require("./session.cjs"), exports);
|
|
28
|
+
__exportStar(require("./storage.cjs"), exports);
|
|
29
|
+
__exportStar(require("./thunk.cjs"), exports);
|
|
30
|
+
__exportStar(require("./topics.cjs"), exports);
|
|
31
|
+
__exportStar(require("./util.cjs"), exports);
|
|
32
|
+
__exportStar(require("./zappers.cjs"), exports);
|
|
33
|
+
const net_1 = require("@welshman/net");
|
|
34
|
+
const core_1 = require("./core.cjs");
|
|
35
|
+
const session_1 = require("./session.cjs");
|
|
36
|
+
Object.assign(net_1.NetworkContext, {
|
|
37
|
+
onAuth: session_1.onAuth,
|
|
38
|
+
onEvent: (url, event) => core_1.tracker.track(event.id, url),
|
|
39
|
+
isDeleted: (url, event) => core_1.repository.isDeleted(event),
|
|
40
|
+
});
|
|
20
41
|
//# sourceMappingURL=index.cjs.map
|
package/build/src/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,8CAAuB;AACvB,gDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAAsB;AACtB,mDAA4B;AAC5B,kDAA2B;AAC3B,gDAAyB;AACzB,gDAAyB;AACzB,8CAAuB;AACvB,kDAA2B;AAC3B,iDAA0B;AAC1B,+CAAwB;AACxB,wDAAiC;AACjC,gDAAyB;AACzB,gDAAyB;AACzB,8CAAuB;AACvB,+CAAwB;AACxB,6CAAsB;AACtB,gDAAyB;AAEzB,uCAA4C;AAE5C,qCAA0C;AAC1C,2CAAgC;AAEhC,MAAM,CAAC,MAAM,CAAC,oBAAc,EAAE;IAC5B,MAAM,EAAN,gBAAM;IACN,OAAO,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,cAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC;IAC3E,SAAS,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,iBAAU,CAAC,SAAS,CAAC,KAAK,CAAC;CAC7E,CAAC,CAAA"}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './collection';
|
|
3
|
+
export * from './freshness';
|
|
4
|
+
export * from './follows';
|
|
5
|
+
export * from './handles';
|
|
6
|
+
export * from './mutes';
|
|
7
|
+
export * from './plaintext';
|
|
8
|
+
export * from './profiles';
|
|
9
|
+
export * from './relays';
|
|
10
|
+
export * from './relaySelections';
|
|
3
11
|
export * from './session';
|
|
12
|
+
export * from './storage';
|
|
13
|
+
export * from './thunk';
|
|
14
|
+
export * from './topics';
|
|
15
|
+
export * from './util';
|
|
16
|
+
export * from './zappers';
|
package/build/src/index.mjs
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./core.mjs";
|
|
2
|
+
export * from "./collection.mjs";
|
|
3
|
+
export * from "./freshness.mjs";
|
|
4
|
+
export * from "./follows.mjs";
|
|
5
|
+
export * from "./handles.mjs";
|
|
6
|
+
export * from "./mutes.mjs";
|
|
7
|
+
export * from "./plaintext.mjs";
|
|
8
|
+
export * from "./profiles.mjs";
|
|
9
|
+
export * from "./relays.mjs";
|
|
10
|
+
export * from "./relaySelections.mjs";
|
|
3
11
|
export * from "./session.mjs";
|
|
12
|
+
export * from "./storage.mjs";
|
|
13
|
+
export * from "./thunk.mjs";
|
|
14
|
+
export * from "./topics.mjs";
|
|
15
|
+
export * from "./util.mjs";
|
|
16
|
+
export * from "./zappers.mjs";
|
|
17
|
+
import { NetworkContext } from "@welshman/net";
|
|
18
|
+
import { tracker, repository } from "./core.mjs";
|
|
19
|
+
import { onAuth } from "./session.mjs";
|
|
20
|
+
Object.assign(NetworkContext, {
|
|
21
|
+
onAuth,
|
|
22
|
+
onEvent: (url, event) => tracker.track(event.id, url),
|
|
23
|
+
isDeleted: (url, event) => repository.isDeleted(event),
|
|
24
|
+
});
|
|
4
25
|
//# sourceMappingURL=index.mjs.map
|
package/build/src/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;OAiBO,EAAC,cAAc,EAAC,MAAM,eAAe;OAErC,EAAC,OAAO,EAAE,UAAU,EAAC;OACrB,EAAC,MAAM,EAAC;AAEf,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;IAC5B,MAAM;IACN,OAAO,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC;IAC3E,SAAS,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;CAC7E,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.loadMutes = exports.deriveMutes = exports.mutesByPubkey = exports.mutes = void 0;
|
|
5
|
+
const util_1 = require("@welshman/util");
|
|
6
|
+
const store_1 = require("@welshman/store");
|
|
7
|
+
const core_1 = require("./core.cjs");
|
|
8
|
+
const collection_1 = require("./collection.cjs");
|
|
9
|
+
const plaintext_1 = require("./plaintext.cjs");
|
|
10
|
+
const relaySelections_1 = require("./relaySelections.cjs");
|
|
11
|
+
exports.mutes = (0, store_1.withGetter)((0, store_1.deriveEventsMapped)(core_1.repository, {
|
|
12
|
+
filters: [{ kinds: [util_1.MUTES] }],
|
|
13
|
+
itemToEvent: item => item.event,
|
|
14
|
+
eventToItem: async (event) => (0, util_1.readList)((0, util_1.asDecryptedEvent)(event, {
|
|
15
|
+
content: await (0, plaintext_1.ensurePlaintext)(event),
|
|
16
|
+
})),
|
|
17
|
+
}));
|
|
18
|
+
_a = (0, collection_1.collection)({
|
|
19
|
+
name: "mutes",
|
|
20
|
+
store: exports.mutes,
|
|
21
|
+
getKey: mute => mute.event.pubkey,
|
|
22
|
+
load: async (pubkey, hints = [], request = {}) => {
|
|
23
|
+
const relays = (0, relaySelections_1.getWriteRelayUrls)(await (0, relaySelections_1.loadRelaySelections)(pubkey, hints));
|
|
24
|
+
return (0, core_1.load)({
|
|
25
|
+
...request,
|
|
26
|
+
relays: [...relays, ...hints],
|
|
27
|
+
filters: [{ kinds: [util_1.MUTES], authors: [pubkey] }],
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
}), exports.mutesByPubkey = _a.indexStore, exports.deriveMutes = _a.deriveItem, exports.loadMutes = _a.loadItem;
|
|
31
|
+
//# sourceMappingURL=mutes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutes.cjs","sourceRoot":"","sources":["../../src/mutes.ts"],"names":[],"mappings":";;;;AAAA,yCAAgE;AAGhE,2CAA8D;AAC9D,qCAAuC;AACvC,iDAAuC;AACvC,+CAA2C;AAC3C,2DAAwE;AAE3D,QAAA,KAAK,GAAG,IAAA,kBAAU,EAC7B,IAAA,0BAAkB,EAAgB,iBAAU,EAAE;IAC5C,OAAO,EAAE,CAAC,EAAC,KAAK,EAAE,CAAC,YAAK,CAAC,EAAC,CAAC;IAC3B,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK;IAC/B,WAAW,EAAE,KAAK,EAAE,KAAmB,EAAE,EAAE,CACzC,IAAA,eAAQ,EACN,IAAA,uBAAgB,EAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,IAAA,2BAAe,EAAC,KAAK,CAAC;KACtC,CAAC,CACH;CACJ,CAAC,CACH,CAAA;AAEY,KAIT,IAAA,uBAAU,EAAC;IACb,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,aAAK;IACZ,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM;IACjC,IAAI,EAAE,KAAK,EAAE,MAAc,EAAE,KAAK,GAAG,EAAE,EAAE,UAAqC,EAAE,EAAE,EAAE;QAClF,MAAM,MAAM,GAAG,IAAA,mCAAiB,EAAC,MAAM,IAAA,qCAAmB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;QAE1E,OAAO,IAAA,WAAI,EAAC;YACV,GAAG,OAAO;YACV,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;YAC7B,OAAO,EAAE,CAAC,EAAC,KAAK,EAAE,CAAC,YAAK,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAC,CAAC;SAC/C,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,EAhBY,qBAAa,kBACb,mBAAW,kBACb,iBAAS,eAcnB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import { type PublishedList } from '@welshman/util';
|
|
3
|
+
import { type SubscribeRequest } from "@welshman/net";
|
|
4
|
+
export declare const mutes: import("svelte/store").Readable<PublishedList[]> & {
|
|
5
|
+
get: () => PublishedList[];
|
|
6
|
+
};
|
|
7
|
+
export declare const mutesByPubkey: import("svelte/store").Readable<Map<string, PublishedList>> & {
|
|
8
|
+
get: () => Map<string, PublishedList>;
|
|
9
|
+
}, deriveMutes: (key: import("@welshman/lib").Maybe<string>, hints?: any, request?: Partial<SubscribeRequest> | undefined) => import("svelte/store").Readable<PublishedList | undefined>, loadMutes: (key: string, hints?: any, request?: Partial<SubscribeRequest> | undefined) => Promise<PublishedList | undefined>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MUTES, asDecryptedEvent, readList } from '@welshman/util';
|
|
2
|
+
import { deriveEventsMapped, withGetter } from '@welshman/store';
|
|
3
|
+
import { repository, load } from "./core.mjs";
|
|
4
|
+
import { collection } from "./collection.mjs";
|
|
5
|
+
import { ensurePlaintext } from "./plaintext.mjs";
|
|
6
|
+
import { getWriteRelayUrls, loadRelaySelections } from "./relaySelections.mjs";
|
|
7
|
+
export const mutes = withGetter(deriveEventsMapped(repository, {
|
|
8
|
+
filters: [{ kinds: [MUTES] }],
|
|
9
|
+
itemToEvent: item => item.event,
|
|
10
|
+
eventToItem: async (event) => readList(asDecryptedEvent(event, {
|
|
11
|
+
content: await ensurePlaintext(event),
|
|
12
|
+
})),
|
|
13
|
+
}));
|
|
14
|
+
export const { indexStore: mutesByPubkey, deriveItem: deriveMutes, loadItem: loadMutes, } = collection({
|
|
15
|
+
name: "mutes",
|
|
16
|
+
store: mutes,
|
|
17
|
+
getKey: mute => mute.event.pubkey,
|
|
18
|
+
load: async (pubkey, hints = [], request = {}) => {
|
|
19
|
+
const relays = getWriteRelayUrls(await loadRelaySelections(pubkey, hints));
|
|
20
|
+
return load({
|
|
21
|
+
...request,
|
|
22
|
+
relays: [...relays, ...hints],
|
|
23
|
+
filters: [{ kinds: [MUTES], authors: [pubkey] }],
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=mutes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutes.mjs","sourceRoot":"","sources":["../../src/mutes.ts"],"names":[],"mappings":"OAAO,EAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAC,MAAM,gBAAgB;OAGzD,EAAC,kBAAkB,EAAE,UAAU,EAAC,MAAM,iBAAiB;OACvD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