pleasenobugs 0.2.0 → 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/README.md +137 -38
- package/dist/chunks/client-CkFi6gmV.js +358 -0
- package/dist/chunks/demo-DLTn5oUs.js +232 -0
- package/dist/chunks/index-B1dIQO6N.js +2795 -0
- package/dist/client.js +7 -294
- package/dist/index.js +9 -10
- package/dist/pleasenobugs.iife.js +2 -2
- package/dist/types/client.d.ts +72 -4
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/demo.d.ts +39 -3
- package/dist/types/demo.d.ts.map +1 -1
- package/dist/types/element.d.ts +19 -13
- package/dist/types/element.d.ts.map +1 -1
- package/dist/types/filter.d.ts +66 -0
- package/dist/types/filter.d.ts.map +1 -0
- package/dist/types/i18n.d.ts +222 -531
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/readonly.d.ts +4 -3
- package/dist/types/readonly.d.ts.map +1 -1
- package/dist/types/signer.d.ts +7 -0
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/ui/App.d.ts +4 -3
- package/dist/types/ui/App.d.ts.map +1 -1
- package/dist/types/ui/Compose.d.ts +12 -7
- package/dist/types/ui/Compose.d.ts.map +1 -1
- package/dist/types/ui/Face.d.ts +17 -0
- package/dist/types/ui/Face.d.ts.map +1 -0
- package/dist/types/ui/Manage.d.ts +60 -0
- package/dist/types/ui/Manage.d.ts.map +1 -0
- package/dist/types/ui/PostCard.d.ts +53 -6
- package/dist/types/ui/PostCard.d.ts.map +1 -1
- package/dist/types/ui/Sheets.d.ts +32 -28
- package/dist/types/ui/Sheets.d.ts.map +1 -1
- package/dist/types/ui/Talk.d.ts +57 -0
- package/dist/types/ui/Talk.d.ts.map +1 -0
- package/dist/types/ui/Updates.d.ts +37 -0
- package/dist/types/ui/Updates.d.ts.map +1 -0
- package/dist/types/ui/icons.d.ts +16 -0
- package/dist/types/ui/icons.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/demo-nnvUgJyJ.js +0 -107
- package/dist/chunks/index-13DToKWI.js +0 -1751
package/dist/client.js
CHANGED
|
@@ -1,296 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
return e.replace(/\s+/g, "").toUpperCase();
|
|
3
|
-
}
|
|
4
|
-
const U = 30 * 24 * 60 * 60 * 1e3, A = 5 * 60 * 1e3;
|
|
5
|
-
function D(e) {
|
|
6
|
-
return [
|
|
7
|
-
"PleaseNoBugs login",
|
|
8
|
-
`Project: ${e.project}`,
|
|
9
|
-
`Origin: ${C(e.origin)}`,
|
|
10
|
-
`Issued: ${new Date(e.issued).toISOString()}`
|
|
11
|
-
].join(`
|
|
12
|
-
`);
|
|
13
|
-
}
|
|
14
|
-
function C(e) {
|
|
15
|
-
try {
|
|
16
|
-
return new URL(e).origin;
|
|
17
|
-
} catch {
|
|
18
|
-
return e;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function j(e, r = Date.now()) {
|
|
22
|
-
return Number.isFinite(e) && e <= r + A && r - e <= U;
|
|
23
|
-
}
|
|
24
|
-
function G(e) {
|
|
25
|
-
return `Nimiq ${M(JSON.stringify(e))}`;
|
|
26
|
-
}
|
|
27
|
-
function M(e) {
|
|
28
|
-
const r = new TextEncoder().encode(e);
|
|
29
|
-
let o = "";
|
|
30
|
-
for (const i of r)
|
|
31
|
-
o += String.fromCharCode(i);
|
|
32
|
-
return btoa(o).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
33
|
-
}
|
|
34
|
-
const x = [
|
|
35
|
-
// Dutch
|
|
36
|
-
"aan",
|
|
37
|
-
"als",
|
|
38
|
-
"bij",
|
|
39
|
-
"dan",
|
|
40
|
-
"dat",
|
|
41
|
-
"deze",
|
|
42
|
-
"die",
|
|
43
|
-
"dit",
|
|
44
|
-
"een",
|
|
45
|
-
"heb",
|
|
46
|
-
"het",
|
|
47
|
-
"ik",
|
|
48
|
-
"is",
|
|
49
|
-
"kan",
|
|
50
|
-
"kun",
|
|
51
|
-
"maar",
|
|
52
|
-
"met",
|
|
53
|
-
"mijn",
|
|
54
|
-
"niet",
|
|
55
|
-
"ook",
|
|
56
|
-
"van",
|
|
57
|
-
"voor",
|
|
58
|
-
"wil",
|
|
59
|
-
"word",
|
|
60
|
-
"wordt",
|
|
61
|
-
"zijn",
|
|
62
|
-
"zou",
|
|
63
|
-
"graag",
|
|
64
|
-
"meer",
|
|
65
|
-
"moet",
|
|
66
|
-
// English
|
|
67
|
-
"and",
|
|
68
|
-
"are",
|
|
69
|
-
"but",
|
|
70
|
-
"can",
|
|
71
|
-
"for",
|
|
72
|
-
"have",
|
|
73
|
-
"more",
|
|
74
|
-
"not",
|
|
75
|
-
"should",
|
|
76
|
-
"that",
|
|
77
|
-
"the",
|
|
78
|
-
"this",
|
|
79
|
-
"want",
|
|
80
|
-
"when",
|
|
81
|
-
"with",
|
|
82
|
-
"would",
|
|
83
|
-
"you",
|
|
84
|
-
"your",
|
|
85
|
-
// German
|
|
86
|
-
"aber",
|
|
87
|
-
"auch",
|
|
88
|
-
"bitte",
|
|
89
|
-
"dass",
|
|
90
|
-
"denn",
|
|
91
|
-
"ein",
|
|
92
|
-
"eine",
|
|
93
|
-
"einen",
|
|
94
|
-
"gerne",
|
|
95
|
-
"ich",
|
|
96
|
-
"ist",
|
|
97
|
-
"kann",
|
|
98
|
-
"mehr",
|
|
99
|
-
"mein",
|
|
100
|
-
"meine",
|
|
101
|
-
"nicht",
|
|
102
|
-
"oder",
|
|
103
|
-
"sein",
|
|
104
|
-
"sollte",
|
|
105
|
-
"und",
|
|
106
|
-
"wenn",
|
|
107
|
-
"werden",
|
|
108
|
-
"wird",
|
|
109
|
-
"wollen",
|
|
110
|
-
"möchte",
|
|
111
|
-
// Every board is about an app
|
|
112
|
-
"app"
|
|
113
|
-
];
|
|
114
|
-
function B(e = []) {
|
|
115
|
-
const r = /* @__PURE__ */ new Set([...x, ...[...e].map((n) => n.toLowerCase())]), o = /* @__PURE__ */ new WeakMap(), i = (n) => new Set(n.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter((f) => f.length >= 4 && !r.has(f)));
|
|
116
|
-
return function(f, m, p = 3) {
|
|
117
|
-
const d = i(m);
|
|
118
|
-
return d.size < 2 ? [] : f.map((s) => {
|
|
119
|
-
let u = o.get(s);
|
|
120
|
-
u || (u = i(s.text), o.set(s, u));
|
|
121
|
-
let g = 0;
|
|
122
|
-
for (const T of d)
|
|
123
|
-
u.has(T) && g++;
|
|
124
|
-
return { post: s, shared: g };
|
|
125
|
-
}).filter((s) => s.shared >= 2).sort((s, u) => u.shared - s.shared || u.post.votes - s.post.votes).slice(0, p).map((s) => s.post);
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function H(e, r) {
|
|
129
|
-
const o = [...e];
|
|
130
|
-
return r === "new" ? o.sort((i, n) => n.at - i.at) : o.sort((i, n) => n.votes - i.votes || n.at - i.at);
|
|
131
|
-
}
|
|
132
|
-
class $ extends Error {
|
|
133
|
-
constructor(r, o) {
|
|
134
|
-
super(o ?? r), this.reason = r, this.name = "SignerError";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const J = 2e3;
|
|
138
|
-
function R() {
|
|
139
|
-
return typeof window < "u" && !!window.nimiq;
|
|
140
|
-
}
|
|
141
|
-
function F(e) {
|
|
142
|
-
return window.nimiq ? Promise.resolve(window.nimiq) : new Promise((r, o) => {
|
|
143
|
-
const i = Date.now(), n = setInterval(() => {
|
|
144
|
-
window.nimiq ? (clearInterval(n), r(window.nimiq)) : Date.now() - i > e && (clearInterval(n), o(new $("no_wallet", "Not running inside Nimiq Pay")));
|
|
145
|
-
}, 50);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function K(e = J) {
|
|
149
|
-
return async (r) => {
|
|
150
|
-
const o = await F(e), i = await o.listAccounts();
|
|
151
|
-
if (!Array.isArray(i) || !i.length) throw new $("no_account");
|
|
152
|
-
const n = await o.sign(r);
|
|
153
|
-
if (!n || !("signature" in n))
|
|
154
|
-
throw new $("declined", n && "error" in n ? n.error.message : void 0);
|
|
155
|
-
return { address: i[0], publicKey: n.publicKey, signature: n.signature };
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function Q(e) {
|
|
159
|
-
const r = e.server.replace(/\/+$/, ""), o = e.project, i = C(e.origin ?? (typeof location < "u" ? location.origin : "")), n = e.signer === null ? void 0 : e.signer ?? (R() ? K() : void 0), f = e.fetch ?? globalThis.fetch.bind(globalThis), m = e.storage === void 0 ? W() : e.storage, p = `pleasenobugs.proof.${o}.${i}`;
|
|
160
|
-
let d = T(), s = null, u = !1;
|
|
161
|
-
function g() {
|
|
162
|
-
if (u || !e.appLogin) return null;
|
|
163
|
-
const t = typeof e.appLogin == "function" ? e.appLogin() : e.appLogin;
|
|
164
|
-
return t ? { ...t, origin: i, issued: 0 } : null;
|
|
165
|
-
}
|
|
166
|
-
function T() {
|
|
167
|
-
try {
|
|
168
|
-
const t = m?.getItem(p);
|
|
169
|
-
if (!t) return null;
|
|
170
|
-
const a = JSON.parse(t);
|
|
171
|
-
return j(a.issued) ? a : null;
|
|
172
|
-
} catch {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function S(t) {
|
|
177
|
-
d = t;
|
|
178
|
-
try {
|
|
179
|
-
t ? m?.setItem(p, JSON.stringify(t)) : m?.removeItem(p);
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function q() {
|
|
184
|
-
const t = g();
|
|
185
|
-
return t || (d && !j(d.issued) && S(null), d);
|
|
186
|
-
}
|
|
187
|
-
function N() {
|
|
188
|
-
const t = g();
|
|
189
|
-
return t ? Promise.resolve({ ok: !0, data: L(t.address) }) : n ? s || (s = (async () => {
|
|
190
|
-
try {
|
|
191
|
-
const a = Date.now(), c = await n(D({ project: o, origin: i, issued: a }));
|
|
192
|
-
return S({ ...c, origin: i, issued: a }), { ok: !0, data: L(c.address) };
|
|
193
|
-
} catch (a) {
|
|
194
|
-
return a instanceof $ && a.reason === "no_wallet" ? { ok: !1, status: 0, error: "no_signer" } : { ok: !1, status: 0, error: "declined" };
|
|
195
|
-
} finally {
|
|
196
|
-
s = null;
|
|
197
|
-
}
|
|
198
|
-
})(), s) : Promise.resolve({ ok: !1, status: 0, error: "no_signer" });
|
|
199
|
-
}
|
|
200
|
-
async function l(t, a, c) {
|
|
201
|
-
const I = async (v) => {
|
|
202
|
-
const _ = {};
|
|
203
|
-
c.body !== void 0 && (_["content-type"] = "application/json"), v && (_.authorization = G(v));
|
|
204
|
-
let w;
|
|
205
|
-
try {
|
|
206
|
-
w = await f(`${r}${a}`, {
|
|
207
|
-
method: t,
|
|
208
|
-
headers: _,
|
|
209
|
-
...c.body !== void 0 ? { body: JSON.stringify(c.body) } : {}
|
|
210
|
-
});
|
|
211
|
-
} catch {
|
|
212
|
-
return { ok: !1, status: 0, error: "network" };
|
|
213
|
-
}
|
|
214
|
-
if (w.ok && c.blob) {
|
|
215
|
-
const E = await w.blob().catch(() => null);
|
|
216
|
-
return E ? { ok: !0, data: E } : { ok: !1, status: 0, error: "network" };
|
|
217
|
-
}
|
|
218
|
-
const k = await w.json().catch(() => null);
|
|
219
|
-
if (w.ok) return { ok: !0, data: k };
|
|
220
|
-
const z = k && typeof k.error == "string" ? k.error : "internal";
|
|
221
|
-
return { ok: !1, status: w.status, error: z, body: k };
|
|
222
|
-
};
|
|
223
|
-
if (c.auth === "none") return I(null);
|
|
224
|
-
let b = q();
|
|
225
|
-
if (!b && c.auth === "required") {
|
|
226
|
-
const v = await N();
|
|
227
|
-
if (!v.ok) return v;
|
|
228
|
-
b = q();
|
|
229
|
-
}
|
|
230
|
-
const P = await I(b);
|
|
231
|
-
if (P.ok || P.status !== 401 || !b) return P;
|
|
232
|
-
if (b.message !== void 0 ? u = !0 : S(null), c.auth === "optional") return I(null);
|
|
233
|
-
const O = await N();
|
|
234
|
-
return O.ok ? I(q()) : O;
|
|
235
|
-
}
|
|
236
|
-
const h = (t = "") => `/v1/projects/${encodeURIComponent(o)}${t}`, y = (t) => h(`/posts/${encodeURIComponent(t)}`);
|
|
237
|
-
return {
|
|
238
|
-
/** The project this client talks to. */
|
|
239
|
-
project: o,
|
|
240
|
-
/** Whether the user can be signed in at all: a signer, or an app login. */
|
|
241
|
-
get canSign() {
|
|
242
|
-
return !!n || g() !== null;
|
|
243
|
-
},
|
|
244
|
-
/** The signed-in address, if a proof is stored. */
|
|
245
|
-
address() {
|
|
246
|
-
const t = q();
|
|
247
|
-
return t ? L(t.address) : null;
|
|
248
|
-
},
|
|
249
|
-
signIn: N,
|
|
250
|
-
/** Forget the stored proof. The next write asks the wallet again. */
|
|
251
|
-
signOut() {
|
|
252
|
-
S(null);
|
|
253
|
-
},
|
|
254
|
-
/** The whole board, plus `me` when signed in. Never prompts. */
|
|
255
|
-
board: () => l("GET", h("/posts"), { auth: "optional" }),
|
|
256
|
-
me: () => l("GET", h("/me"), { auth: "required" }),
|
|
257
|
-
answers: () => l("GET", h("/answers"), { auth: "required" }),
|
|
258
|
-
/**
|
|
259
|
-
* Write one. A review needs `rating` (1 to 5); a bug or an idea may carry
|
|
260
|
-
* `shot`, a screenshot as base64. It goes on the board for everyone only
|
|
261
|
-
* with `board: true`, which says the user agreed; without it only the
|
|
262
|
-
* project's owners see it.
|
|
263
|
-
*/
|
|
264
|
-
post: (t) => l("POST", h("/posts"), { body: t, auth: "required" }),
|
|
265
|
-
/** A post's screenshot: anybody's for one on the board, owners' for any. */
|
|
266
|
-
shot: (t) => l("GET", `${y(t)}/shot`, { auth: "optional", blob: !0 }),
|
|
267
|
-
/**
|
|
268
|
-
* Where a screenshot on the board can be read without a proof, for an
|
|
269
|
-
* `<img>` to load by itself.
|
|
270
|
-
*/
|
|
271
|
-
shotUrl: (t) => `${r}${y(t)}/shot`,
|
|
272
|
-
vote: (t, a) => l("POST", `${y(t)}/vote`, {
|
|
273
|
-
body: { up: a },
|
|
274
|
-
auth: "required"
|
|
275
|
-
}),
|
|
276
|
-
remove: (t) => l("DELETE", y(t), { auth: "required" }),
|
|
277
|
-
setName: (t) => l("PUT", h("/me"), { body: { name: t }, auth: "required" }),
|
|
278
|
-
manage: (t, a) => l("POST", `${y(t)}/manage`, { body: a, auth: "required" })
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
function W() {
|
|
282
|
-
try {
|
|
283
|
-
const e = globalThis.localStorage, r = "__pleasenobugs__";
|
|
284
|
-
return e.setItem(r, "1"), e.removeItem(r), e;
|
|
285
|
-
} catch {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
1
|
+
import { S as s, a as e, c as i, i as t, n, s as o } from "./chunks/client-CkFi6gmV.js";
|
|
289
2
|
export {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
3
|
+
s as SignerError,
|
|
4
|
+
e as createClient,
|
|
5
|
+
i as createMatcher,
|
|
6
|
+
t as insideNimiqPay,
|
|
7
|
+
n as nimiqPaySigner,
|
|
8
|
+
o as sortPosts
|
|
296
9
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
import {
|
|
1
|
+
import { P as s, o as r } from "./chunks/index-B1dIQO6N.js";
|
|
2
|
+
import { S as o, a as t, c as n, i as m, n as P, s as c } from "./chunks/client-CkFi6gmV.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
i as readableOn,
|
|
4
|
+
s as PleaseNoBugsElement,
|
|
5
|
+
o as SignerError,
|
|
6
|
+
t as createClient,
|
|
7
|
+
n as createMatcher,
|
|
8
|
+
m as insideNimiqPay,
|
|
9
|
+
P as nimiqPaySigner,
|
|
10
|
+
r as open,
|
|
12
11
|
c as sortPosts
|
|
13
12
|
};
|