@mindbowser_inc/ui-feedback-plugin 0.3.1 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindbowser_inc/ui-feedback-plugin",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "A floating widget for collecting annotated UI feedback on web prototypes — Figma-style comments, screenshots, reply threads, Firebase/Supabase/AWS support",
5
5
  "main": "dist/ui-feedback-plugin.umd.js",
6
6
  "module": "dist/ui-feedback-plugin.es.js",
@@ -50,5 +50,17 @@
50
50
  "typescript": "^5.4.5",
51
51
  "vite": "^5.2.11",
52
52
  "vite-plugin-dts": "^3.9.1"
53
+ },
54
+ "peerDependencies": {
55
+ "@aws-sdk/client-s3": "^3.0.0",
56
+ "@aws-sdk/credential-provider-cognito-identity": "^3.0.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "@aws-sdk/client-s3": {
60
+ "optional": true
61
+ },
62
+ "@aws-sdk/credential-provider-cognito-identity": {
63
+ "optional": true
64
+ }
53
65
  }
54
66
  }
@@ -1,134 +0,0 @@
1
- var h = Object.defineProperty;
2
- var u = (c, t, e) => t in c ? h(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
- var l = (c, t, e) => u(c, typeof t != "symbol" ? t + "" : t, e);
4
- class g {
5
- constructor(t) {
6
- l(this, "cfg");
7
- l(this, "_s3", null);
8
- this.cfg = t;
9
- }
10
- async s3() {
11
- if (this._s3) return this._s3;
12
- const [{ S3Client: t }, { fromCognitoIdentityPool: e }] = await Promise.all([
13
- import("./index-B-1NC_TX.mjs").then((s) => s.j),
14
- import("./index-ClYqXfVs.mjs")
15
- ]);
16
- return this._s3 = new t({
17
- region: this.cfg.region,
18
- credentials: e({
19
- identityPoolId: this.cfg.identityPoolId,
20
- clientConfig: { region: this.cfg.region }
21
- })
22
- }), this._s3;
23
- }
24
- async pageHash(t) {
25
- const e = new TextEncoder().encode(t), s = await crypto.subtle.digest("SHA-256", e);
26
- return Array.from(new Uint8Array(s)).map((n) => n.toString(16).padStart(2, "0")).join("").slice(0, 16);
27
- }
28
- async put(t, e, s) {
29
- const { PutObjectCommand: n } = await import("./index-B-1NC_TX.mjs").then((i) => i.j);
30
- await (await this.s3()).send(new n({
31
- Bucket: this.cfg.bucket,
32
- Key: t,
33
- Body: e,
34
- ContentType: s
35
- }));
36
- }
37
- async getJson(t) {
38
- const { GetObjectCommand: e } = await import("./index-B-1NC_TX.mjs").then((i) => i.j), o = await (await (await this.s3()).send(new e({ Bucket: this.cfg.bucket, Key: t }))).Body.transformToString();
39
- return JSON.parse(o);
40
- }
41
- async listKeys(t) {
42
- const { ListObjectsV2Command: e } = await import("./index-B-1NC_TX.mjs").then((i) => i.j), s = await this.s3(), n = [];
43
- let o;
44
- do {
45
- const i = await s.send(new e({
46
- Bucket: this.cfg.bucket,
47
- Prefix: t,
48
- ContinuationToken: o
49
- }));
50
- for (const a of i.Contents ?? [])
51
- a.Key && n.push(a.Key);
52
- o = i.NextContinuationToken;
53
- } while (o);
54
- return n;
55
- }
56
- indexKey(t) {
57
- return `ufp/_index/${t}.json`;
58
- }
59
- async lookupComment(t) {
60
- const { p: e, h: s } = await this.getJson(this.indexKey(t));
61
- return { key: `ufp/${e}/${s}/comments/${t}.json` };
62
- }
63
- async addComment(t) {
64
- const e = await this.pageHash(t.pageUrl), s = crypto.randomUUID();
65
- return await Promise.all([
66
- this.put(
67
- `ufp/${t.projectKey}/${e}/comments/${s}.json`,
68
- JSON.stringify({ id: s, ...t }),
69
- "application/json"
70
- ),
71
- this.put(
72
- this.indexKey(s),
73
- JSON.stringify({ p: t.projectKey, h: e }),
74
- "application/json"
75
- )
76
- ]), s;
77
- }
78
- async getComments(t, e) {
79
- const s = await this.pageHash(t), n = await this.listKeys(`ufp/${e}/${s}/comments/`);
80
- return (await Promise.all(
81
- n.map(
82
- (i) => this.getJson(i).catch(() => null)
83
- )
84
- )).filter((i) => i !== null && !i.deleted).sort((i, a) => a.createdAt - i.createdAt);
85
- }
86
- async updateComment(t, e) {
87
- const { key: s } = await this.lookupComment(t), n = await this.getJson(s);
88
- await this.put(s, JSON.stringify({ ...n, ...e }), "application/json");
89
- }
90
- async deleteComment(t) {
91
- const { key: e } = await this.lookupComment(t), s = await this.getJson(e);
92
- await this.put(e, JSON.stringify({ ...s, deleted: !0 }), "application/json");
93
- }
94
- async addReply(t) {
95
- const e = crypto.randomUUID();
96
- return await this.put(
97
- `ufp/replies/${t.commentId}/${e}.json`,
98
- JSON.stringify({ id: e, ...t }),
99
- "application/json"
100
- ), e;
101
- }
102
- async getReplies(t) {
103
- const e = await this.listKeys(`ufp/replies/${t}/`);
104
- return (await Promise.all(
105
- e.map((n) => this.getJson(n).catch(() => null))
106
- )).filter((n) => n !== null).sort((n, o) => n.createdAt - o.createdAt);
107
- }
108
- subscribeToComments(t, e, s) {
109
- let n = !0;
110
- const o = this.cfg.pollInterval ?? 5e3, i = async () => {
111
- if (n) {
112
- try {
113
- const a = await this.getComments(t, e);
114
- n && s(a);
115
- } catch (a) {
116
- console.error("[ui-feedback-plugin] AWS poll error:", a);
117
- }
118
- n && setTimeout(i, o);
119
- }
120
- };
121
- return i(), () => {
122
- n = !1;
123
- };
124
- }
125
- async uploadScreenshot(t, e) {
126
- const { p: s, h: n } = await this.getJson(this.indexKey(t)), o = `ufp/${s}/${n}/screenshots/${t}.png`, i = e.split(",")[1], a = atob(i), p = new Uint8Array(a.length);
127
- for (let r = 0; r < a.length; r++) p[r] = a.charCodeAt(r);
128
- return await this.put(o, p, "image/png"), `https://${this.cfg.bucket}.s3.${this.cfg.region}.amazonaws.com/${o}`;
129
- }
130
- }
131
- export {
132
- g as AWSAdapter
133
- };
134
- //# sourceMappingURL=aws-CkWYvUhs.mjs.map