@mindbowser_inc/ui-feedback-plugin 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 +163 -0
- package/dist/firebase-BGU5KpRU.mjs +15481 -0
- package/dist/firebase-BGU5KpRU.mjs.map +1 -0
- package/dist/html2canvas.esm-d2sM-0Wm.mjs +4871 -0
- package/dist/html2canvas.esm-d2sM-0Wm.mjs.map +1 -0
- package/dist/index-BcqBbswO.mjs +18420 -0
- package/dist/index-BcqBbswO.mjs.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/s3-DkzKoz0A.mjs +32 -0
- package/dist/s3-DkzKoz0A.mjs.map +1 -0
- package/dist/supabase-BUHP2OkK.mjs +128 -0
- package/dist/supabase-BUHP2OkK.mjs.map +1 -0
- package/dist/ui-feedback-plugin.es.js +1382 -0
- package/dist/ui-feedback-plugin.es.js.map +1 -0
- package/dist/ui-feedback-plugin.umd.js +3036 -0
- package/dist/ui-feedback-plugin.umd.js.map +1 -0
- package/package.json +50 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
declare type DatabaseConfig = FirebaseProviderConfig | SupabaseProviderConfig;
|
|
2
|
+
|
|
3
|
+
declare interface FirebaseProviderConfig {
|
|
4
|
+
provider: 'firebase';
|
|
5
|
+
/**
|
|
6
|
+
* Firebase API key. This is a public identifier — not a secret.
|
|
7
|
+
* Secure your data with Firebase Security Rules.
|
|
8
|
+
* Store in an environment variable (VITE_FIREBASE_API_KEY, REACT_APP_FIREBASE_API_KEY, etc.)
|
|
9
|
+
*/
|
|
10
|
+
apiKey: string;
|
|
11
|
+
authDomain: string;
|
|
12
|
+
projectId: string;
|
|
13
|
+
/** Required when using Firebase Storage for screenshots. */
|
|
14
|
+
storageBucket?: string;
|
|
15
|
+
messagingSenderId?: string;
|
|
16
|
+
appId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare function initFeedbackPlugin(config: PluginConfig): () => void;
|
|
20
|
+
|
|
21
|
+
export declare interface PluginConfig {
|
|
22
|
+
/** Database provider for storing comments and replies. */
|
|
23
|
+
database: DatabaseConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Screenshot storage provider.
|
|
26
|
+
* Defaults to the same provider as `database`.
|
|
27
|
+
* Use `s3` to keep screenshots off Firebase/Supabase.
|
|
28
|
+
*/
|
|
29
|
+
screenshots?: ScreenshotConfig;
|
|
30
|
+
/** Namespace comments by project. Use this when multiple prototypes share a backend. */
|
|
31
|
+
projectKey?: string;
|
|
32
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
|
+
theme?: {
|
|
34
|
+
primaryColor?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* S3 screenshot storage via a backend proxy endpoint.
|
|
40
|
+
* NEVER pass AWS credentials to the frontend — your backend holds those.
|
|
41
|
+
* Your endpoint receives { commentId, imageData } and returns { url }.
|
|
42
|
+
*/
|
|
43
|
+
declare interface S3ScreenshotConfig {
|
|
44
|
+
provider: 's3';
|
|
45
|
+
/** Your backend endpoint that accepts the screenshot and returns { url: string } */
|
|
46
|
+
uploadEndpoint: string;
|
|
47
|
+
/** Optional headers (e.g. an authorization token for your own backend) */
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Controls where screenshots are stored.
|
|
53
|
+
* - `'firebase'` / `'supabase'`: reuse the same provider configured in `database`
|
|
54
|
+
* - `'s3'`: forward screenshots to your own backend proxy (AWS credentials stay on your server)
|
|
55
|
+
*/
|
|
56
|
+
declare type ScreenshotConfig = {
|
|
57
|
+
provider: 'firebase';
|
|
58
|
+
} | {
|
|
59
|
+
provider: 'supabase';
|
|
60
|
+
} | S3ScreenshotConfig;
|
|
61
|
+
|
|
62
|
+
declare interface SupabaseProviderConfig {
|
|
63
|
+
provider: 'supabase';
|
|
64
|
+
url: string;
|
|
65
|
+
/**
|
|
66
|
+
* Supabase anon key. This is a public key — not a secret.
|
|
67
|
+
* Secure your data with Supabase Row Level Security (RLS) policies.
|
|
68
|
+
* Store in an environment variable.
|
|
69
|
+
*/
|
|
70
|
+
anonKey: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var d = (n, e, t) => e in n ? a(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var r = (n, e, t) => d(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class c {
|
|
5
|
+
constructor(e, t = {}) {
|
|
6
|
+
r(this, "endpoint");
|
|
7
|
+
r(this, "headers");
|
|
8
|
+
this.endpoint = e, this.headers = t;
|
|
9
|
+
}
|
|
10
|
+
async uploadScreenshot(e, t) {
|
|
11
|
+
const i = t.includes(",") ? t.split(",")[1] : t, o = await fetch(this.endpoint, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
...this.headers
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify({ commentId: e, imageData: i })
|
|
18
|
+
});
|
|
19
|
+
if (!o.ok)
|
|
20
|
+
throw new Error(
|
|
21
|
+
`[ui-feedback-plugin] Screenshot upload failed: ${o.status} ${o.statusText}`
|
|
22
|
+
);
|
|
23
|
+
const s = await o.json();
|
|
24
|
+
if (!(s != null && s.url))
|
|
25
|
+
throw new Error("[ui-feedback-plugin] Upload endpoint did not return { url }");
|
|
26
|
+
return s.url;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
c as S3ScreenshotAdapter
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=s3-DkzKoz0A.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-DkzKoz0A.mjs","sources":["../src/adapters/s3.ts"],"sourcesContent":["/**\n * S3 screenshot adapter — routes uploads through your own backend endpoint.\n *\n * AWS credentials MUST live on your server, never in browser code.\n * Your endpoint receives: POST { commentId: string, imageData: string (base64) }\n * Your endpoint returns: { url: string } (the public S3 URL)\n *\n * Minimal Node/Express example:\n *\n * const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3')\n * const s3 = new S3Client({\n * region: process.env.AWS_REGION,\n * credentials: {\n * accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n * },\n * })\n *\n * app.post('/upload-screenshot', async (req, res) => {\n * const { commentId, imageData } = req.body\n * const buffer = Buffer.from(imageData, 'base64')\n * await s3.send(new PutObjectCommand({\n * Bucket: process.env.S3_BUCKET,\n * Key: `ufp/${commentId}.png`,\n * Body: buffer,\n * ContentType: 'image/png',\n * }))\n * res.json({ url: `https://${process.env.S3_BUCKET}.s3.amazonaws.com/ufp/${commentId}.png` })\n * })\n */\nimport type { ScreenshotAdapter } from '../core/types'\n\nexport class S3ScreenshotAdapter implements ScreenshotAdapter {\n private endpoint: string\n private headers: Record<string, string>\n\n constructor(endpoint: string, headers: Record<string, string> = {}) {\n this.endpoint = endpoint\n this.headers = headers\n }\n\n async uploadScreenshot(commentId: string, dataUrl: string): Promise<string> {\n // Strip the data URL prefix — send only the base64 payload\n const imageData = dataUrl.includes(',') ? dataUrl.split(',')[1] : dataUrl\n\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...this.headers,\n },\n body: JSON.stringify({ commentId, imageData }),\n })\n\n if (!response.ok) {\n throw new Error(\n `[ui-feedback-plugin] Screenshot upload failed: ${response.status} ${response.statusText}`\n )\n }\n\n const json = await response.json() as { url: string }\n if (!json?.url) {\n throw new Error('[ui-feedback-plugin] Upload endpoint did not return { url }')\n }\n return json.url\n }\n}\n"],"names":["S3ScreenshotAdapter","endpoint","headers","__publicField","commentId","dataUrl","imageData","response","json"],"mappings":";;;AAgCO,MAAMA,EAAiD;AAAA,EAI5D,YAAYC,GAAkBC,IAAkC,IAAI;AAH5D,IAAAC,EAAA;AACA,IAAAA,EAAA;AAGN,SAAK,WAAWF,GAChB,KAAK,UAAUC;AAAA,EACjB;AAAA,EAEA,MAAM,iBAAiBE,GAAmBC,GAAkC;AAE1E,UAAMC,IAAYD,EAAQ,SAAS,GAAG,IAAIA,EAAQ,MAAM,GAAG,EAAE,CAAC,IAAIA,GAE5DE,IAAW,MAAM,MAAM,KAAK,UAAU;AAAA,MAC1C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAG,KAAK;AAAA,MAAA;AAAA,MAEV,MAAM,KAAK,UAAU,EAAE,WAAAH,GAAW,WAAAE,GAAW;AAAA,IAAA,CAC9C;AAED,QAAI,CAACC,EAAS;AACZ,YAAM,IAAI;AAAA,QACR,kDAAkDA,EAAS,MAAM,IAAIA,EAAS,UAAU;AAAA,MAAA;AAI5F,UAAMC,IAAO,MAAMD,EAAS,KAAA;AAC5B,QAAI,EAACC,KAAA,QAAAA,EAAM;AACT,YAAM,IAAI,MAAM,6DAA6D;AAE/E,WAAOA,EAAK;AAAA,EACd;AACF;"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var g = (t, n, e) => n in t ? f(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
|
|
3
|
+
var c = (t, n, e) => g(t, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
function b(t) {
|
|
5
|
+
return {
|
|
6
|
+
id: t.id,
|
|
7
|
+
pageUrl: t.page_url,
|
|
8
|
+
projectKey: t.project_key,
|
|
9
|
+
authorName: t.author_name,
|
|
10
|
+
text: t.text,
|
|
11
|
+
screenshotUrl: t.screenshot_url ?? "",
|
|
12
|
+
annotation: t.annotation,
|
|
13
|
+
resolved: t.resolved,
|
|
14
|
+
createdAt: t.created_at
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function y(t) {
|
|
18
|
+
return {
|
|
19
|
+
page_url: t.pageUrl,
|
|
20
|
+
project_key: t.projectKey,
|
|
21
|
+
author_name: t.authorName,
|
|
22
|
+
text: t.text,
|
|
23
|
+
screenshot_url: t.screenshotUrl,
|
|
24
|
+
annotation: t.annotation,
|
|
25
|
+
resolved: t.resolved,
|
|
26
|
+
created_at: t.createdAt
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function w(t) {
|
|
30
|
+
return {
|
|
31
|
+
id: t.id,
|
|
32
|
+
commentId: t.comment_id,
|
|
33
|
+
authorName: t.author_name,
|
|
34
|
+
text: t.text,
|
|
35
|
+
createdAt: t.created_at
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function C(t) {
|
|
39
|
+
return {
|
|
40
|
+
comment_id: t.commentId,
|
|
41
|
+
author_name: t.authorName,
|
|
42
|
+
text: t.text,
|
|
43
|
+
created_at: t.createdAt
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
class x {
|
|
47
|
+
constructor(n, e) {
|
|
48
|
+
c(this, "client");
|
|
49
|
+
c(this, "_url");
|
|
50
|
+
c(this, "_key");
|
|
51
|
+
c(this, "_client", null);
|
|
52
|
+
this._url = n, this._key = e;
|
|
53
|
+
}
|
|
54
|
+
async _getClient() {
|
|
55
|
+
if (this._client) return this._client;
|
|
56
|
+
try {
|
|
57
|
+
const { createClient: n } = await import("./index-BcqBbswO.mjs");
|
|
58
|
+
return this._client = n(this._url, this._key), this._client;
|
|
59
|
+
} catch {
|
|
60
|
+
throw new Error(
|
|
61
|
+
"[ui-feedback-plugin] @supabase/supabase-js is not installed. Run: npm install @supabase/supabase-js"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async addComment(n) {
|
|
66
|
+
const e = await this._getClient(), { data: a, error: r } = await e.from("ufp_comments").insert(y(n)).select("id").single();
|
|
67
|
+
if (r) throw r;
|
|
68
|
+
return a.id;
|
|
69
|
+
}
|
|
70
|
+
async getComments(n, e) {
|
|
71
|
+
const a = await this._getClient(), { data: r, error: s } = await a.from("ufp_comments").select("*").eq("page_url", n).eq("project_key", e);
|
|
72
|
+
if (s) throw s;
|
|
73
|
+
return (r ?? []).map(b).sort((o, l) => l.createdAt - o.createdAt);
|
|
74
|
+
}
|
|
75
|
+
async updateComment(n, e) {
|
|
76
|
+
const a = await this._getClient(), r = {};
|
|
77
|
+
e.resolved !== void 0 && (r.resolved = e.resolved), e.screenshotUrl !== void 0 && (r.screenshot_url = e.screenshotUrl), e.text !== void 0 && (r.text = e.text), e.annotation !== void 0 && (r.annotation = e.annotation);
|
|
78
|
+
const { error: s } = await a.from("ufp_comments").update(r).eq("id", n);
|
|
79
|
+
if (s) throw s;
|
|
80
|
+
}
|
|
81
|
+
async deleteComment(n) {
|
|
82
|
+
const e = await this._getClient(), { error: a } = await e.from("ufp_comments").delete().eq("id", n);
|
|
83
|
+
if (a) throw a;
|
|
84
|
+
}
|
|
85
|
+
async addReply(n) {
|
|
86
|
+
const e = await this._getClient(), { data: a, error: r } = await e.from("ufp_replies").insert(C(n)).select("id").single();
|
|
87
|
+
if (r) throw r;
|
|
88
|
+
return a.id;
|
|
89
|
+
}
|
|
90
|
+
async getReplies(n) {
|
|
91
|
+
const e = await this._getClient(), { data: a, error: r } = await e.from("ufp_replies").select("*").eq("comment_id", n);
|
|
92
|
+
if (r) throw r;
|
|
93
|
+
return (a ?? []).map(w).sort((i, o) => i.createdAt - o.createdAt);
|
|
94
|
+
}
|
|
95
|
+
subscribeToComments(n, e, a) {
|
|
96
|
+
let r = null, s = !0;
|
|
97
|
+
const i = async () => {
|
|
98
|
+
if (s)
|
|
99
|
+
try {
|
|
100
|
+
const o = await this.getComments(n, e);
|
|
101
|
+
s && a(o);
|
|
102
|
+
} catch (o) {
|
|
103
|
+
console.error("[ui-feedback-plugin] Supabase fetch error:", o);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return i(), this._getClient().then((o) => {
|
|
107
|
+
s && (r = o.channel("ufp-comments").on("postgres_changes", { event: "*", schema: "public", table: "ufp_comments" }, () => {
|
|
108
|
+
i();
|
|
109
|
+
}).subscribe());
|
|
110
|
+
}).catch(console.error), () => {
|
|
111
|
+
s = !1, r && this._getClient().then((o) => o.removeChannel(r)).catch(() => {
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async uploadScreenshot(n, e) {
|
|
116
|
+
var p;
|
|
117
|
+
const a = await this._getClient(), [r, s] = e.split(","), i = ((p = r.match(/:(.*?);/)) == null ? void 0 : p[1]) ?? "image/png", o = atob(s), l = new Uint8Array(o.length);
|
|
118
|
+
for (let u = 0; u < o.length; u++) l[u] = o.charCodeAt(u);
|
|
119
|
+
const d = new Blob([l], { type: i }), h = `${n}.png`, { error: m } = await a.storage.from("ufp-screenshots").upload(h, d, { contentType: "image/png", upsert: !0 });
|
|
120
|
+
if (m) throw m;
|
|
121
|
+
const { data: _ } = a.storage.from("ufp-screenshots").getPublicUrl(h);
|
|
122
|
+
return _.publicUrl;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
x as SupabaseAdapter
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=supabase-BUHP2OkK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase-BUHP2OkK.mjs","sources":["../src/adapters/supabase.ts"],"sourcesContent":["/**\n * Supabase adapter — requires @supabase/supabase-js v2.\n *\n * Run this SQL in your Supabase project before use:\n *\n * create table if not exists ufp_comments (\n * id uuid primary key default gen_random_uuid(),\n * page_url text not null,\n * project_key text not null default 'default',\n * author_name text not null,\n * text text not null,\n * screenshot_url text default '',\n * annotation jsonb not null default '{}',\n * resolved boolean default false,\n * created_at bigint not null\n * );\n *\n * create table if not exists ufp_replies (\n * id uuid primary key default gen_random_uuid(),\n * comment_id uuid not null references ufp_comments(id) on delete cascade,\n * author_name text not null,\n * text text not null,\n * created_at bigint not null\n * );\n *\n * alter table ufp_comments enable row level security;\n * alter table ufp_replies enable row level security;\n * -- Restrict these policies for production!\n * create policy \"ufp_comments_all\" on ufp_comments for all using (true) with check (true);\n * create policy \"ufp_replies_all\" on ufp_replies for all using (true) with check (true);\n *\n * -- Enable real-time (run in SQL editor):\n * alter publication supabase_realtime add table ufp_comments;\n *\n * -- Create storage bucket for screenshots (Supabase dashboard → Storage → New bucket):\n * -- Name: ufp-screenshots, Public: true\n */\nimport type {\n FeedbackComment,\n Reply,\n DatabaseAdapter,\n ScreenshotAdapter,\n AnnotationData,\n} from '../core/types'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SBClient = any\n\nfunction fromCommentRow(row: Record<string, unknown>): FeedbackComment {\n return {\n id: row.id as string,\n pageUrl: row.page_url as string,\n projectKey: row.project_key as string,\n authorName: row.author_name as string,\n text: row.text as string,\n screenshotUrl: (row.screenshot_url as string) ?? '',\n annotation: row.annotation as AnnotationData,\n resolved: row.resolved as boolean,\n createdAt: row.created_at as number,\n }\n}\n\nfunction toCommentRow(comment: Omit<FeedbackComment, 'id'>): Record<string, unknown> {\n return {\n page_url: comment.pageUrl,\n project_key: comment.projectKey,\n author_name: comment.authorName,\n text: comment.text,\n screenshot_url: comment.screenshotUrl,\n annotation: comment.annotation,\n resolved: comment.resolved,\n created_at: comment.createdAt,\n }\n}\n\nfunction fromReplyRow(row: Record<string, unknown>): Reply {\n return {\n id: row.id as string,\n commentId: row.comment_id as string,\n authorName: row.author_name as string,\n text: row.text as string,\n createdAt: row.created_at as number,\n }\n}\n\nfunction toReplyRow(reply: Omit<Reply, 'id'>): Record<string, unknown> {\n return {\n comment_id: reply.commentId,\n author_name: reply.authorName,\n text: reply.text,\n created_at: reply.createdAt,\n }\n}\n\nexport class SupabaseAdapter implements DatabaseAdapter, ScreenshotAdapter {\n private client: SBClient\n\n constructor(url: string, anonKey: string) {\n // Dynamic import so @supabase/supabase-js is optional at bundle time\n // The constructor is intentionally sync — client is created lazily in _getClient()\n this._url = url\n this._key = anonKey\n }\n\n private _url: string\n private _key: string\n private _client: SBClient | null = null\n\n private async _getClient(): Promise<SBClient> {\n if (this._client) return this._client\n try {\n const { createClient } = await import('@supabase/supabase-js')\n this._client = createClient(this._url, this._key)\n return this._client\n } catch {\n throw new Error(\n '[ui-feedback-plugin] @supabase/supabase-js is not installed. Run: npm install @supabase/supabase-js'\n )\n }\n }\n\n async addComment(comment: Omit<FeedbackComment, 'id'>): Promise<string> {\n const sb = await this._getClient()\n const { data, error } = await sb\n .from('ufp_comments')\n .insert(toCommentRow(comment))\n .select('id')\n .single()\n if (error) throw error\n return data.id as string\n }\n\n async getComments(pageUrl: string, projectKey: string): Promise<FeedbackComment[]> {\n const sb = await this._getClient()\n const { data, error } = await sb\n .from('ufp_comments')\n .select('*')\n .eq('page_url', pageUrl)\n .eq('project_key', projectKey)\n if (error) throw error\n const rows = (data ?? []) as Record<string, unknown>[]\n return rows.map(fromCommentRow).sort((a, b) => b.createdAt - a.createdAt)\n }\n\n async updateComment(id: string, fields: Partial<FeedbackComment>): Promise<void> {\n const sb = await this._getClient()\n // Map camelCase fields to snake_case before sending\n const mapped: Record<string, unknown> = {}\n if (fields.resolved !== undefined) mapped.resolved = fields.resolved\n if (fields.screenshotUrl !== undefined) mapped.screenshot_url = fields.screenshotUrl\n if (fields.text !== undefined) mapped.text = fields.text\n if (fields.annotation !== undefined) mapped.annotation = fields.annotation\n const { error } = await sb.from('ufp_comments').update(mapped).eq('id', id)\n if (error) throw error\n }\n\n async deleteComment(id: string): Promise<void> {\n const sb = await this._getClient()\n const { error } = await sb.from('ufp_comments').delete().eq('id', id)\n if (error) throw error\n }\n\n async addReply(reply: Omit<Reply, 'id'>): Promise<string> {\n const sb = await this._getClient()\n const { data, error } = await sb\n .from('ufp_replies')\n .insert(toReplyRow(reply))\n .select('id')\n .single()\n if (error) throw error\n return data.id as string\n }\n\n async getReplies(commentId: string): Promise<Reply[]> {\n const sb = await this._getClient()\n const { data, error } = await sb\n .from('ufp_replies')\n .select('*')\n .eq('comment_id', commentId)\n if (error) throw error\n const rows = (data ?? []) as Record<string, unknown>[]\n return rows.map(fromReplyRow).sort((a, b) => a.createdAt - b.createdAt)\n }\n\n subscribeToComments(\n pageUrl: string,\n projectKey: string,\n callback: (comments: FeedbackComment[]) => void\n ): () => void {\n let channel: SBClient | null = null\n let active = true\n\n const refetch = async () => {\n if (!active) return\n try {\n const comments = await this.getComments(pageUrl, projectKey)\n if (active) callback(comments)\n } catch (err) {\n console.error('[ui-feedback-plugin] Supabase fetch error:', err)\n }\n }\n\n // Initial fetch\n refetch()\n\n // Set up real-time after getting the client\n this._getClient().then((sb) => {\n if (!active) return\n channel = sb\n .channel('ufp-comments')\n .on('postgres_changes', { event: '*', schema: 'public', table: 'ufp_comments' }, () => {\n refetch()\n })\n .subscribe()\n }).catch(console.error)\n\n return () => {\n active = false\n if (channel) {\n this._getClient().then((sb) => sb.removeChannel(channel)).catch(() => {})\n }\n }\n }\n\n async uploadScreenshot(commentId: string, dataUrl: string): Promise<string> {\n const sb = await this._getClient()\n\n // Convert data URL to Blob\n const [header, base64] = dataUrl.split(',')\n const mime = header.match(/:(.*?);/)?.[1] ?? 'image/png'\n const binary = atob(base64)\n const bytes = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)\n const blob = new Blob([bytes], { type: mime })\n\n const path = `${commentId}.png`\n const { error } = await sb.storage\n .from('ufp-screenshots')\n .upload(path, blob, { contentType: 'image/png', upsert: true })\n\n if (error) throw error\n\n const { data } = sb.storage.from('ufp-screenshots').getPublicUrl(path)\n return data.publicUrl as string\n }\n}\n"],"names":["fromCommentRow","row","toCommentRow","comment","fromReplyRow","toReplyRow","reply","SupabaseAdapter","url","anonKey","__publicField","createClient","sb","data","error","pageUrl","projectKey","a","b","id","fields","mapped","commentId","callback","channel","active","refetch","comments","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