nostr-components 0.2.7 → 0.3.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.
Files changed (140) hide show
  1. package/README.md +105 -185
  2. package/dist/assets/{base-styles-BSEzBDsk.js → base-styles-DC0ilu4S.js} +3 -3
  3. package/dist/assets/{base-styles-BSEzBDsk.js.map → base-styles-DC0ilu4S.js.map} +1 -1
  4. package/dist/assets/{copy-delegation-B7y2q5Kn.js → copy-delegation-CcagQMIW.js} +5 -5
  5. package/dist/assets/{copy-delegation-B7y2q5Kn.js.map → copy-delegation-CcagQMIW.js.map} +1 -1
  6. package/dist/assets/{dialog-component-Da1ZIYh9.js → dialog-component-Dqg0QU9I.js} +2 -7
  7. package/dist/assets/dialog-component-Dqg0QU9I.js.map +1 -0
  8. package/dist/assets/{dialog-likers-BqDn2P_3.js → dialog-likers-D3c7WIMp.js} +5 -5
  9. package/dist/assets/dialog-likers-D3c7WIMp.js.map +1 -0
  10. package/dist/assets/index.esm-ByUtE_cm.js +2159 -0
  11. package/dist/assets/index.esm-ByUtE_cm.js.map +1 -0
  12. package/dist/assets/nip05-utils-BNBHUmkr.js.map +1 -1
  13. package/dist/assets/nostr-login-service-D2FmscPI.js +2 -0
  14. package/dist/assets/nostr-login-service-D2FmscPI.js.map +1 -0
  15. package/dist/assets/nostr-service-m3Hgc5Xx.js +266 -0
  16. package/dist/assets/nostr-service-m3Hgc5Xx.js.map +1 -0
  17. package/dist/assets/nostr-user-component-XEnanH-d.js +2 -0
  18. package/dist/assets/nostr-user-component-XEnanH-d.js.map +1 -0
  19. package/dist/assets/{pure-DPo-pzxM.js → pure-laCRX9eG.js} +2 -2
  20. package/dist/assets/pure-laCRX9eG.js.map +1 -0
  21. package/dist/assets/{theme-BN1Bvweb.js → theme-C1r1Zw8r.js} +2 -2
  22. package/dist/assets/{theme-BN1Bvweb.js.map → theme-C1r1Zw8r.js.map} +1 -1
  23. package/dist/assets/{user-resolver-CMmbtY9Y.js → user-resolver-DqI5KGh6.js} +2 -2
  24. package/dist/assets/{user-resolver-CMmbtY9Y.js.map → user-resolver-DqI5KGh6.js.map} +1 -1
  25. package/dist/assets/utils--bxLbhGF.js.map +1 -1
  26. package/dist/assets/zap-utils-BZcaCsT_.js +2 -0
  27. package/dist/assets/zap-utils-BZcaCsT_.js.map +1 -0
  28. package/dist/components/nostr-comment.es.js +26 -26
  29. package/dist/components/nostr-comment.es.js.map +1 -1
  30. package/dist/components/nostr-dm.es.js +2 -2
  31. package/dist/components/nostr-dm.es.js.map +1 -1
  32. package/dist/components/nostr-follow-button.es.js +6 -7
  33. package/dist/components/nostr-follow-button.es.js.map +1 -1
  34. package/dist/components/nostr-like.es.js +16 -16
  35. package/dist/components/nostr-like.es.js.map +1 -1
  36. package/dist/components/nostr-live-chat.es.js +3 -3
  37. package/dist/components/nostr-live-chat.es.js.map +1 -1
  38. package/dist/components/nostr-post.es.js +19 -19
  39. package/dist/components/nostr-post.es.js.map +1 -1
  40. package/dist/components/nostr-profile-badge.es.js +3 -3
  41. package/dist/components/nostr-profile-badge.es.js.map +1 -1
  42. package/dist/components/nostr-profile.es.js +2 -2
  43. package/dist/components/nostr-profile.es.js.map +1 -1
  44. package/dist/components/nostr-zap.es.js +24 -24
  45. package/dist/components/nostr-zap.es.js.map +1 -1
  46. package/dist/nostr-components.es.js +1 -1
  47. package/dist/nostr-components.es.js.map +1 -1
  48. package/dist/nostr-components.umd.js +2644 -305
  49. package/dist/nostr-components.umd.js.map +1 -1
  50. package/package.json +5 -2
  51. package/dist/assets/dark-nostrich-running.gif +0 -0
  52. package/dist/assets/default_dp-NQ3TGrtT.png +0 -0
  53. package/dist/assets/default_dp.png +0 -0
  54. package/dist/assets/default_dp_32.png +0 -0
  55. package/dist/assets/dialog-component-Da1ZIYh9.js.map +0 -1
  56. package/dist/assets/dialog-likers-BqDn2P_3.js.map +0 -1
  57. package/dist/assets/light-nostrich-running.gif +0 -0
  58. package/dist/assets/nostr-service-CnaPxjc6.js +0 -78
  59. package/dist/assets/nostr-service-CnaPxjc6.js.map +0 -1
  60. package/dist/assets/nostr-user-component-Cbs97dlK.js +0 -2
  61. package/dist/assets/nostr-user-component-Cbs97dlK.js.map +0 -1
  62. package/dist/assets/pure-DPo-pzxM.js.map +0 -1
  63. package/dist/assets/zap-utils-KFUD_vTU.js +0 -2
  64. package/dist/assets/zap-utils-KFUD_vTU.js.map +0 -1
  65. package/dist/index.d.ts +0 -6
  66. package/dist/nostr-comment.d.ts +0 -4
  67. package/dist/nostr-dm.d.ts +0 -4
  68. package/dist/nostr-follow-button.d.ts +0 -4
  69. package/dist/nostr-like.d.ts +0 -4
  70. package/dist/nostr-live-chat.d.ts +0 -4
  71. package/dist/nostr-post.d.ts +0 -4
  72. package/dist/nostr-profile-badge.d.ts +0 -4
  73. package/dist/nostr-profile.d.ts +0 -4
  74. package/dist/nostr-zap.d.ts +0 -4
  75. package/dist/src/base/base-component/nostr-base-component.d.ts +0 -116
  76. package/dist/src/base/copy-delegation.d.ts +0 -5
  77. package/dist/src/base/dialog-component/dialog-component.d.ts +0 -67
  78. package/dist/src/base/dialog-component/style.d.ts +0 -5
  79. package/dist/src/base/event-component/nostr-event-component.d.ts +0 -53
  80. package/dist/src/base/render-options.d.ts +0 -5
  81. package/dist/src/base/resolvers/event-resolver.d.ts +0 -20
  82. package/dist/src/base/resolvers/user-resolver.d.ts +0 -19
  83. package/dist/src/base/text-row/render-name.d.ts +0 -7
  84. package/dist/src/base/text-row/render-nip05.d.ts +0 -1
  85. package/dist/src/base/text-row/render-npub.d.ts +0 -1
  86. package/dist/src/base/text-row/render-text-row.d.ts +0 -9
  87. package/dist/src/base/user-component/nostr-user-component.d.ts +0 -43
  88. package/dist/src/common/base-styles.d.ts +0 -44
  89. package/dist/src/common/constants.d.ts +0 -4
  90. package/dist/src/common/date-utils.d.ts +0 -9
  91. package/dist/src/common/icons.d.ts +0 -7
  92. package/dist/src/common/nip05-utils.d.ts +0 -13
  93. package/dist/src/common/nostr-service.d.ts +0 -40
  94. package/dist/src/common/theme.d.ts +0 -4
  95. package/dist/src/common/types.d.ts +0 -1
  96. package/dist/src/common/utils.d.ts +0 -34
  97. package/dist/src/index.d.ts +0 -32
  98. package/dist/src/nostr-comment/nostr-comment.d.ts +0 -60
  99. package/dist/src/nostr-comment/render.d.ts +0 -15
  100. package/dist/src/nostr-comment/utils.d.ts +0 -81
  101. package/dist/src/nostr-dm/nostr-dm.d.ts +0 -34
  102. package/dist/src/nostr-dm/render.d.ts +0 -15
  103. package/dist/src/nostr-follow-button/nostr-follow-button.d.ts +0 -24
  104. package/dist/src/nostr-follow-button/render.d.ts +0 -11
  105. package/dist/src/nostr-follow-button/style.d.ts +0 -1
  106. package/dist/src/nostr-like/dialog-help-style.d.ts +0 -1
  107. package/dist/src/nostr-like/dialog-help.d.ts +0 -2
  108. package/dist/src/nostr-like/dialog-likers-style.d.ts +0 -1
  109. package/dist/src/nostr-like/dialog-likers.d.ts +0 -24
  110. package/dist/src/nostr-like/like-utils.d.ts +0 -52
  111. package/dist/src/nostr-like/nostr-like.d.ts +0 -49
  112. package/dist/src/nostr-like/render.d.ts +0 -10
  113. package/dist/src/nostr-like/style.d.ts +0 -1
  114. package/dist/src/nostr-live-chat/nostr-live-chat.d.ts +0 -65
  115. package/dist/src/nostr-live-chat/render.d.ts +0 -31
  116. package/dist/src/nostr-post/nostr-post.d.ts +0 -25
  117. package/dist/src/nostr-post/parse-text.d.ts +0 -8
  118. package/dist/src/nostr-post/render-content.d.ts +0 -5
  119. package/dist/src/nostr-post/render.d.ts +0 -19
  120. package/dist/src/nostr-post/style.d.ts +0 -1
  121. package/dist/src/nostr-profile/nostr-profile.d.ts +0 -24
  122. package/dist/src/nostr-profile/render-stats.d.ts +0 -1
  123. package/dist/src/nostr-profile/render.d.ts +0 -22
  124. package/dist/src/nostr-profile/style.d.ts +0 -1
  125. package/dist/src/nostr-profile-badge/nostr-profile-badge.d.ts +0 -34
  126. package/dist/src/nostr-profile-badge/render.d.ts +0 -11
  127. package/dist/src/nostr-profile-badge/style.d.ts +0 -1
  128. package/dist/src/nostr-zap/dialog-help-style.d.ts +0 -5
  129. package/dist/src/nostr-zap/dialog-help.d.ts +0 -2
  130. package/dist/src/nostr-zap/dialog-zap-style.d.ts +0 -6
  131. package/dist/src/nostr-zap/dialog-zap.d.ts +0 -31
  132. package/dist/src/nostr-zap/dialog-zappers-style.d.ts +0 -1
  133. package/dist/src/nostr-zap/dialog-zappers.d.ts +0 -25
  134. package/dist/src/nostr-zap/nostr-zap.d.ts +0 -45
  135. package/dist/src/nostr-zap/render.d.ts +0 -9
  136. package/dist/src/nostr-zap/style.d.ts +0 -1
  137. package/dist/src/nostr-zap/zap-utils.d.ts +0 -53
  138. package/dist/vite.config.d.ts +0 -2
  139. package/dist/vite.config.esm.d.ts +0 -2
  140. package/dist/vite.config.umd.d.ts +0 -2
