@stefan.inc/feedback-engine 1.0.1 → 1.1.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 +2 -2
- package/package.json +1 -1
- package/src/core/annotations.ts +12 -3
- package/src/core/session.ts +1 -0
- package/src/dom/procrastimate-icon.ts +3 -0
- package/src/editor/Editor.svelte +40 -23
- package/src/editor/destinations.ts +25 -0
- package/src/editor/engine.ts +2 -1
- package/src/react/public.d.ts +2 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@ Alt+Meta+click anything in the browser, click any component on the frozen screen
|
|
|
8
8
|
|
|
9
9
|
| The editor in the browser | The `feedback.png` it exports |
|
|
10
10
|
| :---: | :---: |
|
|
11
|
-
| <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-editor.png" alt="The Feedback editor in Google Chrome over the React example: the page's screenshot on the left with four notes numbered 1
|
|
11
|
+
| <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-editor.png" alt="The Feedback editor in Google Chrome over the React example: the page's screenshot on the left with four notes numbered 1 to 4 and an @5 tag on the New List button, and the panel on the right with the Groceries row, a ListRow, selected and its note, Show a progress bar here." width="320"> | <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-export.png" alt="The feedback.png exported from the browser: the page with four numbered boxes and the New List button tagged @5. Each box links to a card with its note, the component or element, and its file:line, and the app's details sit at the top right. The note on Settings reads Move this next to @5_Button." width="520"> |
|
|
12
12
|
|
|
13
|
-
Four notes on the React example in Google Chrome. The last one points at a second element. Type `@`, click the element, and the note reads `Move this next to @
|
|
13
|
+
Four notes on the React example in Google Chrome. The last one points at a second element. Type `@`, click the element, and the note reads `Move this next to @5_Button`. The export draws that element's box and highlights the token in the same color, so an agent knows which button you meant. Each card names its component or element and the `file:line` it comes from, such as `src/components/ListRow.tsx:4`.
|
|
14
14
|
|
|
15
15
|
Prefer structured data? Share JSON for the whole component tree, each component's data, and the app context you attached, or both in one ZIP. A [webhook](#webhooks) adds a Share entry that posts both to a server of yours in one click, such as one that files a GitHub issue. [The report format](https://github.com/smirea/feedback-engine/blob/master/spec/report.md) is the same on every platform.
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stefan.inc/feedback-engine",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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
|
@@ -12,12 +12,14 @@ export const tag = (reference: Reference) => `@${reference.number}`;
|
|
|
12
12
|
/**
|
|
13
13
|
* Everything a share exports besides the capture. Items and references share one count: a node takes the next number
|
|
14
14
|
* and color the first time it is flagged or referenced, and keeps them for the capture, so no two boxes show the same
|
|
15
|
-
* number.
|
|
15
|
+
* number. A new item that references other nodes holds its number before theirs. Removing an item leaves its number
|
|
16
|
+
* unused, since tokens in other texts may still name it.
|
|
16
17
|
*/
|
|
17
18
|
export class Annotations {
|
|
18
19
|
items: FeedbackItem[] = [];
|
|
19
20
|
references: Reference[] = [];
|
|
20
|
-
|
|
21
|
+
/** Nodes in the order they took their numbers. `undefined` is the number held for the next new item. */
|
|
22
|
+
private marked: (number | undefined)[] = [];
|
|
21
23
|
|
|
22
24
|
colorIndex(node: number) {
|
|
23
25
|
const index = this.marked.indexOf(node);
|
|
@@ -36,10 +38,17 @@ export class Annotations {
|
|
|
36
38
|
item.text = text;
|
|
37
39
|
} else {
|
|
38
40
|
this.items.push({ id: crypto.randomUUID(), target, text });
|
|
39
|
-
this.
|
|
41
|
+
const held = this.marked.indexOf(undefined);
|
|
42
|
+
if (held !== -1 && !this.marked.includes(target)) this.marked[held] = target;
|
|
43
|
+
else this.mark(target);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/** Holds the next number for the new item being written, so the nodes it references number after it. */
|
|
48
|
+
reserve() {
|
|
49
|
+
if (!this.marked.includes(undefined)) this.marked.push(undefined);
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
remove(id: string) {
|
|
44
53
|
this.items = this.items.filter(item => item.id !== id);
|
|
45
54
|
}
|
package/src/core/session.ts
CHANGED
|
@@ -100,6 +100,7 @@ export class Session {
|
|
|
100
100
|
insertReference() {
|
|
101
101
|
const node = this.referenceTarget;
|
|
102
102
|
if (!node) return;
|
|
103
|
+
if (!this.editing) this.annotations.reserve();
|
|
103
104
|
this.text = `${this.text.slice(0, -1)}${this.annotations.reference(node).token} `;
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** ProcrastiMate's app icon without its tile, 66 pixels square for 22 CSS pixels. Rendered by `scripts/procrastimate-icon.ts` from ProcrastiMate's `app-icon.svg`. */
|
|
2
|
+
export const procrastimateIcon =
|
|
3
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAABiVBMVEVHcEwUPIM3if03ifs1hf81jf83if03ifw4if83ifw3ifwUNHQ3if03ifw3ifw3if03ifw3if03ifw4ifw2if83ifw3ifw3ifwOLGo3ifs3ifw3ifo3iPoZRpMVPIQcTJkyfOn99uU3ifwEFUc4ifwbcPT99uYEFUZCTW/08eYKG0wmYsBLlPq/vr2Oo8Nob4caK1dTapXw7uQQI1YkW7QlYLvM2ONudYpno/cqbM83R2shMlsqOWK5z+vW3+j69ORNV3VhaoEmd/Ti5ucXQIqxyqTn4tc0QWVZY3wPJ1/c4+eAlLaru9KnxO1cnPaZvu9NjvEtdNt6gJIdSpcxfOjo6uc0g/QnZcSfss91iKqPk5+UpsPE0+WDiJh8r/SQuvJheqaBmsFtoe+pqrCho6t5kIZJXIXFxMKFnI3a189Yc6KEr+4mU6CJm7l3pu/W0824xNQyfu5wi7VLYG27ydqPqdDOzMePp5JvhYA9UX4weOJt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qez0L4MeiQbo0Ik6iwvAQXEvNl1KOcCHxIWNlNlMtBtWqvyDu/6+xMvh1m74aJnsICHVmM5SaB5hUAh2MEbCCDbYBMj0M5mWLRWfLsMrBYFmMqhY2z9AQI5/s5mzsCE/L6RojxEGJRwsOrr91Xkoqw9C+uto7A+hCvxMEq+DAJwD9XyqRYz5K+guJiURhUT68gCgfAh/XVNVDdC+A4fCMHAp/EmKKHMH8OBb4Fc8GlQvUEjeE0v5Zz+lqel89AGMWqJzTeG/wJ3WRPLFUhEiKqhPd5/7eje5HTo4qIEoLKAs7O2nWZqjvQl5HfrxNiz+fz7YHNXAkF+W6hu7ZeaGKIDEDV4U+M4LvC4yE0WGVhPI90vVUQ6ThQBN9bPBoSB/luxaaDaDVjwWyKIrzJ9hEWMZ5FW+1paGCRmaI9BkOg4RlAg5wWQqsOotvIog/MYMcMGBllCFSXAb0WL0waA43FAC42xHWUIYwqBWhAr0W7vtnVs8AQAZ9mo3GsA7kMLFoa6oaEslBkpFRUZata1K4D93punkW+Gkyfb4TtDyMLe00D2sGzoBDgL4owU42vTgtXvVaLsRhnLtNkSyk6kCuPghqLdrM+x1nNEQUi+8a3l+WzVQyqe8JV50PMo2ZqTssPTQfyzKFlxqH51SMd+AKKFs3avqIkLhAOnsbHP0UKKFlUcpW7TktigWTGo182LU5L9289SPIbLSmJDovX9dRPtKbXv/xUY69//fHd/j/Yf9pylQ+uqoR2AAAAAElFTkSuQmCC';
|
package/src/editor/Editor.svelte
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
type ExportFormat,
|
|
24
24
|
} from '../dom/share.ts';
|
|
25
25
|
import type { Webhook } from '../dom/webhook.ts';
|
|
26
|
+
import { destinations, shortcutCount, type Destination } from './destinations.ts';
|
|
26
27
|
import type { Engine } from './engine.ts';
|
|
27
28
|
import ItemsSheet from './ItemsSheet.svelte';
|
|
28
29
|
import ProcrastimateSheet from './ProcrastimateSheet.svelte';
|
|
@@ -91,6 +92,8 @@
|
|
|
91
92
|
let showsShare = $state(false);
|
|
92
93
|
let showsProcrastimate = $state(false);
|
|
93
94
|
let posting = $state<Webhook>();
|
|
95
|
+
// svelte-ignore state_referenced_locally
|
|
96
|
+
const targets = destinations(engine.options);
|
|
94
97
|
let confirmsClose = $state(false);
|
|
95
98
|
let pending = $state<{ format: ExportFormat; ready: Export }>();
|
|
96
99
|
let busy = $state(false);
|
|
@@ -209,6 +212,12 @@
|
|
|
209
212
|
}
|
|
210
213
|
}
|
|
211
214
|
|
|
215
|
+
function send(destination: Destination) {
|
|
216
|
+
showsShare = false;
|
|
217
|
+
if (destination.kind === 'procrastimate') showsProcrastimate = true;
|
|
218
|
+
else posting = destination.webhook;
|
|
219
|
+
}
|
|
220
|
+
|
|
212
221
|
async function choose(format: ExportFormat) {
|
|
213
222
|
showsShare = false;
|
|
214
223
|
busy = true;
|
|
@@ -271,6 +280,22 @@
|
|
|
271
280
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01" /></svg>
|
|
272
281
|
{#if view.items.length}<span class="count" aria-hidden="true">{view.items.length}</span>{/if}
|
|
273
282
|
</button>
|
|
283
|
+
{#each targets.slice(0, shortcutCount) as destination, index (index)}
|
|
284
|
+
<button
|
|
285
|
+
type="button"
|
|
286
|
+
class="round"
|
|
287
|
+
aria-label={destination.name}
|
|
288
|
+
title={destination.name}
|
|
289
|
+
disabled={!view.items.length || busy}
|
|
290
|
+
onclick={() => send(destination)}
|
|
291
|
+
>
|
|
292
|
+
{#if destination.image}
|
|
293
|
+
<img src={destination.image} alt="" />
|
|
294
|
+
{:else}
|
|
295
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" /></svg>
|
|
296
|
+
{/if}
|
|
297
|
+
</button>
|
|
298
|
+
{/each}
|
|
274
299
|
<div class="menu">
|
|
275
300
|
<button
|
|
276
301
|
type="button"
|
|
@@ -288,28 +313,10 @@
|
|
|
288
313
|
{#each Object.entries(exportTitles) as [format, name] (format)}
|
|
289
314
|
<button type="button" role="menuitem" onclick={() => void choose(format as ExportFormat)}>{name}</button>
|
|
290
315
|
{/each}
|
|
291
|
-
{#
|
|
292
|
-
<button
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
onclick={() => {
|
|
296
|
-
showsShare = false;
|
|
297
|
-
showsProcrastimate = true;
|
|
298
|
-
}}>ProcrastiMate</button
|
|
299
|
-
>
|
|
300
|
-
{/if}
|
|
301
|
-
{#each engine.options.webhooks ?? [] as webhook, index (index)}
|
|
302
|
-
<button
|
|
303
|
-
type="button"
|
|
304
|
-
role="menuitem"
|
|
305
|
-
class="webhook"
|
|
306
|
-
onclick={() => {
|
|
307
|
-
showsShare = false;
|
|
308
|
-
posting = webhook;
|
|
309
|
-
}}
|
|
310
|
-
>
|
|
311
|
-
{#if webhook.image}<img src={webhook.image} alt="" />{/if}
|
|
312
|
-
{webhook.name}
|
|
316
|
+
{#each targets as destination, index (index)}
|
|
317
|
+
<button type="button" role="menuitem" class="destination" onclick={() => send(destination)}>
|
|
318
|
+
{#if destination.image}<img src={destination.image} alt="" />{/if}
|
|
319
|
+
{destination.name}
|
|
313
320
|
</button>
|
|
314
321
|
{/each}
|
|
315
322
|
</div>
|
|
@@ -624,7 +631,11 @@
|
|
|
624
631
|
|
|
625
632
|
h1 {
|
|
626
633
|
flex: 1;
|
|
634
|
+
min-width: 0;
|
|
627
635
|
margin: 0;
|
|
636
|
+
overflow: hidden;
|
|
637
|
+
text-overflow: ellipsis;
|
|
638
|
+
white-space: nowrap;
|
|
628
639
|
font-size: 17px;
|
|
629
640
|
font-weight: 600;
|
|
630
641
|
text-align: center;
|
|
@@ -641,6 +652,12 @@
|
|
|
641
652
|
background: #2c2c2e;
|
|
642
653
|
}
|
|
643
654
|
|
|
655
|
+
.round img {
|
|
656
|
+
width: 22px;
|
|
657
|
+
height: 22px;
|
|
658
|
+
object-fit: contain;
|
|
659
|
+
}
|
|
660
|
+
|
|
644
661
|
.round.small {
|
|
645
662
|
width: 30px;
|
|
646
663
|
height: 30px;
|
|
@@ -698,7 +715,7 @@
|
|
|
698
715
|
background: rgb(255 255 255 / 0.08);
|
|
699
716
|
}
|
|
700
717
|
|
|
701
|
-
.popup .
|
|
718
|
+
.popup .destination {
|
|
702
719
|
display: flex;
|
|
703
720
|
align-items: center;
|
|
704
721
|
gap: 10px;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ProcrastimateConfig } from '../dom/procrastimate.ts';
|
|
2
|
+
import { procrastimateIcon } from '../dom/procrastimate-icon.ts';
|
|
3
|
+
import { githubIcon, type Webhook } from '../dom/webhook.ts';
|
|
4
|
+
|
|
5
|
+
/** A server the feedback can be posted to, as the Share menu lists it after the exports. */
|
|
6
|
+
export type Destination = { name: string; image?: string } & (
|
|
7
|
+
| { kind: 'procrastimate' }
|
|
8
|
+
| { kind: 'webhook'; webhook: Webhook }
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
/** How many destinations also get a button beside Share. */
|
|
12
|
+
export const shortcutCount = 2;
|
|
13
|
+
|
|
14
|
+
/** ProcrastiMate first, then the webhooks with GitHub's icon, then the other webhooks in the app's order. */
|
|
15
|
+
export function destinations(options: { procrastimate?: ProcrastimateConfig; webhooks?: Webhook[] }): Destination[] {
|
|
16
|
+
const webhooks = [...(options.webhooks ?? [])].sort(
|
|
17
|
+
(a, b) => Number(b.image === githubIcon) - Number(a.image === githubIcon),
|
|
18
|
+
);
|
|
19
|
+
return [
|
|
20
|
+
...(options.procrastimate
|
|
21
|
+
? [{ kind: 'procrastimate' as const, name: 'ProcrastiMate', image: procrastimateIcon }]
|
|
22
|
+
: []),
|
|
23
|
+
...webhooks.map(webhook => ({ kind: 'webhook' as const, name: webhook.name, image: webhook.image, webhook })),
|
|
24
|
+
];
|
|
25
|
+
}
|
package/src/editor/engine.ts
CHANGED
|
@@ -27,7 +27,8 @@ export type FeedbackOptions = {
|
|
|
27
27
|
procrastimate?: ProcrastimateConfig;
|
|
28
28
|
/**
|
|
29
29
|
* Adds one entry to the Share menu per webhook. Choosing it posts the image export and the JSON export to the
|
|
30
|
-
* webhook's `url`, with nothing more to fill in.
|
|
30
|
+
* webhook's `url`, with nothing more to fill in. The menu lists ProcrastiMate, then the webhooks with `githubIcon`,
|
|
31
|
+
* then the others, and the first two of them also get a button beside Share.
|
|
31
32
|
*/
|
|
32
33
|
webhooks?: Webhook[];
|
|
33
34
|
};
|
package/src/react/public.d.ts
CHANGED
|
@@ -32,7 +32,8 @@ export type FeedbackOptions = {
|
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Adds one entry to the Share menu per webhook. Choosing it posts the image export and the JSON export to the
|
|
35
|
-
* webhook's `url`, with nothing more to fill in.
|
|
35
|
+
* webhook's `url`, with nothing more to fill in. The menu lists ProcrastiMate, then the webhooks with `githubIcon`,
|
|
36
|
+
* then the others, and the first two of them also get a button beside Share.
|
|
36
37
|
*/
|
|
37
38
|
webhooks?: Webhook[];
|
|
38
39
|
};
|