@stefan.inc/feedback-engine 1.6.0 → 1.6.2
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/package.json +1 -1
- package/src/core/session.ts +6 -2
- package/src/dom/procrastimate.ts +13 -10
- package/src/editor/Editor.svelte +42 -7
- package/src/editor/ProblemCard.svelte +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stefan.inc/feedback-engine",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "In-app feedback for Svelte and React: point at a component, write what should change, and export its name, file:line, and data for an agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
package/src/core/session.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Annotations, type FeedbackItem, type Reference } from './annotations.ts';
|
|
2
2
|
import { hitTest, pathFrom, similar, type Capture, type Node, type Point } from './model.ts';
|
|
3
|
+
import type { Problem } from './problem.ts';
|
|
3
4
|
import { reportJSON } from './report.ts';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Tapping a toast with a link opens it, such as the task a post created. One with a problem is red and stays until it
|
|
8
|
+
* is tapped, which opens the problem in full.
|
|
9
|
+
*/
|
|
10
|
+
export type Toast = { text: string; link?: string; problem?: Problem };
|
|
7
11
|
|
|
8
12
|
/** The editor's state and rules, without any drawing. */
|
|
9
13
|
export class Session {
|
package/src/dom/procrastimate.ts
CHANGED
|
@@ -16,9 +16,8 @@ export type Project = { id: string; name: string; sections: Section[] };
|
|
|
16
16
|
/** Where a task goes: the Inbox without a project, and the project's top, above its sections, without a section. */
|
|
17
17
|
export type Place = { projectId?: string; sectionId?: string };
|
|
18
18
|
|
|
19
|
-
/** ProcrastiMate's `FILE_PART_BYTES`
|
|
20
|
-
const
|
|
21
|
-
const fileMaxBytes = 25_000_000;
|
|
19
|
+
/** ProcrastiMate's `FILE_PART_BYTES` (`shared/images.ts` there): the most it takes as a file in one request. */
|
|
20
|
+
const fileMaxBytes = 16 * 1024 * 1024;
|
|
22
21
|
const defaultApp = 'https://procrastimate.stf.lol';
|
|
23
22
|
|
|
24
23
|
const projectsKey = 'feedback.procrastimate.projects';
|
|
@@ -161,7 +160,8 @@ export async function postTask(
|
|
|
161
160
|
step: (text: string) => void,
|
|
162
161
|
) {
|
|
163
162
|
const bytes = new TextEncoder().encode(report);
|
|
164
|
-
if (bytes.length > fileMaxBytes)
|
|
163
|
+
if (bytes.length > fileMaxBytes)
|
|
164
|
+
throw new Error('The JSON report is over the 16 MB ProcrastiMate takes in one upload.');
|
|
165
165
|
step('Encoding the image');
|
|
166
166
|
const full = await jpeg(image, 2048, 1_500_000);
|
|
167
167
|
const thumb = await jpeg(image, 320, 200_000);
|
|
@@ -171,12 +171,15 @@ export async function postTask(
|
|
|
171
171
|
await send(config, 'PUT', 'api/images', { id: imageId, size: 'full' }, full.blob, 'image/jpeg');
|
|
172
172
|
step('Uploading the thumbnail');
|
|
173
173
|
await send(config, 'PUT', 'api/images', { id: imageId, size: 'thumb' }, thumb.blob, 'image/jpeg');
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
step('Uploading feedback.json');
|
|
175
|
+
await send(
|
|
176
|
+
config,
|
|
177
|
+
'PUT',
|
|
178
|
+
'api/images',
|
|
179
|
+
{ id: reportId, size: 'file', name: 'feedback.json', type: 'application/json' },
|
|
180
|
+
bytes,
|
|
181
|
+
'application/octet-stream',
|
|
182
|
+
);
|
|
180
183
|
step('Creating the task');
|
|
181
184
|
const created = await send(
|
|
182
185
|
config,
|
package/src/editor/Editor.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
nearestComponent,
|
|
7
7
|
nearestSource,
|
|
8
8
|
paletteColor,
|
|
9
|
+
Problem,
|
|
9
10
|
Session,
|
|
10
11
|
tag,
|
|
11
12
|
title,
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
import { savedDelivery, type Delivery } from '../dom/webhook.ts';
|
|
28
29
|
import { destinations, pinnedDestinations, type Destination } from './destinations.ts';
|
|
29
30
|
import type { Engine } from './engine.ts';
|
|
31
|
+
import ProblemCard from './ProblemCard.svelte';
|
|
30
32
|
import ProcrastimateSheet from './ProcrastimateSheet.svelte';
|
|
31
33
|
import WebhookDialog from './WebhookDialog.svelte';
|
|
32
34
|
import WebhookSheet from './WebhookSheet.svelte';
|
|
@@ -103,6 +105,7 @@
|
|
|
103
105
|
const pinned = $derived(pinnedDestinations(targets, engine.options.pinned));
|
|
104
106
|
let confirmsClose = $state(false);
|
|
105
107
|
let pending = $state<{ format: ExportFormat; ready: Export }>();
|
|
108
|
+
let failure = $state<{ title: string; problem: Problem }>();
|
|
106
109
|
let busy = $state(false);
|
|
107
110
|
|
|
108
111
|
/** Fits the part that was on screen, and never goes below half the width, where targets get too small to tap. */
|
|
@@ -148,7 +151,7 @@
|
|
|
148
151
|
|
|
149
152
|
$effect(() => {
|
|
150
153
|
const toast = view.toast;
|
|
151
|
-
if (!toast) return;
|
|
154
|
+
if (!toast || toast.problem) return;
|
|
152
155
|
const timer = setTimeout(() => act(() => (session.toast = undefined)), toast.link ? 5000 : 3000);
|
|
153
156
|
return () => clearTimeout(timer);
|
|
154
157
|
});
|
|
@@ -209,7 +212,10 @@
|
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
function requestClose() {
|
|
212
|
-
|
|
215
|
+
// The error is drawn over the other sheets, so it is the one to leave first.
|
|
216
|
+
if (failure) {
|
|
217
|
+
failure = undefined;
|
|
218
|
+
} else if (showsInfo || showsShare || showsProcrastimate || posting || pending || editing) {
|
|
213
219
|
showsInfo = showsShare = showsProcrastimate = false;
|
|
214
220
|
posting = pending = editing = undefined;
|
|
215
221
|
} else if (session.isTyping || session.unshared.length) {
|
|
@@ -271,7 +277,7 @@
|
|
|
271
277
|
else if (action === 'save') saveExport(ready);
|
|
272
278
|
else if (!(await shareExport(ready))) return;
|
|
273
279
|
} catch (error) {
|
|
274
|
-
act(() => (session.toast = { text: `Could not ${action}:
|
|
280
|
+
act(() => (session.toast = { text: `Could not ${action}`, problem: Problem.from(error) }));
|
|
275
281
|
return;
|
|
276
282
|
}
|
|
277
283
|
pending = undefined;
|
|
@@ -556,15 +562,18 @@
|
|
|
556
562
|
</div>
|
|
557
563
|
|
|
558
564
|
{#if view.toast}
|
|
559
|
-
|
|
565
|
+
{@const { text, link, problem } = view.toast}
|
|
566
|
+
<div class="toast" role={problem ? 'alert' : 'status'}>
|
|
560
567
|
<button
|
|
561
568
|
type="button"
|
|
569
|
+
class:failed={problem}
|
|
562
570
|
onclick={() => {
|
|
563
|
-
if (
|
|
571
|
+
if (link) open(link, '_blank', 'noopener');
|
|
572
|
+
if (problem) failure = { title: text, problem };
|
|
564
573
|
act(() => (session.toast = undefined));
|
|
565
574
|
}}
|
|
566
575
|
>
|
|
567
|
-
✓ {
|
|
576
|
+
{#if problem}⚠ {text}: {problem.message} ›{:else}✓ {text}{link ? ' ↗' : ''}{/if}
|
|
568
577
|
</button>
|
|
569
578
|
</div>
|
|
570
579
|
{/if}
|
|
@@ -646,6 +655,20 @@
|
|
|
646
655
|
</div>
|
|
647
656
|
</div>
|
|
648
657
|
{/if}
|
|
658
|
+
|
|
659
|
+
{#if failure}
|
|
660
|
+
<div
|
|
661
|
+
class="scrim"
|
|
662
|
+
role="presentation"
|
|
663
|
+
onclick={event => event.target === event.currentTarget && (failure = undefined)}
|
|
664
|
+
>
|
|
665
|
+
<div class="sheet actions" role="dialog" tabindex="-1" aria-label={failure.title}>
|
|
666
|
+
<h2>{failure.title}</h2>
|
|
667
|
+
<ProblemCard problem={failure.problem} open />
|
|
668
|
+
<button type="button" class="quiet" onclick={() => (failure = undefined)}>Close</button>
|
|
669
|
+
</div>
|
|
670
|
+
</div>
|
|
671
|
+
{/if}
|
|
649
672
|
</dialog>
|
|
650
673
|
|
|
651
674
|
<style>
|
|
@@ -1175,7 +1198,8 @@
|
|
|
1175
1198
|
position: absolute;
|
|
1176
1199
|
top: 60px;
|
|
1177
1200
|
left: 50%;
|
|
1178
|
-
|
|
1201
|
+
/* Above a sheet's scrim: a failed copy leaves the export's sheet open, and its toast must still take a click. */
|
|
1202
|
+
z-index: 6;
|
|
1179
1203
|
width: max-content;
|
|
1180
1204
|
max-width: calc(100% - 32px);
|
|
1181
1205
|
translate: -50% 0;
|
|
@@ -1189,6 +1213,17 @@
|
|
|
1189
1213
|
font-weight: 600;
|
|
1190
1214
|
}
|
|
1191
1215
|
|
|
1216
|
+
.toast .failed {
|
|
1217
|
+
display: -webkit-box;
|
|
1218
|
+
-webkit-box-orient: vertical;
|
|
1219
|
+
-webkit-line-clamp: 2;
|
|
1220
|
+
line-clamp: 2;
|
|
1221
|
+
overflow: hidden;
|
|
1222
|
+
border-radius: 18px;
|
|
1223
|
+
background: rgb(255 69 58 / 0.94);
|
|
1224
|
+
text-align: start;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1192
1227
|
.scrim {
|
|
1193
1228
|
position: absolute;
|
|
1194
1229
|
inset: 0;
|
|
@@ -3,17 +3,12 @@
|
|
|
3
3
|
<script lang="ts">
|
|
4
4
|
import type { Problem } from '../core/index.ts';
|
|
5
5
|
|
|
6
|
-
let { problem }: { problem: Problem } = $props();
|
|
6
|
+
let { problem, open = false }: { problem: Problem; open?: boolean } = $props();
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<div class="problem" role="alert">
|
|
10
10
|
<p class="message">{problem.message}</p>
|
|
11
|
-
|
|
12
|
-
<details>
|
|
13
|
-
<summary>Details</summary>
|
|
14
|
-
<pre>{problem.details}</pre>
|
|
15
|
-
</details>
|
|
16
|
-
{/if}
|
|
11
|
+
<!-- Above the details, which can fill a sheet when open: the copy must not need a scroll. -->
|
|
17
12
|
<button
|
|
18
13
|
type="button"
|
|
19
14
|
onclick={async event => {
|
|
@@ -23,6 +18,12 @@
|
|
|
23
18
|
setTimeout(() => (button.textContent = 'Copy Error'), 2000);
|
|
24
19
|
}}>Copy Error</button
|
|
25
20
|
>
|
|
21
|
+
{#if problem.facts.length}
|
|
22
|
+
<details {open}>
|
|
23
|
+
<summary>Details</summary>
|
|
24
|
+
<pre>{problem.details}</pre>
|
|
25
|
+
</details>
|
|
26
|
+
{/if}
|
|
26
27
|
</div>
|
|
27
28
|
|
|
28
29
|
<style>
|