pleasenobugs 0.3.0 → 0.5.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 +85 -53
- package/dist/chunks/client-C6NaBcR4.js +363 -0
- package/dist/chunks/demo-pEOxDlaa.js +240 -0
- package/dist/chunks/index-DNGYeoDU.js +3179 -0
- package/dist/client.js +7 -326
- package/dist/index.js +6 -6
- package/dist/pleasenobugs.iife.js +2 -2
- package/dist/types/client.d.ts +13 -3
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/demo.d.ts +4 -2
- package/dist/types/demo.d.ts.map +1 -1
- package/dist/types/element.d.ts +12 -6
- package/dist/types/element.d.ts.map +1 -1
- package/dist/types/i18n.d.ts +41 -6
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/prefs.d.ts +10 -0
- package/dist/types/prefs.d.ts.map +1 -0
- package/dist/types/readonly.d.ts +3 -2
- 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 +7 -2
- package/dist/types/ui/App.d.ts.map +1 -1
- package/dist/types/ui/Compose.d.ts +7 -9
- 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/PostCard.d.ts +6 -3
- package/dist/types/ui/PostCard.d.ts.map +1 -1
- package/dist/types/ui/Settings.d.ts +38 -0
- package/dist/types/ui/Settings.d.ts.map +1 -0
- package/dist/types/ui/Sheets.d.ts +49 -7
- package/dist/types/ui/Sheets.d.ts.map +1 -1
- package/dist/types/ui/icons.d.ts +11 -0
- package/dist/types/ui/icons.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/demo-CL3oK-zC.js +0 -212
- package/dist/chunks/index--SJW3aE-.js +0 -2749
package/dist/client.js
CHANGED
|
@@ -1,328 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
return t.replace(/\s+/g, "").toUpperCase();
|
|
3
|
-
}
|
|
4
|
-
const D = 30 * 24 * 60 * 60 * 1e3, z = 5 * 60 * 1e3;
|
|
5
|
-
function A(t) {
|
|
6
|
-
return [
|
|
7
|
-
"PleaseNoBugs login",
|
|
8
|
-
`Project: ${t.project}`,
|
|
9
|
-
`Origin: ${U(t.origin)}`,
|
|
10
|
-
`Issued: ${new Date(t.issued).toISOString()}`
|
|
11
|
-
].join(`
|
|
12
|
-
`);
|
|
13
|
-
}
|
|
14
|
-
function U(t) {
|
|
15
|
-
try {
|
|
16
|
-
return new URL(t).origin;
|
|
17
|
-
} catch {
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function C(t, r = Date.now()) {
|
|
22
|
-
return Number.isFinite(t) && t <= r + z && r - t <= D;
|
|
23
|
-
}
|
|
24
|
-
function G(t) {
|
|
25
|
-
return `Nimiq ${M(JSON.stringify(t))}`;
|
|
26
|
-
}
|
|
27
|
-
function M(t) {
|
|
28
|
-
const r = new TextEncoder().encode(t);
|
|
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 R = [
|
|
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(t = []) {
|
|
115
|
-
const r = /* @__PURE__ */ new Set([...R, ...[...t].map((n) => n.toLowerCase())]), o = /* @__PURE__ */ new WeakMap(), i = (n) => new Set(n.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter((h) => h.length >= 4 && !r.has(h)));
|
|
116
|
-
return function(h, w, y = 3) {
|
|
117
|
-
const g = i(w);
|
|
118
|
-
return g.size < 2 ? [] : h.map((a) => {
|
|
119
|
-
let l = o.get(a);
|
|
120
|
-
l || (l = i(a.text), o.set(a, l));
|
|
121
|
-
let m = 0;
|
|
122
|
-
for (const I of g)
|
|
123
|
-
l.has(I) && m++;
|
|
124
|
-
return { post: a, shared: m };
|
|
125
|
-
}).filter((a) => a.shared >= 2).sort((a, l) => l.shared - a.shared || l.post.votes - a.post.votes).slice(0, y).map((a) => a.post);
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function H(t, r) {
|
|
129
|
-
const o = [...t];
|
|
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 T extends Error {
|
|
133
|
-
constructor(r, o) {
|
|
134
|
-
super(o ?? r), this.reason = r, this.name = "SignerError";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const x = 2e3;
|
|
138
|
-
function J() {
|
|
139
|
-
return typeof window < "u" && !!window.nimiq;
|
|
140
|
-
}
|
|
141
|
-
function F(t) {
|
|
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 > t && (clearInterval(n), o(new T("no_wallet", "Not running inside Nimiq Pay")));
|
|
145
|
-
}, 50);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function K(t = x) {
|
|
149
|
-
return async (r) => {
|
|
150
|
-
const o = await F(t), i = await o.listAccounts();
|
|
151
|
-
if (!Array.isArray(i) || !i.length) throw new T("no_account");
|
|
152
|
-
const n = await o.sign(r);
|
|
153
|
-
if (!n || !("signature" in n))
|
|
154
|
-
throw new T("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(t) {
|
|
159
|
-
const r = t.server.replace(/\/+$/, ""), o = t.project, i = U(t.origin ?? (typeof location < "u" ? location.origin : "")), n = t.signer === null ? void 0 : t.signer ?? (J() ? K() : void 0), h = t.fetch ?? globalThis.fetch.bind(globalThis), w = t.storage === void 0 ? W() : t.storage, y = `pleasenobugs.proof.${o}.${i}`;
|
|
160
|
-
let g = I(), a = null, l = !1;
|
|
161
|
-
function m() {
|
|
162
|
-
if (l || !t.appLogin) return null;
|
|
163
|
-
const e = typeof t.appLogin == "function" ? t.appLogin() : t.appLogin;
|
|
164
|
-
return e ? { ...e, origin: i, issued: 0 } : null;
|
|
165
|
-
}
|
|
166
|
-
function I() {
|
|
167
|
-
try {
|
|
168
|
-
const e = w?.getItem(y);
|
|
169
|
-
if (!e) return null;
|
|
170
|
-
const s = JSON.parse(e);
|
|
171
|
-
return C(s.issued) ? s : null;
|
|
172
|
-
} catch {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function S(e) {
|
|
177
|
-
g = e;
|
|
178
|
-
try {
|
|
179
|
-
e ? w?.setItem(y, JSON.stringify(e)) : w?.removeItem(y);
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function q() {
|
|
184
|
-
const e = m();
|
|
185
|
-
return e || (g && !C(g.issued) && S(null), g);
|
|
186
|
-
}
|
|
187
|
-
function E() {
|
|
188
|
-
const e = m();
|
|
189
|
-
return e ? Promise.resolve({ ok: !0, data: O(e.address) }) : n ? a || (a = (async () => {
|
|
190
|
-
try {
|
|
191
|
-
const s = Date.now(), c = await n(A({ project: o, origin: i, issued: s }));
|
|
192
|
-
return S({ ...c, origin: i, issued: s }), { ok: !0, data: O(c.address) };
|
|
193
|
-
} catch (s) {
|
|
194
|
-
return s instanceof T && s.reason === "no_wallet" ? { ok: !1, status: 0, error: "no_signer" } : { ok: !1, status: 0, error: "declined" };
|
|
195
|
-
} finally {
|
|
196
|
-
a = null;
|
|
197
|
-
}
|
|
198
|
-
})(), a) : Promise.resolve({ ok: !1, status: 0, error: "no_signer" });
|
|
199
|
-
}
|
|
200
|
-
async function u(e, s, c) {
|
|
201
|
-
const $ = async (v) => {
|
|
202
|
-
const L = {};
|
|
203
|
-
c.body !== void 0 && (L["content-type"] = "application/json"), v && (L.authorization = G(v));
|
|
204
|
-
let p;
|
|
205
|
-
try {
|
|
206
|
-
p = await h(`${r}${s}`, {
|
|
207
|
-
method: e,
|
|
208
|
-
headers: L,
|
|
209
|
-
...c.body !== void 0 ? { body: JSON.stringify(c.body) } : {}
|
|
210
|
-
});
|
|
211
|
-
} catch {
|
|
212
|
-
return { ok: !1, status: 0, error: "network" };
|
|
213
|
-
}
|
|
214
|
-
if (p.ok && c.blob) {
|
|
215
|
-
const _ = await p.blob().catch(() => null);
|
|
216
|
-
return _ ? { ok: !0, data: _ } : { ok: !1, status: 0, error: "network" };
|
|
217
|
-
}
|
|
218
|
-
const k = await p.json().catch(() => null);
|
|
219
|
-
if (p.ok) return { ok: !0, data: k };
|
|
220
|
-
const j = k && typeof k.error == "string" ? k.error : "internal";
|
|
221
|
-
return { ok: !1, status: p.status, error: j, body: k };
|
|
222
|
-
};
|
|
223
|
-
if (c.auth === "none") return $(null);
|
|
224
|
-
let b = q();
|
|
225
|
-
if (!b && c.auth === "required") {
|
|
226
|
-
const v = await E();
|
|
227
|
-
if (!v.ok) return v;
|
|
228
|
-
b = q();
|
|
229
|
-
}
|
|
230
|
-
const P = await $(b);
|
|
231
|
-
if (P.ok || P.status !== 401 || !b) return P;
|
|
232
|
-
if (b.message !== void 0 ? l = !0 : S(null), c.auth === "optional") return $(null);
|
|
233
|
-
const N = await E();
|
|
234
|
-
return N.ok ? $(q()) : N;
|
|
235
|
-
}
|
|
236
|
-
const d = (e = "") => `/v1/projects/${encodeURIComponent(o)}${e}`, f = (e) => d(`/posts/${encodeURIComponent(e)}`);
|
|
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 || m() !== null;
|
|
243
|
-
},
|
|
244
|
-
/** The signed-in address, if a proof is stored. */
|
|
245
|
-
address() {
|
|
246
|
-
const e = q();
|
|
247
|
-
return e ? O(e.address) : null;
|
|
248
|
-
},
|
|
249
|
-
signIn: E,
|
|
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: () => u("GET", d("/posts"), { auth: "optional" }),
|
|
256
|
-
me: () => u("GET", d("/me"), { auth: "required" }),
|
|
257
|
-
answers: () => u("GET", d("/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: (e) => u("POST", d("/posts"), { body: e, auth: "required" }),
|
|
265
|
-
/** A post's screenshot: anybody's for one on the board, owners' for any. */
|
|
266
|
-
shot: (e) => u("GET", `${f(e)}/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: (e) => `${r}${f(e)}/shot`,
|
|
272
|
-
vote: (e, s) => u("POST", `${f(e)}/vote`, {
|
|
273
|
-
body: { up: s },
|
|
274
|
-
auth: "required"
|
|
275
|
-
}),
|
|
276
|
-
remove: (e) => u("DELETE", f(e), { auth: "required" }),
|
|
277
|
-
setName: (e) => u("PUT", d("/me"), { body: { name: e }, auth: "required" }),
|
|
278
|
-
/**
|
|
279
|
-
* An owner answering a post. `fix` says where the fix is, on a bug or an
|
|
280
|
-
* idea set to done: `{ version?, link? }`, the link on github.com or
|
|
281
|
-
* gitlab.com. Moving a post away from done takes its fix away by itself.
|
|
282
|
-
*/
|
|
283
|
-
manage: (e, s) => u("POST", `${f(e)}/manage`, { body: s, auth: "required" }),
|
|
284
|
-
/**
|
|
285
|
-
* Write under a post: an owner for the app, whenever they like; its
|
|
286
|
-
* author only right after the app, on a bug or an idea that is not done
|
|
287
|
-
* (`not_your_turn`, `closed` otherwise). `message.id` is yours to mint.
|
|
288
|
-
*/
|
|
289
|
-
say: (e, s) => u("POST", `${f(e)}/messages`, { body: s, auth: "required" }),
|
|
290
|
-
/**
|
|
291
|
-
* Change your own last message before anybody answered it (`text`), or,
|
|
292
|
-
* as an owner, take an author's message off the board or put it back
|
|
293
|
-
* (`hidden`).
|
|
294
|
-
*/
|
|
295
|
-
editMessage: (e, s, c) => u("PATCH", `${f(e)}/messages/${encodeURIComponent(s)}`, {
|
|
296
|
-
body: c,
|
|
297
|
-
auth: "required"
|
|
298
|
-
}),
|
|
299
|
-
/** Take your own last message back, before anybody answered it. */
|
|
300
|
-
unsay: (e, s) => u("DELETE", `${f(e)}/messages/${encodeURIComponent(s)}`, { auth: "required" }),
|
|
301
|
-
/** What changed in the app, newest first. Anybody's to read; never prompts. */
|
|
302
|
-
updates: () => u("GET", d("/updates"), { auth: "optional" }),
|
|
303
|
-
/**
|
|
304
|
-
* An owner writing one. `link` is a page on github.com or gitlab.com;
|
|
305
|
-
* `posts` are the bugs and ideas it fixed, which go to done with its
|
|
306
|
-
* version and link.
|
|
307
|
-
*/
|
|
308
|
-
postUpdate: (e) => u("POST", d("/updates"), { body: e, auth: "required" }),
|
|
309
|
-
/** An owner taking one off the page. The posts it fixed stay done. */
|
|
310
|
-
removeUpdate: (e) => u("DELETE", d(`/updates/${encodeURIComponent(e)}`), { auth: "required" })
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
function W() {
|
|
314
|
-
try {
|
|
315
|
-
const t = globalThis.localStorage, r = "__pleasenobugs__";
|
|
316
|
-
return t.setItem(r, "1"), t.removeItem(r), t;
|
|
317
|
-
} catch {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
1
|
+
import { S as s, a as e, c as i, i as t, n, s as o } from "./chunks/client-C6NaBcR4.js";
|
|
321
2
|
export {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
3
|
+
s as SignerError,
|
|
4
|
+
e as createClient,
|
|
5
|
+
i as createMatcher,
|
|
6
|
+
t as insideNimiqPay,
|
|
7
|
+
n as nimiqPaySigner,
|
|
8
|
+
o as sortPosts
|
|
328
9
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
import {
|
|
1
|
+
import { P as s, o as r } from "./chunks/index-DNGYeoDU.js";
|
|
2
|
+
import { S as o, a as t, c as n, i as m, n as P, s as c } from "./chunks/client-C6NaBcR4.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
s as PleaseNoBugsElement,
|
|
5
|
+
o as SignerError,
|
|
6
|
+
t as createClient,
|
|
7
7
|
n as createMatcher,
|
|
8
8
|
m as insideNimiqPay,
|
|
9
9
|
P as nimiqPaySigner,
|
|
10
|
-
|
|
10
|
+
r as open,
|
|
11
11
|
c as sortPosts
|
|
12
12
|
};
|