nostr-components 0.3.0 → 0.3.1
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/README.md +25 -16
- package/dist/assets/{base-styles-DC0ilu4S.js → base-styles-Dmuzg8I4.js} +3 -3
- package/dist/assets/{base-styles-DC0ilu4S.js.map → base-styles-Dmuzg8I4.js.map} +1 -1
- package/dist/assets/{copy-delegation-CcagQMIW.js → copy-delegation-xzt-t_do.js} +5 -5
- package/dist/assets/{copy-delegation-CcagQMIW.js.map → copy-delegation-xzt-t_do.js.map} +1 -1
- package/dist/assets/dark-nostrich-running.gif +0 -0
- package/dist/assets/default_dp-NQ3TGrtT.png +0 -0
- package/dist/assets/default_dp.png +0 -0
- package/dist/assets/default_dp_32.png +0 -0
- package/dist/assets/{dialog-component-Dqg0QU9I.js → dialog-component-Da1ZIYh9.js} +7 -2
- package/dist/assets/dialog-component-Da1ZIYh9.js.map +1 -0
- package/dist/assets/{dialog-likers-D3c7WIMp.js → dialog-likers-B15m_NxI.js} +4 -4
- package/dist/assets/{dialog-likers-D3c7WIMp.js.map → dialog-likers-B15m_NxI.js.map} +1 -1
- package/dist/assets/light-nostrich-running.gif +0 -0
- package/dist/assets/{nostr-service-m3Hgc5Xx.js → nostr-service-CA0Qx4nJ.js} +3 -3
- package/dist/assets/{nostr-service-m3Hgc5Xx.js.map → nostr-service-CA0Qx4nJ.js.map} +1 -1
- package/dist/assets/nostr-user-component-r-MUbTL6.js +2 -0
- package/dist/assets/nostr-user-component-r-MUbTL6.js.map +1 -0
- package/dist/assets/{pure-laCRX9eG.js → pure-DOoUcNQv.js} +2 -2
- package/dist/assets/{pure-laCRX9eG.js.map → pure-DOoUcNQv.js.map} +1 -1
- package/dist/assets/{theme-C1r1Zw8r.js → theme-BN1Bvweb.js} +2 -2
- package/dist/assets/{theme-C1r1Zw8r.js.map → theme-BN1Bvweb.js.map} +1 -1
- package/dist/assets/{user-resolver-DqI5KGh6.js → user-resolver-ArI0680e.js} +2 -2
- package/dist/assets/{user-resolver-DqI5KGh6.js.map → user-resolver-ArI0680e.js.map} +1 -1
- package/dist/assets/{zap-utils-BZcaCsT_.js → zap-utils-QRxLBOst.js} +2 -2
- package/dist/assets/{zap-utils-BZcaCsT_.js.map → zap-utils-QRxLBOst.js.map} +1 -1
- package/dist/components/nostr-comment.es.js +6 -6
- package/dist/components/nostr-comment.es.js.map +1 -1
- package/dist/components/nostr-dm.es.js +2 -2
- package/dist/components/nostr-dm.es.js.map +1 -1
- package/dist/components/nostr-follow-button.es.js +3 -3
- package/dist/components/nostr-follow-button.es.js.map +1 -1
- package/dist/components/nostr-like.es.js +6 -6
- package/dist/components/nostr-like.es.js.map +1 -1
- package/dist/components/nostr-live-chat.es.js +3 -3
- package/dist/components/nostr-live-chat.es.js.map +1 -1
- package/dist/components/nostr-post.es.js +2 -2
- package/dist/components/nostr-post.es.js.map +1 -1
- package/dist/components/nostr-profile-badge.es.js +3 -3
- package/dist/components/nostr-profile-badge.es.js.map +1 -1
- package/dist/components/nostr-profile.es.js +5 -5
- package/dist/components/nostr-profile.es.js.map +1 -1
- package/dist/components/nostr-zap.es.js +5 -5
- package/dist/components/nostr-zap.es.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/nostr-comment.d.ts +4 -0
- package/dist/nostr-components.es.js +1 -1
- package/dist/nostr-components.es.js.map +1 -1
- package/dist/nostr-components.umd.js +69 -40
- package/dist/nostr-components.umd.js.map +1 -1
- package/dist/nostr-dm.d.ts +4 -0
- package/dist/nostr-follow-button.d.ts +4 -0
- package/dist/nostr-like.d.ts +4 -0
- package/dist/nostr-live-chat.d.ts +4 -0
- package/dist/nostr-post.d.ts +4 -0
- package/dist/nostr-profile-badge.d.ts +4 -0
- package/dist/nostr-profile.d.ts +4 -0
- package/dist/nostr-zap.d.ts +4 -0
- package/dist/src/base/base-component/nostr-base-component.d.ts +116 -0
- package/dist/src/base/copy-delegation.d.ts +5 -0
- package/dist/src/base/dialog-component/dialog-component.d.ts +67 -0
- package/dist/src/base/dialog-component/style.d.ts +5 -0
- package/dist/src/base/event-component/nostr-event-component.d.ts +53 -0
- package/dist/src/base/render-options.d.ts +5 -0
- package/dist/src/base/resolvers/event-resolver.d.ts +20 -0
- package/dist/src/base/resolvers/user-resolver.d.ts +19 -0
- package/dist/src/base/text-row/render-name.d.ts +7 -0
- package/dist/src/base/text-row/render-nip05.d.ts +1 -0
- package/dist/src/base/text-row/render-npub.d.ts +1 -0
- package/dist/src/base/text-row/render-text-row.d.ts +9 -0
- package/dist/src/base/user-component/nostr-user-component.d.ts +43 -0
- package/dist/src/common/base-styles.d.ts +44 -0
- package/dist/src/common/constants.d.ts +4 -0
- package/dist/src/common/date-utils.d.ts +9 -0
- package/dist/src/common/icons.d.ts +7 -0
- package/dist/src/common/nip05-utils.d.ts +13 -0
- package/dist/src/common/nostr-login-service.d.ts +26 -0
- package/dist/src/common/nostr-service.d.ts +40 -0
- package/dist/src/common/theme.d.ts +4 -0
- package/dist/src/common/types.d.ts +1 -0
- package/dist/src/common/utils.d.ts +34 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/nostr-comment/nostr-comment.d.ts +60 -0
- package/dist/src/nostr-comment/render.d.ts +15 -0
- package/dist/src/nostr-comment/utils.d.ts +81 -0
- package/dist/src/nostr-dm/nostr-dm.d.ts +34 -0
- package/dist/src/nostr-dm/render.d.ts +15 -0
- package/dist/src/nostr-follow-button/nostr-follow-button.d.ts +24 -0
- package/dist/src/nostr-follow-button/render.d.ts +11 -0
- package/dist/src/nostr-follow-button/style.d.ts +1 -0
- package/dist/src/nostr-like/dialog-help-style.d.ts +1 -0
- package/dist/src/nostr-like/dialog-help.d.ts +2 -0
- package/dist/src/nostr-like/dialog-likers-style.d.ts +1 -0
- package/dist/src/nostr-like/dialog-likers.d.ts +24 -0
- package/dist/src/nostr-like/like-utils.d.ts +48 -0
- package/dist/src/nostr-like/nostr-like.d.ts +49 -0
- package/dist/src/nostr-like/render.d.ts +10 -0
- package/dist/src/nostr-like/style.d.ts +1 -0
- package/dist/src/nostr-live-chat/nostr-live-chat.d.ts +65 -0
- package/dist/src/nostr-live-chat/render.d.ts +31 -0
- package/dist/src/nostr-post/nostr-post.d.ts +25 -0
- package/dist/src/nostr-post/parse-text.d.ts +8 -0
- package/dist/src/nostr-post/render-content.d.ts +5 -0
- package/dist/src/nostr-post/render.d.ts +19 -0
- package/dist/src/nostr-post/style.d.ts +1 -0
- package/dist/src/nostr-profile/nostr-profile.d.ts +24 -0
- package/dist/src/nostr-profile/render-stats.d.ts +1 -0
- package/dist/src/nostr-profile/render.d.ts +22 -0
- package/dist/src/nostr-profile/style.d.ts +1 -0
- package/dist/src/nostr-profile-badge/nostr-profile-badge.d.ts +34 -0
- package/dist/src/nostr-profile-badge/render.d.ts +11 -0
- package/dist/src/nostr-profile-badge/style.d.ts +1 -0
- package/dist/src/nostr-zap/dialog-help-style.d.ts +5 -0
- package/dist/src/nostr-zap/dialog-help.d.ts +2 -0
- package/dist/src/nostr-zap/dialog-zap-style.d.ts +6 -0
- package/dist/src/nostr-zap/dialog-zap.d.ts +31 -0
- package/dist/src/nostr-zap/dialog-zappers-style.d.ts +1 -0
- package/dist/src/nostr-zap/dialog-zappers.d.ts +25 -0
- package/dist/src/nostr-zap/nostr-zap.d.ts +45 -0
- package/dist/src/nostr-zap/render.d.ts +9 -0
- package/dist/src/nostr-zap/style.d.ts +1 -0
- package/dist/src/nostr-zap/zap-utils.d.ts +57 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.esm.d.ts +2 -0
- package/dist/vite.config.umd.d.ts +2 -0
- package/package.json +1 -1
- package/dist/assets/dialog-component-Dqg0QU9I.js.map +0 -1
- package/dist/assets/nostr-user-component-XEnanH-d.js +0 -2
- package/dist/assets/nostr-user-component-XEnanH-d.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
2
|
+
interface Comment {
|
|
3
|
+
id: string;
|
|
4
|
+
pubkey: string;
|
|
5
|
+
content: string;
|
|
6
|
+
created_at: number;
|
|
7
|
+
replies: Comment[];
|
|
8
|
+
userProfile?: NDKUserProfile;
|
|
9
|
+
replyTo?: string;
|
|
10
|
+
depth?: number;
|
|
11
|
+
}
|
|
12
|
+
export default class NostrComment extends HTMLElement {
|
|
13
|
+
private rendered;
|
|
14
|
+
private nostrService;
|
|
15
|
+
private shadow;
|
|
16
|
+
private theme;
|
|
17
|
+
private isLoading;
|
|
18
|
+
private isError;
|
|
19
|
+
private errorMessage;
|
|
20
|
+
private comments;
|
|
21
|
+
private baseUrl;
|
|
22
|
+
private userPublicKey;
|
|
23
|
+
private userPrivateKey;
|
|
24
|
+
private currentUserProfile;
|
|
25
|
+
private isSubmitting;
|
|
26
|
+
private replyingToComment;
|
|
27
|
+
private commentAs;
|
|
28
|
+
private hasNip07;
|
|
29
|
+
private anonPrivateKeyHex;
|
|
30
|
+
private eventListeners;
|
|
31
|
+
private nip07MonitoringInterval;
|
|
32
|
+
private loadVersion;
|
|
33
|
+
constructor();
|
|
34
|
+
getRelays: () => string[];
|
|
35
|
+
getTheme: () => void;
|
|
36
|
+
getBaseUrl: () => string;
|
|
37
|
+
private detectNip07Extension;
|
|
38
|
+
private handleNip07StateChange;
|
|
39
|
+
private setupNip07StateMonitoring;
|
|
40
|
+
loadComments: () => Promise<void>;
|
|
41
|
+
buildCommentTree: (allComments: Comment[]) => Comment[];
|
|
42
|
+
initializeUser: () => Promise<void>;
|
|
43
|
+
submitComment: (content: string) => Promise<void>;
|
|
44
|
+
addReplyToComment: (newComment: Comment, parentId: string) => void;
|
|
45
|
+
private findRootAndParent;
|
|
46
|
+
startReply: (commentId: string) => void;
|
|
47
|
+
cancelReply: () => void;
|
|
48
|
+
connectedCallback(): Promise<void>;
|
|
49
|
+
static get observedAttributes(): string[];
|
|
50
|
+
attributeChangedCallback(name: string, _oldValue: string, _newValue: string): Promise<void>;
|
|
51
|
+
disconnectedCallback(): void;
|
|
52
|
+
attachEventListeners(): void;
|
|
53
|
+
attachAvatarErrorHandlers(): void;
|
|
54
|
+
private removeEventListeners;
|
|
55
|
+
private showError;
|
|
56
|
+
private getDefaultAvatarUrl;
|
|
57
|
+
private ensureAnonKey;
|
|
58
|
+
render(): void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Theme } from '../common/types';
|
|
2
|
+
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
3
|
+
interface Comment {
|
|
4
|
+
id: string;
|
|
5
|
+
pubkey: string;
|
|
6
|
+
content: string;
|
|
7
|
+
created_at: number;
|
|
8
|
+
replies: Comment[];
|
|
9
|
+
userProfile?: NDKUserProfile;
|
|
10
|
+
replyTo?: string;
|
|
11
|
+
depth?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function renderCommentWidget(isLoading: boolean, isError: boolean, errorMessage: string, comments: Comment[], readonly: boolean, placeholder: string, isSubmitting: boolean, currentUserProfile?: NDKUserProfile | null, replyingToComment?: string | null, identityMode?: 'user' | 'anon', hasNip07?: boolean): string;
|
|
14
|
+
export declare function getCommentStyles(theme: Theme): string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
2
|
+
export interface CommentEvent {
|
|
3
|
+
id: string;
|
|
4
|
+
pubkey: string;
|
|
5
|
+
content: string;
|
|
6
|
+
created_at: number;
|
|
7
|
+
tags: string[][];
|
|
8
|
+
sig: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ParsedComment {
|
|
11
|
+
id: string;
|
|
12
|
+
pubkey: string;
|
|
13
|
+
content: string;
|
|
14
|
+
created_at: number;
|
|
15
|
+
replyTo?: string;
|
|
16
|
+
rootUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Normalize URL for consistent comment identification
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeURL(raw: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Parse Nostr event into comment structure
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseCommentEvent(event: NDKEvent): ParsedComment | null;
|
|
26
|
+
/**
|
|
27
|
+
* Create a comment event for publishing
|
|
28
|
+
*/
|
|
29
|
+
export declare function createCommentEvent(content: string, pubkey: string, url: string, replyTo?: string): Omit<CommentEvent, 'id' | 'sig'>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate if a string is a valid Nostr public key
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidPublicKey(pubkey: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Validate if a string is a valid Nostr event ID
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidEventId(eventId: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Truncate public key for display
|
|
40
|
+
*/
|
|
41
|
+
export declare function truncatePublicKey(pubkey: string, length?: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* Format timestamp to relative time
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatRelativeTime(timestamp: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Sanitize HTML content to prevent XSS
|
|
48
|
+
*/
|
|
49
|
+
export declare function sanitizeContent(content: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Parse URLs in content and make them clickable
|
|
52
|
+
*/
|
|
53
|
+
export declare function linkifyContent(content: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate a simple hash for content deduplication
|
|
56
|
+
*/
|
|
57
|
+
export declare function hashContent(content: string, pubkey: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Check if user has a Nostr extension (NIP-07)
|
|
60
|
+
*/
|
|
61
|
+
export declare function hasNostrExtension(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get stored private key from localStorage
|
|
64
|
+
*/
|
|
65
|
+
export declare function getStoredPrivateKey(): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Store private key in localStorage
|
|
68
|
+
*/
|
|
69
|
+
export declare function storePrivateKey(privateKey: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Validate if a string is a valid private key
|
|
72
|
+
*/
|
|
73
|
+
export declare function isValidPrivateKey(privateKey: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Clear stored private key (for logout functionality)
|
|
76
|
+
*/
|
|
77
|
+
export declare function clearStoredPrivateKey(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Debounce function for rate limiting
|
|
80
|
+
*/
|
|
81
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default class NostrDm extends HTMLElement {
|
|
2
|
+
private rendered;
|
|
3
|
+
private nostrService;
|
|
4
|
+
private theme;
|
|
5
|
+
private recipientNpub;
|
|
6
|
+
private recipientNip05;
|
|
7
|
+
private recipientName;
|
|
8
|
+
private recipientPicture;
|
|
9
|
+
private recipientPubkey;
|
|
10
|
+
private message;
|
|
11
|
+
private isLoading;
|
|
12
|
+
private isFinding;
|
|
13
|
+
private isError;
|
|
14
|
+
private errorMessage;
|
|
15
|
+
private isSent;
|
|
16
|
+
private boundHandleFind;
|
|
17
|
+
private boundHandleSend;
|
|
18
|
+
private boundHandleTextareaChange;
|
|
19
|
+
constructor();
|
|
20
|
+
getRelays: () => readonly ["wss://relay.damus.io", "wss://nostr.wine", "wss://relay.nostr.net", "wss://nos.lol", "wss://nostr-pub.wellorder.net", "wss://relay.getalby.com", "wss://relay.primal.net"] | string[];
|
|
21
|
+
getTheme: () => Promise<void>;
|
|
22
|
+
getRecipient: () => void;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
static get observedAttributes(): string[];
|
|
25
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
26
|
+
private lookupRecipient;
|
|
27
|
+
private lookupRecipientByNip05;
|
|
28
|
+
private handleFindClick;
|
|
29
|
+
private handleSendClick;
|
|
30
|
+
private handleTextareaChange;
|
|
31
|
+
attachEventListeners(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
private render;
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Theme } from '../common/types';
|
|
2
|
+
export interface RenderDmOptions {
|
|
3
|
+
theme: Theme;
|
|
4
|
+
recipientNpub: string | null;
|
|
5
|
+
recipientName: string | null;
|
|
6
|
+
recipientPicture: string | null;
|
|
7
|
+
message: string;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
isFinding: boolean;
|
|
10
|
+
isError: boolean;
|
|
11
|
+
errorMessage: string;
|
|
12
|
+
isSent: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function renderDm({ theme, recipientNpub, recipientName, recipientPicture, message, isLoading, isFinding, isError, errorMessage, isSent, }: RenderDmOptions): string;
|
|
15
|
+
export declare function getDmStyles(theme: Theme): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NostrUserComponent } from '../base/user-component/nostr-user-component';
|
|
2
|
+
import { NCStatus } from '../base/base-component/nostr-base-component';
|
|
3
|
+
/**
|
|
4
|
+
* TODO:
|
|
5
|
+
* 1. To have a text attribute. Default value being "Follow me on Nostr"
|
|
6
|
+
* 2. show-avatar attribute to show the avatar of the user, instead of nostr logo.
|
|
7
|
+
*/
|
|
8
|
+
export default class NostrFollowButton extends NostrUserComponent {
|
|
9
|
+
protected followStatus: {
|
|
10
|
+
set: (s: NCStatus, e?: string) => void;
|
|
11
|
+
get: () => NCStatus;
|
|
12
|
+
};
|
|
13
|
+
private isFollowed;
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
17
|
+
/** Base class functions */
|
|
18
|
+
protected onStatusChange(_status: NCStatus): void;
|
|
19
|
+
protected onUserReady(_user: any, _profile: any): void;
|
|
20
|
+
/** Private functions */
|
|
21
|
+
private handleFollowClick;
|
|
22
|
+
private attachDelegatedListeners;
|
|
23
|
+
protected renderContent(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IRenderOptions } from '../base/render-options';
|
|
2
|
+
import { NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
3
|
+
export interface RenderFollowButtonOptions extends IRenderOptions {
|
|
4
|
+
isFollowed: boolean;
|
|
5
|
+
isFollowing: boolean;
|
|
6
|
+
showAvatar?: boolean;
|
|
7
|
+
user?: NDKUser | null;
|
|
8
|
+
profile?: NDKUserProfile | null;
|
|
9
|
+
customText?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function renderFollowButton({ isLoading, isError, errorMessage, isFollowed, isFollowing, showAvatar, user, profile, customText, }: RenderFollowButtonOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFollowButtonStyles(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getHelpDialogStyles(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLikersDialogStyles(theme?: 'light' | 'dark'): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DialogComponent } from '../base/dialog-component/dialog-component';
|
|
2
|
+
import { LikeDetails } from './like-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Modal dialog for displaying individual like details (likers).
|
|
5
|
+
*
|
|
6
|
+
* Shows a list of all users who liked a URL with:
|
|
7
|
+
* - User's name
|
|
8
|
+
* - User's profile picture
|
|
9
|
+
* - Time of like (relative time)
|
|
10
|
+
* - Clickable links to user profiles via njump.me
|
|
11
|
+
*/
|
|
12
|
+
export interface OpenLikersModalParams {
|
|
13
|
+
likeDetails: LikeDetails[];
|
|
14
|
+
theme?: 'light' | 'dark';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Inject likers dialog content styles into document head
|
|
18
|
+
* Prevents duplicate injection by checking for existing styles
|
|
19
|
+
*/
|
|
20
|
+
export declare const injectLikersDialogStyles: (theme?: "light" | "dark") => void;
|
|
21
|
+
/**
|
|
22
|
+
* Opens the likers dialog showing individual like details
|
|
23
|
+
*/
|
|
24
|
+
export declare function openLikersDialog(params: OpenLikersModalParams): Promise<DialogComponent>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper utilities for Nostr like operations using NIP-25 External Content Reactions.
|
|
3
|
+
* These are deliberately kept self-contained so `nostr-like` Web Component can import
|
|
4
|
+
* everything from a single module without polluting the rest of the codebase.
|
|
5
|
+
*/
|
|
6
|
+
export interface LikeDetails {
|
|
7
|
+
authorPubkey: string;
|
|
8
|
+
date: Date;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LikeCountResult {
|
|
12
|
+
totalCount: number;
|
|
13
|
+
likeDetails: LikeDetails[];
|
|
14
|
+
likedCount: number;
|
|
15
|
+
dislikedCount: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Fetch all likes for a URL using NIP-25 kind 17 events
|
|
19
|
+
*/
|
|
20
|
+
export declare function fetchLikesForUrl(url: string, relays: string[]): Promise<LikeCountResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Create reaction event (kind 17)
|
|
23
|
+
* @param url - URL to react to
|
|
24
|
+
* @param content - '+' for like, '-' for unlike
|
|
25
|
+
*/
|
|
26
|
+
export declare function createReactionEvent(url: string, content: '+' | '-'): any;
|
|
27
|
+
/**
|
|
28
|
+
* Create like event (kind 17)
|
|
29
|
+
* @deprecated Use createReactionEvent(url, '+') instead
|
|
30
|
+
*/
|
|
31
|
+
export declare function createLikeEvent(url: string): any;
|
|
32
|
+
/**
|
|
33
|
+
* Create unlike event (kind 17 with '-' content)
|
|
34
|
+
* @deprecated Use createReactionEvent(url, '-') instead
|
|
35
|
+
*/
|
|
36
|
+
export declare function createUnlikeEvent(url: string): any;
|
|
37
|
+
/**
|
|
38
|
+
* Check if user has liked a URL
|
|
39
|
+
*/
|
|
40
|
+
export declare function hasUserLiked(url: string, userPubkey: string, relays: string[]): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Get user's pubkey from NostrLogin
|
|
43
|
+
*/
|
|
44
|
+
export declare function getUserPubkey(): Promise<string | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Sign event with NostrLogin
|
|
47
|
+
*/
|
|
48
|
+
export declare function signEvent(event: any): Promise<any>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NostrBaseComponent, NCStatus } from '../base/base-component/nostr-base-component';
|
|
2
|
+
/**
|
|
3
|
+
* <nostr-like>
|
|
4
|
+
* Attributes:
|
|
5
|
+
* - url (optional) : URL to like (default: current page URL)
|
|
6
|
+
* - text (optional) : custom text (default "Like") (Max 32 characters)
|
|
7
|
+
* - relays (optional) : comma-separated relay URLs
|
|
8
|
+
* - data-theme (optional) : "light" | "dark" (default light)
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - URL-based likes using NIP-25 kind 17 events
|
|
12
|
+
* - Click count to view likers
|
|
13
|
+
*/
|
|
14
|
+
export default class NostrLike extends NostrBaseComponent {
|
|
15
|
+
protected likeActionStatus: {
|
|
16
|
+
set: (s: NCStatus, e?: string) => void;
|
|
17
|
+
get: () => NCStatus;
|
|
18
|
+
};
|
|
19
|
+
protected likeListStatus: {
|
|
20
|
+
set: (s: NCStatus, e?: string) => void;
|
|
21
|
+
get: () => NCStatus;
|
|
22
|
+
};
|
|
23
|
+
private currentUrl;
|
|
24
|
+
private isLiked;
|
|
25
|
+
private likeCount;
|
|
26
|
+
private cachedLikeDetails;
|
|
27
|
+
private loadSeq;
|
|
28
|
+
constructor();
|
|
29
|
+
connectedCallback(): void;
|
|
30
|
+
static get observedAttributes(): string[];
|
|
31
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
32
|
+
/** Base class functions */
|
|
33
|
+
protected validateInputs(): boolean;
|
|
34
|
+
protected onStatusChange(_status: NCStatus): void;
|
|
35
|
+
protected onNostrRelaysConnected(): void;
|
|
36
|
+
/** Private functions */
|
|
37
|
+
/**
|
|
38
|
+
* Lazy initializer for currentUrl - ensures it's set before like/unlike operations
|
|
39
|
+
*/
|
|
40
|
+
private ensureCurrentUrl;
|
|
41
|
+
private updateLikeCount;
|
|
42
|
+
private handleLikeClick;
|
|
43
|
+
private handleLike;
|
|
44
|
+
private handleUnlike;
|
|
45
|
+
private handleCountClick;
|
|
46
|
+
private handleHelpClick;
|
|
47
|
+
private attachDelegatedListeners;
|
|
48
|
+
protected renderContent(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IRenderOptions } from '../base/render-options';
|
|
2
|
+
export interface RenderLikeButtonOptions extends IRenderOptions {
|
|
3
|
+
buttonText: string;
|
|
4
|
+
isLiked: boolean;
|
|
5
|
+
likeCount: number;
|
|
6
|
+
hasLikes?: boolean;
|
|
7
|
+
isCountLoading?: boolean;
|
|
8
|
+
theme?: 'light' | 'dark';
|
|
9
|
+
}
|
|
10
|
+
export declare function renderLikeButton({ isLoading, isError, errorMessage, buttonText, isLiked, likeCount, hasLikes, isCountLoading, theme, }: RenderLikeButtonOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLikeButtonStyles(): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default class NostrLiveChat extends HTMLElement {
|
|
2
|
+
private rendered;
|
|
3
|
+
private nostrService;
|
|
4
|
+
private dmSubscription;
|
|
5
|
+
private theme;
|
|
6
|
+
private recipientNpub;
|
|
7
|
+
private recipientNip05;
|
|
8
|
+
private recipientName;
|
|
9
|
+
private recipientPicture;
|
|
10
|
+
private recipientPubkey;
|
|
11
|
+
private message;
|
|
12
|
+
private messages;
|
|
13
|
+
private currentUserPubkey;
|
|
14
|
+
private currentUserNpub;
|
|
15
|
+
private currentUserName;
|
|
16
|
+
private currentUserPicture;
|
|
17
|
+
private static readonly DEFAULT_WELCOME_TEXT;
|
|
18
|
+
private static readonly DEFAULT_START_CHAT_TEXT;
|
|
19
|
+
private static readonly DEFAULT_ONLINE_TEXT;
|
|
20
|
+
private static readonly DEFAULT_HELP_TEXT;
|
|
21
|
+
private displayType;
|
|
22
|
+
private isOpen;
|
|
23
|
+
private showWelcome;
|
|
24
|
+
private welcomeText;
|
|
25
|
+
private startChatText;
|
|
26
|
+
private onlineText;
|
|
27
|
+
private helpText;
|
|
28
|
+
private readonly MESSAGE_MAX_LENGTH;
|
|
29
|
+
private isLoading;
|
|
30
|
+
private isFinding;
|
|
31
|
+
private isError;
|
|
32
|
+
private errorMessage;
|
|
33
|
+
private keySupplier;
|
|
34
|
+
private boundHandleFind;
|
|
35
|
+
private boundHandleSend;
|
|
36
|
+
private boundHandleTextareaChange;
|
|
37
|
+
private boundHandleLauncherClick;
|
|
38
|
+
private boundHandleCloseClick;
|
|
39
|
+
private boundHandleStartChat;
|
|
40
|
+
private boundHandleNpubKeydown;
|
|
41
|
+
private resubscribeTimer;
|
|
42
|
+
constructor();
|
|
43
|
+
getRelays: () => readonly ["wss://relay.damus.io", "wss://nostr.wine", "wss://relay.nostr.net", "wss://nos.lol", "wss://nostr-pub.wellorder.net", "wss://relay.getalby.com", "wss://relay.primal.net"] | string[];
|
|
44
|
+
private getCurrentUserInfo;
|
|
45
|
+
private getDisplayType;
|
|
46
|
+
getTheme: () => void;
|
|
47
|
+
getRecipient: () => void;
|
|
48
|
+
connectedCallback(): void;
|
|
49
|
+
static get observedAttributes(): string[];
|
|
50
|
+
private unsubscribeFromDms;
|
|
51
|
+
private clearRecipientAndChatState;
|
|
52
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
53
|
+
private lookupRecipient;
|
|
54
|
+
private lookupRecipientByNip05;
|
|
55
|
+
private handleFindClick;
|
|
56
|
+
private handleSendClick;
|
|
57
|
+
private handleTextareaChange;
|
|
58
|
+
private handleStartChat;
|
|
59
|
+
private subscribeToDms;
|
|
60
|
+
private attachEventListeners;
|
|
61
|
+
disconnectedCallback(): void;
|
|
62
|
+
setKeySupplier(supplier: (() => string | Promise<string>) | null): void;
|
|
63
|
+
private escapeHtml;
|
|
64
|
+
private render;
|
|
65
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Theme } from '../common/types';
|
|
2
|
+
export interface ChatMessage {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
sender: 'me' | 'them';
|
|
6
|
+
timestamp: number;
|
|
7
|
+
status: 'sending' | 'sent' | 'failed';
|
|
8
|
+
}
|
|
9
|
+
export interface RenderLiveChatOptions {
|
|
10
|
+
theme: Theme;
|
|
11
|
+
recipientNpub: string | null;
|
|
12
|
+
recipientName: string | null;
|
|
13
|
+
recipientPicture: string | null;
|
|
14
|
+
message: string;
|
|
15
|
+
messages: ChatMessage[];
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
isFinding: boolean;
|
|
18
|
+
isError: boolean;
|
|
19
|
+
errorMessage: string;
|
|
20
|
+
currentUserName?: string | null;
|
|
21
|
+
currentUserPicture?: string | null;
|
|
22
|
+
showWelcome?: boolean;
|
|
23
|
+
welcomeText?: string;
|
|
24
|
+
startChatText?: string;
|
|
25
|
+
onlineText?: string;
|
|
26
|
+
helpText?: string;
|
|
27
|
+
maxMessageLength: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function renderLiveChat({ theme, recipientNpub, recipientName, recipientPicture, message, messages, isLoading, isFinding, isError, errorMessage, currentUserName, currentUserPicture, showWelcome, welcomeText, startChatText, onlineText, helpText, maxMessageLength, }: RenderLiveChatOptions): string;
|
|
30
|
+
export declare function renderLiveChatInner({ theme, recipientNpub, recipientName, recipientPicture, message, messages, isLoading, isFinding, isError, errorMessage, currentUserName, currentUserPicture, showWelcome, welcomeText, startChatText, maxMessageLength, }: Omit<RenderLiveChatOptions, 'onlineText' | 'helpText'>): string;
|
|
31
|
+
export declare function getLiveChatStyles(theme: Theme): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
2
|
+
import { Stats } from '../common/utils';
|
|
3
|
+
import { NostrEventComponent } from '../base/event-component/nostr-event-component';
|
|
4
|
+
import { NCStatus } from '../base/base-component/nostr-base-component';
|
|
5
|
+
export default class NostrPost extends NostrEventComponent {
|
|
6
|
+
protected stats: Stats | null;
|
|
7
|
+
protected statsLoading: boolean;
|
|
8
|
+
protected embeddedPosts: Map<string, NDKEvent>;
|
|
9
|
+
private glideInitialized;
|
|
10
|
+
private cachedParsedContent;
|
|
11
|
+
private cachedHtmlToRender;
|
|
12
|
+
connectedCallback(): Promise<void>;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
15
|
+
/** Base class functions */
|
|
16
|
+
protected onStatusChange(_status: NCStatus): void;
|
|
17
|
+
protected onEventReady(_event: any): Promise<void>;
|
|
18
|
+
private invalidateCache;
|
|
19
|
+
getPostStats(): Promise<void>;
|
|
20
|
+
private onPostClick;
|
|
21
|
+
private onAuthorClick;
|
|
22
|
+
private onMentionClick;
|
|
23
|
+
private attachDelegatedListeners;
|
|
24
|
+
protected renderContent(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
2
|
+
import { NostrService } from '../common/nostr-service';
|
|
3
|
+
export type ContentItem = {
|
|
4
|
+
type: 'text' | 'image' | 'gif' | 'video' | 'link' | 'embedded-note';
|
|
5
|
+
value?: string;
|
|
6
|
+
noteId?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseText(text: string, post: NDKEvent | null, embeddedPosts: Map<string, NDKEvent>, nostrService: NostrService): Promise<ContentItem[]>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContentItem } from './parse-text';
|
|
2
|
+
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
3
|
+
export declare function renderContent(content: ContentItem[]): string;
|
|
4
|
+
export declare function replaceEmbeddedPostPlaceholders(shadowRoot: ShadowRoot | null, embeddedPosts: Map<string, NDKEvent>, event: NDKEvent | null, nostrService: any): Promise<void>;
|
|
5
|
+
export declare function renderEmbeddedPostContent(noteId: string, embeddedPosts: Map<string, NDKEvent>, event: NDKEvent | null, nostrService: any): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IRenderOptions } from '../base/render-options';
|
|
2
|
+
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
3
|
+
export interface RenderPostOptions extends IRenderOptions {
|
|
4
|
+
author: NDKUserProfile | null | undefined;
|
|
5
|
+
date: string;
|
|
6
|
+
shouldShowStats: boolean;
|
|
7
|
+
stats: {
|
|
8
|
+
replies: number;
|
|
9
|
+
likes: number;
|
|
10
|
+
} | null;
|
|
11
|
+
statsLoading: boolean;
|
|
12
|
+
htmlToRender: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function renderPost(options: RenderPostOptions): string;
|
|
15
|
+
export declare function renderEmbeddedPost(noteId: string, authorProfile: {
|
|
16
|
+
displayName?: string;
|
|
17
|
+
image?: string;
|
|
18
|
+
nip05?: string;
|
|
19
|
+
} | undefined, date: string, content: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPostStyles(): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NCStatus } from '../base/base-component/nostr-base-component';
|
|
2
|
+
import { NostrUserComponent } from '../base/user-component/nostr-user-component';
|
|
3
|
+
export default class NostrProfile extends NostrUserComponent {
|
|
4
|
+
protected profileStatus: {
|
|
5
|
+
set: (s: NCStatus, e?: string) => void;
|
|
6
|
+
get: () => NCStatus;
|
|
7
|
+
};
|
|
8
|
+
private isStatsLoading;
|
|
9
|
+
private isStatsFollowsLoading;
|
|
10
|
+
private isStatsFollowersLoading;
|
|
11
|
+
private isZapsLoading;
|
|
12
|
+
private stats;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
connectedCallback(): Promise<void>;
|
|
15
|
+
/** Base class functions */
|
|
16
|
+
protected onStatusChange(_status: NCStatus): void;
|
|
17
|
+
protected onUserReady(_user: any, _profile: any): void;
|
|
18
|
+
getUserStats: () => Promise<void>;
|
|
19
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
20
|
+
/** Private functions */
|
|
21
|
+
private onProfileClick;
|
|
22
|
+
private attachDelegatedListeners;
|
|
23
|
+
protected renderContent(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderStats(label: string, value: number, isLoading: boolean): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
2
|
+
import { IRenderOptions } from '../base/render-options';
|
|
3
|
+
export interface Stats {
|
|
4
|
+
notes: number;
|
|
5
|
+
replies: number;
|
|
6
|
+
follows: number;
|
|
7
|
+
followers: number;
|
|
8
|
+
zaps: number;
|
|
9
|
+
relays: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RenderProfileOptions extends IRenderOptions {
|
|
12
|
+
npub: string;
|
|
13
|
+
userProfile: NDKUserProfile;
|
|
14
|
+
isStatsLoading: boolean;
|
|
15
|
+
isStatsFollowersLoading: boolean;
|
|
16
|
+
isStatsFollowsLoading: boolean;
|
|
17
|
+
isZapsLoading: boolean;
|
|
18
|
+
stats: Stats;
|
|
19
|
+
showFollow: boolean;
|
|
20
|
+
showNpub: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function renderProfile(options: RenderProfileOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getProfileStyles(): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NCStatus } from '../base/base-component/nostr-base-component';
|
|
2
|
+
import { NostrUserComponent } from '../base/user-component/nostr-user-component';
|
|
3
|
+
import { NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
4
|
+
/**
|
|
5
|
+
* NostrProfileBadge
|
|
6
|
+
* =================
|
|
7
|
+
* UI component (extends `NostrUserComponent`) that renders a compact user badge
|
|
8
|
+
* with avatar/name/nip05 and optional npub + follow button.
|
|
9
|
+
*
|
|
10
|
+
* Observed attributes
|
|
11
|
+
* - `show-npub` — boolean-like attribute to display the masked npub + copy
|
|
12
|
+
* - `show-follow` — boolean-like attribute to display the follow button
|
|
13
|
+
*
|
|
14
|
+
* Events
|
|
15
|
+
* - `nc:status` — (from base) status changes for connection/user
|
|
16
|
+
* - `nc:user` — emitted when user & profile are ready (from parent)
|
|
17
|
+
* - `nc:profile_badge` — fired on badge click (detail: `NDKUserProfile | null`);
|
|
18
|
+
* default action opens `https://njump.me/<nip05|npub>`
|
|
19
|
+
*
|
|
20
|
+
* Note: Follow button placement to be improved in future versions
|
|
21
|
+
*/
|
|
22
|
+
export default class NostrProfileBadge extends NostrUserComponent {
|
|
23
|
+
/** Lifecycle methods */
|
|
24
|
+
static get observedAttributes(): string[];
|
|
25
|
+
connectedCallback(): void;
|
|
26
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
27
|
+
/** Base class functions */
|
|
28
|
+
protected onStatusChange(_status: NCStatus): void;
|
|
29
|
+
protected onUserReady(_user: NDKUser, _profile: NDKUserProfile | null): void;
|
|
30
|
+
/** Private functions */
|
|
31
|
+
private onProfileClick;
|
|
32
|
+
private attachDelegatedListeners;
|
|
33
|
+
protected renderContent(): void;
|
|
34
|
+
}
|