@nuniapp/widget 0.1.2 → 0.1.4
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 +12 -11
- package/dist/index.d.ts +39 -3
- package/dist/index.js +645 -105
- package/dist/mark-BeysEAHp.js +66 -0
- package/dist/nuni-screenshot.global.js +14 -0
- package/dist/nuni.global.js +30 -3
- package/dist/screenshot-B2x2-nI_.js +1288 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -18,13 +18,13 @@ Get a project ID by running: npx @nuniapp/cli@latest init (it prints the ID and
|
|
|
18
18
|
Steps:
|
|
19
19
|
1. Detect the framework and package manager.
|
|
20
20
|
2. If the app uses React (Next.js, Vite, Remix, React Router, TanStack Start, etc.):
|
|
21
|
-
- Install @nuniapp/react.
|
|
21
|
+
- Install @nuniapp/react@latest.
|
|
22
22
|
- Render <Nuni project="PROJECT_ID" /> once, globally, in the root layout or app entry (for Next.js App Router: app/layout.tsx, inside <body>). It is already a client component.
|
|
23
23
|
3. Otherwise, if there is a bundler (Vue, Svelte, Astro, Angular, etc.):
|
|
24
|
-
- Install @nuniapp/widget.
|
|
24
|
+
- Install @nuniapp/widget@latest.
|
|
25
25
|
- Call init({ project: "PROJECT_ID" }) once on the client, in the app entry or root layout. import { init } from "@nuniapp/widget".
|
|
26
26
|
4. If there is no bundler (plain HTML, WordPress, Webflow): add this before </body> on every page:
|
|
27
|
-
<script src="https://cdn.jsdelivr.net/npm/@nuniapp/widget@
|
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/@nuniapp/widget@latest/dist/nuni.global.js" data-project="PROJECT_ID" defer></script>
|
|
28
28
|
5. Commit the project ID directly in the code. It is public, not a secret. Do not put it in an env var.
|
|
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).
|
|
@@ -38,8 +38,8 @@ Docs: https://nuni.praveenjuge.com/quickstart
|
|
|
38
38
|
Or do it yourself:
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
npx @nuniapp/cli init # prints your project ID and the snippet for your framework
|
|
42
|
-
npm install @nuniapp/widget
|
|
41
|
+
npx @nuniapp/cli@latest init # prints your project ID and the snippet for your framework
|
|
42
|
+
npm install @nuniapp/widget@latest
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
```ts
|
|
@@ -52,7 +52,7 @@ Using React? Use [`@nuniapp/react`](https://www.npmjs.com/package/@nuniapp/react
|
|
|
52
52
|
|
|
53
53
|
```html
|
|
54
54
|
<script
|
|
55
|
-
src="https://cdn.jsdelivr.net/npm/@nuniapp/widget@
|
|
55
|
+
src="https://cdn.jsdelivr.net/npm/@nuniapp/widget@latest/dist/nuni.global.js"
|
|
56
56
|
data-project="nuni_..."
|
|
57
57
|
defer
|
|
58
58
|
></script>
|
|
@@ -60,11 +60,12 @@ Using React? Use [`@nuniapp/react`](https://www.npmjs.com/package/@nuniapp/react
|
|
|
60
60
|
|
|
61
61
|
## Options
|
|
62
62
|
|
|
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.
|
|
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. |
|
|
68
|
+
| `capture` | Optional. Owner-only page context per comment: `{ console, network, dom, screenshot }`, all on by default. |
|
|
68
69
|
|
|
69
70
|
`init` returns `{ destroy() }`.
|
|
70
71
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,13 +10,49 @@ interface NuniOptions {
|
|
|
10
10
|
appUrl?: string;
|
|
11
11
|
/** Custom page key. Comments are matched by this; defaults to the normalized path. */
|
|
12
12
|
getPageKey?: (url: URL) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Extra context attached to each comment for the project owner and their
|
|
15
|
+
* coding agent. Everything is on by default; set a key to `false` to stop
|
|
16
|
+
* capturing it.
|
|
17
|
+
*/
|
|
18
|
+
capture?: {
|
|
19
|
+
/** Recent console errors and warnings. */
|
|
20
|
+
console?: boolean;
|
|
21
|
+
/** Recent failed requests (method, origin + path, status). */
|
|
22
|
+
network?: boolean;
|
|
23
|
+
/** The element's markup (form values removed) and key styles. */
|
|
24
|
+
dom?: boolean;
|
|
25
|
+
/** An image of the element and its surroundings. */
|
|
26
|
+
screenshot?: boolean;
|
|
27
|
+
};
|
|
13
28
|
}
|
|
14
29
|
export declare const VERSION: string;
|
|
15
30
|
//#endregion
|
|
16
|
-
//#region src/
|
|
17
|
-
|
|
31
|
+
//#region src/screenshot.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Screenshots are loaded lazily (a separate chunk for npm users, a separate
|
|
34
|
+
* script for the CDN build), so the widget itself stays small.
|
|
35
|
+
*/
|
|
36
|
+
interface ScreenshotOptions {
|
|
37
|
+
/** Nuni's own host element, left out of the image. */
|
|
38
|
+
exclude: Element;
|
|
39
|
+
/** Outline color drawn around the commented element. */
|
|
40
|
+
accent: string;
|
|
41
|
+
}
|
|
42
|
+
type CaptureScreenshot = (el: Element, options: ScreenshotOptions) => Promise<Blob | null>;
|
|
43
|
+
declare global {
|
|
44
|
+
interface Window {
|
|
45
|
+
/** Set by nuni-screenshot.global.js (the CDN build). */
|
|
46
|
+
__nuniScreenshot?: CaptureScreenshot;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/mount.d.ts
|
|
51
|
+
interface NuniInstance {
|
|
18
52
|
destroy(): void;
|
|
19
53
|
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/index.d.ts
|
|
20
56
|
/**
|
|
21
57
|
* Mount Nuni on the page. Call once on the client. Calling it again with the
|
|
22
58
|
* same project shares the mounted widget; it is removed when every handle is
|
|
@@ -25,4 +61,4 @@ export interface NuniInstance {
|
|
|
25
61
|
*/
|
|
26
62
|
export declare function init(options: NuniOptions): NuniInstance;
|
|
27
63
|
//#endregion
|
|
28
|
-
export type { NuniOptions };
|
|
64
|
+
export type { NuniInstance, NuniOptions };
|