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/README.md
CHANGED
|
@@ -16,8 +16,11 @@ 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 round button in the corner.
|
|
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.
|
|
21
24
|
|
|
22
25
|
`floating` and `overlay` cover the whole screen on a phone. From 640 pixels
|
|
23
26
|
wide they are a panel in the bottom-right corner instead, 375 wide and up to
|
|
@@ -36,17 +39,17 @@ menuItem.onclick = () => open({ project: 'YOUR_PROJECT_ID', server: 'https://YOU
|
|
|
36
39
|
|---|---|
|
|
37
40
|
| `project`, `server` | Required. |
|
|
38
41
|
| `mode` | `inline`, `floating` or `overlay`. |
|
|
39
|
-
| `
|
|
40
|
-
| `theme` | `
|
|
41
|
-
| `
|
|
42
|
-
| `app-name` | What answers are signed with ("
|
|
43
|
-
| `name` | A display name you already know,
|
|
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. |
|
|
45
|
+
| `app-name` | What answers are signed with ("My app says"). Defaults to the project's name. |
|
|
46
|
+
| `name` | A display name you already know, filled in for a user who has not chosen one on this board yet. |
|
|
44
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. |
|
|
45
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. |
|
|
46
|
-
| `names` | `off` leaves out
|
|
49
|
+
| `names` | `off` leaves out the name field and the "Post anonymously" switch: every post is anonymous, with no name and no identicon. |
|
|
47
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. |
|
|
48
|
-
| `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. |
|
|
49
|
-
| `screen` | With `demo` only: hold one screen in view, `button`, `tiles`, `board`, `write` or `
|
|
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. |
|
|
50
53
|
|
|
51
54
|
| Property | |
|
|
52
55
|
|---|---|
|
|
@@ -54,7 +57,8 @@ menuItem.onclick = () => open({ project: 'YOUR_PROJECT_ID', server: 'https://YOU
|
|
|
54
57
|
| `appLogin` | Your app's own login signature, so nobody signs twice (below). |
|
|
55
58
|
| `context` | Sent with every bug report, to owners only: `{ version: '1.4.0' }`. |
|
|
56
59
|
| `noise` | Words common in your app, so "said already?" ignores them: `['nim', 'wallet']`. |
|
|
57
|
-
| `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 }]`. |
|
|
58
62
|
|
|
59
63
|
Events: `pleasenobugs:posted` (`detail: { id, kind }`) and `pleasenobugs:close`.
|
|
60
64
|
|
|
@@ -65,6 +69,12 @@ Tapping **+** opens three tiles: **Report a bug**, **Share an idea** and
|
|
|
65
69
|
board with the average on top, so people can see what others like about your
|
|
66
70
|
app. One review per wallet.
|
|
67
71
|
|
|
72
|
+
A post goes out with **the user's wallet identicon and a name** they fill in
|
|
73
|
+
once per board, never their address. Changing the name changes it on their
|
|
74
|
+
earlier posts too. **"Post anonymously"** leaves both off. The identicon is
|
|
75
|
+
drawn by your PleaseNoBugs server (`/v1/identicons/…`), like screenshots, so
|
|
76
|
+
the page needs that server in its `img-src`.
|
|
77
|
+
|
|
68
78
|
A bug or an idea can carry **a screenshot, shown on the board** under the
|
|
69
79
|
post, so everybody can see what is meant. Before picking one the user reads
|
|
70
80
|
that everyone will see it and should check it for a balance, an address or a
|
|
@@ -72,16 +82,16 @@ name; after picking, **nothing is sent until they tick "I checked it: everyone
|
|
|
72
82
|
may see this screenshot"** under the picture. The widget redraws it as a JPEG
|
|
73
83
|
before sending, which leaves the photo's location and camera details behind.
|
|
74
84
|
|
|
75
|
-
You see every screenshot
|
|
85
|
+
You see every screenshot on the page where you answer a post, and can **take
|
|
76
86
|
one off the board** there while the post stays up, or hide the whole post. A
|
|
77
|
-
screenshot is deleted by itself when you mark the post Done or Not doing, or
|
|
87
|
+
screenshot is deleted by itself when you mark the post Fixed, Done or Not doing, or
|
|
78
88
|
when the post is thrown away. Taking one off stops it being shown; it cannot
|
|
79
89
|
take it back from anybody who already saved it.
|
|
80
90
|
|
|
81
91
|
**Approving first.** On a project made with `PNB_PROJECT_APPROVE=on`, a new
|
|
82
92
|
post waits until an owner approves it. Its author sees it on the board marked
|
|
83
93
|
"Waiting for approval", and "Feedback sent!" says it shows once approved;
|
|
84
|
-
nobody else sees it yet. Owners see it too, and approve it
|
|
94
|
+
nobody else sees it yet. Owners see it too, and approve it on the page where
|
|
85
95
|
they answer it. Your own posts as an owner never wait.
|
|
86
96
|
|
|
87
97
|
With `screenshots="owners"` they stay yours alone, never the board and not
|
|
@@ -93,37 +103,106 @@ If your page has a Content Security Policy, screenshots on the board load as
|
|
|
93
103
|
plain images from your server, so `img-src` needs your server next to
|
|
94
104
|
`connect-src`.
|
|
95
105
|
|
|
106
|
+
**Fixed, and where.** When you mark a bug **Fixed** or an idea **Done**, the page asks
|
|
107
|
+
for the version it shipped in and a link to the fix, a commit, a pull request
|
|
108
|
+
or a release. Both are optional; only github.com and gitlab.com links are
|
|
109
|
+
accepted. The card then says "Fixed in 1.4.2 · View on GitHub" (or GitLab)
|
|
110
|
+
for everybody,
|
|
111
|
+
and whoever reported it gets a note on top of their board, "Your bug is fixed
|
|
112
|
+
in 1.4.2", until they close it. Which notes were closed is remembered in the
|
|
113
|
+
browser, as post ids and nothing else.
|
|
114
|
+
|
|
115
|
+
**Updates.** The megaphone at the top of the board opens the Updates page:
|
|
116
|
+
what changed in your app, newest first, each one opening its page on GitHub
|
|
117
|
+
or GitLab.
|
|
118
|
+
Anybody can read it, signed in or not. You write one with **+** there: a
|
|
119
|
+
title, a version, a GitHub or GitLab link, a few lines, and which open bugs and ideas
|
|
120
|
+
it fixes. Those you tick are marked Fixed (bugs) or Done (ideas) with that version and link, and their
|
|
121
|
+
authors get the note. Until you write the first one, only you see the button.
|
|
122
|
+
|
|
96
123
|
## Theming
|
|
97
124
|
|
|
98
125
|
The widget lives in a shadow root, so your CSS cannot break it. These custom
|
|
99
|
-
properties cross that boundary on purpose and are the theming API
|
|
126
|
+
properties cross that boundary on purpose and are the theming API. The
|
|
127
|
+
defaults below are the `nimiq` look; `nimiq-dark` sets the colours again on
|
|
128
|
+
navy:
|
|
100
129
|
|
|
101
130
|
```css
|
|
102
131
|
please-no-bugs {
|
|
103
|
-
--pnb-bg: #
|
|
104
|
-
--pnb-surface: #
|
|
105
|
-
--pnb-surface-2: #
|
|
106
|
-
--pnb-sunken: #
|
|
107
|
-
--pnb-line: #
|
|
108
|
-
--pnb-text: #
|
|
109
|
-
--pnb-text-quiet: #
|
|
110
|
-
--pnb-accent: #
|
|
111
|
-
--pnb-accent
|
|
112
|
-
--pnb-
|
|
113
|
-
--pnb-
|
|
114
|
-
--pnb-
|
|
115
|
-
--pnb-
|
|
116
|
-
--pnb-
|
|
132
|
+
--pnb-bg: #ffffff; /* the page */
|
|
133
|
+
--pnb-surface: #fafaf8; /* a card */
|
|
134
|
+
--pnb-surface-2: #f2f3f4; /* a chip or field inside a card */
|
|
135
|
+
--pnb-sunken: #f2f3f4; /* the Top/New trough */
|
|
136
|
+
--pnb-line: #e6e6e9;
|
|
137
|
+
--pnb-text: #040724;
|
|
138
|
+
--pnb-text-quiet: #686a7c;
|
|
139
|
+
--pnb-accent: #040724;
|
|
140
|
+
--pnb-on-accent: #ffffff;
|
|
141
|
+
--pnb-danger: #cb0015;
|
|
142
|
+
--pnb-bug: #cb0015; --pnb-idea: #ffb700; --pnb-review: #4f5166;
|
|
143
|
+
--pnb-planned: #ffc758; --pnb-done: #040724; --pnb-declined: #9b9ca7;
|
|
144
|
+
--pnb-on-dot: #ffffff; /* the glyph on a chip's dot; or per kind and status: */
|
|
145
|
+
--pnb-on-bug: var(--pnb-on-dot); /* --pnb-on-idea, -review, -planned, -done, -declined */
|
|
146
|
+
--pnb-star: #ffb700;
|
|
147
|
+
--pnb-filter: var(--pnb-text); /* the chosen filter, and the chosen status in your answer sheet */
|
|
148
|
+
--pnb-on-filter: var(--pnb-bg); /* its words: set both, as they are not picked for you */
|
|
117
149
|
--pnb-tile-bug: var(--pnb-bug); /* the three tiles; may be gradients */
|
|
118
150
|
--pnb-tile-idea: var(--pnb-idea);
|
|
119
151
|
--pnb-tile-review: var(--pnb-review);
|
|
120
|
-
--pnb-tile-ink: #
|
|
152
|
+
--pnb-tile-ink: #ffffff; /* the words on them */
|
|
153
|
+
--pnb-tile-ink-bug: var(--pnb-tile-ink); /* the words on one tile (-idea, -review too) */
|
|
154
|
+
--pnb-tile-dot-bug: transparent; /* a disc behind each tile's glyph (-idea, -review too) */
|
|
155
|
+
--pnb-tile-glyph-bug: var(--pnb-tile-ink-bug); /* and the glyph's colour (-idea, -review too) */
|
|
156
|
+
--pnb-tile-icon: 44px; /* the box the glyph sits in */
|
|
157
|
+
--pnb-choose-title: var(--pnb-text); /* the question above the tiles */
|
|
158
|
+
--pnb-title-board: var(--pnb-text); /* the title in the board's bar */
|
|
159
|
+
--pnb-title-write: var(--pnb-text); /* the title above the form */
|
|
160
|
+
--pnb-card: #ffffff; /* the posts and the rating on the board, */
|
|
161
|
+
--pnb-card-text: var(--pnb-text); /* their words, */
|
|
162
|
+
--pnb-card-quiet: var(--pnb-text-quiet); /* and their names, dates and counts */
|
|
163
|
+
--pnb-field: #f2f3f4; /* every field you type in (form, search, answer, update), */
|
|
164
|
+
--pnb-field-text: var(--pnb-text); /* what is typed in it, */
|
|
165
|
+
--pnb-field-quiet: var(--pnb-text-quiet); /* its hint while empty, */
|
|
166
|
+
--pnb-field-line: var(--pnb-line); /* and the line round it */
|
|
167
|
+
--pnb-news: var(--pnb-surface-2); /* the note on top of the board ("... answered your idea"), */
|
|
168
|
+
--pnb-news-line: var(--pnb-accent); /* its line, */
|
|
169
|
+
--pnb-news-text: var(--pnb-text); /* its words, */
|
|
170
|
+
--pnb-news-link: var(--pnb-accent); /* its link, */
|
|
171
|
+
--pnb-news-quiet: var(--pnb-text-quiet); /* and its small words and close */
|
|
172
|
+
--pnb-filter-btn: #ffffff; /* the Filter button: its ground, */
|
|
173
|
+
--pnb-filter-btn-text: var(--pnb-text); /* its word, */
|
|
174
|
+
--pnb-filter-btn-line: #cdcdd3; /* and its line */
|
|
175
|
+
--pnb-bar-icon: var(--pnb-text); /* the icons in every bar: close, back, updates, new post */
|
|
176
|
+
--pnb-order: var(--pnb-sunken); /* behind Top / New, */
|
|
177
|
+
--pnb-order-text: var(--pnb-text-quiet); /* and the word not chosen */
|
|
178
|
+
--pnb-vote: #f2f3f4; /* the vote button, */
|
|
179
|
+
--pnb-vote-text: var(--pnb-card-text); /* its count, */
|
|
180
|
+
--pnb-vote-on: var(--pnb-accent); /* a vote you gave, */
|
|
181
|
+
--pnb-on-vote-on: var(--pnb-on-accent); /* and its count */
|
|
182
|
+
--pnb-choose-link: var(--pnb-text-quiet); /* "See the board" under the tiles */
|
|
183
|
+
--pnb-form-quiet: var(--pnb-text-quiet); /* the small words in a form */
|
|
184
|
+
--pnb-switch: var(--pnb-surface-2); /* a switch when off, */
|
|
185
|
+
--pnb-switch-line: var(--pnb-line); /* its line, */
|
|
186
|
+
--pnb-switch-knob: var(--pnb-text-quiet); /* its knob, */
|
|
187
|
+
--pnb-switch-on: var(--pnb-accent); /* the switch when on, */
|
|
188
|
+
--pnb-on-switch-on: var(--pnb-on-accent); /* and its knob */
|
|
189
|
+
--pnb-shot-line: var(--pnb-line); /* the line round "Add screenshot" */
|
|
190
|
+
--pnb-order-on: var(--pnb-surface); /* the chosen half of Top/New, */
|
|
191
|
+
--pnb-on-order: var(--pnb-text); /* and its words */
|
|
121
192
|
--pnb-sent: var(--pnb-bg); /* behind "Feedback sent!" */
|
|
122
|
-
--pnb-
|
|
123
|
-
--pnb-
|
|
193
|
+
--pnb-sent-title: var(--pnb-text); /* its title, */
|
|
194
|
+
--pnb-sent-note: var(--pnb-text-quiet); /* its small words and "Back to the board", */
|
|
195
|
+
--pnb-sent-check: #040724; /* and the disc behind its tick */
|
|
196
|
+
--pnb-on-sent-check: #ffffff; /* the tick itself */
|
|
197
|
+
--pnb-fab: #ffb700; /* the round floating button */
|
|
198
|
+
--pnb-on-fab: #040724; /* its glyph */
|
|
199
|
+
--pnb-fab-shadow: var(--pnb-shadow); /* its shadow, */
|
|
200
|
+
--pnb-fab-shadow-pressed: var(--pnb-fab-shadow); /* pressed, */
|
|
201
|
+
--pnb-fab-squeeze: 0.94; /* and how small it gets pressed */
|
|
124
202
|
--pnb-radius-panel: 16px; /* the panel on a wide screen */
|
|
125
|
-
--pnb-radius:
|
|
203
|
+
--pnb-radius: 10px;
|
|
126
204
|
--pnb-radius-sheet: 16px;
|
|
205
|
+
--pnb-radius-pill: 999px; /* filters, chips, votes, Top/New, buttons */
|
|
127
206
|
--pnb-font: inherit; /* your app's font */
|
|
128
207
|
--pnb-z: 2147483000; /* overlay and floating button */
|
|
129
208
|
--pnb-inset-top: env(safe-area-inset-top, 0px); /* what covers the screen's top */
|
|
@@ -145,9 +224,19 @@ to the widget and nobody signs twice:
|
|
|
145
224
|
board.appLogin = { address, publicKey, signature, message: 'Sign in to My app' };
|
|
146
225
|
```
|
|
147
226
|
|
|
148
|
-
The project has to
|
|
149
|
-
|
|
150
|
-
|
|
227
|
+
The project has to accept that message first: set `PNB_PROJECT_LOGIN_MESSAGE`
|
|
228
|
+
on your server (on a server that already runs, set it and restart; with one
|
|
229
|
+
project it is added to that one), or use the dashboard or
|
|
230
|
+
`create-project --login-message`. If your login message changes every time,
|
|
231
|
+
because it carries a date or a random code, give its fixed start followed by
|
|
232
|
+
`*`, like `Sign in to My app*` (at least 12 characters before the `*`). Set
|
|
233
|
+
`appLogin` to `null` when the user logs out of your app.
|
|
234
|
+
|
|
235
|
+
This is how a mini app in Nimiq Pay, or a website with its own wallet login,
|
|
236
|
+
lets its users post and vote without signing anything again. Without it, the
|
|
237
|
+
widget asks the wallet to sign once by itself, at the first vote or post:
|
|
238
|
+
inside Nimiq Pay a short confirmation, kept for a month; in a browser through
|
|
239
|
+
the Nimiq Hub, kept until the tab closes.
|
|
151
240
|
|
|
152
241
|
## Signing outside Nimiq Pay
|
|
153
242
|
|
|
@@ -165,8 +254,13 @@ document.querySelector('please-no-bugs').signer = async (message) => {
|
|
|
165
254
|
};
|
|
166
255
|
```
|
|
167
256
|
|
|
168
|
-
|
|
169
|
-
|
|
257
|
+
With a signer and outside Nimiq Pay, the board offers **"Sign in with Nimiq"**
|
|
258
|
+
on top until the user has signed in, since signing opens a wallet window
|
|
259
|
+
there. Without a signer outside Nimiq Pay, the board is read-only and says
|
|
260
|
+
"Sign in with your Nimiq wallet to post and vote" when somebody tries to post.
|
|
261
|
+
On a website with its own wallet login, that is the moment to hand the login
|
|
262
|
+
over with `appLogin` (above): set it once the user has signed in to your site,
|
|
263
|
+
and back to `null` when they sign out.
|
|
170
264
|
|
|
171
265
|
## Headless
|
|
172
266
|
|
|
@@ -183,6 +277,11 @@ await client.post({ id: crypto.randomUUID(), kind: 'idea', text: 'Dark mode' });
|
|
|
183
277
|
await client.post({ id: crypto.randomUUID(), kind: 'review', text: 'Love it', rating: 5 });
|
|
184
278
|
const shot = await client.shot(postId); // the screenshot as a Blob: on the board, or yours as an owner
|
|
185
279
|
const src = client.shotUrl(postId); // a board screenshot's address, for an <img>
|
|
280
|
+
const news = await client.updates(); // what changed in the app; never asks the wallet
|
|
281
|
+
// The conversation under a post: the app any time, its author right after the app.
|
|
282
|
+
await client.say(postId, { id: crypto.randomUUID(), text: 'A Pixel 7, every time.' });
|
|
283
|
+
await client.editMessage(postId, messageId, { text: 'A Pixel 8, every time.' }); // your last, until answered
|
|
284
|
+
await client.unsay(postId, messageId);
|
|
186
285
|
```
|
|
187
286
|
|
|
188
287
|
Every call answers `{ ok: true, data }` or `{ ok: false, status, error }`, and
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
function T(t) {
|
|
2
|
+
return t.replace(/\s+/g, "").toUpperCase();
|
|
3
|
+
}
|
|
4
|
+
const M = 30 * 24 * 60 * 60 * 1e3, x = 5 * 60 * 1e3;
|
|
5
|
+
function J(t) {
|
|
6
|
+
return [
|
|
7
|
+
"PleaseNoBugs login",
|
|
8
|
+
`Project: ${t.project}`,
|
|
9
|
+
`Origin: ${D(t.origin)}`,
|
|
10
|
+
`Issued: ${new Date(t.issued).toISOString()}`
|
|
11
|
+
].join(`
|
|
12
|
+
`);
|
|
13
|
+
}
|
|
14
|
+
function D(t) {
|
|
15
|
+
try {
|
|
16
|
+
return new URL(t).origin;
|
|
17
|
+
} catch {
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function A(t, n = Date.now()) {
|
|
22
|
+
return Number.isFinite(t) && t <= n + x && n - t <= M;
|
|
23
|
+
}
|
|
24
|
+
function F(t) {
|
|
25
|
+
return `Nimiq ${K(JSON.stringify(t))}`;
|
|
26
|
+
}
|
|
27
|
+
function K(t) {
|
|
28
|
+
const n = new TextEncoder().encode(t);
|
|
29
|
+
let o = "";
|
|
30
|
+
for (const a of n)
|
|
31
|
+
o += String.fromCharCode(a);
|
|
32
|
+
return btoa(o).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
33
|
+
}
|
|
34
|
+
const W = [
|
|
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 Z(t = []) {
|
|
115
|
+
const n = /* @__PURE__ */ new Set([...W, ...[...t].map((r) => r.toLowerCase())]), o = /* @__PURE__ */ new WeakMap(), a = (r) => new Set(r.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter((m) => m.length >= 4 && !n.has(m)));
|
|
116
|
+
return function(m, q, w = 3) {
|
|
117
|
+
const p = a(q);
|
|
118
|
+
return p.size < 2 ? [] : m.map((u) => {
|
|
119
|
+
let l = o.get(u);
|
|
120
|
+
l || (l = a(u.text), o.set(u, l));
|
|
121
|
+
let d = 0;
|
|
122
|
+
for (const h of p)
|
|
123
|
+
l.has(h) && d++;
|
|
124
|
+
return { post: u, shared: d };
|
|
125
|
+
}).filter((u) => u.shared >= 2).sort((u, l) => l.shared - u.shared || l.post.votes - u.post.votes).slice(0, w).map((u) => u.post);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function ee(t, n) {
|
|
129
|
+
const o = [...t];
|
|
130
|
+
return n === "new" ? o.sort((a, r) => r.at - a.at) : o.sort((a, r) => r.votes - a.votes || r.at - a.at);
|
|
131
|
+
}
|
|
132
|
+
class E extends Error {
|
|
133
|
+
constructor(n, o) {
|
|
134
|
+
super(o ?? n), this.reason = n, this.name = "SignerError";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const B = 2e3;
|
|
138
|
+
function j() {
|
|
139
|
+
return typeof window < "u" && !!window.nimiq;
|
|
140
|
+
}
|
|
141
|
+
function H(t) {
|
|
142
|
+
return window.nimiq ? Promise.resolve(window.nimiq) : new Promise((n, o) => {
|
|
143
|
+
const a = Date.now(), r = setInterval(() => {
|
|
144
|
+
window.nimiq ? (clearInterval(r), n(window.nimiq)) : Date.now() - a > t && (clearInterval(r), o(new E("no_wallet", "Not running inside Nimiq Pay")));
|
|
145
|
+
}, 50);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function Q(t = B) {
|
|
149
|
+
return async (n) => {
|
|
150
|
+
const o = await H(t), a = await o.listAccounts();
|
|
151
|
+
if (!Array.isArray(a) || !a.length) throw new E("no_account");
|
|
152
|
+
const r = await o.sign(n);
|
|
153
|
+
if (!r || !("signature" in r))
|
|
154
|
+
throw new E("declined", r && "error" in r ? r.error.message : void 0);
|
|
155
|
+
return { address: a[0], publicKey: r.publicKey, signature: r.signature };
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function V() {
|
|
159
|
+
try {
|
|
160
|
+
const t = await window.nimiq?.listAccounts();
|
|
161
|
+
return Array.isArray(t) && t.length ? t[0] : null;
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function te(t) {
|
|
167
|
+
const n = t.server.replace(/\/+$/, ""), o = t.project, a = D(t.origin ?? (typeof location < "u" ? location.origin : "")), r = t.signer === null ? void 0 : t.signer ?? (j() ? Q() : void 0), m = t.fetch ?? globalThis.fetch.bind(globalThis), q = j(), w = `pleasenobugs.proof.${o}.${a}`, p = t.storage === void 0 ? q ? Y() : X(w) : t.storage, u = t.account ?? (t.signer === void 0 && q ? V : void 0);
|
|
168
|
+
let l = 0, d = R(), h = null, N = !1;
|
|
169
|
+
function P() {
|
|
170
|
+
if (N || !t.appLogin) return null;
|
|
171
|
+
const e = typeof t.appLogin == "function" ? t.appLogin() : t.appLogin;
|
|
172
|
+
return e ? { ...e, origin: a, issued: 0 } : null;
|
|
173
|
+
}
|
|
174
|
+
function R() {
|
|
175
|
+
try {
|
|
176
|
+
const e = p?.getItem(w);
|
|
177
|
+
if (!e) return null;
|
|
178
|
+
const s = JSON.parse(e);
|
|
179
|
+
return A(s.issued) ? s : null;
|
|
180
|
+
} catch {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function b(e) {
|
|
185
|
+
d = e;
|
|
186
|
+
try {
|
|
187
|
+
e ? p?.setItem(w, JSON.stringify(e)) : p?.removeItem(w);
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async function z() {
|
|
192
|
+
if (!u || !d || Date.now() - l < 3e4) return;
|
|
193
|
+
l = Date.now();
|
|
194
|
+
const e = await u();
|
|
195
|
+
e && d && T(e) !== T(d.address) && b(null);
|
|
196
|
+
}
|
|
197
|
+
function $() {
|
|
198
|
+
const e = P();
|
|
199
|
+
return e || (d && !A(d.issued) && b(null), d);
|
|
200
|
+
}
|
|
201
|
+
function _() {
|
|
202
|
+
const e = P();
|
|
203
|
+
return e ? Promise.resolve({ ok: !0, data: T(e.address) }) : r ? h || (h = (async () => {
|
|
204
|
+
try {
|
|
205
|
+
const s = Date.now(), c = await r(J({ project: o, origin: a, issued: s }));
|
|
206
|
+
return b({ ...c, origin: a, issued: s }), { ok: !0, data: T(c.address) };
|
|
207
|
+
} catch (s) {
|
|
208
|
+
return s instanceof E && s.reason === "no_wallet" ? { ok: !1, status: 0, error: "no_signer" } : { ok: !1, status: 0, error: "declined" };
|
|
209
|
+
} finally {
|
|
210
|
+
h = null;
|
|
211
|
+
}
|
|
212
|
+
})(), h) : Promise.resolve({ ok: !1, status: 0, error: "no_signer" });
|
|
213
|
+
}
|
|
214
|
+
async function i(e, s, c) {
|
|
215
|
+
c.auth !== "none" && await z();
|
|
216
|
+
const I = async (S) => {
|
|
217
|
+
const O = {};
|
|
218
|
+
c.body !== void 0 && (O["content-type"] = "application/json"), S && (O.authorization = F(S));
|
|
219
|
+
let y;
|
|
220
|
+
try {
|
|
221
|
+
y = await m(`${n}${s}`, {
|
|
222
|
+
method: e,
|
|
223
|
+
headers: O,
|
|
224
|
+
...c.body !== void 0 ? { body: JSON.stringify(c.body) } : {}
|
|
225
|
+
});
|
|
226
|
+
} catch {
|
|
227
|
+
return { ok: !1, status: 0, error: "network" };
|
|
228
|
+
}
|
|
229
|
+
if (y.ok && c.blob) {
|
|
230
|
+
const U = await y.blob().catch(() => null);
|
|
231
|
+
return U ? { ok: !0, data: U } : { ok: !1, status: 0, error: "network" };
|
|
232
|
+
}
|
|
233
|
+
const k = await y.json().catch(() => null);
|
|
234
|
+
if (y.ok) return { ok: !0, data: k };
|
|
235
|
+
const G = k && typeof k.error == "string" ? k.error : "internal";
|
|
236
|
+
return { ok: !1, status: y.status, error: G, body: k };
|
|
237
|
+
};
|
|
238
|
+
if (c.auth === "none") return I(null);
|
|
239
|
+
let v = $();
|
|
240
|
+
if (!v && c.auth === "required") {
|
|
241
|
+
const S = await _();
|
|
242
|
+
if (!S.ok) return S;
|
|
243
|
+
v = $();
|
|
244
|
+
}
|
|
245
|
+
const L = await I(v);
|
|
246
|
+
if (L.ok || L.status !== 401 || !v) return L;
|
|
247
|
+
if (v.message !== void 0 ? N = !0 : b(null), c.auth === "optional") return I(null);
|
|
248
|
+
const C = await _();
|
|
249
|
+
return C.ok ? I($()) : C;
|
|
250
|
+
}
|
|
251
|
+
const f = (e = "") => `/v1/projects/${encodeURIComponent(o)}${e}`, g = (e) => f(`/posts/${encodeURIComponent(e)}`);
|
|
252
|
+
return {
|
|
253
|
+
/** The project this client talks to. */
|
|
254
|
+
project: o,
|
|
255
|
+
/** Whether the user can be signed in at all: a signer, or an app login. */
|
|
256
|
+
get canSign() {
|
|
257
|
+
return !!r || P() !== null;
|
|
258
|
+
},
|
|
259
|
+
/** The signed-in address, if a proof is stored. */
|
|
260
|
+
address() {
|
|
261
|
+
const e = $();
|
|
262
|
+
return e ? T(e.address) : null;
|
|
263
|
+
},
|
|
264
|
+
signIn: _,
|
|
265
|
+
/** Forget the stored proof. The next write asks the wallet again. */
|
|
266
|
+
signOut() {
|
|
267
|
+
b(null);
|
|
268
|
+
},
|
|
269
|
+
/** The whole board, plus `me` when signed in. Never prompts. */
|
|
270
|
+
board: () => i("GET", f("/posts"), { auth: "optional" }),
|
|
271
|
+
me: () => i("GET", f("/me"), { auth: "required" }),
|
|
272
|
+
answers: () => i("GET", f("/answers"), { auth: "required" }),
|
|
273
|
+
/**
|
|
274
|
+
* Write one. A review needs `rating` (1 to 5); a bug or an idea may carry
|
|
275
|
+
* `shot`, a screenshot as base64. It goes on the board for everyone only
|
|
276
|
+
* with `board: true`, which says the user agreed; without it only the
|
|
277
|
+
* project's owners see it.
|
|
278
|
+
*/
|
|
279
|
+
post: (e) => i("POST", f("/posts"), { body: e, auth: "required" }),
|
|
280
|
+
/** A post's screenshot: anybody's for one on the board, owners' for any. */
|
|
281
|
+
shot: (e) => i("GET", `${g(e)}/shot`, { auth: "optional", blob: !0 }),
|
|
282
|
+
/**
|
|
283
|
+
* Where a screenshot on the board can be read without a proof, for an
|
|
284
|
+
* `<img>` to load by itself.
|
|
285
|
+
*/
|
|
286
|
+
shotUrl: (e) => `${n}${g(e)}/shot`,
|
|
287
|
+
/** Where the server draws an identicon, by the code a post carries in `face`. */
|
|
288
|
+
faceUrl: (e) => `${n}/v1/identicons/${encodeURIComponent(e)}.svg`,
|
|
289
|
+
vote: (e, s) => i("POST", `${g(e)}/vote`, {
|
|
290
|
+
body: { up: s },
|
|
291
|
+
auth: "required"
|
|
292
|
+
}),
|
|
293
|
+
remove: (e) => i("DELETE", g(e), { auth: "required" }),
|
|
294
|
+
setName: (e) => i("PUT", f("/me"), { body: { name: e }, auth: "required" }),
|
|
295
|
+
/**
|
|
296
|
+
* An owner answering a post. `fix` says where the fix is, on a bug or an
|
|
297
|
+
* idea set to done: `{ version?, link? }`, the link on github.com or
|
|
298
|
+
* gitlab.com. Moving a post away from done takes its fix away by itself.
|
|
299
|
+
*/
|
|
300
|
+
manage: (e, s) => i("POST", `${g(e)}/manage`, { body: s, auth: "required" }),
|
|
301
|
+
/**
|
|
302
|
+
* Write under a post: an owner for the app, whenever they like; its
|
|
303
|
+
* author only right after the app, on a bug or an idea that is not done
|
|
304
|
+
* (`not_your_turn`, `closed` otherwise). `message.id` is yours to mint.
|
|
305
|
+
*/
|
|
306
|
+
say: (e, s) => i("POST", `${g(e)}/messages`, { body: s, auth: "required" }),
|
|
307
|
+
/**
|
|
308
|
+
* Change your own last message before anybody answered it (`text`), or,
|
|
309
|
+
* as an owner, take an author's message off the board or put it back
|
|
310
|
+
* (`hidden`).
|
|
311
|
+
*/
|
|
312
|
+
editMessage: (e, s, c) => i("PATCH", `${g(e)}/messages/${encodeURIComponent(s)}`, {
|
|
313
|
+
body: c,
|
|
314
|
+
auth: "required"
|
|
315
|
+
}),
|
|
316
|
+
/** Take your own last message back, before anybody answered it. */
|
|
317
|
+
unsay: (e, s) => i("DELETE", `${g(e)}/messages/${encodeURIComponent(s)}`, { auth: "required" }),
|
|
318
|
+
/** What changed in the app, newest first. Anybody's to read; never prompts. */
|
|
319
|
+
updates: () => i("GET", f("/updates"), { auth: "optional" }),
|
|
320
|
+
/**
|
|
321
|
+
* An owner writing one. `link` is a page on github.com or gitlab.com;
|
|
322
|
+
* `posts` are the bugs and ideas it fixed, which go to done with its
|
|
323
|
+
* version and link.
|
|
324
|
+
*/
|
|
325
|
+
postUpdate: (e) => i("POST", f("/updates"), { body: e, auth: "required" }),
|
|
326
|
+
/** An owner taking one off the page. The posts it fixed stay done. */
|
|
327
|
+
removeUpdate: (e) => i("DELETE", f(`/updates/${encodeURIComponent(e)}`), { auth: "required" })
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function X(t) {
|
|
331
|
+
try {
|
|
332
|
+
globalThis.localStorage?.removeItem(t);
|
|
333
|
+
} catch {
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
const n = globalThis.sessionStorage, o = "__pleasenobugs__";
|
|
337
|
+
return n.setItem(o, "1"), n.removeItem(o), n;
|
|
338
|
+
} catch {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function Y() {
|
|
343
|
+
try {
|
|
344
|
+
const t = globalThis.localStorage, n = "__pleasenobugs__";
|
|
345
|
+
return t.setItem(n, "1"), t.removeItem(n), t;
|
|
346
|
+
} catch {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
export {
|
|
351
|
+
E as S,
|
|
352
|
+
te as a,
|
|
353
|
+
T as b,
|
|
354
|
+
Z as c,
|
|
355
|
+
j as i,
|
|
356
|
+
Q as n,
|
|
357
|
+
ee as s
|
|
358
|
+
};
|