comment-mode 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +8 -112
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,19 +1,6 @@
1
1
  ## Comment Mode
2
2
 
3
- Embeddable commenting for live prototypes (Next.js / React) that talks to your Comment Mode API.
4
-
5
- ### Pushing to GitHub
6
-
7
- The project is already a git repo with an initial commit. To put it on GitHub:
8
-
9
- 1. **Create a new repository** on [GitHub](https://github.com/new): name it e.g. `commentator` (or `comment-mode`). Do **not** initialize with a README, .gitignore, or license—they already exist locally.
10
- 2. **Add the remote and push:**
11
- ```bash
12
- git remote add origin https://github.com/YOUR_USERNAME/commentator.git
13
- git branch -M main
14
- git push -u origin main
15
- ```
16
- Replace `YOUR_USERNAME` with your GitHub username (or org) and `commentator` with the repo name you chose.
3
+ Embeddable commenting for live prototypes (Next.js / React). Add a comment overlay and threaded discussions to any prototype with minimal setup.
17
4
 
18
5
  ### Installation
19
6
 
@@ -32,8 +19,6 @@ function App() {
32
19
  config={{
33
20
  projectSlug: "my-prototype",
34
21
  surfaceId: window.location.pathname,
35
- // Optional: override if you self-host the API
36
- // apiBaseUrl: "https://api.commentmode.dev",
37
22
  }}
38
23
  >
39
24
  {/* your prototype UI */}
@@ -43,103 +28,14 @@ function App() {
43
28
  }
44
29
  ```
45
30
 
46
- The current implementation includes:
47
-
48
- - **CommentProvider**: React context that holds configuration and talks to the Comment Mode HTTP API.
49
- - **CommentOverlay**: A fullscreen overlay with a toggle button, persisted pins (threads), and a basic comments panel per pin.
50
- - **useComments**: Hook exposing thread and comment APIs (create thread, load comments, add comment).
51
-
52
- By default, the package calls the shared API at `https://api.commentmode.dev`. You can override with `apiBaseUrl` in the config if you run your own backend.
53
-
54
- ### Backend API sketch
55
-
56
- At minimum, the backend behind `apiBaseUrl` should expose:
57
-
58
- - **POST `/threads`**
59
- - Request JSON:
60
-
61
- ```json
62
- {
63
- "projectSlug": "my-prototype",
64
- "surfaceId": "/some/route",
65
- "anchorX": 0.42,
66
- "anchorY": 0.17
67
- }
68
- ```
69
-
70
- - Response JSON:
71
-
72
- ```json
73
- {
74
- "id": "thread-uuid"
75
- }
76
- ```
77
-
78
- This backend can be implemented in a separate Next.js app that owns your Supabase credentials and inserts rows into `threads` (and later `comments`, `users`, etc.).
79
-
80
- ### Running the shared API (one backend for everyone)
81
-
82
- If you want to run a **shared API** so that everyone who installs `comment-mode` can use it without running their own backend:
83
-
84
- 1. **Deploy the API**
85
- The `commentator-api` folder in this repo is a Next.js app. Deploy it to [Vercel](https://vercel.com) (or similar):
86
- - Connect your GitHub repo and set the **root directory** to `commentator-api` (or deploy from inside that folder).
87
- - Add **Environment Variables** in the Vercel project:
88
- - `SUPABASE_URL` — your Supabase project URL
89
- - `SUPABASE_SERVICE_ROLE_KEY` — service role key (API uses this for threads/comments)
90
- - `SUPABASE_ANON_KEY` — anon key (exposed to the client via `/auth/config` for Supabase Auth)
91
- - Deploy. Add your custom domain (e.g. `api.commentmode.dev`) in Vercel so the API is served there.
92
-
93
- 2. **SDK default**
94
- The package already defaults to `https://api.commentmode.dev` (see `src/constants.ts`). After you deploy the API to that URL, run `npm run build` and publish the package; anyone who installs `comment-mode` will use your shared API by default.
95
-
96
- 3. **Configure Supabase for production**
97
- In **Supabase Dashboard → Authentication → URL Configuration**:
98
- - **Site URL**: your main production app URL (e.g. `https://commentmode.dev` or the URL of a prototype that uses the SDK).
99
- - **Redirect URLs**: add every origin where the commenting UI will run (e.g. `https://commentmode.dev`, `https://commentmode.dev/**`, and any other prototype domains). You can add more later as people use the SDK on different sites.
100
-
101
- ### Supabase URLs when going live
102
-
103
- If you run your own API (e.g. the `commentator-api` in this repo) and use Supabase Auth (magic link, GitHub, etc.), you must configure URLs in the **Supabase Dashboard** so auth works on production:
104
-
105
- 1. **Authentication → URL Configuration**
106
- - **Site URL**: set to your production app origin (e.g. `https://my-prototype.vercel.app`). This is the main URL where the SDK runs.
107
- - **Redirect URLs**: add every origin where the commenting UI will load. For example:
108
- - `https://my-prototype.vercel.app`
109
- - `https://my-prototype.vercel.app/**`
110
- - Any other prototype or app domains that use the same Comment Mode API.
111
-
112
- Without these, Supabase will block redirects from localhost-only and auth (sign-in, magic link) will fail on deployed sites.
113
-
114
- To build the package:
115
-
116
- ```bash
117
- npm install
118
- npm run build
119
- ```
120
-
121
- You can now link or publish the resulting package and import it into your Next.js prototypes.
122
-
123
- ### Publishing to npm
124
-
125
- To publish this package as **comment-mode**:
126
-
127
- 1. **npm account**
128
- Create an account at [npmjs.com](https://www.npmjs.com/signup) and log in with `npm login`.
129
-
130
- 2. **Point repo URLs to your repo**
131
- In `package.json`, set `repository.url`, `bugs.url`, and `homepage` to your real GitHub (or other) repo (replace `your-org` with your org/username, e.g. `https://github.com/your-org/comment-mode`).
31
+ **Config:**
132
32
 
133
- 3. **Optional: LICENSE**
134
- A root `LICENSE` file (e.g. MIT) is included; update the copyright holder if needed.
33
+ - **projectSlug** — Identifies your project (e.g. `"my-prototype"`).
34
+ - **surfaceId** Identifies the page/surface (e.g. `window.location.pathname`).
135
35
 
136
- 4. **Publish**
137
- From the repo root:
138
- ```bash
139
- npm run build
140
- npm publish
141
- ```
142
36
 
143
- 5. **Later releases**
144
- Bump `version` in `package.json` (e.g. `0.1.1`), then `npm publish` again.
37
+ ### What you get
145
38
 
39
+ - **CommentProvider** — Wraps your app and connects to the Comment Mode API.
40
+ - **CommentOverlay** — Fullscreen overlay with a toggle, comment pins (threads), and a panel to view/add comments.
41
+ - **useComments** — Hook for creating threads, loading comments, and adding replies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comment-mode",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Embeddable commenting for live prototypes (Next.js/React) that talks to your Comment Mode API.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",