@@ -1,40 +0,0 @@
1
- import { default as NDK, NDKUser, NDKUserProfile, NDKEvent } from '@nostr-dev-kit/ndk';
2
- export declare class NostrService {
3
- private static instance;
4
- private ndk;
5
- private isConnected;
6
- private constructor();
7
- static getInstance(): NostrService;
8
- connectToNostr(relays?: string[]): Promise<void>;
9
- getRelays(): string[];
10
- resolveNDKUser(identifier: {
11
- npub?: string | null;
12
- nip05?: string | null;
13
- pubkey?: string | null;
14
- }): Promise<NDKUser | null>;
15
- resolveNDKEvent(identifier: {
16
- hex?: string | null;
17
- }): Promise<NDKEvent | null>;
18
- /**
19
- * Convenience helper to fetch zap count for a profile.
20
- * It determines the user based on the provided identifier and
21
- * returns the number of zap receipts found (count, **not** total sats).
22
- */
23
- getZapCount(identifier: {
24
- npub?: string;
25
- nip05?: string;
26
- pubkey?: string;
27
- }): Promise<number>;
28
- getProfile(user: NDKUser | null): Promise<NDKUserProfile | null>;
29
- getPost(eventId: string): Promise<NDKEvent | null>;
30
- fetchFollows(user: NDKUser): Promise<number>;
31
- fetchFollowers(user: NDKUser): Promise<number>;
32
- fetchNotesAndReplies(user: NDKUser): Promise<[number, number]>;
33
- fetchZaps(user: NDKUser): Promise<number>;
34
- getNDK(): NDK;
35
- /**
36
- * Check if a Nostr signer is available
37
- * @returns boolean indicating if a signer is available
38
- */
39
- hasSigner(): boolean;
40
- }
@@ -1,4 +0,0 @@
1
- import { Theme } from './types';
2
- export declare function getNostrLogo(width?: number, height?: number): string;
3
- export declare function getLoadingNostrich(): string;
4
- export declare function getSuccessAnimation(theme?: Theme): string;
@@ -1 +0,0 @@
1
- export type Theme = 'light' | 'dark' | 'ocean-glass' | 'holographic' | 'neo-matrix' | 'bitcoin-orange';
@@ -1,34 +0,0 @@
1
- import { default as NDK } from '@nostr-dev-kit/ndk';
2
- import { Theme } from './types';
3
- export declare const decodeNpub: (npub: string) => string;
4
- /**
5
- * Convert hex pubkey to npub
6
- */
7
- export declare function hexToNpub(hex: string): string;
8
- export declare const decodeNip19Entity: (entity: string) => any;
9
- export declare function maskNPub(npubString?: string, length?: number): string;
10
- export type Stats = {
11
- likes: number;
12
- reposts: number;
13
- zaps: number;
14
- replies: number;
15
- };
16
- export declare function getPostStats(ndk: NDK, postId: string): Promise<Stats>;
17
- export declare function parseRelays(relaysAttr: string | null): string[];
18
- export declare function parseTheme(themeAttr: string | null): Theme;
19
- export declare function parseBooleanAttribute(attr: string | null): boolean;
20
- export declare function escapeHtml(text: string): string;
21
- export declare function isValidUrl(url: string): boolean;
22
- export declare function isValidRelayUrl(url: string): boolean;
23
- export declare function isValidHex(hex: string): boolean;
24
- export declare function validateNpub(npub: string): boolean;
25
- export declare function validateNip05(nip05: string): boolean;
26
- export declare function validateNoteId(noteId: string): boolean;
27
- export declare function validateEventId(eventId: string): boolean;
28
- export declare function copyToClipboard(text: string): Promise<void>;
29
- /**
30
- * Format timestamp as relative time (e.g., "2 mins ago", "1 month ago")
31
- * @param ts Timestamp in seconds
32
- * @returns Formatted relative time string
33
- */
34
- export declare function formatRelativeTime(ts: number): string;
@@ -1,32 +0,0 @@
1
- import { default as NostrProfileBadge } from './nostr-profile-badge/nostr-profile-badge.ts';
2
- import { default as NostrPost } from './nostr-post/nostr-post.ts';
3
- import { default as NostrProfile } from './nostr-profile/nostr-profile.ts';
4
- import { default as NostrFollowButton } from './nostr-follow-button/nostr-follow-button.ts';
5
- import { default as NostrZap } from './nostr-zap/nostr-zap.ts';
6
- import { default as NostrComment } from './nostr-comment/nostr-comment.ts';
7
- import { default as NostrDm } from './nostr-dm/nostr-dm.ts';
8
- import { default as NostrLiveChat } from './nostr-live-chat/nostr-live-chat.ts';
9
- import { default as NostrLike } from './nostr-like/nostr-like.ts';
10
- export { default as NostrProfileBadge } from './nostr-profile-badge/nostr-profile-badge.ts';
11
- export { default as NostrPost } from './nostr-post/nostr-post.ts';
12
- export { default as NostrProfile } from './nostr-profile/nostr-profile.ts';
13
- export { default as NostrFollowButton } from './nostr-follow-button/nostr-follow-button.ts';
14
- export { default as NostrZap } from './nostr-zap/nostr-zap.ts';
15
- export { default as NostrComment } from './nostr-comment/nostr-comment.ts';
16
- export { default as NostrDm } from './nostr-dm/nostr-dm.ts';
17
- export { default as NostrLiveChat } from './nostr-live-chat/nostr-live-chat.ts';
18
- export { default as NostrLike } from './nostr-like/nostr-like.ts';
19
- export declare function init(): void;
20
- declare const _default: {
21
- init: typeof init;
22
- NostrProfileBadge: typeof NostrProfileBadge;
23
- NostrPost: typeof NostrPost;
24
- NostrProfile: typeof NostrProfile;
25
- NostrFollowButton: typeof NostrFollowButton;
26
- NostrZap: typeof NostrZap;
27
- NostrComment: typeof NostrComment;
28
- NostrDm: typeof NostrDm;
29
- NostrLiveChat: typeof NostrLiveChat;
30
- NostrLike: typeof NostrLike;
31
- };
32
- export default _default;
@@ -1,60 +0,0 @@
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 {};
@@ -1,15 +0,0 @@
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 {};
@@ -1,81 +0,0 @@
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;
@@ -1,34 +0,0 @@
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://relay.nostr.band", "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
- }
@@ -1,15 +0,0 @@
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;
@@ -1,24 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare function getFollowButtonStyles(): string;
@@ -1 +0,0 @@
1
- export declare function getHelpDialogStyles(): string;
@@ -1,2 +0,0 @@
1
- export declare const injectHelpDialogStyles: () => void;
2
- export declare const showHelpDialog: (theme?: "light" | "dark") => Promise<void>;
@@ -1 +0,0 @@
1
- export declare function getLikersDialogStyles(theme?: 'light' | 'dark'): string;
@@ -1,24 +0,0 @@
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>;
@@ -1,52 +0,0 @@
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 NIP-07 signer
43
- */
44
- export declare function getUserPubkey(): Promise<string | null>;
45
- /**
46
- * Sign event with NIP-07
47
- */
48
- export declare function signEvent(event: any): Promise<any>;
49
- /**
50
- * Check if NIP-07 extension is available
51
- */
52
- export declare function isNip07Available(): boolean;
@@ -1,49 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare function getLikeButtonStyles(): string;
@@ -1,65 +0,0 @@
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://relay.nostr.band", "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
- }
@@ -1,31 +0,0 @@
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;
@@ -1,25 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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[]>;
@@ -1,5 +0,0 @@
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>;