@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,47 @@
|
|
|
1
|
+
import Fuse from "fuse.js";
|
|
2
|
+
import { sortBy } from "@welshman/lib";
|
|
3
|
+
export const createSearch = (options, opts) => {
|
|
4
|
+
const fuse = new Fuse(options, { ...opts.fuseOptions, includeScore: true });
|
|
5
|
+
const map = new Map(options.map(item => [opts.getValue(item), item]));
|
|
6
|
+
const search = (term) => {
|
|
7
|
+
let results = term ? fuse.search(term) : options.map(item => ({ item, score: 1 }));
|
|
8
|
+
if (opts.sortFn) {
|
|
9
|
+
results = sortBy(opts.sortFn, results);
|
|
10
|
+
}
|
|
11
|
+
return results.map(result => result.item);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
options,
|
|
15
|
+
getValue: opts.getValue,
|
|
16
|
+
getOption: (value) => map.get(value),
|
|
17
|
+
searchOptions: (term) => search(term),
|
|
18
|
+
searchValues: (term) => search(term).map(opts.getValue),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const secondsToDate = (ts) => new Date(ts * 1000);
|
|
22
|
+
export const dateToSeconds = (date) => Math.round(date.valueOf() / 1000);
|
|
23
|
+
export const getTimeZone = () => new Date().toString().match(/GMT[^\s]+/);
|
|
24
|
+
export const createLocalDate = (dateString) => new Date(`${dateString} ${getTimeZone()}`);
|
|
25
|
+
export const getLocale = () => new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
26
|
+
export const formatTimestamp = (ts) => {
|
|
27
|
+
const formatter = new Intl.DateTimeFormat(getLocale(), {
|
|
28
|
+
dateStyle: "short",
|
|
29
|
+
timeStyle: "short",
|
|
30
|
+
});
|
|
31
|
+
return formatter.format(secondsToDate(ts));
|
|
32
|
+
};
|
|
33
|
+
export const formatTimestampAsDate = (ts) => {
|
|
34
|
+
const formatter = new Intl.DateTimeFormat(getLocale(), {
|
|
35
|
+
year: "numeric",
|
|
36
|
+
month: "long",
|
|
37
|
+
day: "numeric",
|
|
38
|
+
});
|
|
39
|
+
return formatter.format(secondsToDate(ts));
|
|
40
|
+
};
|
|
41
|
+
export const formatTimestampAsTime = (ts) => {
|
|
42
|
+
const formatter = new Intl.DateTimeFormat(getLocale(), {
|
|
43
|
+
timeStyle: "short",
|
|
44
|
+
});
|
|
45
|
+
return formatter.format(secondsToDate(ts));
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=util.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.mjs","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"OAAO,IAAI,MAAM,SAAS;OAEnB,EAAC,MAAM,EAAC,MAAM,eAAe;AAgBpC,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,IAAI,CAAC,CAAC,CAAC,CAAA;IAE3E,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE;QAC9B,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAC,CAAkB,CAAC,CAAA;QAEjG,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SACvC;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC,CAAA;IAED,OAAO;QACL,OAAO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,CAAC,CAAC,CAAA;AAC5C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE;QACrD,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,SAAS;KACf,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE;QACrD,SAAS,EAAE,OAAO;KACnB,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5C,CAAC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.loadZapper = exports.deriveZapper = exports.zappersByLnurl = exports.fetchZappers = exports.zappersByPubkey = exports.zappers = 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.zappers = (0, store_2.withGetter)((0, store_1.writable)([]));
|
|
12
|
+
exports.zappersByPubkey = (0, store_1.derived)([profiles_1.profilesByPubkey, exports.zappers], ([$profilesByPubkey, $zappers]) => (0, lib_1.indexBy)($zapper => $zapper.pubkey, $zappers.filter($zapper => { var _a; return $zapper.pubkey && ((_a = $profilesByPubkey.get($zapper.pubkey)) === null || _a === void 0 ? void 0 : _a.lnurl) === $zapper.lnurl; })));
|
|
13
|
+
const fetchZappers = (lnurls) => {
|
|
14
|
+
const base = core_1.env.DUFFLEPUD_URL;
|
|
15
|
+
if (!base) {
|
|
16
|
+
throw new Error("DUFFLEPUD_URL is required to fetch zapper info");
|
|
17
|
+
}
|
|
18
|
+
const zappersByLnurl = new Map();
|
|
19
|
+
const res = (0, lib_1.postJson)(`${base}/zapper/info`, {
|
|
20
|
+
lnurls: lnurls.map(lnurl => (0, lib_1.tryCatch)(() => (0, lib_1.bech32ToHex)(lnurl))).filter(lib_1.identity),
|
|
21
|
+
});
|
|
22
|
+
for (const { lnurl, info } of (res === null || res === void 0 ? void 0 : res.data) || []) {
|
|
23
|
+
(0, lib_1.tryCatch)(() => zappersByLnurl.set((0, lib_1.bech32ToHex)(lnurl), info));
|
|
24
|
+
}
|
|
25
|
+
return zappersByLnurl;
|
|
26
|
+
};
|
|
27
|
+
exports.fetchZappers = fetchZappers;
|
|
28
|
+
_a = (0, collection_1.collection)({
|
|
29
|
+
name: "zappers",
|
|
30
|
+
store: exports.zappers,
|
|
31
|
+
getKey: (zapper) => zapper.lnurl,
|
|
32
|
+
load: (0, lib_1.batcher)(800, async (lnurls) => {
|
|
33
|
+
const fresh = await (0, exports.fetchZappers)((0, lib_1.uniq)(lnurls));
|
|
34
|
+
const stale = exports.zappersByLnurl.get();
|
|
35
|
+
const items = lnurls.map(lnurl => {
|
|
36
|
+
const zapper = fresh.get(lnurl) || stale.get(lnurl) || {};
|
|
37
|
+
return { ...zapper, lnurl };
|
|
38
|
+
});
|
|
39
|
+
exports.zappers.update($zappers => (0, lib_1.uniqBy)($zapper => $zapper.lnurl, [...$zappers, ...items]));
|
|
40
|
+
return items;
|
|
41
|
+
}),
|
|
42
|
+
}), exports.zappersByLnurl = _a.indexStore, exports.deriveZapper = _a.deriveItem, exports.loadZapper = _a.loadItem;
|
|
43
|
+
//# sourceMappingURL=zappers.cj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@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Zapper } from '@welshman/util';
|
|
3
|
+
export declare const zappers: import("svelte/store").Writable<Zapper[]> & {
|
|
4
|
+
get: () => Zapper[];
|
|
5
|
+
};
|
|
6
|
+
export declare const zappersByPubkey: import("svelte/store").Readable<Map<string | undefined, Zapper>>;
|
|
7
|
+
export declare const fetchZappers: (lnurls: string[]) => Map<string, Zapper>;
|
|
8
|
+
export declare const zappersByLnurl: import("svelte/store").Readable<Map<string, Zapper>> & {
|
|
9
|
+
get: () => Map<string, Zapper>;
|
|
10
|
+
}, deriveZapper: (key: import("@welshman/lib").Maybe<string>) => import("svelte/store").Readable<Zapper | undefined>, loadZapper: (key: string) => Promise<Zapper | undefined>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { writable, derived } from 'svelte/store';
|
|
2
|
+
import { withGetter } from '@welshman/store';
|
|
3
|
+
import { uniq, identity, bech32ToHex, indexBy, tryCatch, uniqBy, batcher, postJson } from '@welshman/lib';
|
|
4
|
+
import { env } from "./core.mjs";
|
|
5
|
+
import { collection } from "./collection.mjs";
|
|
6
|
+
import { profilesByPubkey } from "./profiles.mjs";
|
|
7
|
+
export const zappers = withGetter(writable([]));
|
|
8
|
+
export const zappersByPubkey = derived([profilesByPubkey, zappers], ([$profilesByPubkey, $zappers]) => indexBy($zapper => $zapper.pubkey, $zappers.filter($zapper => { var _a; return $zapper.pubkey && ((_a = $profilesByPubkey.get($zapper.pubkey)) === null || _a === void 0 ? void 0 : _a.lnurl) === $zapper.lnurl; })));
|
|
9
|
+
export const fetchZappers = (lnurls) => {
|
|
10
|
+
const base = env.DUFFLEPUD_URL;
|
|
11
|
+
if (!base) {
|
|
12
|
+
throw new Error("DUFFLEPUD_URL is required to fetch zapper info");
|
|
13
|
+
}
|
|
14
|
+
const zappersByLnurl = new Map();
|
|
15
|
+
const res = postJson(`${base}/zapper/info`, {
|
|
16
|
+
lnurls: lnurls.map(lnurl => tryCatch(() => bech32ToHex(lnurl))).filter(identity),
|
|
17
|
+
});
|
|
18
|
+
for (const { lnurl, info } of (res === null || res === void 0 ? void 0 : res.data) || []) {
|
|
19
|
+
tryCatch(() => zappersByLnurl.set(bech32ToHex(lnurl), info));
|
|
20
|
+
}
|
|
21
|
+
return zappersByLnurl;
|
|
22
|
+
};
|
|
23
|
+
export const { indexStore: zappersByLnurl, deriveItem: deriveZapper, loadItem: loadZapper, } = collection({
|
|
24
|
+
name: "zappers",
|
|
25
|
+
store: zappers,
|
|
26
|
+
getKey: (zapper) => zapper.lnurl,
|
|
27
|
+
load: batcher(800, async (lnurls) => {
|
|
28
|
+
const fresh = await fetchZappers(uniq(lnurls));
|
|
29
|
+
const stale = zappersByLnurl.get();
|
|
30
|
+
const items = lnurls.map(lnurl => {
|
|
31
|
+
const zapper = fresh.get(lnurl) || stale.get(lnurl) || {};
|
|
32
|
+
return { ...zapper, lnurl };
|
|
33
|
+
});
|
|
34
|
+
zappers.update($zappers => uniqBy($zapper => $zapper.lnurl, [...$zappers, ...items]));
|
|
35
|
+
return items;
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=zappers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zappers.mjs","sourceRoot":"","sources":["../../src/zappers.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,cAAc;OACvC,EAAC,UAAU,EAAC,MAAM,iBAAiB;OAEnC,EAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,eAAe;OAChG,EAAC,GAAG,EAAC;OACL,EAAC,UAAU,EAAC;OACZ,EAAC,gBAAgB,EAAC;AAEzB,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAW,EAAE,CAAC,CAAC,CAAA;AAEzD,M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c,EAC1B,UAAU,EAAE,YAAY,EACxB,QAAQ,EAAE,UAAU,GACrB,GAAG,UAAU,CAAC;IACb,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK;IACxC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,MAAgB,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAC9C,MAAM,KAAK,GAAG,cAAc,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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@welshman/app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"author": "hodlbod",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A collection of svelte stores for use in building nostr client applications.",
|
|
@@ -31,8 +31,14 @@
|
|
|
31
31
|
"typescript": "~5.1.6"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@welshman/lib": "0.0.
|
|
35
|
-
"@welshman/
|
|
36
|
-
"
|
|
34
|
+
"@welshman/lib": "0.0.16",
|
|
35
|
+
"@welshman/net": "0.0.20",
|
|
36
|
+
"@welshman/signer": "0.0.4",
|
|
37
|
+
"@welshman/store": "0.0.4",
|
|
38
|
+
"@welshman/util": "0.0.29",
|
|
39
|
+
"fuse.js": "^7.0.0",
|
|
40
|
+
"idb": "^8.0.0",
|
|
41
|
+
"svelte": "^4.2.18",
|
|
42
|
+
"throttle-debounce": "^5.0.2"
|
|
37
43
|
}
|
|
38
44
|
}
|
package/build/src/relay.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tracker = exports.relay = exports.repository = void 0;
|
|
4
|
-
const util_1 = require("@welshman/util");
|
|
5
|
-
const net_1 = require("@welshman/net");
|
|
6
|
-
exports.repository = new util_1.Repository();
|
|
7
|
-
exports.relay = new util_1.Relay(exports.repository);
|
|
8
|
-
exports.tracker = new net_1.Tracker();
|
|
9
|
-
Object.assign(net_1.NetworkContext, {
|
|
10
|
-
onEvent: (url, event) => exports.tracker.track(event.id, url),
|
|
11
|
-
isDeleted: (url, event) => exports.repository.isDeleted(event),
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=relay.cjs.map
|
package/build/src/relay.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relay.cjs","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":";;;AACA,yCAAgD;AAChD,uCAAqD;AAExC,QAAA,UAAU,GAAG,IAAI,iBAAU,EAAe,CAAA;AAE1C,QAAA,KAAK,GAAG,IAAI,YAAK,CAAC,kBAAU,CAAC,CAAA;AAE7B,QAAA,OAAO,GAAG,IAAI,aAAO,EAAE,CAAA;AAEpC,MAAM,CAAC,MAAM,CAAC,oBAAc,EAAE;IAC5B,OAAO,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,eAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC;IAC3E,SAAS,EAAE,CAAC,GAAW,EAAE,KAAmB,EAAE,EAAE,CAAC,kBAAU,CAAC,SAAS,CAAC,KAAK,CAAC;CAC7E,CAAC,CAAA"}
|
package/build/src/relay.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { HashedEvent } from "@welshman/util";
|
|
2
|
-
import { Repository, Relay } from "@welshman/util";
|
|
3
|
-
import { Tracker } from "@welshman/net";
|
|
4
|
-
export declare const repository: Repository<HashedEvent>;
|
|
5
|
-
export declare const relay: Relay<HashedEvent>;
|
|
6
|
-
export declare const tracker: Tracker;
|
package/build/src/relay.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Repository, Relay } from "@welshman/util";
|
|
2
|
-
import { NetworkContext, Tracker } from "@welshman/net";
|
|
3
|
-
export const repository = new Repository();
|
|
4
|
-
export const relay = new Relay(repository);
|
|
5
|
-
export const tracker = new Tracker();
|
|
6
|
-
Object.assign(NetworkContext, {
|
|
7
|
-
onEvent: (url, event) => tracker.track(event.id, url),
|
|
8
|
-
isDeleted: (url, event) => repository.isDeleted(event),
|
|
9
|
-
});
|
|
10
|
-
//# sourceMappingURL=relay.mjs.map
|
package/build/src/relay.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relay.mjs","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"OACO,EAAC,UAAU,EAAE,KAAK,EAAC,MAAM,gBAAgB;OACzC,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,eAAe;AAErD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAe,CAAA;AAEvD,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,CAAC,cAAc,EAAE;IAC5B,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"}
|
package/build/src/types.cjs
DELETED
package/build/src/types.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/build/src/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Nip46Handler } from "@welshman/signer";
|
|
2
|
-
import type { RelayProfile } from "@welshman/util";
|
|
3
|
-
export type Session = {
|
|
4
|
-
method: string;
|
|
5
|
-
pubkey: string;
|
|
6
|
-
secret?: string;
|
|
7
|
-
handler?: Nip46Handler;
|
|
8
|
-
};
|
|
9
|
-
export type Relay = RelayProfile;
|
|
10
|
-
export type Handle = {
|
|
11
|
-
pubkey: string;
|
|
12
|
-
nip05: string;
|
|
13
|
-
nip46: string[];
|
|
14
|
-
relays: string[];
|
|
15
|
-
};
|
package/build/src/types.mjs
DELETED
package/build/src/types.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|