nostr-comments 0.4.0 → 0.6.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/README.md +10 -1
- package/dist/components/CommentEditor.d.ts +3 -2
- package/dist/hooks/useComments.d.ts +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/nostr-comments.cjs +78 -20
- package/dist/nostr-comments.js +1463 -1370
- package/dist/nostr-comments.umd.js +78 -20
- package/dist/services/comment.d.ts +3 -8
- package/dist/services/nostr.d.ts +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/utils/nip22.d.ts +2 -8
- package/dist/utils/pow-worker.d.ts +5 -0
- package/dist/utils/pubkey.d.ts +1 -0
- package/package.json +4 -14
|
@@ -19,14 +19,9 @@ export declare function fetchComments(options: FetchCommentsOptions): Promise<No
|
|
|
19
19
|
export declare function publishComment(signer: Signer, options: {
|
|
20
20
|
url: string;
|
|
21
21
|
content: string;
|
|
22
|
+
parentEvent?: NostrEvent | null;
|
|
22
23
|
relays?: string[];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export declare function publishReply(signer: Signer, options: {
|
|
26
|
-
url: string;
|
|
27
|
-
content: string;
|
|
28
|
-
parentEvent: NostrEvent;
|
|
29
|
-
relays?: string[];
|
|
30
|
-
authorPubkeys?: string[];
|
|
24
|
+
mention?: string;
|
|
25
|
+
pow?: number;
|
|
31
26
|
}): Promise<NostrEvent>;
|
|
32
27
|
export declare function buildCommentTree(events: NostrEvent[]): Comment[];
|
package/dist/services/nostr.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare function getDefaultRelays(): string[];
|
|
|
3
3
|
export declare function queryEvents(relays: string[], filter: Filter): Promise<NostrEvent[]>;
|
|
4
4
|
export declare function subscribeEvents(relays: string[], filter: Filter, onEvent: (event: NostrEvent) => void, onEose?: () => void): () => void;
|
|
5
5
|
export declare function publishEvent(relays: string[], event: NostrEvent): Promise<void>;
|
|
6
|
-
export declare function getRelays(relays?: string[],
|
|
6
|
+
export declare function getRelays(relays?: string[], mention?: string): Promise<string[]>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface Translations {
|
|
|
20
20
|
replyTo: string;
|
|
21
21
|
publish: string;
|
|
22
22
|
publishing: string;
|
|
23
|
+
computing: string;
|
|
23
24
|
cancel: string;
|
|
24
25
|
login: string;
|
|
25
26
|
logout: string;
|
|
@@ -60,7 +61,8 @@ export interface Translations {
|
|
|
60
61
|
}
|
|
61
62
|
export interface NostrCommentsProps {
|
|
62
63
|
url: string;
|
|
63
|
-
|
|
64
|
+
/** Public key to mention in comments (receives notifications) */
|
|
65
|
+
mention?: string;
|
|
64
66
|
relays?: string[];
|
|
65
67
|
pageSize?: number;
|
|
66
68
|
locale?: string;
|
|
@@ -75,6 +77,8 @@ export interface NostrCommentsProps {
|
|
|
75
77
|
loginModal?: string;
|
|
76
78
|
};
|
|
77
79
|
enabledSigners?: ("nip07" | "bunker" | "temp")[];
|
|
80
|
+
/** POW difficulty (number of leading zero bits). Requires more computation time but helps prevent spam. */
|
|
81
|
+
pow?: number;
|
|
78
82
|
onCommentPublished?: (event: NostrEvent) => void;
|
|
79
83
|
onError?: (error: Error) => void;
|
|
80
84
|
}
|
package/dist/utils/nip22.d.ts
CHANGED
|
@@ -2,16 +2,10 @@ import type { EventTemplate, NostrEvent } from "nostr-tools";
|
|
|
2
2
|
export interface WebCommentOptions {
|
|
3
3
|
url: string;
|
|
4
4
|
content: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export interface ReplyCommentOptions {
|
|
8
|
-
url: string;
|
|
9
|
-
content: string;
|
|
10
|
-
parentEvent: NostrEvent;
|
|
11
|
-
authorPubkeys?: string[];
|
|
5
|
+
parentEvent?: NostrEvent | null;
|
|
6
|
+
mention?: string;
|
|
12
7
|
}
|
|
13
8
|
export declare function buildWebComment(options: WebCommentOptions): EventTemplate;
|
|
14
|
-
export declare function buildReplyComment(options: ReplyCommentOptions): EventTemplate;
|
|
15
9
|
export declare function isReply(event: NostrEvent): boolean;
|
|
16
10
|
export declare function getParentId(event: NostrEvent): string | null;
|
|
17
11
|
export declare function getRootUrl(event: NostrEvent): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidPubkey(pubkey: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A Nostr-based web comment component using NIP-22 protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/nostr-comments.cjs",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"dev": "vite",
|
|
21
21
|
"build": "vite build && tsc --emitDeclarationOnly",
|
|
22
22
|
"preview": "vite preview",
|
|
23
|
-
"
|
|
24
|
-
"build
|
|
23
|
+
"demo": "vite --config vite.demo.config.ts",
|
|
24
|
+
"build:demo": "vite build --config vite.demo.config.ts"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"nostr",
|
|
@@ -42,23 +42,13 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@nostr/gadgets": "npm:@jsr/nostr__gadgets@^0.0.46",
|
|
45
|
-
"@chromatic-com/storybook": "^5.0.0",
|
|
46
|
-
"@storybook/addon-a11y": "^10.2.0",
|
|
47
|
-
"@storybook/addon-docs": "^10.2.0",
|
|
48
|
-
"@storybook/addon-vitest": "^10.2.0",
|
|
49
|
-
"@storybook/react-vite": "^10.2.0",
|
|
50
45
|
"@types/react": "^19.1.6",
|
|
51
46
|
"@types/react-dom": "^19.1.5",
|
|
52
47
|
"@vitejs/plugin-react": "^4.5.1",
|
|
53
|
-
"@vitest/browser-playwright": "^4.0.18",
|
|
54
|
-
"@vitest/coverage-v8": "^4.0.18",
|
|
55
|
-
"playwright": "^1.58.0",
|
|
56
48
|
"react": "^19.1.0",
|
|
57
49
|
"react-dom": "^19.1.0",
|
|
58
|
-
"storybook": "^10.2.0",
|
|
59
50
|
"typescript": "^5.7.3",
|
|
60
51
|
"vite": "^6.0.11",
|
|
61
|
-
"vite-plugin-css-injected-by-js": "^3.5.2"
|
|
62
|
-
"vitest": "^4.0.18"
|
|
52
|
+
"vite-plugin-css-injected-by-js": "^3.5.2"
|
|
63
53
|
}
|
|
64
54
|
}
|