@nuniapp/widget 0.1.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 ADDED
@@ -0,0 +1,86 @@
1
+ # @nuniapp/widget
2
+
3
+ Pin a comment to anything on your site. Talk it through with your team. Give your agent the context.
4
+
5
+ Nuni adds Figma-style comments to your real, running website: localhost, preview URLs, staging or production. Anyone who can open the site can leave a comment. No commenter accounts, no API keys, no dashboard setup.
6
+
7
+ ## Install
8
+
9
+ The fastest way is to paste this prompt into Codex, Claude Code, Cursor or any coding agent:
10
+
11
+ <!-- prompt:start -->
12
+
13
+ ```text
14
+ Add Nuni (pinned comments on the live site) to this project.
15
+
16
+ Get a project ID by running: npx @nuniapp/cli@latest init (it prints the ID and the exact snippet for this framework).
17
+
18
+ Steps:
19
+ 1. Detect the framework and package manager.
20
+ 2. If the app uses React (Next.js, Vite, Remix, React Router, TanStack Start, etc.):
21
+ - Install @nuniapp/react.
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
+ 3. Otherwise, if there is a bundler (Vue, Svelte, Astro, Angular, etc.):
24
+ - Install @nuniapp/widget.
25
+ - Call init({ project: "PROJECT_ID" }) once on the client, in the app entry or root layout. import { init } from "@nuniapp/widget".
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@0/dist/nuni.global.js" data-project="PROJECT_ID" defer></script>
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
+ 6. Do not add Nuni to server-only code, and do not load it more than once.
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
+ 8. Start the dev server, open the site, and confirm the Nuni button appears in the bottom-right corner.
32
+
33
+ Docs: https://nuni.praveenjuge.com/quickstart
34
+ ```
35
+
36
+ <!-- prompt:end -->
37
+
38
+ Or do it yourself:
39
+
40
+ ```sh
41
+ npx @nuniapp/cli init # prints your project ID and the snippet for your framework
42
+ npm install @nuniapp/widget
43
+ ```
44
+
45
+ ```ts
46
+ import { init } from "@nuniapp/widget"
47
+
48
+ init({ project: "nuni_..." })
49
+ ```
50
+
51
+ Using React? Use [`@nuniapp/react`](https://www.npmjs.com/package/@nuniapp/react). No bundler? Use the script tag:
52
+
53
+ ```html
54
+ <script
55
+ src="https://cdn.jsdelivr.net/npm/@nuniapp/widget@0/dist/nuni.global.js"
56
+ data-project="nuni_..."
57
+ defer
58
+ ></script>
59
+ ```
60
+
61
+ ## Options
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. |
68
+
69
+ `init` returns `{ destroy() }`.
70
+
71
+ ## Using it
72
+
73
+ - Press **C** (or the Comment button), click any element and write your comment.
74
+ - 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
+ - Your name is remembered in this browser. You can edit and delete your own comments.
76
+ - The site owner claims the project from the widget ("Claim Nuni", GitHub sign-in) and can then resolve, reopen and delete comments.
77
+
78
+ ## Privacy
79
+
80
+ Comments are visible to everyone who can open the site, and to anyone who knows the project ID. Don't put secrets in comments.
81
+
82
+ ## Content Security Policy
83
+
84
+ If your site sends a CSP, allow `connect-src https://*.convex.cloud wss://*.convex.cloud https://*.convex.site` (and `script-src cdn.jsdelivr.net` for the script tag).
85
+
86
+ Docs: https://nuni.praveenjuge.com
@@ -0,0 +1,28 @@
1
+ //#region src/config.d.ts
2
+ interface NuniOptions {
3
+ /** Public project ID, e.g. "nuni_4Hk9...". Safe to commit. */
4
+ project: string;
5
+ /** Override the Convex deployment (self-hosting and local development). */
6
+ convexUrl?: string;
7
+ /** Override the Convex HTTP actions URL (`*.convex.site`). */
8
+ convexSiteUrl?: string;
9
+ /** Override the dashboard URL used for claiming and owner sign-in. */
10
+ appUrl?: string;
11
+ /** Custom page key. Comments are matched by this; defaults to the normalized path. */
12
+ getPageKey?: (url: URL) => string;
13
+ }
14
+ export declare const VERSION: string;
15
+ //#endregion
16
+ //#region src/index.d.ts
17
+ export interface NuniInstance {
18
+ destroy(): void;
19
+ }
20
+ /**
21
+ * Mount Nuni on the page. Call once on the client. Calling it again with the
22
+ * same project shares the mounted widget; it is removed when every handle is
23
+ * destroyed. A different project replaces it. Each handle only ever tears
24
+ * down the widget it was created for.
25
+ */
26
+ export declare function init(options: NuniOptions): NuniInstance;
27
+ //#endregion
28
+ export type { NuniOptions };