pleasenobugs 0.2.0 → 0.3.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 +108 -30
- package/dist/chunks/demo-CL3oK-zC.js +212 -0
- package/dist/chunks/index--SJW3aE-.js +2749 -0
- package/dist/client.js +139 -107
- package/dist/index.js +9 -10
- package/dist/pleasenobugs.iife.js +2 -2
- package/dist/types/client.d.ts +59 -1
- 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 +17 -12
- 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 +212 -526
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/readonly.d.ts +1 -1
- package/dist/types/readonly.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 +5 -4
- package/dist/types/ui/Compose.d.ts.map +1 -1
- 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 +50 -5
- 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,37 +1,37 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function O(t) {
|
|
2
|
+
return t.replace(/\s+/g, "").toUpperCase();
|
|
3
3
|
}
|
|
4
|
-
const
|
|
5
|
-
function
|
|
4
|
+
const D = 30 * 24 * 60 * 60 * 1e3, z = 5 * 60 * 1e3;
|
|
5
|
+
function A(t) {
|
|
6
6
|
return [
|
|
7
7
|
"PleaseNoBugs login",
|
|
8
|
-
`Project: ${
|
|
9
|
-
`Origin: ${
|
|
10
|
-
`Issued: ${new Date(
|
|
8
|
+
`Project: ${t.project}`,
|
|
9
|
+
`Origin: ${U(t.origin)}`,
|
|
10
|
+
`Issued: ${new Date(t.issued).toISOString()}`
|
|
11
11
|
].join(`
|
|
12
12
|
`);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function U(t) {
|
|
15
15
|
try {
|
|
16
|
-
return new URL(
|
|
16
|
+
return new URL(t).origin;
|
|
17
17
|
} catch {
|
|
18
|
-
return
|
|
18
|
+
return t;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return Number.isFinite(
|
|
21
|
+
function C(t, r = Date.now()) {
|
|
22
|
+
return Number.isFinite(t) && t <= r + z && r - t <= D;
|
|
23
23
|
}
|
|
24
|
-
function G(
|
|
25
|
-
return `Nimiq ${M(JSON.stringify(
|
|
24
|
+
function G(t) {
|
|
25
|
+
return `Nimiq ${M(JSON.stringify(t))}`;
|
|
26
26
|
}
|
|
27
|
-
function M(
|
|
28
|
-
const r = new TextEncoder().encode(
|
|
27
|
+
function M(t) {
|
|
28
|
+
const r = new TextEncoder().encode(t);
|
|
29
29
|
let o = "";
|
|
30
30
|
for (const i of r)
|
|
31
31
|
o += String.fromCharCode(i);
|
|
32
32
|
return btoa(o).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const R = [
|
|
35
35
|
// Dutch
|
|
36
36
|
"aan",
|
|
37
37
|
"als",
|
|
@@ -111,186 +111,218 @@ const x = [
|
|
|
111
111
|
// Every board is about an app
|
|
112
112
|
"app"
|
|
113
113
|
];
|
|
114
|
-
function B(
|
|
115
|
-
const r = /* @__PURE__ */ new Set([...
|
|
116
|
-
return function(
|
|
117
|
-
const
|
|
118
|
-
return
|
|
119
|
-
let
|
|
120
|
-
|
|
121
|
-
let
|
|
122
|
-
for (const
|
|
123
|
-
|
|
124
|
-
return { post:
|
|
125
|
-
}).filter((
|
|
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
126
|
};
|
|
127
127
|
}
|
|
128
|
-
function H(
|
|
129
|
-
const o = [...
|
|
128
|
+
function H(t, r) {
|
|
129
|
+
const o = [...t];
|
|
130
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
131
|
}
|
|
132
|
-
class
|
|
132
|
+
class T extends Error {
|
|
133
133
|
constructor(r, o) {
|
|
134
134
|
super(o ?? r), this.reason = r, this.name = "SignerError";
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
137
|
+
const x = 2e3;
|
|
138
|
+
function J() {
|
|
139
139
|
return typeof window < "u" && !!window.nimiq;
|
|
140
140
|
}
|
|
141
|
-
function F(
|
|
141
|
+
function F(t) {
|
|
142
142
|
return window.nimiq ? Promise.resolve(window.nimiq) : new Promise((r, o) => {
|
|
143
143
|
const i = Date.now(), n = setInterval(() => {
|
|
144
|
-
window.nimiq ? (clearInterval(n), r(window.nimiq)) : Date.now() - i >
|
|
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
145
|
}, 50);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function K(
|
|
148
|
+
function K(t = x) {
|
|
149
149
|
return async (r) => {
|
|
150
|
-
const o = await F(
|
|
151
|
-
if (!Array.isArray(i) || !i.length) throw new
|
|
150
|
+
const o = await F(t), i = await o.listAccounts();
|
|
151
|
+
if (!Array.isArray(i) || !i.length) throw new T("no_account");
|
|
152
152
|
const n = await o.sign(r);
|
|
153
153
|
if (!n || !("signature" in n))
|
|
154
|
-
throw new
|
|
154
|
+
throw new T("declined", n && "error" in n ? n.error.message : void 0);
|
|
155
155
|
return { address: i[0], publicKey: n.publicKey, signature: n.signature };
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
function Q(
|
|
159
|
-
const r =
|
|
160
|
-
let
|
|
161
|
-
function
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
return
|
|
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
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function I() {
|
|
167
167
|
try {
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
170
|
-
const
|
|
171
|
-
return
|
|
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
172
|
} catch {
|
|
173
173
|
return null;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function S(
|
|
177
|
-
|
|
176
|
+
function S(e) {
|
|
177
|
+
g = e;
|
|
178
178
|
try {
|
|
179
|
-
|
|
179
|
+
e ? w?.setItem(y, JSON.stringify(e)) : w?.removeItem(y);
|
|
180
180
|
} catch {
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
function q() {
|
|
184
|
-
const
|
|
185
|
-
return
|
|
184
|
+
const e = m();
|
|
185
|
+
return e || (g && !C(g.issued) && S(null), g);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
const
|
|
189
|
-
return
|
|
187
|
+
function E() {
|
|
188
|
+
const e = m();
|
|
189
|
+
return e ? Promise.resolve({ ok: !0, data: O(e.address) }) : n ? a || (a = (async () => {
|
|
190
190
|
try {
|
|
191
|
-
const
|
|
192
|
-
return S({ ...c, origin: i, issued:
|
|
193
|
-
} catch (
|
|
194
|
-
return
|
|
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
195
|
} finally {
|
|
196
|
-
|
|
196
|
+
a = null;
|
|
197
197
|
}
|
|
198
|
-
})(),
|
|
198
|
+
})(), a) : Promise.resolve({ ok: !1, status: 0, error: "no_signer" });
|
|
199
199
|
}
|
|
200
|
-
async function
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
c.body !== void 0 && (
|
|
204
|
-
let
|
|
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
205
|
try {
|
|
206
|
-
|
|
207
|
-
method:
|
|
208
|
-
headers:
|
|
206
|
+
p = await h(`${r}${s}`, {
|
|
207
|
+
method: e,
|
|
208
|
+
headers: L,
|
|
209
209
|
...c.body !== void 0 ? { body: JSON.stringify(c.body) } : {}
|
|
210
210
|
});
|
|
211
211
|
} catch {
|
|
212
212
|
return { ok: !1, status: 0, error: "network" };
|
|
213
213
|
}
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
return
|
|
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
217
|
}
|
|
218
|
-
const k = await
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
return { ok: !1, status:
|
|
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
222
|
};
|
|
223
|
-
if (c.auth === "none") return
|
|
223
|
+
if (c.auth === "none") return $(null);
|
|
224
224
|
let b = q();
|
|
225
225
|
if (!b && c.auth === "required") {
|
|
226
|
-
const v = await
|
|
226
|
+
const v = await E();
|
|
227
227
|
if (!v.ok) return v;
|
|
228
228
|
b = q();
|
|
229
229
|
}
|
|
230
|
-
const P = await
|
|
230
|
+
const P = await $(b);
|
|
231
231
|
if (P.ok || P.status !== 401 || !b) return P;
|
|
232
|
-
if (b.message !== void 0 ?
|
|
233
|
-
const
|
|
234
|
-
return
|
|
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
235
|
}
|
|
236
|
-
const
|
|
236
|
+
const d = (e = "") => `/v1/projects/${encodeURIComponent(o)}${e}`, f = (e) => d(`/posts/${encodeURIComponent(e)}`);
|
|
237
237
|
return {
|
|
238
238
|
/** The project this client talks to. */
|
|
239
239
|
project: o,
|
|
240
240
|
/** Whether the user can be signed in at all: a signer, or an app login. */
|
|
241
241
|
get canSign() {
|
|
242
|
-
return !!n ||
|
|
242
|
+
return !!n || m() !== null;
|
|
243
243
|
},
|
|
244
244
|
/** The signed-in address, if a proof is stored. */
|
|
245
245
|
address() {
|
|
246
|
-
const
|
|
247
|
-
return
|
|
246
|
+
const e = q();
|
|
247
|
+
return e ? O(e.address) : null;
|
|
248
248
|
},
|
|
249
|
-
signIn:
|
|
249
|
+
signIn: E,
|
|
250
250
|
/** Forget the stored proof. The next write asks the wallet again. */
|
|
251
251
|
signOut() {
|
|
252
252
|
S(null);
|
|
253
253
|
},
|
|
254
254
|
/** The whole board, plus `me` when signed in. Never prompts. */
|
|
255
|
-
board: () =>
|
|
256
|
-
me: () =>
|
|
257
|
-
answers: () =>
|
|
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
258
|
/**
|
|
259
259
|
* Write one. A review needs `rating` (1 to 5); a bug or an idea may carry
|
|
260
260
|
* `shot`, a screenshot as base64. It goes on the board for everyone only
|
|
261
261
|
* with `board: true`, which says the user agreed; without it only the
|
|
262
262
|
* project's owners see it.
|
|
263
263
|
*/
|
|
264
|
-
post: (
|
|
264
|
+
post: (e) => u("POST", d("/posts"), { body: e, auth: "required" }),
|
|
265
265
|
/** A post's screenshot: anybody's for one on the board, owners' for any. */
|
|
266
|
-
shot: (
|
|
266
|
+
shot: (e) => u("GET", `${f(e)}/shot`, { auth: "optional", blob: !0 }),
|
|
267
267
|
/**
|
|
268
268
|
* Where a screenshot on the board can be read without a proof, for an
|
|
269
269
|
* `<img>` to load by itself.
|
|
270
270
|
*/
|
|
271
|
-
shotUrl: (
|
|
272
|
-
vote: (
|
|
273
|
-
body: { up:
|
|
271
|
+
shotUrl: (e) => `${r}${f(e)}/shot`,
|
|
272
|
+
vote: (e, s) => u("POST", `${f(e)}/vote`, {
|
|
273
|
+
body: { up: s },
|
|
274
274
|
auth: "required"
|
|
275
275
|
}),
|
|
276
|
-
remove: (
|
|
277
|
-
setName: (
|
|
278
|
-
|
|
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" })
|
|
279
311
|
};
|
|
280
312
|
}
|
|
281
313
|
function W() {
|
|
282
314
|
try {
|
|
283
|
-
const
|
|
284
|
-
return
|
|
315
|
+
const t = globalThis.localStorage, r = "__pleasenobugs__";
|
|
316
|
+
return t.setItem(r, "1"), t.removeItem(r), t;
|
|
285
317
|
} catch {
|
|
286
318
|
return null;
|
|
287
319
|
}
|
|
288
320
|
}
|
|
289
321
|
export {
|
|
290
|
-
|
|
322
|
+
T as SignerError,
|
|
291
323
|
Q as createClient,
|
|
292
324
|
B as createMatcher,
|
|
293
|
-
|
|
325
|
+
J as insideNimiqPay,
|
|
294
326
|
K as nimiqPaySigner,
|
|
295
327
|
H as sortPosts
|
|
296
328
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
import { SignerError as
|
|
1
|
+
import { P as o, o as i } from "./chunks/index--SJW3aE-.js";
|
|
2
|
+
import { SignerError as a, createClient as s, createMatcher as n, insideNimiqPay as m, nimiqPaySigner as P, sortPosts as c } from "./client.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
i as readableOn,
|
|
4
|
+
o as PleaseNoBugsElement,
|
|
5
|
+
a as SignerError,
|
|
6
|
+
s as createClient,
|
|
7
|
+
n as createMatcher,
|
|
8
|
+
m as insideNimiqPay,
|
|
9
|
+
P as nimiqPaySigner,
|
|
10
|
+
i as open,
|
|
12
11
|
c as sortPosts
|
|
13
12
|
};
|