pleasenobugs 0.1.1 → 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 +156 -20
- package/dist/chunks/demo-CL3oK-zC.js +212 -0
- package/dist/chunks/index--SJW3aE-.js +2749 -0
- package/dist/client.js +165 -116
- package/dist/index.js +10 -1151
- package/dist/pleasenobugs.iife.js +2 -2
- package/dist/types/client.d.ts +81 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/demo.d.ts +53 -0
- package/dist/types/demo.d.ts.map +1 -0
- package/dist/types/element.d.ts +43 -10
- 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 -321
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +13 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/readonly.d.ts +17 -0
- package/dist/types/readonly.d.ts.map +1 -0
- package/dist/types/ui/App.d.ts +27 -2
- package/dist/types/ui/App.d.ts.map +1 -1
- package/dist/types/ui/Choose.d.ts +37 -0
- package/dist/types/ui/Choose.d.ts.map +1 -0
- package/dist/types/ui/Compose.d.ts +46 -18
- 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 +79 -9
- package/dist/types/ui/PostCard.d.ts.map +1 -1
- package/dist/types/ui/Sheets.d.ts +41 -16
- 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 +29 -2
- package/dist/types/ui/icons.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,8 +16,15 @@ wallet by itself; everywhere else it reads, and your app can hand it a signer.
|
|
|
16
16
|
| `mode` | What it does |
|
|
17
17
|
|---|---|
|
|
18
18
|
| `inline` (default) | Fills the element. Give it a height, or it grows with its posts. |
|
|
19
|
-
| `floating` | A
|
|
20
|
-
| `overlay` |
|
|
19
|
+
| `floating` | A round button in the corner. A tap grows it into the panel; closing shrinks it back into the button. Without the motion when the phone asks for less. |
|
|
20
|
+
| `overlay` | Over the page, right now. |
|
|
21
|
+
|
|
22
|
+
Each opens on the tiles (bug, idea, review), with the board one tap under
|
|
23
|
+
them. `start="board"` opens on the board instead.
|
|
24
|
+
|
|
25
|
+
`floating` and `overlay` cover the whole screen on a phone. From 640 pixels
|
|
26
|
+
wide they are a panel in the bottom-right corner instead, 375 wide and up to
|
|
27
|
+
640 tall, over a dimmed page; a click beside it or Escape closes it.
|
|
21
28
|
|
|
22
29
|
From a button of your own:
|
|
23
30
|
|
|
@@ -32,11 +39,17 @@ menuItem.onclick = () => open({ project: 'YOUR_PROJECT_ID', server: 'https://YOU
|
|
|
32
39
|
|---|---|
|
|
33
40
|
| `project`, `server` | Required. |
|
|
34
41
|
| `mode` | `inline`, `floating` or `overlay`. |
|
|
35
|
-
| `
|
|
36
|
-
| `theme` | `
|
|
37
|
-
| `
|
|
42
|
+
| `start` | `tiles` (default) or `board`: what opens first. A `readonly` board is always the board. |
|
|
43
|
+
| `theme` | `nimiq` (default): the Nimiq Foundation's 2026 brand, navy on white with a gold round button. `nimiq-dark`: the same on navy. |
|
|
44
|
+
| `lang` | The language of your `strings`, so dates follow it: `nl` writes "14 sep". English by default. |
|
|
38
45
|
| `app-name` | What answers are signed with ("Shitti says"). Defaults to the project's name. |
|
|
39
46
|
| `name` | A display name you already know, offered when the user chooses to show theirs. |
|
|
47
|
+
| `kinds` | Which kinds to offer, of the ones your project takes: `bug,idea,review` by default. `kinds="bug,idea"` leaves reviews off the tiles and out of the list. |
|
|
48
|
+
| `screenshots` | Who sees screenshots on bugs and ideas. On the board for everyone by default, each one only after its author ticks that everyone may see it. `owners` keeps them for your eyes only; `off` leaves the "Add a screenshot" button out. An unknown value counts as `owners`. The project's own rule (`PNB_PROJECT_SCREENSHOTS` on the server) wins when it is stricter. |
|
|
49
|
+
| `names` | `off` leaves out "Show my name", so every post is anonymous. For a board on a public page. |
|
|
50
|
+
| `readonly` | The board to read and scroll through, nothing else: no **+**, no votes (the count still shows), no "Sign in", and it never asks a wallet or sends a proof, not even inside Nimiq Pay. Every post shows as anonymous and without its screenshot, whatever its author chose, because a read-only board is usually shown somewhere other than the app its authors wrote for. |
|
|
51
|
+
| `demo` | A board of sample posts in the page's memory, with no server: `<please-no-bugs demo>`. Voting and writing work, nothing is sent or stored, and a reload starts over. For trying the widget, or showing it off. `demo="owner"` is the same board as its owner sees it: answer, set a status and "Fixed in", write updates. |
|
|
52
|
+
| `screen` | With `demo` only: hold one screen in view, `button`, `tiles`, `board`, `write`, `sent` or `updates`. What the website's Make it yours uses to show each part. |
|
|
40
53
|
|
|
41
54
|
| Property | |
|
|
42
55
|
|---|---|
|
|
@@ -44,31 +57,146 @@ menuItem.onclick = () => open({ project: 'YOUR_PROJECT_ID', server: 'https://YOU
|
|
|
44
57
|
| `appLogin` | Your app's own login signature, so nobody signs twice (below). |
|
|
45
58
|
| `context` | Sent with every bug report, to owners only: `{ version: '1.4.0' }`. |
|
|
46
59
|
| `noise` | Words common in your app, so "said already?" ignores them: `['nim', 'wallet']`. |
|
|
47
|
-
| `strings` | Override any text: `{ 'board.title': 'Ideas box' }`.
|
|
60
|
+
| `strings` | Override any text, or put the whole board in your app's language: `{ 'board.title': 'Ideas box' }`. The widget ships in English; the keys and the English are in `src/i18n.ts`. |
|
|
61
|
+
| `samples` | With `demo` only: the posts the demo board starts with, instead of its own, and no updates: `[{ kind: 'idea', text: 'Pin my contacts', votes: 12 }]`. |
|
|
48
62
|
|
|
49
63
|
Events: `pleasenobugs:posted` (`detail: { id, kind }`) and `pleasenobugs:close`.
|
|
50
64
|
|
|
65
|
+
## What your users see
|
|
66
|
+
|
|
67
|
+
Tapping **+** opens three tiles: **Report a bug**, **Share an idea** and
|
|
68
|
+
**Write a review**. A review is one to five stars and a few words, shown on the
|
|
69
|
+
board with the average on top, so people can see what others like about your
|
|
70
|
+
app. One review per wallet.
|
|
71
|
+
|
|
72
|
+
A bug or an idea can carry **a screenshot, shown on the board** under the
|
|
73
|
+
post, so everybody can see what is meant. Before picking one the user reads
|
|
74
|
+
that everyone will see it and should check it for a balance, an address or a
|
|
75
|
+
name; after picking, **nothing is sent until they tick "I checked it: everyone
|
|
76
|
+
may see this screenshot"** under the picture. The widget redraws it as a JPEG
|
|
77
|
+
before sending, which leaves the photo's location and camera details behind.
|
|
78
|
+
|
|
79
|
+
You see every screenshot on the page where you answer a post, and can **take
|
|
80
|
+
one off the board** there while the post stays up, or hide the whole post. A
|
|
81
|
+
screenshot is deleted by itself when you mark the post Fixed, Done or Not doing, or
|
|
82
|
+
when the post is thrown away. Taking one off stops it being shown; it cannot
|
|
83
|
+
take it back from anybody who already saved it.
|
|
84
|
+
|
|
85
|
+
**Approving first.** On a project made with `PNB_PROJECT_APPROVE=on`, a new
|
|
86
|
+
post waits until an owner approves it. Its author sees it on the board marked
|
|
87
|
+
"Waiting for approval", and "Feedback sent!" says it shows once approved;
|
|
88
|
+
nobody else sees it yet. Owners see it too, and approve it on the page where
|
|
89
|
+
they answer it. Your own posts as an owner never wait.
|
|
90
|
+
|
|
91
|
+
With `screenshots="owners"` they stay yours alone, never the board and not
|
|
92
|
+
even their author: the warning says so instead, and there is nothing to tick.
|
|
93
|
+
Any screenshot sent without that tick keeps that promise, whatever you change
|
|
94
|
+
later.
|
|
95
|
+
|
|
96
|
+
If your page has a Content Security Policy, screenshots on the board load as
|
|
97
|
+
plain images from your server, so `img-src` needs your server next to
|
|
98
|
+
`connect-src`.
|
|
99
|
+
|
|
100
|
+
**Fixed, and where.** When you mark a bug **Fixed** or an idea **Done**, the page asks
|
|
101
|
+
for the version it shipped in and a link to the fix, a commit, a pull request
|
|
102
|
+
or a release. Both are optional; only github.com and gitlab.com links are
|
|
103
|
+
accepted. The card then says "Fixed in 1.4.2 · View on GitHub" (or GitLab)
|
|
104
|
+
for everybody,
|
|
105
|
+
and whoever reported it gets a note on top of their board, "Your bug is fixed
|
|
106
|
+
in 1.4.2", until they close it. Which notes were closed is remembered in the
|
|
107
|
+
browser, as post ids and nothing else.
|
|
108
|
+
|
|
109
|
+
**Updates.** The megaphone at the top of the board opens the Updates page:
|
|
110
|
+
what changed in your app, newest first, each one opening its page on GitHub
|
|
111
|
+
or GitLab.
|
|
112
|
+
Anybody can read it, signed in or not. You write one with **+** there: a
|
|
113
|
+
title, a version, a GitHub or GitLab link, a few lines, and which open bugs and ideas
|
|
114
|
+
it fixes. Those you tick are marked Fixed (bugs) or Done (ideas) with that version and link, and their
|
|
115
|
+
authors get the note. Until you write the first one, only you see the button.
|
|
116
|
+
|
|
51
117
|
## Theming
|
|
52
118
|
|
|
53
119
|
The widget lives in a shadow root, so your CSS cannot break it. These custom
|
|
54
|
-
properties cross that boundary on purpose and are the theming API
|
|
120
|
+
properties cross that boundary on purpose and are the theming API. The
|
|
121
|
+
defaults below are the `nimiq` look; `nimiq-dark` sets the colours again on
|
|
122
|
+
navy:
|
|
55
123
|
|
|
56
124
|
```css
|
|
57
125
|
please-no-bugs {
|
|
58
|
-
--pnb-bg: #
|
|
59
|
-
--pnb-surface: #
|
|
60
|
-
--pnb-surface-2: #
|
|
61
|
-
--pnb-sunken: #
|
|
62
|
-
--pnb-line: #
|
|
63
|
-
--pnb-text: #
|
|
64
|
-
--pnb-text-quiet: #
|
|
65
|
-
--pnb-accent: #
|
|
66
|
-
--pnb-on-accent: #
|
|
67
|
-
--pnb-danger: #
|
|
68
|
-
--pnb-bug: #
|
|
69
|
-
--pnb-planned: #
|
|
70
|
-
--pnb-
|
|
126
|
+
--pnb-bg: #ffffff; /* the page */
|
|
127
|
+
--pnb-surface: #fafaf8; /* a card */
|
|
128
|
+
--pnb-surface-2: #f2f3f4; /* a chip or field inside a card */
|
|
129
|
+
--pnb-sunken: #f2f3f4; /* the Top/New trough */
|
|
130
|
+
--pnb-line: #e6e6e9;
|
|
131
|
+
--pnb-text: #040724;
|
|
132
|
+
--pnb-text-quiet: #686a7c;
|
|
133
|
+
--pnb-accent: #040724;
|
|
134
|
+
--pnb-on-accent: #ffffff;
|
|
135
|
+
--pnb-danger: #cb0015;
|
|
136
|
+
--pnb-bug: #cb0015; --pnb-idea: #ffb700; --pnb-review: #4f5166;
|
|
137
|
+
--pnb-planned: #ffc758; --pnb-done: #040724; --pnb-declined: #9b9ca7;
|
|
138
|
+
--pnb-on-dot: #ffffff; /* the glyph on a chip's dot; or per kind and status: */
|
|
139
|
+
--pnb-on-bug: var(--pnb-on-dot); /* --pnb-on-idea, -review, -planned, -done, -declined */
|
|
140
|
+
--pnb-star: #ffb700;
|
|
141
|
+
--pnb-filter: var(--pnb-text); /* the chosen filter, and the chosen status in your answer sheet */
|
|
142
|
+
--pnb-on-filter: var(--pnb-bg); /* its words: set both, as they are not picked for you */
|
|
143
|
+
--pnb-tile-bug: var(--pnb-bug); /* the three tiles; may be gradients */
|
|
144
|
+
--pnb-tile-idea: var(--pnb-idea);
|
|
145
|
+
--pnb-tile-review: var(--pnb-review);
|
|
146
|
+
--pnb-tile-ink: #ffffff; /* the words on them */
|
|
147
|
+
--pnb-tile-ink-bug: var(--pnb-tile-ink); /* the words on one tile (-idea, -review too) */
|
|
148
|
+
--pnb-tile-dot-bug: transparent; /* a disc behind each tile's glyph (-idea, -review too) */
|
|
149
|
+
--pnb-tile-glyph-bug: var(--pnb-tile-ink-bug); /* and the glyph's colour (-idea, -review too) */
|
|
150
|
+
--pnb-tile-icon: 44px; /* the box the glyph sits in */
|
|
151
|
+
--pnb-choose-title: var(--pnb-text); /* the question above the tiles */
|
|
152
|
+
--pnb-title-board: var(--pnb-text); /* the title in the board's bar */
|
|
153
|
+
--pnb-title-write: var(--pnb-text); /* the title above the form */
|
|
154
|
+
--pnb-card: #ffffff; /* the posts and the rating on the board, */
|
|
155
|
+
--pnb-card-text: var(--pnb-text); /* their words, */
|
|
156
|
+
--pnb-card-quiet: var(--pnb-text-quiet); /* and their names, dates and counts */
|
|
157
|
+
--pnb-field: #f2f3f4; /* every field you type in (form, search, answer, update), */
|
|
158
|
+
--pnb-field-text: var(--pnb-text); /* what is typed in it, */
|
|
159
|
+
--pnb-field-quiet: var(--pnb-text-quiet); /* its hint while empty, */
|
|
160
|
+
--pnb-field-line: var(--pnb-line); /* and the line round it */
|
|
161
|
+
--pnb-news: var(--pnb-surface-2); /* the note on top of the board ("... answered your idea"), */
|
|
162
|
+
--pnb-news-line: var(--pnb-accent); /* its line, */
|
|
163
|
+
--pnb-news-text: var(--pnb-text); /* its words, */
|
|
164
|
+
--pnb-news-link: var(--pnb-accent); /* its link, */
|
|
165
|
+
--pnb-news-quiet: var(--pnb-text-quiet); /* and its small words and close */
|
|
166
|
+
--pnb-filter-btn: #ffffff; /* the Filter button: its ground, */
|
|
167
|
+
--pnb-filter-btn-text: var(--pnb-text); /* its word, */
|
|
168
|
+
--pnb-filter-btn-line: #cdcdd3; /* and its line */
|
|
169
|
+
--pnb-bar-icon: var(--pnb-text); /* the icons in every bar: close, back, updates, new post */
|
|
170
|
+
--pnb-order: var(--pnb-sunken); /* behind Top / New, */
|
|
171
|
+
--pnb-order-text: var(--pnb-text-quiet); /* and the word not chosen */
|
|
172
|
+
--pnb-vote: #f2f3f4; /* the vote button, */
|
|
173
|
+
--pnb-vote-text: var(--pnb-card-text); /* its count, */
|
|
174
|
+
--pnb-vote-on: var(--pnb-accent); /* a vote you gave, */
|
|
175
|
+
--pnb-on-vote-on: var(--pnb-on-accent); /* and its count */
|
|
176
|
+
--pnb-choose-link: var(--pnb-text-quiet); /* "See the board" under the tiles */
|
|
177
|
+
--pnb-form-quiet: var(--pnb-text-quiet); /* the small words in a form */
|
|
178
|
+
--pnb-switch: var(--pnb-surface-2); /* a switch when off, */
|
|
179
|
+
--pnb-switch-line: var(--pnb-line); /* its line, */
|
|
180
|
+
--pnb-switch-knob: var(--pnb-text-quiet); /* its knob, */
|
|
181
|
+
--pnb-switch-on: var(--pnb-accent); /* the switch when on, */
|
|
182
|
+
--pnb-on-switch-on: var(--pnb-on-accent); /* and its knob */
|
|
183
|
+
--pnb-shot-line: var(--pnb-line); /* the line round "Add screenshot" */
|
|
184
|
+
--pnb-order-on: var(--pnb-surface); /* the chosen half of Top/New, */
|
|
185
|
+
--pnb-on-order: var(--pnb-text); /* and its words */
|
|
186
|
+
--pnb-sent: var(--pnb-bg); /* behind "Feedback sent!" */
|
|
187
|
+
--pnb-sent-title: var(--pnb-text); /* its title, */
|
|
188
|
+
--pnb-sent-note: var(--pnb-text-quiet); /* its small words and "Back to the board", */
|
|
189
|
+
--pnb-sent-check: #040724; /* and the disc behind its tick */
|
|
190
|
+
--pnb-on-sent-check: #ffffff; /* the tick itself */
|
|
191
|
+
--pnb-fab: #ffb700; /* the round floating button */
|
|
192
|
+
--pnb-on-fab: #040724; /* its glyph */
|
|
193
|
+
--pnb-fab-shadow: var(--pnb-shadow); /* its shadow, */
|
|
194
|
+
--pnb-fab-shadow-pressed: var(--pnb-fab-shadow); /* pressed, */
|
|
195
|
+
--pnb-fab-squeeze: 0.94; /* and how small it gets pressed */
|
|
196
|
+
--pnb-radius-panel: 16px; /* the panel on a wide screen */
|
|
197
|
+
--pnb-radius: 10px;
|
|
71
198
|
--pnb-radius-sheet: 16px;
|
|
199
|
+
--pnb-radius-pill: 999px; /* filters, chips, votes, Top/New, buttons */
|
|
72
200
|
--pnb-font: inherit; /* your app's font */
|
|
73
201
|
--pnb-z: 2147483000; /* overlay and floating button */
|
|
74
202
|
--pnb-inset-top: env(safe-area-inset-top, 0px); /* what covers the screen's top */
|
|
@@ -125,6 +253,14 @@ const client = createClient({ server: 'https://YOUR_SERVER', project: 'YOUR_PROJ
|
|
|
125
253
|
const board = await client.board(); // never asks the wallet
|
|
126
254
|
if (board.ok) render(sortPosts(board.data.posts, 'top'));
|
|
127
255
|
await client.post({ id: crypto.randomUUID(), kind: 'idea', text: 'Dark mode' }); // asks once, then remembers
|
|
256
|
+
await client.post({ id: crypto.randomUUID(), kind: 'review', text: 'Love it', rating: 5 });
|
|
257
|
+
const shot = await client.shot(postId); // the screenshot as a Blob: on the board, or yours as an owner
|
|
258
|
+
const src = client.shotUrl(postId); // a board screenshot's address, for an <img>
|
|
259
|
+
const news = await client.updates(); // what changed in the app; never asks the wallet
|
|
260
|
+
// The conversation under a post: the app any time, its author right after the app.
|
|
261
|
+
await client.say(postId, { id: crypto.randomUUID(), text: 'A Pixel 7, every time.' });
|
|
262
|
+
await client.editMessage(postId, messageId, { text: 'A Pixel 8, every time.' }); // your last, until answered
|
|
263
|
+
await client.unsay(postId, messageId);
|
|
128
264
|
```
|
|
129
265
|
|
|
130
266
|
Every call answers `{ ok: true, data }` or `{ ok: false, status, error }`, and
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { D as y, c as E, l as D, a as A, i as T, b } from "./index--SJW3aE-.js";
|
|
2
|
+
function N({ owner: u = !1, samples: h } = {}) {
|
|
3
|
+
const x = Date.now();
|
|
4
|
+
let l = (h ?? U).map((t, e) => ({
|
|
5
|
+
id: `demo-${e}`,
|
|
6
|
+
kind: t.kind,
|
|
7
|
+
text: t.text,
|
|
8
|
+
at: x - (t.ago ?? _),
|
|
9
|
+
status: t.status ?? "open",
|
|
10
|
+
votes: t.votes ?? 1,
|
|
11
|
+
voted: !1,
|
|
12
|
+
// A visitor's own; an owner is never the author of a sample.
|
|
13
|
+
mine: !u && !!t.mine,
|
|
14
|
+
...t.who ? { who: t.who } : {},
|
|
15
|
+
...t.rating ? { rating: t.rating } : {},
|
|
16
|
+
...P(e, t, x - (t.ago ?? _)),
|
|
17
|
+
...t.fix ? { fix: { version: t.fix, link: O } } : {},
|
|
18
|
+
// What the app sent along, which only owners see.
|
|
19
|
+
...u && t.context ? { context: { ...t.context } } : {}
|
|
20
|
+
})), p = (h ? [] : $).map((t, e) => ({
|
|
21
|
+
id: `demo-update-${e}`,
|
|
22
|
+
title: t.title,
|
|
23
|
+
text: t.text,
|
|
24
|
+
version: t.version,
|
|
25
|
+
link: O,
|
|
26
|
+
at: x - t.ago,
|
|
27
|
+
posts: t.posts.map((o) => `demo-${o}`)
|
|
28
|
+
})), f, m = y.perDay;
|
|
29
|
+
const k = /* @__PURE__ */ new Map(), a = (t) => S({ ok: !0, data: t }), r = (t, e) => S({ ok: !1, status: t, error: e }), c = (t) => l.find((e) => e.id === t), w = (t, e) => {
|
|
30
|
+
e.length ? t.thread = e : delete t.thread;
|
|
31
|
+
const o = b(e);
|
|
32
|
+
o ? t.reply = o : delete t.reply;
|
|
33
|
+
}, g = (t) => u ? "app" : t.mine ? "author" : null;
|
|
34
|
+
return {
|
|
35
|
+
project: "demo",
|
|
36
|
+
canSign: !0,
|
|
37
|
+
address: () => M,
|
|
38
|
+
signIn: () => a(M),
|
|
39
|
+
signOut() {
|
|
40
|
+
},
|
|
41
|
+
// At once, without the wait: the tiles are there while the panel grows,
|
|
42
|
+
// instead of a spinner they replace halfway.
|
|
43
|
+
board: () => Promise.resolve({
|
|
44
|
+
ok: !0,
|
|
45
|
+
data: {
|
|
46
|
+
project: { id: "demo", name: "Demo app", rules: { ...y, kinds: [...y.kinds] } },
|
|
47
|
+
posts: l.map((t) => ({ ...t })),
|
|
48
|
+
me: { owner: u, left: m, ...f ? { name: f } : {} },
|
|
49
|
+
updates: p.length
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
me: () => a({ owner: u, left: m, ...f ? { name: f } : {} }),
|
|
53
|
+
answers: () => a({ answers: [] }),
|
|
54
|
+
post(t) {
|
|
55
|
+
return m <= 0 ? r(429, "too_many") : t.kind === "review" && l.some((e) => e.mine && e.kind === "review") ? r(409, "reviewed") : (m -= 1, l = [
|
|
56
|
+
{
|
|
57
|
+
id: t.id,
|
|
58
|
+
kind: t.kind,
|
|
59
|
+
text: t.text,
|
|
60
|
+
at: Date.now(),
|
|
61
|
+
status: "open",
|
|
62
|
+
votes: 1,
|
|
63
|
+
voted: !0,
|
|
64
|
+
mine: !0,
|
|
65
|
+
...!t.anon && f ? { who: f } : {},
|
|
66
|
+
...t.kind === "review" ? { rating: t.rating } : {},
|
|
67
|
+
...t.shot?.board ? { shot: !0 } : {}
|
|
68
|
+
},
|
|
69
|
+
...l
|
|
70
|
+
], t.shot?.board && k.set(t.id, `data:${t.shot.type};base64,${t.shot.data}`), a({ ok: !0, left: m }));
|
|
71
|
+
},
|
|
72
|
+
// The visitor's own screenshots on the board; nothing else exists here.
|
|
73
|
+
shot: async (t) => {
|
|
74
|
+
const e = k.get(t);
|
|
75
|
+
return e ? a(await (await fetch(e)).blob()) : r(404, "not_found");
|
|
76
|
+
},
|
|
77
|
+
shotUrl: (t) => k.get(t) ?? "",
|
|
78
|
+
vote(t, e) {
|
|
79
|
+
const o = c(t);
|
|
80
|
+
return o ? (o.voted !== e && (o.votes += e ? 1 : -1), o.voted = e, a({ ok: !0, votes: o.votes, voted: o.voted })) : r(404, "not_found");
|
|
81
|
+
},
|
|
82
|
+
remove(t) {
|
|
83
|
+
const e = c(t);
|
|
84
|
+
return e ? (l = l.filter((o) => o !== e), k.delete(t), a({ ok: !0 })) : r(404, "not_found");
|
|
85
|
+
},
|
|
86
|
+
setName(t) {
|
|
87
|
+
f = t.trim() || void 0;
|
|
88
|
+
for (const e of l) e.mine && e.who !== void 0 && (e.who = f);
|
|
89
|
+
return a({ ok: !0, ...f ? { name: f } : {} });
|
|
90
|
+
},
|
|
91
|
+
// As the server: one change for all of it, and a fix only on a done
|
|
92
|
+
// bug or idea, gone as soon as it stands anywhere else.
|
|
93
|
+
manage(t, e) {
|
|
94
|
+
if (!u) return r(403, "not_owner");
|
|
95
|
+
const o = c(t);
|
|
96
|
+
if (!o) return r(404, "not_found");
|
|
97
|
+
if (e.status && o.kind !== "review" && (o.status = e.status), e.reply !== void 0) {
|
|
98
|
+
const n = e.reply.trim(), i = o.thread ?? [], s = D(i);
|
|
99
|
+
n !== (b(i)?.text ?? "") && (s?.from === "app" ? w(
|
|
100
|
+
o,
|
|
101
|
+
n ? i.map((d) => d === s ? { ...d, text: n, edited: Date.now() } : d) : i.filter((d) => d !== s)
|
|
102
|
+
) : n && w(o, [...i, { id: `reply-${Date.now()}`, from: "app", text: n, at: Date.now() }]));
|
|
103
|
+
}
|
|
104
|
+
if (e.hidden !== void 0 && (e.hidden ? o.hidden = !0 : delete o.hidden), e.approved && delete o.pending, o.status !== "done" || o.kind === "review") delete o.fix;
|
|
105
|
+
else if (e.fix !== void 0) {
|
|
106
|
+
const n = e.fix && E(e.fix);
|
|
107
|
+
if (e.fix && !n) return r(400, "bad_request");
|
|
108
|
+
n && (n.version || n.link) ? o.fix = n : delete o.fix;
|
|
109
|
+
}
|
|
110
|
+
return a({ ok: !0 });
|
|
111
|
+
},
|
|
112
|
+
// The conversation, by the server's rules (see `authorMayAnswer`).
|
|
113
|
+
say(t, e) {
|
|
114
|
+
const o = c(t);
|
|
115
|
+
if (!o) return r(404, "not_found");
|
|
116
|
+
const n = g(o), i = e.text.trim();
|
|
117
|
+
if (!i || i.length > y.replyMax) return r(400, "bad_request");
|
|
118
|
+
if (!n) return r(403, "not_yours");
|
|
119
|
+
if (n === "author" && !A(o))
|
|
120
|
+
return r(409, o.kind === "review" || T(o.status) ? "closed" : "not_your_turn");
|
|
121
|
+
if (n === "app" && o.kind === "review" && o.thread?.some((d) => d.from === "app")) return r(409, "not_your_turn");
|
|
122
|
+
const s = { id: e.id, from: n, text: i, at: Date.now() };
|
|
123
|
+
return w(o, [...o.thread ?? [], s]), a({ ok: !0, message: s });
|
|
124
|
+
},
|
|
125
|
+
editMessage(t, e, o) {
|
|
126
|
+
const n = c(t), i = n?.thread?.find((d) => d.id === e);
|
|
127
|
+
if (!n || !i) return r(404, "not_found");
|
|
128
|
+
let s = { ...i };
|
|
129
|
+
if (o.hidden !== void 0) {
|
|
130
|
+
if (!u) return r(403, "not_owner");
|
|
131
|
+
if (i.from !== "author") return r(400, "bad_request");
|
|
132
|
+
o.hidden ? s.hidden = !0 : delete s.hidden;
|
|
133
|
+
}
|
|
134
|
+
if (o.text !== void 0) {
|
|
135
|
+
const d = o.text.trim();
|
|
136
|
+
if (!d || d.length > y.replyMax) return r(400, "bad_request");
|
|
137
|
+
if (g(n) !== i.from) return r(403, "not_yours");
|
|
138
|
+
if (D(n.thread)?.id !== i.id) return r(409, "not_your_turn");
|
|
139
|
+
d !== i.text && (s = { ...s, text: d, edited: Date.now() });
|
|
140
|
+
}
|
|
141
|
+
return w(n, (n.thread ?? []).map((d) => d === i ? s : d)), a({ ok: !0, message: s });
|
|
142
|
+
},
|
|
143
|
+
unsay(t, e) {
|
|
144
|
+
const o = c(t), n = o?.thread?.find((i) => i.id === e);
|
|
145
|
+
return !o || !n ? r(404, "not_found") : g(o) !== n.from ? r(403, "not_yours") : D(o.thread)?.id !== n.id ? r(409, "not_your_turn") : (w(o, (o.thread ?? []).filter((i) => i !== n)), a({ ok: !0 }));
|
|
146
|
+
},
|
|
147
|
+
// Only those whose posts are still here, like the server; at once, like
|
|
148
|
+
// the board, so the page is there to read rather than a spinner first.
|
|
149
|
+
updates: () => Promise.resolve({
|
|
150
|
+
ok: !0,
|
|
151
|
+
data: { updates: p.map((t) => ({ ...t, posts: t.posts.filter((e) => !!c(e)) })) }
|
|
152
|
+
}),
|
|
153
|
+
// The bugs and ideas it names go to done, with its version and link.
|
|
154
|
+
postUpdate(t) {
|
|
155
|
+
if (!u) return r(403, "not_owner");
|
|
156
|
+
const e = E({ version: t.version ?? "", link: t.link });
|
|
157
|
+
if (!t.title.trim() || !e?.link) return r(400, "bad_request");
|
|
158
|
+
const o = (t.posts ?? []).filter((i) => {
|
|
159
|
+
const s = c(i);
|
|
160
|
+
return s && s.kind !== "review";
|
|
161
|
+
});
|
|
162
|
+
for (const i of o) {
|
|
163
|
+
const s = c(i);
|
|
164
|
+
s.status = "done", s.fix = e;
|
|
165
|
+
}
|
|
166
|
+
const n = {
|
|
167
|
+
id: t.id,
|
|
168
|
+
title: t.title.trim(),
|
|
169
|
+
...t.text?.trim() ? { text: t.text.trim() } : {},
|
|
170
|
+
...e.version ? { version: e.version } : {},
|
|
171
|
+
link: e.link,
|
|
172
|
+
at: Date.now(),
|
|
173
|
+
posts: o
|
|
174
|
+
};
|
|
175
|
+
return p = [n, ...p], a({ ok: !0, update: n });
|
|
176
|
+
},
|
|
177
|
+
removeUpdate(t) {
|
|
178
|
+
return u ? p.some((e) => e.id === t) ? (p = p.filter((e) => e.id !== t), a({ ok: !0 })) : r(404, "not_found") : r(403, "not_owner");
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const M = "NQ00 DEMO DEMO DEMO DEMO DEMO DEMO DEMO DEMO", O = "https://github.com/lennylenders/PleaseNoBugs/releases";
|
|
183
|
+
function S(u) {
|
|
184
|
+
return new Promise((h) => setTimeout(() => h(u), 250));
|
|
185
|
+
}
|
|
186
|
+
const _ = 36e5, v = 24 * _;
|
|
187
|
+
function P(u, h, x) {
|
|
188
|
+
const l = h.thread ?? (h.reply ? [["app", h.reply]] : []);
|
|
189
|
+
if (!l.length) return {};
|
|
190
|
+
const p = l.map(([m, k], a) => ({
|
|
191
|
+
id: `demo-${u}-m${a}`,
|
|
192
|
+
from: m,
|
|
193
|
+
text: k,
|
|
194
|
+
at: x + (a + 1) * 5 * 6e4
|
|
195
|
+
})), f = b(p);
|
|
196
|
+
return { thread: p, ...f ? { reply: f } : {} };
|
|
197
|
+
}
|
|
198
|
+
const $ = [
|
|
199
|
+
{ title: "Switching accounts works again", text: "The send button stayed grey after you switched accounts. It now follows the account you picked.", version: "1.4.2", ago: 2 * v, posts: [1] },
|
|
200
|
+
{ title: "Opens faster", text: "About twice as fast on older phones.", version: "1.4.0", ago: 21 * v, posts: [] }
|
|
201
|
+
], U = [
|
|
202
|
+
{ kind: "idea", text: "A dark mode that follows my phone", votes: 24, ago: 6 * v, status: "planned", who: "Mira", reply: "On its way in the next release." },
|
|
203
|
+
{ kind: "bug", text: "The send button does nothing after I switch accounts", votes: 17, ago: 2 * v, status: "done", fix: "1.4.2", reply: "Thanks for the steps, that made it easy to find." },
|
|
204
|
+
{ kind: "review", text: "Fast, simple and it never asks me twice. Love it.", votes: 9, ago: 3 * v, rating: 5, who: "Joost" },
|
|
205
|
+
{ kind: "idea", text: "Let me pin my favourite contacts to the top", votes: 12, ago: 4 * _, mine: !0, thread: [["app", "Good one! Pinned at the top of the list, or on a Favourites tab of their own?"]] },
|
|
206
|
+
{ kind: "review", text: "Does what it says. The history screen could be clearer.", votes: 4, ago: 9 * v, rating: 4 },
|
|
207
|
+
{ kind: "bug", text: "Amounts over 1,000 overlap the currency on small phones", votes: 6, ago: 20 * _, who: "Sam", context: { version: "1.4.2", screen: "Send" }, thread: [["app", "Thanks! Which phone is it, and which currency?"], ["author", "An iPhone SE, in euros."]] },
|
|
208
|
+
{ kind: "idea", text: "Export my history as a CSV file", votes: 3, ago: 12 * v, status: "declined", reply: "Not for now: it would mean storing more than we want to." }
|
|
209
|
+
];
|
|
210
|
+
export {
|
|
211
|
+
N as createDemoClient
|
|
212
|
+
};
|