@welshman/app 0.0.6 → 0.0.8
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 +1 -1
- package/build/src/collection.cjs.map +1 -1
- package/build/src/collection.mjs +2 -2
- package/build/src/collection.mjs.map +1 -1
- package/build/src/context.cjs +1 -0
- package/build/src/context.cjs.map +1 -1
- package/build/src/context.mjs +1 -0
- package/build/src/context.mjs.map +1 -1
- package/build/src/core.cjs +0 -3
- package/build/src/core.cjs.map +1 -1
- package/build/src/core.mjs +0 -3
- package/build/src/core.mjs.map +1 -1
- package/build/src/follows.cjs +3 -1
- package/build/src/follows.cjs.map +1 -1
- package/build/src/follows.d.ts +1 -0
- package/build/src/follows.mjs +2 -1
- package/build/src/follows.mjs.map +1 -1
- package/build/src/freshness.cjs +7 -8
- package/build/src/freshness.cjs.map +1 -1
- package/build/src/freshness.d.ts +7 -2
- package/build/src/freshness.mjs +6 -6
- package/build/src/freshness.mjs.map +1 -1
- package/build/src/index.cjs +3 -0
- package/build/src/index.cjs.map +1 -1
- package/build/src/index.d.ts +3 -0
- package/build/src/index.mjs +3 -0
- package/build/src/mutes.cjs +3 -1
- package/build/src/mutes.cjs.map +1 -1
- package/build/src/mutes.d.ts +1 -0
- package/build/src/mutes.mjs +2 -1
- package/build/src/mutes.mjs.map +1 -1
- package/build/src/plaintext.cjs +4 -1
- package/build/src/plaintext.cjs.map +1 -1
- package/build/src/plaintext.mjs +4 -1
- package/build/src/plaintext.mjs.map +1 -1
- package/build/src/profiles.cjs +13 -1
- package/build/src/profiles.cjs.map +1 -1
- package/build/src/profiles.d.ts +2 -0
- package/build/src/profiles.mjs +12 -0
- package/build/src/profiles.mjs.map +1 -1
- package/build/src/session.cjs +2 -0
- package/build/src/session.cjs.map +1 -1
- package/build/src/session.d.ts +4 -3
- package/build/src/session.mjs +3 -1
- package/build/src/session.mjs.map +1 -1
- package/build/src/storage.cjs +13 -16
- package/build/src/storage.cjs.map +1 -1
- package/build/src/storage.d.ts +2 -5
- package/build/src/storage.mjs +14 -17
- package/build/src/storage.mjs.map +1 -1
- package/build/src/sync.cjs +39 -0
- package/build/src/sync.cjs.map +1 -0
- package/build/src/sync.d.ts +9 -0
- package/build/src/sync.mjs +32 -0
- package/build/src/sync.mjs.map +1 -0
- package/build/src/tags.cjs +94 -0
- package/build/src/tags.cjs.map +1 -0
- package/build/src/tags.d.ts +6 -0
- package/build/src/tags.mjs +86 -0
- package/build/src/tags.mjs.map +1 -0
- package/build/src/util.cjs +2 -0
- package/build/src/util.cjs.map +1 -1
- package/build/src/util.d.ts +1 -0
- package/build/src/util.mjs +2 -0
- package/build/src/util.mjs.map +1 -1
- package/build/src/wot.cjs +64 -0
- package/build/src/wot.cjs.map +1 -0
- package/build/src/wot.d.ts +9 -0
- package/build/src/wot.mjs +55 -0
- package/build/src/wot.mjs.map +1 -0
- package/package.json +6 -6
package/build/src/util.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.mjs","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"OAAO,IAAI,MAAM,SAAS;OAEnB,EAAC,MAAM,EAAC,MAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"util.mjs","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"OAAO,IAAI,MAAM,SAAS;OAEnB,EAAC,MAAM,EAAC,MAAM,eAAe;AAiBpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAO,OAAY,EAAE,IAAyB,EAAgB,EAAE;IAC1F,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,EAAC,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,EAAC,CAAC,CAAA;IACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,I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+1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserWotScore = exports.getWotScore = exports.wotGraph = exports.getFollowsWhoMute = exports.getFollowsWhoFollow = exports.getMuters = exports.getFollowers = exports.mutersByPubkey = exports.followersByPubkey = void 0;
|
|
4
|
+
const throttle_debounce_1 = require("throttle-debounce");
|
|
5
|
+
const store_1 = require("svelte/store");
|
|
6
|
+
const lib_1 = require("@welshman/lib");
|
|
7
|
+
const util_1 = require("@welshman/util");
|
|
8
|
+
const store_2 = require("@welshman/store");
|
|
9
|
+
const session_1 = require("./session.cjs");
|
|
10
|
+
const follows_1 = require("./follows.cjs");
|
|
11
|
+
const mutes_1 = require("./mutes.cjs");
|
|
12
|
+
exports.followersByPubkey = (0, store_2.withGetter)((0, store_1.derived)((0, store_2.throttled)(1000, follows_1.follows), lists => {
|
|
13
|
+
const $followersByPubkey = new Map();
|
|
14
|
+
for (const list of lists) {
|
|
15
|
+
for (const pubkey of (0, util_1.getListValues)("p", list)) {
|
|
16
|
+
(0, lib_1.addToMapKey)($followersByPubkey, pubkey, list.event.pubkey);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return $followersByPubkey;
|
|
20
|
+
}));
|
|
21
|
+
exports.mutersByPubkey = (0, store_2.withGetter)((0, store_1.derived)((0, store_2.throttled)(1000, mutes_1.mutes), lists => {
|
|
22
|
+
const $mutersByPubkey = new Map();
|
|
23
|
+
for (const list of lists) {
|
|
24
|
+
for (const pubkey of (0, util_1.getListValues)("p", list)) {
|
|
25
|
+
(0, lib_1.addToMapKey)($mutersByPubkey, pubkey, list.event.pubkey);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return $mutersByPubkey;
|
|
29
|
+
}));
|
|
30
|
+
const getFollowers = (pubkey) => Array.from(exports.followersByPubkey.get().get(pubkey) || []);
|
|
31
|
+
exports.getFollowers = getFollowers;
|
|
32
|
+
const getMuters = (pubkey) => Array.from(exports.mutersByPubkey.get().get(pubkey) || []);
|
|
33
|
+
exports.getMuters = getMuters;
|
|
34
|
+
const getFollowsWhoFollow = (pubkey, target) => (0, follows_1.getFollows)(pubkey).filter(other => (0, follows_1.getFollows)(other).includes(target));
|
|
35
|
+
exports.getFollowsWhoFollow = getFollowsWhoFollow;
|
|
36
|
+
const getFollowsWhoMute = (pubkey, target) => (0, follows_1.getFollows)(pubkey).filter(other => (0, mutes_1.getMutes)(other).includes(target));
|
|
37
|
+
exports.getFollowsWhoMute = getFollowsWhoMute;
|
|
38
|
+
exports.wotGraph = (0, store_2.withGetter)((0, store_1.writable)(new Map()));
|
|
39
|
+
const buildGraph = (0, throttle_debounce_1.throttle)(1000, () => {
|
|
40
|
+
const $pubkey = session_1.pubkey.get();
|
|
41
|
+
const $graph = new Map();
|
|
42
|
+
const $follows = $pubkey ? (0, follows_1.getFollows)($pubkey) : follows_1.followsByPubkey.get().keys();
|
|
43
|
+
for (const follow of $follows) {
|
|
44
|
+
for (const pubkey of (0, follows_1.getFollows)(follow)) {
|
|
45
|
+
$graph.set(pubkey, (0, lib_1.inc)($graph.get(pubkey)));
|
|
46
|
+
}
|
|
47
|
+
for (const pubkey of (0, mutes_1.getMutes)(follow)) {
|
|
48
|
+
$graph.set(pubkey, (0, lib_1.dec)($graph.get(pubkey)));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.wotGraph.set($graph);
|
|
52
|
+
});
|
|
53
|
+
session_1.pubkey.subscribe(buildGraph);
|
|
54
|
+
follows_1.follows.subscribe(buildGraph);
|
|
55
|
+
mutes_1.mutes.subscribe(buildGraph);
|
|
56
|
+
const getWotScore = (pubkey, target) => {
|
|
57
|
+
const follows = pubkey ? (0, exports.getFollowsWhoFollow)(pubkey, target) : (0, exports.getFollowers)(target);
|
|
58
|
+
const mutes = pubkey ? (0, exports.getFollowsWhoMute)(pubkey, target) : (0, exports.getMuters)(target);
|
|
59
|
+
return follows.length - mutes.length;
|
|
60
|
+
};
|
|
61
|
+
exports.getWotScore = getWotScore;
|
|
62
|
+
const getUserWotScore = (pubkey) => exports.wotGraph.get().get(pubkey) || 0;
|
|
63
|
+
exports.getUserWotScore = getUserWotScore;
|
|
64
|
+
//# sourceMappingURL=wot.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wot.cjs","sourceRoot":"","sources":["../../src/wot.ts"],"names":[],"mappings":";;;AAAA,yDAA0C;AAC1C,wCAA8C;AAC9C,uCAAmD;AACnD,yCAA4C;AAC5C,2CAAqD;AACrD,2CAAgC;AAChC,2CAA8D;AAC9D,uCAAuC;AAE1B,QAAA,iBAAiB,GAAG,IAAA,kBAAU,EACzC,IAAA,eAAO,EACL,IAAA,iBAAS,EAAC,IAAI,EAAE,iBAAO,CAAC,EACxB,KAAK,CAAC,EAAE;IACN,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,KAAK,MAAM,MAAM,IAAI,IAAA,oBAAa,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE;YAC7C,IAAA,iBAAW,EAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;SAC3D;KACF;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC,CACF,CACF,CAAA;AAEY,QAAA,cAAc,GAAG,IAAA,kBAAU,EACtC,IAAA,eAAO,EACL,IAAA,iBAAS,EAAC,IAAI,EAAE,aAAK,CAAC,EACtB,KAAK,CAAC,EAAE;IACN,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,KAAK,MAAM,MAAM,IAAI,IAAA,oBAAa,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE;YAC7C,IAAA,iBAAW,EAAC,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAA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AAA,WAAW,eAKvB;AAEM,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,gBAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAArE,QAAA,eAAe,mBAAsD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const followersByPubkey: import("@welshman/store").ReadableWithGetter<Map<string, Set<string>>>;
|
|
2
|
+
export declare const mutersByPubkey: import("@welshman/store").ReadableWithGetter<Map<string, Set<string>>>;
|
|
3
|
+
export declare const getFollowers: (pubkey: string) => string[];
|
|
4
|
+
export declare const getMuters: (pubkey: string) => string[];
|
|
5
|
+
export declare const getFollowsWhoFollow: (pubkey: string, target: string) => string[];
|
|
6
|
+
export declare const getFollowsWhoMute: (pubkey: string, target: string) => string[];
|
|
7
|
+
export declare const wotGraph: import("@welshman/store").WritableWithGetter<Map<string, number>>;
|
|
8
|
+
export declare const getWotScore: (pubkey: string, target: string) => number;
|
|
9
|
+
export declare const getUserWotScore: (pubkey: string) => number;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { throttle } from 'throttle-debounce';
|
|
2
|
+
import { derived, writable } from 'svelte/store';
|
|
3
|
+
import { addToMapKey, inc, dec } from '@welshman/lib';
|
|
4
|
+
import { getListValues } from '@welshman/util';
|
|
5
|
+
import { throttled, withGetter } from '@welshman/store';
|
|
6
|
+
import { pubkey } from "./session.mjs";
|
|
7
|
+
import { follows, getFollows, followsByPubkey } from "./follows.mjs";
|
|
8
|
+
import { mutes, getMutes } from "./mutes.mjs";
|
|
9
|
+
export const followersByPubkey = withGetter(derived(throttled(1000, follows), lists => {
|
|
10
|
+
const $followersByPubkey = new Map();
|
|
11
|
+
for (const list of lists) {
|
|
12
|
+
for (const pubkey of getListValues("p", list)) {
|
|
13
|
+
addToMapKey($followersByPubkey, pubkey, list.event.pubkey);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return $followersByPubkey;
|
|
17
|
+
}));
|
|
18
|
+
export const mutersByPubkey = withGetter(derived(throttled(1000, mutes), lists => {
|
|
19
|
+
const $mutersByPubkey = new Map();
|
|
20
|
+
for (const list of lists) {
|
|
21
|
+
for (const pubkey of getListValues("p", list)) {
|
|
22
|
+
addToMapKey($mutersByPubkey, pubkey, list.event.pubkey);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return $mutersByPubkey;
|
|
26
|
+
}));
|
|
27
|
+
export const getFollowers = (pubkey) => Array.from(followersByPubkey.get().get(pubkey) || []);
|
|
28
|
+
export const getMuters = (pubkey) => Array.from(mutersByPubkey.get().get(pubkey) || []);
|
|
29
|
+
export const getFollowsWhoFollow = (pubkey, target) => getFollows(pubkey).filter(other => getFollows(other).includes(target));
|
|
30
|
+
export const getFollowsWhoMute = (pubkey, target) => getFollows(pubkey).filter(other => getMutes(other).includes(target));
|
|
31
|
+
export const wotGraph = withGetter(writable(new Map()));
|
|
32
|
+
const buildGraph = throttle(1000, () => {
|
|
33
|
+
const $pubkey = pubkey.get();
|
|
34
|
+
const $graph = new Map();
|
|
35
|
+
const $follows = $pubkey ? getFollows($pubkey) : followsByPubkey.get().keys();
|
|
36
|
+
for (const follow of $follows) {
|
|
37
|
+
for (const pubkey of getFollows(follow)) {
|
|
38
|
+
$graph.set(pubkey, inc($graph.get(pubkey)));
|
|
39
|
+
}
|
|
40
|
+
for (const pubkey of getMutes(follow)) {
|
|
41
|
+
$graph.set(pubkey, dec($graph.get(pubkey)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
wotGraph.set($graph);
|
|
45
|
+
});
|
|
46
|
+
pubkey.subscribe(buildGraph);
|
|
47
|
+
follows.subscribe(buildGraph);
|
|
48
|
+
mutes.subscribe(buildGraph);
|
|
49
|
+
export const getWotScore = (pubkey, target) => {
|
|
50
|
+
const follows = pubkey ? getFollowsWhoFollow(pubkey, target) : getFollowers(target);
|
|
51
|
+
const mutes = pubkey ? getFollowsWhoMute(pubkey, target) : getMuters(target);
|
|
52
|
+
return follows.length - mutes.length;
|
|
53
|
+
};
|
|
54
|
+
export const getUserWotScore = (pubkey) => wotGraph.get().get(pubkey) || 0;
|
|
55
|
+
//# sourceMappingURL=wot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wot.mjs","sourceRoot":"","sources":["../../src/wot.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB;OACnC,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc;OACvC,EAAC,WAAW,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,eAAe;OAC5C,EAAC,aAAa,EAAC,MAAM,gBAAgB;OACrC,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,iBAAiB;OAC9C,EAAC,MAAM,EAAC;OACR,EAAC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAC;OACtC,EAAC,KAAK,EAAE,QAAQ,EAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CACzC,OAAO,CACL,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,EACxB,KAAK,CAAC,EAAE;IACN,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,KAAK,MAAM,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;YAC7C,WAAW,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;SAC3D;KACF;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC,CACF,CACF,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CACtC,OAAO,CACL,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,EACtB,KAAK,CAAC,EAAE;IACN,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEtD,KAAK,MAAM,IAAI,IAAI,K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,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@welshman/app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"author": "hodlbod",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A collection of svelte stores for use in building nostr client applications.",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"typescript": "~5.1.6"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@welshman/lib": "0.0.
|
|
35
|
-
"@welshman/net": "0.0.
|
|
36
|
-
"@welshman/signer": "0.0.
|
|
37
|
-
"@welshman/store": "0.0.
|
|
38
|
-
"@welshman/util": "0.0.
|
|
34
|
+
"@welshman/lib": "^0.0.18",
|
|
35
|
+
"@welshman/net": "^0.0.23",
|
|
36
|
+
"@welshman/signer": "^0.0.6",
|
|
37
|
+
"@welshman/store": "^0.0.8",
|
|
38
|
+
"@welshman/util": "^0.0.34",
|
|
39
39
|
"fuse.js": "^7.0.0",
|
|
40
40
|
"idb": "^8.0.0",
|
|
41
41
|
"svelte": "^4.2.18",
|