applesauce-common 5.1.0 → 6.0.0
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/dist/casts/_circular-import.d.ts +7 -0
- package/dist/casts/_circular-import.js +9 -0
- package/dist/casts/article.d.ts +1 -1
- package/dist/casts/badge-award.d.ts +24 -0
- package/dist/casts/badge-award.js +39 -0
- package/dist/casts/badge.d.ts +19 -0
- package/dist/casts/badge.js +48 -0
- package/dist/casts/bookmarks.d.ts +5 -5
- package/dist/casts/cast.d.ts +1 -30
- package/dist/casts/cast.js +2 -67
- package/dist/casts/comment.d.ts +5 -5
- package/dist/casts/emoji-pack.d.ts +11 -0
- package/dist/casts/emoji-pack.js +25 -0
- package/dist/casts/favorite-emojis.d.ts +25 -0
- package/dist/casts/favorite-emojis.js +62 -0
- package/dist/casts/file-metadata.d.ts +22 -0
- package/dist/casts/file-metadata.js +55 -0
- package/dist/casts/groups.d.ts +1 -1
- package/dist/casts/index.d.ts +7 -0
- package/dist/casts/index.js +7 -0
- package/dist/casts/mutes.d.ts +1 -1
- package/dist/casts/note.d.ts +7 -7
- package/dist/casts/profile-badges.d.ts +28 -0
- package/dist/casts/profile-badges.js +59 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-lists.d.ts +1 -1
- package/dist/casts/relay-monitor.d.ts +1 -1
- package/dist/casts/report.d.ts +2 -2
- package/dist/casts/share.d.ts +2 -2
- package/dist/casts/stream.d.ts +9 -9
- package/dist/casts/torrent.d.ts +3 -3
- package/dist/casts/trusted-assertions.d.ts +144 -0
- package/dist/casts/trusted-assertions.js +281 -0
- package/dist/casts/user.d.ts +22 -38
- package/dist/casts/user.js +106 -153
- package/dist/casts/zap-goal.d.ts +2 -2
- package/dist/casts/zap.d.ts +4 -4
- package/dist/factories/app-data.d.ts +13 -0
- package/dist/factories/app-data.js +20 -0
- package/dist/factories/badge-award.d.ts +25 -0
- package/dist/factories/badge-award.js +41 -0
- package/dist/factories/badge.d.ts +32 -0
- package/dist/factories/badge.js +50 -0
- package/dist/factories/blocked-relays.d.ts +10 -0
- package/dist/factories/blocked-relays.js +16 -0
- package/dist/factories/blossom-server-list.d.ts +19 -0
- package/dist/factories/blossom-server-list.js +36 -0
- package/dist/factories/bookmark-list.d.ts +23 -0
- package/dist/factories/bookmark-list.js +45 -0
- package/dist/factories/bookmark-set.d.ts +25 -0
- package/dist/factories/bookmark-set.js +51 -0
- package/dist/factories/calendar-event.d.ts +88 -0
- package/dist/factories/calendar-event.js +175 -0
- package/dist/factories/calendar-rsvp.d.ts +22 -0
- package/dist/factories/calendar-rsvp.js +35 -0
- package/dist/factories/calendar.d.ts +20 -0
- package/dist/factories/calendar.js +36 -0
- package/dist/factories/code-snippet.d.ts +65 -0
- package/dist/factories/code-snippet.js +100 -0
- package/dist/factories/comment.d.ts +26 -0
- package/dist/factories/comment.js +49 -0
- package/dist/factories/contacts.d.ts +19 -0
- package/dist/factories/contacts.js +36 -0
- package/dist/factories/dm-relays.d.ts +10 -0
- package/dist/factories/dm-relays.js +16 -0
- package/dist/factories/favorite-relays.d.ts +16 -0
- package/dist/factories/favorite-relays.js +31 -0
- package/dist/factories/file-metadata.d.ts +54 -0
- package/dist/factories/file-metadata.js +92 -0
- package/dist/factories/follow-set.d.ts +12 -0
- package/dist/factories/follow-set.js +22 -0
- package/dist/factories/gift-wrap.d.ts +17 -0
- package/dist/factories/gift-wrap.js +21 -0
- package/dist/factories/group-management.d.ts +63 -0
- package/dist/factories/group-management.js +147 -0
- package/dist/factories/group.d.ts +35 -0
- package/dist/factories/group.js +69 -0
- package/dist/factories/highlight.d.ts +33 -0
- package/dist/factories/highlight.js +49 -0
- package/dist/factories/index.d.ts +41 -0
- package/dist/factories/index.js +41 -0
- package/dist/factories/legacy-message.d.ts +10 -0
- package/dist/factories/legacy-message.js +19 -0
- package/dist/factories/list.d.ts +56 -0
- package/dist/factories/list.js +120 -0
- package/dist/factories/live-stream.d.ts +48 -0
- package/dist/factories/live-stream.js +90 -0
- package/dist/factories/mute-list.d.ts +27 -0
- package/dist/factories/mute-list.js +57 -0
- package/dist/factories/note.d.ts +38 -0
- package/dist/factories/note.js +66 -0
- package/dist/factories/picture-post.d.ts +28 -0
- package/dist/factories/picture-post.js +46 -0
- package/dist/factories/pin-list.d.ts +14 -0
- package/dist/factories/pin-list.js +24 -0
- package/dist/factories/poll-response.d.ts +36 -0
- package/dist/factories/poll-response.js +46 -0
- package/dist/factories/poll.d.ts +35 -0
- package/dist/factories/poll.js +48 -0
- package/dist/factories/profile-badges.d.ts +31 -0
- package/dist/factories/profile-badges.js +52 -0
- package/dist/factories/reaction.d.ts +22 -0
- package/dist/factories/reaction.js +37 -0
- package/dist/factories/relay-set.d.ts +12 -0
- package/dist/factories/relay-set.js +22 -0
- package/dist/factories/search-relays.d.ts +10 -0
- package/dist/factories/search-relays.js +16 -0
- package/dist/factories/share.d.ts +26 -0
- package/dist/factories/share.js +44 -0
- package/dist/factories/stream-chat-message.d.ts +22 -0
- package/dist/factories/stream-chat-message.js +31 -0
- package/dist/factories/torrent.d.ts +57 -0
- package/dist/factories/torrent.js +93 -0
- package/dist/factories/wrapped-message.d.ts +22 -0
- package/dist/factories/wrapped-message.js +39 -0
- package/dist/factories/zap-goal.d.ts +35 -0
- package/dist/factories/zap-goal.js +49 -0
- package/dist/factories/zap-request.d.ts +28 -0
- package/dist/factories/zap-request.js +55 -0
- package/dist/factories/zap.d.ts +13 -0
- package/dist/factories/zap.js +21 -0
- package/dist/helpers/badge-award.d.ts +15 -0
- package/dist/helpers/badge-award.js +32 -0
- package/dist/helpers/badge.d.ts +27 -0
- package/dist/helpers/badge.js +59 -0
- package/dist/helpers/blossom.d.ts +29 -1
- package/dist/helpers/blossom.js +64 -7
- package/dist/helpers/emoji-pack.d.ts +43 -0
- package/dist/helpers/emoji-pack.js +108 -0
- package/dist/helpers/emoji.d.ts +4 -5
- package/dist/helpers/emoji.js +3 -15
- package/dist/helpers/file-metadata.d.ts +18 -13
- package/dist/helpers/file-metadata.js +10 -4
- package/dist/helpers/groups.d.ts +1 -0
- package/dist/helpers/groups.js +3 -2
- package/dist/helpers/hashtag.d.ts +1 -0
- package/dist/helpers/hashtag.js +3 -3
- package/dist/helpers/index.d.ts +7 -2
- package/dist/helpers/index.js +7 -2
- package/dist/helpers/lists.d.ts +8 -0
- package/dist/helpers/lists.js +27 -5
- package/dist/helpers/picture-post.d.ts +2 -2
- package/dist/helpers/profile-badges.d.ts +23 -0
- package/dist/helpers/profile-badges.js +51 -0
- package/dist/helpers/trusted-assertions.d.ts +81 -0
- package/dist/helpers/trusted-assertions.js +161 -0
- package/dist/helpers/zap.d.ts +8 -2
- package/dist/helpers/zap.js +31 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +1 -1
- package/dist/models/thread.d.ts +1 -1
- package/dist/models/thread.js +23 -7
- package/dist/observable/chainable.d.ts +1 -36
- package/dist/observable/chainable.js +2 -72
- package/dist/operations/app-data.d.ts +8 -3
- package/dist/operations/app-data.js +9 -4
- package/dist/operations/badge-award.d.ts +17 -0
- package/dist/operations/badge-award.js +30 -0
- package/dist/operations/badge.d.ts +22 -0
- package/dist/operations/badge.js +54 -0
- package/dist/operations/blossom.d.ts +1 -1
- package/dist/operations/calendar-event.d.ts +1 -1
- package/dist/operations/calendar-rsvp.d.ts +1 -1
- package/dist/operations/calendar.d.ts +1 -1
- package/dist/operations/channel.d.ts +1 -1
- package/dist/operations/client.d.ts +1 -1
- package/dist/operations/client.js +2 -2
- package/dist/operations/code-snippet.d.ts +27 -0
- package/dist/operations/code-snippet.js +63 -0
- package/dist/operations/comment.d.ts +7 -3
- package/dist/operations/comment.js +8 -4
- package/dist/operations/file-metadata.d.ts +38 -4
- package/dist/operations/file-metadata.js +105 -19
- package/dist/operations/geohash.d.ts +1 -1
- package/dist/operations/gift-wrap.d.ts +19 -7
- package/dist/operations/gift-wrap.js +36 -26
- package/dist/operations/group.d.ts +1 -1
- package/dist/operations/hashtags.d.ts +1 -1
- package/dist/operations/highlight.d.ts +1 -1
- package/dist/operations/highlight.js +5 -5
- package/dist/operations/index.d.ts +7 -1
- package/dist/operations/index.js +7 -1
- package/dist/operations/legacy-message.d.ts +1 -1
- package/dist/operations/list.d.ts +1 -1
- package/dist/operations/live-stream.d.ts +7 -3
- package/dist/operations/live-stream.js +9 -5
- package/dist/operations/media-attachment.d.ts +3 -3
- package/dist/operations/note.d.ts +10 -4
- package/dist/operations/note.js +14 -8
- package/dist/operations/picture-post.d.ts +1 -1
- package/dist/operations/poll-response.d.ts +1 -1
- package/dist/operations/poll-response.js +1 -1
- package/dist/operations/poll.d.ts +1 -1
- package/dist/operations/profile-badges.d.ts +26 -0
- package/dist/operations/profile-badges.js +150 -0
- package/dist/operations/reaction.d.ts +8 -3
- package/dist/operations/reaction.js +10 -5
- package/dist/operations/share.d.ts +8 -3
- package/dist/operations/share.js +10 -5
- package/dist/operations/stream.d.ts +1 -1
- package/dist/operations/tag/bookmarks.d.ts +1 -1
- package/dist/operations/torrent.d.ts +1 -1
- package/dist/operations/wrapped-message.d.ts +1 -1
- package/dist/operations/zap-goal.d.ts +1 -1
- package/dist/operations/zap-request.d.ts +22 -0
- package/dist/operations/zap-request.js +40 -0
- package/dist/operations/zap-split.d.ts +8 -4
- package/dist/operations/zap-split.js +10 -6
- package/dist/operations/zap.d.ts +12 -0
- package/dist/operations/zap.js +34 -0
- package/package.json +13 -12
- package/dist/blueprints/__register__.d.ts +0 -7
- package/dist/blueprints/__register__.js +0 -8
- package/dist/blueprints/app-data.d.ts +0 -5
- package/dist/blueprints/app-data.js +0 -10
- package/dist/blueprints/calendar.d.ts +0 -5
- package/dist/blueprints/calendar.js +0 -7
- package/dist/blueprints/channels.d.ts +0 -6
- package/dist/blueprints/channels.js +0 -13
- package/dist/blueprints/comment.d.ts +0 -13
- package/dist/blueprints/comment.js +0 -15
- package/dist/blueprints/delete.d.ts +0 -9
- package/dist/blueprints/delete.js +0 -14
- package/dist/blueprints/file-metadata.d.ts +0 -8
- package/dist/blueprints/file-metadata.js +0 -11
- package/dist/blueprints/follow-set.d.ts +0 -11
- package/dist/blueprints/follow-set.js +0 -21
- package/dist/blueprints/gift-wrap.d.ts +0 -5
- package/dist/blueprints/gift-wrap.js +0 -6
- package/dist/blueprints/group-mangement.d.ts +0 -25
- package/dist/blueprints/group-mangement.js +0 -40
- package/dist/blueprints/group.d.ts +0 -9
- package/dist/blueprints/group.js +0 -17
- package/dist/blueprints/highlight.d.ts +0 -20
- package/dist/blueprints/highlight.js +0 -12
- package/dist/blueprints/index.d.ts +0 -25
- package/dist/blueprints/index.js +0 -26
- package/dist/blueprints/legacy-message.d.ts +0 -7
- package/dist/blueprints/legacy-message.js +0 -29
- package/dist/blueprints/live-stream.d.ts +0 -6
- package/dist/blueprints/live-stream.js +0 -9
- package/dist/blueprints/note.d.ts +0 -16
- package/dist/blueprints/note.js +0 -30
- package/dist/blueprints/picture-post.d.ts +0 -12
- package/dist/blueprints/picture-post.js +0 -17
- package/dist/blueprints/poll.d.ts +0 -41
- package/dist/blueprints/poll.js +0 -33
- package/dist/blueprints/profile.d.ts +0 -3
- package/dist/blueprints/profile.js +0 -7
- package/dist/blueprints/reaction.d.ts +0 -10
- package/dist/blueprints/reaction.js +0 -14
- package/dist/blueprints/share.d.ts +0 -12
- package/dist/blueprints/share.js +0 -25
- package/dist/blueprints/stream.d.ts +0 -6
- package/dist/blueprints/stream.js +0 -7
- package/dist/blueprints/torrent.d.ts +0 -30
- package/dist/blueprints/torrent.js +0 -29
- package/dist/blueprints/wrapped-message.d.ts +0 -20
- package/dist/blueprints/wrapped-message.js +0 -64
- package/dist/blueprints/zap-goal.d.ts +0 -16
- package/dist/blueprints/zap-goal.js +0 -12
- package/dist/register.d.ts +0 -2
- package/dist/register.js +0 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
2
|
+
import { getReplaceableIdentifier, getTagValue, kinds } from "applesauce-core/helpers/event";
|
|
3
|
+
const BadgeHeroSymbol = Symbol.for("badge-hero-image");
|
|
4
|
+
const BadgeThumbnailsSymbol = Symbol.for("badge-thumbnails");
|
|
5
|
+
function parseDimension(value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
return {};
|
|
8
|
+
const [width, height] = value.split("x").map((v) => parseInt(v, 10));
|
|
9
|
+
return {
|
|
10
|
+
width: Number.isFinite(width) ? width : undefined,
|
|
11
|
+
height: Number.isFinite(height) ? height : undefined,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the event is a valid badge definition (kind 30009).
|
|
16
|
+
* Validates kind and the required `d` tag identifier.
|
|
17
|
+
*/
|
|
18
|
+
export function isValidBadge(event) {
|
|
19
|
+
if (!event || event.kind !== kinds.BadgeDefinition)
|
|
20
|
+
return false;
|
|
21
|
+
const identifier = getReplaceableIdentifier(event);
|
|
22
|
+
return !!identifier && identifier.length > 0;
|
|
23
|
+
}
|
|
24
|
+
export function getBadgeIdentifier(event) {
|
|
25
|
+
if (!isValidBadge(event))
|
|
26
|
+
return undefined;
|
|
27
|
+
return getReplaceableIdentifier(event) || undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Returns the human-readable badge name (`name` tag). */
|
|
30
|
+
export function getBadgeName(event) {
|
|
31
|
+
if (!isValidBadge(event))
|
|
32
|
+
return undefined;
|
|
33
|
+
return getTagValue(event, "name") || undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Returns the long-form badge description (`description` tag). */
|
|
36
|
+
export function getBadgeDescription(event) {
|
|
37
|
+
if (!isValidBadge(event))
|
|
38
|
+
return undefined;
|
|
39
|
+
return getTagValue(event, "description") || undefined;
|
|
40
|
+
}
|
|
41
|
+
/** Returns the hero image declared via the `image` tag. */
|
|
42
|
+
export function getBadgeHeroImage(event) {
|
|
43
|
+
if (!isValidBadge(event))
|
|
44
|
+
return undefined;
|
|
45
|
+
return getOrComputeCachedValue(event, BadgeHeroSymbol, () => {
|
|
46
|
+
const tag = event.tags.find((entry) => entry[0] === "image" && entry[1]);
|
|
47
|
+
return tag ? { url: tag[1], ...parseDimension(tag[2]) } : undefined;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Returns every thumbnail declared via `thumb` tags. */
|
|
51
|
+
export function getBadgeThumbnails(event) {
|
|
52
|
+
if (!isValidBadge(event))
|
|
53
|
+
return [];
|
|
54
|
+
return getOrComputeCachedValue(event, BadgeThumbnailsSymbol, () => event.tags.filter((tag) => tag[0] === "thumb" && tag[1]).map((tag) => ({ url: tag[1], ...parseDimension(tag[2]) })));
|
|
55
|
+
}
|
|
56
|
+
/** Returns the preferred image for display (hero image or first thumbnail). */
|
|
57
|
+
export function getBadgeImage(event) {
|
|
58
|
+
return getBadgeHeroImage(event) ?? getBadgeThumbnails(event)[0];
|
|
59
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Parses a server string or URL to a root URL */
|
|
2
|
+
export declare function normalizeBlossomServer(s: string | URL): URL;
|
|
1
3
|
export declare const BLOSSOM_SERVER_LIST_KIND = 10063;
|
|
2
4
|
/** Check if two servers are the same */
|
|
3
5
|
export declare function areBlossomServersEqual(a: string | URL, b: string | URL): boolean;
|
|
@@ -7,5 +9,31 @@ export declare function isSha256(str: string): boolean;
|
|
|
7
9
|
export declare function getBlossomServersFromList(event: {
|
|
8
10
|
tags: string[][];
|
|
9
11
|
} | string[][]): URL[];
|
|
12
|
+
export interface ParsedBlossomURI {
|
|
13
|
+
/** 64 character lowercase hex sha256 hash of the blob */
|
|
14
|
+
sha256: string;
|
|
15
|
+
/** File extension without the leading dot (e.g. "pdf", "png", "bin") */
|
|
16
|
+
ext: string;
|
|
17
|
+
/** Optional exact blob size in bytes */
|
|
18
|
+
size?: number;
|
|
19
|
+
/** Server hints from repeated `xs` query parameters */
|
|
20
|
+
servers: string[];
|
|
21
|
+
/** Author hex pubkeys from repeated `as` query parameters */
|
|
22
|
+
authors: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parses a BUD-10 `blossom:` URI into its components.
|
|
26
|
+
*
|
|
27
|
+
* @returns The parsed URI, or `null` if the string is not a valid blossom URI.
|
|
28
|
+
* @see https://github.com/hzrd149/blossom/blob/master/buds/10.md
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseBlossomURI(uri: string | URL): ParsedBlossomURI | null;
|
|
31
|
+
/**
|
|
32
|
+
* Encodes a parsed blossom URI back into a string.
|
|
33
|
+
* Defaults `ext` to "bin" if empty, per BUD-10.
|
|
34
|
+
*/
|
|
35
|
+
export declare function encodeBlossomURI(data: ParsedBlossomURI): string;
|
|
10
36
|
/** A method that merges multiple arrays of blossom servers into a single array of unique servers */
|
|
11
|
-
export declare function mergeBlossomServers<T extends URL | string | (string | URL)>(...servers: (T | null | undefined | T[])[]): T[];
|
|
37
|
+
export declare function mergeBlossomServers<T extends URL | string | (string | URL)>(...servers: (T | null | undefined | (T | null | undefined)[])[]): T[];
|
|
38
|
+
/** Alias for {@link mergeBlossomServers} */
|
|
39
|
+
export declare const blossomServers: typeof mergeBlossomServers;
|
package/dist/helpers/blossom.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { isNameValueTag, processTags } from "applesauce-core/helpers/tags";
|
|
2
|
+
import { ensureProtocol } from "applesauce-core/helpers/url";
|
|
3
|
+
/** Parses a server string or URL to a root URL */
|
|
4
|
+
export function normalizeBlossomServer(s) {
|
|
5
|
+
return new URL("/", typeof s === "string" ? ensureProtocol(s, "https:") : s);
|
|
6
|
+
}
|
|
2
7
|
export const BLOSSOM_SERVER_LIST_KIND = 10063;
|
|
3
8
|
/** Check if two servers are the same */
|
|
4
9
|
export function areBlossomServersEqual(a, b) {
|
|
5
|
-
|
|
6
|
-
const hostnameB = new URL("/", b).toString();
|
|
7
|
-
return hostnameA === hostnameB;
|
|
10
|
+
return normalizeBlossomServer(a).href === normalizeBlossomServer(b).href;
|
|
8
11
|
}
|
|
9
12
|
/** Checks if a string is a sha256 hash */
|
|
10
13
|
export function isSha256(str) {
|
|
@@ -20,6 +23,57 @@ export function getBlossomServersFromList(event) {
|
|
|
20
23
|
return undefined;
|
|
21
24
|
});
|
|
22
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Parses a BUD-10 `blossom:` URI into its components.
|
|
28
|
+
*
|
|
29
|
+
* @returns The parsed URI, or `null` if the string is not a valid blossom URI.
|
|
30
|
+
* @see https://github.com/hzrd149/blossom/blob/master/buds/10.md
|
|
31
|
+
*/
|
|
32
|
+
export function parseBlossomURI(uri) {
|
|
33
|
+
let url;
|
|
34
|
+
try {
|
|
35
|
+
url = typeof uri === "string" ? new URL(uri) : uri;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (url.protocol !== "blossom:")
|
|
41
|
+
return null;
|
|
42
|
+
const dotIndex = url.pathname.indexOf(".");
|
|
43
|
+
if (dotIndex === -1)
|
|
44
|
+
return null;
|
|
45
|
+
const sha256 = url.pathname.slice(0, dotIndex);
|
|
46
|
+
const ext = url.pathname.slice(dotIndex + 1);
|
|
47
|
+
if (!isSha256(sha256))
|
|
48
|
+
return null;
|
|
49
|
+
if (ext.length === 0)
|
|
50
|
+
return null;
|
|
51
|
+
const servers = url.searchParams.getAll("xs");
|
|
52
|
+
const authors = url.searchParams.getAll("as");
|
|
53
|
+
let size;
|
|
54
|
+
const sz = url.searchParams.get("sz");
|
|
55
|
+
if (sz !== null) {
|
|
56
|
+
const parsed = Number(sz);
|
|
57
|
+
if (Number.isInteger(parsed) && parsed > 0)
|
|
58
|
+
size = parsed;
|
|
59
|
+
}
|
|
60
|
+
return { sha256, ext, size, servers, authors };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Encodes a parsed blossom URI back into a string.
|
|
64
|
+
* Defaults `ext` to "bin" if empty, per BUD-10.
|
|
65
|
+
*/
|
|
66
|
+
export function encodeBlossomURI(data) {
|
|
67
|
+
const ext = data.ext || "bin";
|
|
68
|
+
const url = new URL(`blossom:${data.sha256}.${ext}`);
|
|
69
|
+
for (const server of data.servers)
|
|
70
|
+
url.searchParams.append("xs", server);
|
|
71
|
+
for (const author of data.authors)
|
|
72
|
+
url.searchParams.append("as", author);
|
|
73
|
+
if (data.size !== undefined)
|
|
74
|
+
url.searchParams.set("sz", String(data.size));
|
|
75
|
+
return url.toString();
|
|
76
|
+
}
|
|
23
77
|
/** A method that merges multiple arrays of blossom servers into a single array of unique servers */
|
|
24
78
|
export function mergeBlossomServers(...servers) {
|
|
25
79
|
let merged = [];
|
|
@@ -29,12 +83,15 @@ export function mergeBlossomServers(...servers) {
|
|
|
29
83
|
for (const s of arr) {
|
|
30
84
|
if (s === null || s === undefined)
|
|
31
85
|
continue;
|
|
32
|
-
const
|
|
33
|
-
|
|
86
|
+
const root = normalizeBlossomServer(s);
|
|
87
|
+
const href = root.href;
|
|
88
|
+
if (seen.has(href))
|
|
34
89
|
continue;
|
|
35
|
-
seen.add(
|
|
36
|
-
merged.push(s);
|
|
90
|
+
seen.add(href);
|
|
91
|
+
merged.push((typeof s === "string" ? href : root));
|
|
37
92
|
}
|
|
38
93
|
}
|
|
39
94
|
return merged;
|
|
40
95
|
}
|
|
96
|
+
/** Alias for {@link mergeBlossomServers} */
|
|
97
|
+
export const blossomServers = mergeBlossomServers;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { HiddenContentSigner } from "applesauce-core/helpers/hidden-content";
|
|
3
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { Emoji } from "./emoji.js";
|
|
5
|
+
import { ReadListTags } from "./lists.js";
|
|
6
|
+
export declare const FAVORITE_EMOJI_PACKS_KIND = 10030;
|
|
7
|
+
export declare const EMOJI_PACK_KIND = 30030;
|
|
8
|
+
export type FavoriteEmojisEvent = KnownEvent<typeof FAVORITE_EMOJI_PACKS_KIND>;
|
|
9
|
+
export type EmojiPackEvent = KnownEvent<typeof EMOJI_PACK_KIND>;
|
|
10
|
+
export declare const FavoriteEmojiPacksPublicSymbol: unique symbol;
|
|
11
|
+
export declare const FavoriteEmojiPacksPublicPointersSymbol: unique symbol;
|
|
12
|
+
export declare const FavoriteEmojiPacksHiddenSymbol: unique symbol;
|
|
13
|
+
export declare const FavoriteEmojiPacksHiddenPointersSymbol: unique symbol;
|
|
14
|
+
export type UnlockedFavoriteEmojiPacks = {
|
|
15
|
+
[FavoriteEmojiPacksHiddenSymbol]: Emoji[];
|
|
16
|
+
[FavoriteEmojiPacksHiddenPointersSymbol]: AddressPointer[];
|
|
17
|
+
};
|
|
18
|
+
/** Validates that an event is a valid favorite emoji packs list (kind 10030) */
|
|
19
|
+
export declare function isValidFavoriteEmojiPacks(event: NostrEvent): event is FavoriteEmojisEvent;
|
|
20
|
+
/** Validates that an event is a valid emoji pack (kind 30030) */
|
|
21
|
+
export declare function isValidEmojiPack(event: NostrEvent): event is EmojiPackEvent;
|
|
22
|
+
/** Returns the name of a NIP-30 emoji pack */
|
|
23
|
+
export declare function getEmojiPackName(pack: NostrEvent): string | undefined;
|
|
24
|
+
export declare function getEmojiPackDescription(pack: NostrEvent): string | undefined;
|
|
25
|
+
/** Returns an array of emojis from a NIP-30 emoji pack */
|
|
26
|
+
export declare function getEmojiPackEmojis(pack: NostrEvent): Emoji[];
|
|
27
|
+
/** Returns the favorite emojis from a kind 10030 list */
|
|
28
|
+
export declare function getFavoriteEmojis(list: NostrEvent, type?: ReadListTags): Emoji[];
|
|
29
|
+
/** Returns the emoji pack pointers from a kind 10030 list */
|
|
30
|
+
export declare function getFavoriteEmojiPackPointers(list: NostrEvent, type?: ReadListTags): AddressPointer[];
|
|
31
|
+
/** Returns the hidden favorite emojis if the list is unlocked */
|
|
32
|
+
export declare function getHiddenFavoriteEmojis<T extends NostrEvent & UnlockedFavoriteEmojiPacks>(list: T): Emoji[];
|
|
33
|
+
export declare function getHiddenFavoriteEmojis<T extends NostrEvent>(list: T): Emoji[] | undefined;
|
|
34
|
+
/** Returns the hidden emoji pack pointers if the list is unlocked */
|
|
35
|
+
export declare function getHiddenFavoriteEmojiPackPointers<T extends NostrEvent & UnlockedFavoriteEmojiPacks>(list: T): AddressPointer[];
|
|
36
|
+
export declare function getHiddenFavoriteEmojiPackPointers<T extends NostrEvent>(list: T): AddressPointer[] | undefined;
|
|
37
|
+
/** Checks if the hidden favorite emoji packs are unlocked */
|
|
38
|
+
export declare function isHiddenFavoriteEmojiPacksUnlocked<T extends NostrEvent>(list: T): list is T & UnlockedFavoriteEmojiPacks;
|
|
39
|
+
/** Unlocks the hidden favorite emojis and pack pointers on a kind 10030 list */
|
|
40
|
+
export declare function unlockHiddenFavoriteEmojiPacks(list: NostrEvent, signer: HiddenContentSigner): Promise<{
|
|
41
|
+
emojis: Emoji[];
|
|
42
|
+
packPointers: AddressPointer[];
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
|
|
2
|
+
import { getReplaceableIdentifier, getTagValue, kinds } from "applesauce-core/helpers/event";
|
|
3
|
+
import { getHiddenTags, isHiddenTagsUnlocked, setHiddenTagsEncryptionMethod, unlockHiddenTags, } from "applesauce-core/helpers/hidden-tags";
|
|
4
|
+
import { getAddressPointerFromATag } from "applesauce-core/helpers/pointers";
|
|
5
|
+
import { processTags } from "applesauce-core/helpers/tags";
|
|
6
|
+
import { getEmojiFromTags } from "./emoji.js";
|
|
7
|
+
import { getListTags } from "./lists.js";
|
|
8
|
+
export const FAVORITE_EMOJI_PACKS_KIND = kinds.UserEmojiList;
|
|
9
|
+
export const EMOJI_PACK_KIND = kinds.Emojisets;
|
|
10
|
+
setHiddenTagsEncryptionMethod(FAVORITE_EMOJI_PACKS_KIND, "nip44");
|
|
11
|
+
export const FavoriteEmojiPacksPublicSymbol = Symbol.for("favorite-emojis-public");
|
|
12
|
+
export const FavoriteEmojiPacksPublicPointersSymbol = Symbol.for("favorite-emoji-packs-public-pointers");
|
|
13
|
+
export const FavoriteEmojiPacksHiddenSymbol = Symbol.for("favorite-emojis-hidden");
|
|
14
|
+
export const FavoriteEmojiPacksHiddenPointersSymbol = Symbol.for("favorite-emoji-packs-hidden-pointers");
|
|
15
|
+
function parseEmojiTags(tags) {
|
|
16
|
+
return processTags(tags, (tag) => {
|
|
17
|
+
if (tag[0] !== "emoji" || !tag[1] || !tag[2])
|
|
18
|
+
return undefined;
|
|
19
|
+
return getEmojiFromTags([tag], tag[1]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function parseEmojiPackPointers(tags) {
|
|
23
|
+
return processTags(tags, (tag) => {
|
|
24
|
+
if (tag[0] !== "a")
|
|
25
|
+
return undefined;
|
|
26
|
+
const pointer = getAddressPointerFromATag(tag);
|
|
27
|
+
if (pointer?.kind !== EMOJI_PACK_KIND)
|
|
28
|
+
return undefined;
|
|
29
|
+
return pointer;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Validates that an event is a valid favorite emoji packs list (kind 10030) */
|
|
33
|
+
export function isValidFavoriteEmojiPacks(event) {
|
|
34
|
+
return event.kind === FAVORITE_EMOJI_PACKS_KIND;
|
|
35
|
+
}
|
|
36
|
+
/** Validates that an event is a valid emoji pack (kind 30030) */
|
|
37
|
+
export function isValidEmojiPack(event) {
|
|
38
|
+
return event.kind === EMOJI_PACK_KIND && !!getReplaceableIdentifier(event);
|
|
39
|
+
}
|
|
40
|
+
/** Returns the name of a NIP-30 emoji pack */
|
|
41
|
+
export function getEmojiPackName(pack) {
|
|
42
|
+
return getTagValue(pack, "title") || getTagValue(pack, "d");
|
|
43
|
+
}
|
|
44
|
+
export function getEmojiPackDescription(pack) {
|
|
45
|
+
return getTagValue(pack, "description");
|
|
46
|
+
}
|
|
47
|
+
/** Returns an array of emojis from a NIP-30 emoji pack */
|
|
48
|
+
export function getEmojiPackEmojis(pack) {
|
|
49
|
+
return parseEmojiTags(pack.tags);
|
|
50
|
+
}
|
|
51
|
+
/** Returns the favorite emojis from a kind 10030 list */
|
|
52
|
+
export function getFavoriteEmojis(list, type) {
|
|
53
|
+
const tags = getListTags(list, type);
|
|
54
|
+
if (type)
|
|
55
|
+
return parseEmojiTags(tags);
|
|
56
|
+
return getOrComputeCachedValue(list, FavoriteEmojiPacksPublicSymbol, () => parseEmojiTags(tags));
|
|
57
|
+
}
|
|
58
|
+
/** Returns the emoji pack pointers from a kind 10030 list */
|
|
59
|
+
export function getFavoriteEmojiPackPointers(list, type) {
|
|
60
|
+
const tags = getListTags(list, type);
|
|
61
|
+
if (type)
|
|
62
|
+
return parseEmojiPackPointers(tags);
|
|
63
|
+
return getOrComputeCachedValue(list, FavoriteEmojiPacksPublicPointersSymbol, () => parseEmojiPackPointers(tags));
|
|
64
|
+
}
|
|
65
|
+
export function getHiddenFavoriteEmojis(list) {
|
|
66
|
+
if (FavoriteEmojiPacksHiddenSymbol in list)
|
|
67
|
+
return list[FavoriteEmojiPacksHiddenSymbol];
|
|
68
|
+
const tags = getHiddenTags(list);
|
|
69
|
+
if (!tags)
|
|
70
|
+
return undefined;
|
|
71
|
+
const emojis = parseEmojiTags(tags);
|
|
72
|
+
Reflect.set(list, FavoriteEmojiPacksHiddenSymbol, emojis);
|
|
73
|
+
return emojis;
|
|
74
|
+
}
|
|
75
|
+
export function getHiddenFavoriteEmojiPackPointers(list) {
|
|
76
|
+
if (FavoriteEmojiPacksHiddenPointersSymbol in list)
|
|
77
|
+
return list[FavoriteEmojiPacksHiddenPointersSymbol];
|
|
78
|
+
const tags = getHiddenTags(list);
|
|
79
|
+
if (!tags)
|
|
80
|
+
return undefined;
|
|
81
|
+
const pointers = parseEmojiPackPointers(tags);
|
|
82
|
+
Reflect.set(list, FavoriteEmojiPacksHiddenPointersSymbol, pointers);
|
|
83
|
+
return pointers;
|
|
84
|
+
}
|
|
85
|
+
/** Checks if the hidden favorite emoji packs are unlocked */
|
|
86
|
+
export function isHiddenFavoriteEmojiPacksUnlocked(list) {
|
|
87
|
+
return (isHiddenTagsUnlocked(list) &&
|
|
88
|
+
(FavoriteEmojiPacksHiddenSymbol in list ||
|
|
89
|
+
FavoriteEmojiPacksHiddenPointersSymbol in list ||
|
|
90
|
+
getHiddenFavoriteEmojis(list) !== undefined ||
|
|
91
|
+
getHiddenFavoriteEmojiPackPointers(list) !== undefined));
|
|
92
|
+
}
|
|
93
|
+
/** Unlocks the hidden favorite emojis and pack pointers on a kind 10030 list */
|
|
94
|
+
export async function unlockHiddenFavoriteEmojiPacks(list, signer) {
|
|
95
|
+
if (isHiddenFavoriteEmojiPacksUnlocked(list)) {
|
|
96
|
+
return {
|
|
97
|
+
emojis: list[FavoriteEmojiPacksHiddenSymbol],
|
|
98
|
+
packPointers: list[FavoriteEmojiPacksHiddenPointersSymbol],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
await unlockHiddenTags(list, signer);
|
|
102
|
+
const emojis = getHiddenFavoriteEmojis(list);
|
|
103
|
+
const packPointers = getHiddenFavoriteEmojiPackPointers(list);
|
|
104
|
+
if (!emojis || !packPointers)
|
|
105
|
+
throw new Error("Failed to unlock hidden favorite emoji packs");
|
|
106
|
+
notifyEventUpdate(list);
|
|
107
|
+
return { emojis, packPointers };
|
|
108
|
+
}
|
package/dist/helpers/emoji.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
2
3
|
export type Emoji = {
|
|
3
4
|
/** The emoji shortcode (without the ::) */
|
|
4
5
|
shortcode: string;
|
|
5
6
|
/** The URL to the emoji image */
|
|
6
7
|
url: string;
|
|
8
|
+
/** The NIP-01 "a" tag address of the emoji pack this emoji belongs to */
|
|
9
|
+
address?: AddressPointer;
|
|
7
10
|
};
|
|
8
11
|
/** Gets an "emoji" tag that matches an emoji code */
|
|
9
12
|
export declare function getEmojiTag(tags: {
|
|
10
13
|
tags: string[][];
|
|
11
|
-
} | string[][], code: string): ["emoji", string, string] | undefined;
|
|
14
|
+
} | string[][], code: string): ["emoji", string, string, ...string[]] | undefined;
|
|
12
15
|
/** Gets an emoji for a shortcode from an array of tags or event */
|
|
13
16
|
export declare function getEmojiFromTags(event: {
|
|
14
17
|
tags: string[][];
|
|
15
18
|
} | string[][], code: string): Emoji | undefined;
|
|
16
|
-
/** Returns the name of a NIP-30 emoji pack */
|
|
17
|
-
export declare function getPackName(pack: NostrEvent): string | undefined;
|
|
18
|
-
/** Returns an array of emojis from a NIP-30 emoji pack */
|
|
19
|
-
export declare function getEmojis(pack: NostrEvent): Emoji[];
|
|
20
19
|
/** Returns the custom emoji for a reaction event */
|
|
21
20
|
export declare function getReactionEmoji(event: NostrEvent): Emoji | undefined;
|
package/dist/helpers/emoji.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseReplaceableAddress } from "applesauce-core/helpers/pointers";
|
|
2
2
|
/** Gets an "emoji" tag that matches an emoji code */
|
|
3
3
|
export function getEmojiTag(tags, code) {
|
|
4
4
|
code = code.replace(/^:|:$/g, "").toLowerCase();
|
|
@@ -9,20 +9,8 @@ export function getEmojiFromTags(event, code) {
|
|
|
9
9
|
const tag = getEmojiTag(event, code);
|
|
10
10
|
if (!tag)
|
|
11
11
|
return undefined;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
url: tag[2],
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/** Returns the name of a NIP-30 emoji pack */
|
|
18
|
-
export function getPackName(pack) {
|
|
19
|
-
return getTagValue(pack, "title") || getTagValue(pack, "d");
|
|
20
|
-
}
|
|
21
|
-
/** Returns an array of emojis from a NIP-30 emoji pack */
|
|
22
|
-
export function getEmojis(pack) {
|
|
23
|
-
return pack.tags
|
|
24
|
-
.filter((t) => t[0] === "emoji" && t[1] && t[2])
|
|
25
|
-
.map((t) => ({ shortcode: t[1], url: t[2] }));
|
|
12
|
+
const address = tag[3] ? parseReplaceableAddress(tag[3]) : undefined;
|
|
13
|
+
return address ? { shortcode: tag[1], url: tag[2], address } : { shortcode: tag[1], url: tag[2] };
|
|
26
14
|
}
|
|
27
15
|
/** Returns the custom emoji for a reaction event */
|
|
28
16
|
export function getReactionEmoji(event) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
1
|
+
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { NameValueTag } from "applesauce-core/helpers";
|
|
3
|
-
export type
|
|
3
|
+
export type FileMetadataFields = {
|
|
4
4
|
/** URL of the file */
|
|
5
5
|
url?: string;
|
|
6
6
|
/** MIME type */
|
|
@@ -33,20 +33,25 @@ export type FileMetadata = {
|
|
|
33
33
|
/** fallback URLs */
|
|
34
34
|
fallback?: string[];
|
|
35
35
|
};
|
|
36
|
-
/**
|
|
37
|
-
export type
|
|
38
|
-
/**
|
|
39
|
-
export
|
|
40
|
-
/**
|
|
41
|
-
export declare function
|
|
36
|
+
/** A kind 1063 file metadata event */
|
|
37
|
+
export type FileMetadataEvent = KnownEvent<1063>;
|
|
38
|
+
/** Alias for {@link FileMetadataFields} */
|
|
39
|
+
export type MediaAttachment = FileMetadataFields;
|
|
40
|
+
/** Type guard for a valid kind 1063 file metadata event */
|
|
41
|
+
export declare function isValidFileMetadata(event?: NostrEvent): event is FileMetadataEvent;
|
|
42
|
+
/** Parses file metadata tags into {@link FileMetadataFields} */
|
|
43
|
+
export declare function parseFileMetadataTags(tags: string[][]): FileMetadataFields;
|
|
44
|
+
/** Parses a imeta tag into a {@link FileMetadataFields} */
|
|
45
|
+
export declare function getFileMetadataFromImetaTag(tag: string[]): FileMetadataFields;
|
|
42
46
|
export declare const MediaAttachmentsSymbol: unique symbol;
|
|
43
47
|
/** Gets all the media attachments on an event */
|
|
44
|
-
export declare function getMediaAttachments(event: NostrEvent):
|
|
48
|
+
export declare function getMediaAttachments(event: NostrEvent): FileMetadataFields[];
|
|
45
49
|
/** Gets {@link FileMetadata} for a NIP-94 kind 1063 event */
|
|
46
|
-
export declare function getFileMetadata(file:
|
|
50
|
+
export declare function getFileMetadata(file: FileMetadataEvent): FileMetadataFields;
|
|
51
|
+
export declare function getFileMetadata(file?: NostrEvent): FileMetadataFields | undefined;
|
|
47
52
|
/** Returns the last 64 length hex string in a URL */
|
|
48
53
|
export declare function getSha256FromURL(url: string | URL): string | undefined;
|
|
49
|
-
/** Creates tags for {@link
|
|
50
|
-
export declare function createFileMetadataTags(attachment:
|
|
54
|
+
/** Creates tags for {@link FileMetadataFields} */
|
|
55
|
+
export declare function createFileMetadataTags(attachment: FileMetadataFields): NameValueTag[];
|
|
51
56
|
/** Creates an imeta tag for a media attachment */
|
|
52
|
-
export declare function createImetaTagForAttachment(attachment:
|
|
57
|
+
export declare function createImetaTagForAttachment(attachment: FileMetadataFields): string[];
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { getTagValue } from "applesauce-core/helpers/event";
|
|
1
2
|
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
2
|
-
/**
|
|
3
|
+
/** Type guard for a valid kind 1063 file metadata event */
|
|
4
|
+
export function isValidFileMetadata(event) {
|
|
5
|
+
return !!event && event.kind === 1063 && !!getTagValue(event, "url");
|
|
6
|
+
}
|
|
7
|
+
/** Parses file metadata tags into {@link FileMetadataFields} */
|
|
3
8
|
export function parseFileMetadataTags(tags) {
|
|
4
9
|
const fields = {};
|
|
5
10
|
let fallback = undefined;
|
|
@@ -42,7 +47,7 @@ export function parseFileMetadataTags(tags) {
|
|
|
42
47
|
metadata.blurhash = fields.blurhash;
|
|
43
48
|
return metadata;
|
|
44
49
|
}
|
|
45
|
-
/** Parses a imeta tag into a {@link
|
|
50
|
+
/** Parses a imeta tag into a {@link FileMetadataFields} */
|
|
46
51
|
export function getFileMetadataFromImetaTag(tag) {
|
|
47
52
|
const parts = tag.slice(1);
|
|
48
53
|
const tags = [];
|
|
@@ -73,8 +78,9 @@ export function getMediaAttachments(event) {
|
|
|
73
78
|
.filter((a) => !!a);
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
|
-
/** Gets {@link FileMetadata} for a NIP-94 kind 1063 event */
|
|
77
81
|
export function getFileMetadata(file) {
|
|
82
|
+
if (!isValidFileMetadata(file))
|
|
83
|
+
return undefined;
|
|
78
84
|
return parseFileMetadataTags(file.tags);
|
|
79
85
|
}
|
|
80
86
|
/** Returns the last 64 length hex string in a URL */
|
|
@@ -86,7 +92,7 @@ export function getSha256FromURL(url) {
|
|
|
86
92
|
return hashes[hashes.length - 1][0];
|
|
87
93
|
return;
|
|
88
94
|
}
|
|
89
|
-
/** Creates tags for {@link
|
|
95
|
+
/** Creates tags for {@link FileMetadataFields} */
|
|
90
96
|
export function createFileMetadataTags(attachment) {
|
|
91
97
|
const tags = [];
|
|
92
98
|
const add = (name, value) => tags.push([name, String(value)]);
|
package/dist/helpers/groups.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { NostrEvent } from "applesauce-core/helpers/event";
|
|
|
2
2
|
import { HiddenContentSigner } from "applesauce-core/helpers/hidden-content";
|
|
3
3
|
export declare const GROUPS_LIST_KIND = 10009;
|
|
4
4
|
export declare const GROUP_MESSAGE_KIND = 9;
|
|
5
|
+
export declare const GROUP_THREAD_KIND = 11;
|
|
5
6
|
export declare const GROUP_METADATA_KIND = 39000;
|
|
6
7
|
export declare const GROUP_ADMINS_KIND = 39001;
|
|
7
8
|
export declare const GROUP_MEMBERS_KIND = 39002;
|
package/dist/helpers/groups.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
|
|
2
|
-
import { getReplaceableIdentifier, getTagValue } from "applesauce-core/helpers/event";
|
|
2
|
+
import { getReplaceableIdentifier, getTagValue, kinds } from "applesauce-core/helpers/event";
|
|
3
3
|
import { getHiddenTags, isHiddenTagsUnlocked, unlockHiddenTags } from "applesauce-core/helpers/hidden-tags";
|
|
4
4
|
import { processTags } from "applesauce-core/helpers/tags";
|
|
5
5
|
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
6
6
|
export const GROUPS_LIST_KIND = 10009;
|
|
7
|
-
export const GROUP_MESSAGE_KIND =
|
|
7
|
+
export const GROUP_MESSAGE_KIND = kinds.ChatMessage;
|
|
8
|
+
export const GROUP_THREAD_KIND = kinds.ForumThread;
|
|
8
9
|
// NIP-29 Group event kinds
|
|
9
10
|
export const GROUP_METADATA_KIND = 39000;
|
|
10
11
|
export const GROUP_ADMINS_KIND = 39001;
|
package/dist/helpers/hashtag.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { isTTag } from "applesauce-core/helpers";
|
|
1
2
|
import { stripInvisibleChar } from "applesauce-core/helpers/string";
|
|
3
|
+
/** Returns a matching ["t", string] tag for a hashtag in an event */
|
|
2
4
|
export function getHashtagTag(event, hashtag) {
|
|
3
5
|
hashtag = stripInvisibleChar(hashtag.replace(/^#/, "").toLocaleLowerCase());
|
|
4
|
-
return event.tags
|
|
5
|
-
.filter((t) => t[0] === "t" && t[1])
|
|
6
|
-
.find((t) => stripInvisibleChar(t[1].toLowerCase()) === hashtag);
|
|
6
|
+
return event.tags.filter(isTTag).find((t) => stripInvisibleChar(t[1].toLowerCase()) === hashtag);
|
|
7
7
|
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./app-handler.js";
|
|
2
2
|
export * from "./article.js";
|
|
3
|
+
export * from "./badge-award.js";
|
|
4
|
+
export * from "./badge.js";
|
|
3
5
|
export * from "./blossom.js";
|
|
4
6
|
export * from "./bolt11.js";
|
|
5
7
|
export * from "./bookmark.js";
|
|
@@ -10,6 +12,7 @@ export * from "./channels.js";
|
|
|
10
12
|
export * from "./comment.js";
|
|
11
13
|
export * from "./content.js";
|
|
12
14
|
export * from "./emoji.js";
|
|
15
|
+
export * from "./emoji-pack.js";
|
|
13
16
|
export * from "./encrypted-content-cache.js";
|
|
14
17
|
export * from "./file-metadata.js";
|
|
15
18
|
export * from "./gift-wrap.js";
|
|
@@ -23,16 +26,18 @@ export * from "./messages.js";
|
|
|
23
26
|
export * from "./mute.js";
|
|
24
27
|
export * from "./picture-post.js";
|
|
25
28
|
export * from "./poll.js";
|
|
29
|
+
export * from "./profile-badges.js";
|
|
26
30
|
export * from "./reaction.js";
|
|
27
31
|
export * from "./relay-discovery.js";
|
|
32
|
+
export * from "./relay-list.js";
|
|
28
33
|
export * from "./reports.js";
|
|
29
34
|
export * from "./share.js";
|
|
30
35
|
export * from "./stream-chat.js";
|
|
31
36
|
export * from "./stream.js";
|
|
32
37
|
export * from "./threading.js";
|
|
33
38
|
export * from "./torrent.js";
|
|
39
|
+
export * from "./trusted-assertions.js";
|
|
34
40
|
export * from "./user-status.js";
|
|
35
41
|
export * from "./wrapped-messages.js";
|
|
36
|
-
export * from "./zap.js";
|
|
37
42
|
export * from "./zap-goal.js";
|
|
38
|
-
export * from "./
|
|
43
|
+
export * from "./zap.js";
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./app-handler.js";
|
|
2
2
|
export * from "./article.js";
|
|
3
|
+
export * from "./badge-award.js";
|
|
4
|
+
export * from "./badge.js";
|
|
3
5
|
export * from "./blossom.js";
|
|
4
6
|
export * from "./bolt11.js";
|
|
5
7
|
export * from "./bookmark.js";
|
|
@@ -10,6 +12,7 @@ export * from "./channels.js";
|
|
|
10
12
|
export * from "./comment.js";
|
|
11
13
|
export * from "./content.js";
|
|
12
14
|
export * from "./emoji.js";
|
|
15
|
+
export * from "./emoji-pack.js";
|
|
13
16
|
export * from "./encrypted-content-cache.js";
|
|
14
17
|
export * from "./file-metadata.js";
|
|
15
18
|
export * from "./gift-wrap.js";
|
|
@@ -23,16 +26,18 @@ export * from "./messages.js";
|
|
|
23
26
|
export * from "./mute.js";
|
|
24
27
|
export * from "./picture-post.js";
|
|
25
28
|
export * from "./poll.js";
|
|
29
|
+
export * from "./profile-badges.js";
|
|
26
30
|
export * from "./reaction.js";
|
|
27
31
|
export * from "./relay-discovery.js";
|
|
32
|
+
export * from "./relay-list.js";
|
|
28
33
|
export * from "./reports.js";
|
|
29
34
|
export * from "./share.js";
|
|
30
35
|
export * from "./stream-chat.js";
|
|
31
36
|
export * from "./stream.js";
|
|
32
37
|
export * from "./threading.js";
|
|
33
38
|
export * from "./torrent.js";
|
|
39
|
+
export * from "./trusted-assertions.js";
|
|
34
40
|
export * from "./user-status.js";
|
|
35
41
|
export * from "./wrapped-messages.js";
|
|
36
|
-
export * from "./zap.js";
|
|
37
42
|
export * from "./zap-goal.js";
|
|
38
|
-
export * from "./
|
|
43
|
+
export * from "./zap.js";
|
package/dist/helpers/lists.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { AddressPointer, EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
|
|
3
3
|
export type ReadListTags = "public" | "hidden" | "all";
|
|
4
|
+
/** A symbol used to cache profile pointers from a list event */
|
|
5
|
+
export declare const ListProfilePointersSymbol: unique symbol;
|
|
6
|
+
/** A symbol used to cache event pointers from a list event */
|
|
7
|
+
export declare const ListEventPointersSymbol: unique symbol;
|
|
8
|
+
/** A symbol used to cache address pointers from a list event */
|
|
9
|
+
export declare const ListAddressPointersSymbol: unique symbol;
|
|
10
|
+
/** A symbol used to cache relay pointers from a list event */
|
|
11
|
+
export declare const ListRelaysSymbol: unique symbol;
|
|
4
12
|
/** Returns all the tags of a list or set */
|
|
5
13
|
export declare function getListTags(list: NostrEvent, type?: ReadListTags): string[][];
|
|
6
14
|
/**
|