@stefan.inc/feedback-engine 1.6.1 → 1.6.3
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 +1 -1
- package/package.json +1 -1
- package/src/core/annotations.ts +15 -2
- package/src/core/session.ts +6 -2
- package/src/editor/Editor.svelte +42 -7
- package/src/editor/ProblemCard.svelte +8 -7
- package/src/react/public.d.ts +1 -1
package/README.md
CHANGED
|
@@ -263,7 +263,7 @@ The token is the switch. With `PROCRASTIMATE_TOKEN` set, **ProcrastiMate** shows
|
|
|
263
263
|
|
|
264
264
|
## Drive it from a script
|
|
265
265
|
|
|
266
|
-
`setupFeedbackEngine()` also puts the engine on `globalThis.__feedbackEngine`. `__feedbackEngine.present()` opens the editor without the click, and `__feedbackEngine.lastExport` holds the files of the last export as `{ name, blob }`, written when a Share menu entry is chosen. `
|
|
266
|
+
`setupFeedbackEngine()` also puts the engine on `globalThis.__feedbackEngine`. `__feedbackEngine.present()` opens the editor without the click, and `__feedbackEngine.lastExport` holds the files of the last export as `{ name, blob }`, written when a Share menu entry is chosen. `scripts/readme-images.ts` in the repository does both with Playwright.
|
|
267
267
|
|
|
268
268
|
## Webhooks
|
|
269
269
|
|
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.3",
|
|
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/annotations.ts
CHANGED
|
@@ -107,7 +107,20 @@ export class Annotations {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
/** The colors items and references take, in order.
|
|
111
|
-
export const palette = [
|
|
110
|
+
/** The colors items and references take, in order. iOS has the same list, so both platforms' exports match. Each pair is at least 18 apart in CIEDE2000, and none is too dark to see on a dark page. */
|
|
111
|
+
export const palette = [
|
|
112
|
+
'#E6194B',
|
|
113
|
+
'#1F6FEB',
|
|
114
|
+
'#2E9E44',
|
|
115
|
+
'#F58231',
|
|
116
|
+
'#8E44D9',
|
|
117
|
+
'#0EA5B7',
|
|
118
|
+
'#E040B0',
|
|
119
|
+
'#8B5A2B',
|
|
120
|
+
'#307060',
|
|
121
|
+
'#9AB500',
|
|
122
|
+
'#D4A000',
|
|
123
|
+
'#6B7280',
|
|
124
|
+
];
|
|
112
125
|
|
|
113
126
|
export const paletteColor = (index: number) => palette[index % palette.length]!;
|
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/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>
|
package/src/react/public.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The types of `@stefan.inc/feedback-engine/react`, written out so an app's compiler never reads the package's source
|
|
3
|
-
* under the app's own options. `public.
|
|
3
|
+
* under the app's own options. `packages/web/public-types.check.ts` fails the type check when they drift from `index.ts`.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export type FeedbackOptions = {
|