@nuniapp/widget 0.1.3 → 0.1.5
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 +13 -6
- package/dist/index.d.ts +181 -3
- package/dist/index.js +2815 -393
- package/dist/mark-B8wojiFu.js +90 -0
- package/dist/nuni-screenshot.global.js +14 -0
- package/dist/nuni.global.js +199 -4
- package/dist/screenshot-DcJ_SzKF.js +1288 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ Steps:
|
|
|
29
29
|
6. Do not add Nuni to server-only code, and do not load it more than once.
|
|
30
30
|
7. If the site sends a Content-Security-Policy, allow connect-src https://*.convex.cloud wss://*.convex.cloud https://*.convex.site (and script-src cdn.jsdelivr.net for the script tag).
|
|
31
31
|
8. Start the dev server, open the site, and confirm the Nuni button appears in the bottom-right corner.
|
|
32
|
+
9. Tell the user they can let you read and resolve comments later: run npx @nuniapp/cli@latest login once, then add the MCP server (for Claude Code: claude mcp add nuni -- npx -y @nuniapp/cli@latest mcp). Do not run login yourself unless asked.
|
|
32
33
|
|
|
33
34
|
Docs: https://nuni.praveenjuge.com/quickstart
|
|
34
35
|
```
|
|
@@ -60,17 +61,23 @@ Using React? Use [`@nuniapp/react`](https://www.npmjs.com/package/@nuniapp/react
|
|
|
60
61
|
|
|
61
62
|
## Options
|
|
62
63
|
|
|
63
|
-
| Option | Description
|
|
64
|
-
| -------------------------------------- |
|
|
65
|
-
| `project` | Your public project ID. Commit it; it is not a secret.
|
|
66
|
-
| `getPageKey(url)` | Optional. Decide which URLs share comments. Defaults to the path, ignoring query and hash.
|
|
67
|
-
| `convexUrl`, `convexSiteUrl`, `appUrl` | Optional. For self-hosting or local development.
|
|
64
|
+
| Option | Description |
|
|
65
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `project` | Your public project ID. Commit it; it is not a secret. |
|
|
67
|
+
| `getPageKey(url)` | Optional. Decide which URLs share comments. Defaults to the path, ignoring query and hash. |
|
|
68
|
+
| `convexUrl`, `convexSiteUrl`, `appUrl` | Optional. For self-hosting or local development. |
|
|
69
|
+
| `capture` | Optional. Owner-only page context per comment: `{ console, network, dom, screenshot }`, all on by default. |
|
|
70
|
+
| `pageKey` | Optional. `"path"` (default), `"path+search"` or `"path+hash"`, when `getPageKey` is not set. |
|
|
71
|
+
| `position`, `accentColor`, `theme` | Optional. Toolbar corner, brand color (any CSS color), and `"auto"`, `"light"` or `"dark"`. |
|
|
72
|
+
| `label`, `hotkey`, `zIndex` | Optional. Comment button text, shortcut key (`false` turns it off) and stacking order. |
|
|
73
|
+
| `locale`, `messages` | Optional. Language for times and counts, and replacements for any of the widget's words. |
|
|
68
74
|
|
|
69
75
|
`init` returns `{ destroy() }`.
|
|
70
76
|
|
|
71
77
|
## Using it
|
|
72
78
|
|
|
73
|
-
- Press **C** (or the Comment button), click any element and write your comment.
|
|
79
|
+
- Press **C** (or the Comment button), click any element and write your comment. Select text to comment on the words, or drag a box to comment on an area.
|
|
80
|
+
- Everything works from the keyboard: while adding, the arrow keys move between elements and Enter comments.
|
|
74
81
|
- Pins follow their element through layout changes, responsive breakpoints and content edits. If an element is removed, its comment is listed as "Couldn't find on this page" instead of pinned to the wrong thing.
|
|
75
82
|
- Your name is remembered in this browser. You can edit and delete your own comments.
|
|
76
83
|
- The site owner claims the project from the widget ("Claim Nuni", GitHub sign-in) and can then resolve, reopen and delete comments.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,113 @@
|
|
|
1
|
+
//#region src/i18n.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every word the widget shows. Override any of them with the `messages`
|
|
4
|
+
* option; `locale` sets how times and counts are written.
|
|
5
|
+
*
|
|
6
|
+
* `{name}` is filled in. A message with forms (`one`, `other`, and `zero`,
|
|
7
|
+
* `two`, `few`, `many` where a language has them) is picked by `{count}`.
|
|
8
|
+
*/
|
|
9
|
+
declare const EN: {
|
|
10
|
+
toolbar: string;
|
|
11
|
+
comment: string;
|
|
12
|
+
addComment: string;
|
|
13
|
+
addCommentKey: string;
|
|
14
|
+
cancelAdding: string;
|
|
15
|
+
pickElement: string;
|
|
16
|
+
allComments: string;
|
|
17
|
+
openCount: string;
|
|
18
|
+
commentSelection: string;
|
|
19
|
+
commentSelectionKey: string;
|
|
20
|
+
pickHint: string;
|
|
21
|
+
pickHintMobile: string;
|
|
22
|
+
pickHintKeys: string;
|
|
23
|
+
picked: string;
|
|
24
|
+
comments: string;
|
|
25
|
+
close: string;
|
|
26
|
+
tabOpen: string;
|
|
27
|
+
tabResolved: string;
|
|
28
|
+
loading: string;
|
|
29
|
+
noOpen: string;
|
|
30
|
+
noOpenKey: string;
|
|
31
|
+
noResolved: string;
|
|
32
|
+
notFoundHere: string;
|
|
33
|
+
otherPages: string;
|
|
34
|
+
openOnPage: string;
|
|
35
|
+
replyCount: {
|
|
36
|
+
one: string;
|
|
37
|
+
other: string;
|
|
38
|
+
};
|
|
39
|
+
edited: string;
|
|
40
|
+
ownSite: string;
|
|
41
|
+
claim: string;
|
|
42
|
+
yourName: string;
|
|
43
|
+
leaveComment: string;
|
|
44
|
+
notYou: string;
|
|
45
|
+
screenshotAlt: string;
|
|
46
|
+
screenshotNote: string;
|
|
47
|
+
remove: string;
|
|
48
|
+
cancel: string;
|
|
49
|
+
post: string;
|
|
50
|
+
posting: string;
|
|
51
|
+
save: string;
|
|
52
|
+
send: string;
|
|
53
|
+
pinLabel: string;
|
|
54
|
+
commentBy: string;
|
|
55
|
+
openScreenshot: string;
|
|
56
|
+
screenshotTaken: string;
|
|
57
|
+
resolved: string;
|
|
58
|
+
leftOn: string;
|
|
59
|
+
approximate: string;
|
|
60
|
+
approximateHint: string;
|
|
61
|
+
notFound: string;
|
|
62
|
+
originallyOn: string;
|
|
63
|
+
resolve: string;
|
|
64
|
+
reopen: string;
|
|
65
|
+
copyForAgent: string;
|
|
66
|
+
copyForAgentHint: string;
|
|
67
|
+
loadingContext: string;
|
|
68
|
+
edit: string;
|
|
69
|
+
delete: string;
|
|
70
|
+
owner: string;
|
|
71
|
+
addReaction: string;
|
|
72
|
+
reactions: string;
|
|
73
|
+
reactWith: string;
|
|
74
|
+
reply: string;
|
|
75
|
+
replyFirst: string;
|
|
76
|
+
sendReply: string;
|
|
77
|
+
editReply: string;
|
|
78
|
+
deleteReply: string;
|
|
79
|
+
confirmDeleteComment: string;
|
|
80
|
+
confirmDeleteReply: string;
|
|
81
|
+
added: string;
|
|
82
|
+
saved: string;
|
|
83
|
+
deleted: string;
|
|
84
|
+
replyDeleted: string;
|
|
85
|
+
reopened: string;
|
|
86
|
+
copied: string;
|
|
87
|
+
copyFailed: string;
|
|
88
|
+
signedIn: string;
|
|
89
|
+
linkGone: string;
|
|
90
|
+
enterName: string;
|
|
91
|
+
writeFirst: string;
|
|
92
|
+
commentTooLong: string;
|
|
93
|
+
replyTooLong: string;
|
|
94
|
+
postFailed: string;
|
|
95
|
+
replyFailed: string;
|
|
96
|
+
reactFailed: string;
|
|
97
|
+
failed: string;
|
|
98
|
+
justNow: string;
|
|
99
|
+
};
|
|
100
|
+
type Plural = {
|
|
101
|
+
other: string;
|
|
102
|
+
} & Partial<Record<Intl.LDMLPluralRule, string>>;
|
|
103
|
+
type MessageKey = keyof typeof EN;
|
|
104
|
+
type Messages = { [K in MessageKey]: string | Plural; };
|
|
105
|
+
//#endregion
|
|
1
106
|
//#region src/config.d.ts
|
|
107
|
+
type Position = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
108
|
+
type Theme = "auto" | "light" | "dark";
|
|
109
|
+
/** Built-in page keys, for when `getPageKey` is not set. */
|
|
110
|
+
type PageKey = "path" | "path+search" | "path+hash";
|
|
2
111
|
interface NuniOptions {
|
|
3
112
|
/** Public project ID, e.g. "nuni_4Hk9...". Safe to commit. */
|
|
4
113
|
project: string;
|
|
@@ -10,13 +119,82 @@ interface NuniOptions {
|
|
|
10
119
|
appUrl?: string;
|
|
11
120
|
/** Custom page key. Comments are matched by this; defaults to the normalized path. */
|
|
12
121
|
getPageKey?: (url: URL) => string;
|
|
122
|
+
/**
|
|
123
|
+
* Which part of the URL tells pages apart, when `getPageKey` is not set:
|
|
124
|
+
* the path (default), the path and query string, or the path and hash.
|
|
125
|
+
*/
|
|
126
|
+
pageKey?: PageKey;
|
|
127
|
+
/** Corner for the toolbar. Default "bottom-right". */
|
|
128
|
+
position?: Position;
|
|
129
|
+
/** Brand color for buttons, pins and highlights (any CSS color). */
|
|
130
|
+
accentColor?: string;
|
|
131
|
+
/** "auto" follows the visitor's system (default). */
|
|
132
|
+
theme?: Theme;
|
|
133
|
+
/** Text on the toolbar's comment button. Default "Comment". */
|
|
134
|
+
label?: string;
|
|
135
|
+
/** Key that starts a comment. Default "c"; `false` turns it off. */
|
|
136
|
+
hotkey?: string | false;
|
|
137
|
+
/** Stacking order of the widget. Default 2147483646. */
|
|
138
|
+
zIndex?: number;
|
|
139
|
+
/** Language for dates and counts, e.g. "de". Defaults to the browser's. */
|
|
140
|
+
locale?: string;
|
|
141
|
+
/** Replace any of the widget's words. See the `EN` messages. */
|
|
142
|
+
messages?: Partial<Messages>;
|
|
143
|
+
/**
|
|
144
|
+
* Extra context attached to each comment for the project owner and their
|
|
145
|
+
* coding agent. Everything is on by default; set a key to `false` to stop
|
|
146
|
+
* capturing it.
|
|
147
|
+
*/
|
|
148
|
+
capture?: {
|
|
149
|
+
/** Recent console errors and warnings. */
|
|
150
|
+
console?: boolean;
|
|
151
|
+
/** Recent failed requests (method, origin + path, status). */
|
|
152
|
+
network?: boolean;
|
|
153
|
+
/** The element's markup (form values removed) and key styles. */
|
|
154
|
+
dom?: boolean;
|
|
155
|
+
/** An image of the element and its surroundings. */
|
|
156
|
+
screenshot?: boolean;
|
|
157
|
+
};
|
|
13
158
|
}
|
|
14
159
|
export declare const VERSION: string;
|
|
15
160
|
//#endregion
|
|
16
|
-
//#region src/
|
|
17
|
-
|
|
161
|
+
//#region src/screenshot.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Screenshots are loaded lazily (a separate chunk for npm users, a separate
|
|
164
|
+
* script for the CDN build), so the widget itself stays small.
|
|
165
|
+
*/
|
|
166
|
+
interface ScreenshotOptions {
|
|
167
|
+
/** Nuni's own host element, left out of the image. */
|
|
168
|
+
exclude: Element;
|
|
169
|
+
/** Outline color drawn around the commented element. */
|
|
170
|
+
accent: string;
|
|
171
|
+
/**
|
|
172
|
+
* The part of the element that was commented on (selected text, an
|
|
173
|
+
* area), in viewport coordinates. The image is cropped around it and it
|
|
174
|
+
* is outlined instead of the whole element.
|
|
175
|
+
*/
|
|
176
|
+
focus?: () => Box;
|
|
177
|
+
}
|
|
178
|
+
type CaptureScreenshot = (el: Element, options: ScreenshotOptions) => Promise<Blob | null>;
|
|
179
|
+
declare global {
|
|
180
|
+
interface Window {
|
|
181
|
+
/** Set by nuni-screenshot.global.js (the CDN build). */
|
|
182
|
+
__nuniScreenshot?: CaptureScreenshot;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
interface Box {
|
|
186
|
+
left: number;
|
|
187
|
+
top: number;
|
|
188
|
+
right: number;
|
|
189
|
+
bottom: number;
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/mount.d.ts
|
|
193
|
+
interface NuniInstance {
|
|
18
194
|
destroy(): void;
|
|
19
195
|
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/index.d.ts
|
|
20
198
|
/**
|
|
21
199
|
* Mount Nuni on the page. Call once on the client. Calling it again with the
|
|
22
200
|
* same project shares the mounted widget; it is removed when every handle is
|
|
@@ -25,4 +203,4 @@ export interface NuniInstance {
|
|
|
25
203
|
*/
|
|
26
204
|
export declare function init(options: NuniOptions): NuniInstance;
|
|
27
205
|
//#endregion
|
|
28
|
-
export type
|
|
206
|
+
export { type Messages, type NuniInstance, type NuniOptions, type PageKey, type Position, type Theme, EN as messages };
|