@hachej/boring-feedback 0.4.2 → 0.4.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/dist/ui/session.d.ts +6 -0
- package/dist/ui/session.js +26 -1
- package/package.json +4 -4
package/dist/ui/session.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export interface SessionNote {
|
|
|
57
57
|
readonly fallback?: string;
|
|
58
58
|
/** The anchor's development source location (`src/settings/SaveBar.tsx:42`), when it has one. */
|
|
59
59
|
readonly source?: string;
|
|
60
|
+
/** The `data-feedback-id` of the element, or else of its nearest marked ancestor, when the policy kept it: what a host viewer matches pins on. */
|
|
61
|
+
readonly feedbackId?: string;
|
|
60
62
|
readonly from?: 'voice';
|
|
61
63
|
/** Pinned while recording: its note is what was said there (empty until transcribed, or when nothing was). */
|
|
62
64
|
readonly recorded?: true;
|
|
@@ -137,6 +139,10 @@ export interface FeedbackSession extends ExternalState<FeedbackSessionSnapshot>
|
|
|
137
139
|
readonly start: (options?: SessionStartOptions) => void;
|
|
138
140
|
/** From the review, back to picking with the notes kept (more notes before Send); otherwise like `start`. */
|
|
139
141
|
readonly resume: (options?: SessionStartOptions) => void;
|
|
142
|
+
/** A trusted viewer's host-DOM proxy for an opaque frame pick. Uses the same root, privacy and anchor checks as page picking. */
|
|
143
|
+
readonly pick: (element: Element) => void;
|
|
144
|
+
/** A trusted viewer moved its proxy elements. Refreshes pin and bubble placement without changing the notes. */
|
|
145
|
+
readonly reposition: () => void;
|
|
140
146
|
/** Done: closes feedback mode, transcribes and aligns voice, and leaves the draft for review. */
|
|
141
147
|
readonly done: () => Promise<void>;
|
|
142
148
|
/** ✕: discards everything (feedback mode or the attached draft). */
|
package/dist/ui/session.js
CHANGED
|
@@ -43,6 +43,24 @@ function readTranscription(answer) {
|
|
|
43
43
|
const NAMED_KEYS = new Set(['Enter', 'Escape', 'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageUp', 'PageDown', 'Home', 'End']);
|
|
44
44
|
const MAX_ELEMENTS = 500;
|
|
45
45
|
const MAX_TRAIL = 5000;
|
|
46
|
+
/** The anchor's own `data-feedback-id`, or the one its path starts from (`[data-feedback-id="…"]`: its nearest marked ancestor). */
|
|
47
|
+
function markedId(signals) {
|
|
48
|
+
if (signals === null || typeof signals !== 'object' || Array.isArray(signals))
|
|
49
|
+
return undefined;
|
|
50
|
+
const { feedbackId, path } = signals;
|
|
51
|
+
if (typeof feedbackId === 'string')
|
|
52
|
+
return feedbackId;
|
|
53
|
+
const base = Array.isArray(path) && typeof path[0] === 'string' ? /^\[data-feedback-id=(".*")\]$/.exec(path[0])?.[1] : undefined;
|
|
54
|
+
if (base === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
try {
|
|
57
|
+
const value = JSON.parse(base);
|
|
58
|
+
return typeof value === 'string' ? value : undefined;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
46
64
|
/** Point mode is on (or finishing): the host hides its panel while this is true and shows it again when it turns false. */
|
|
47
65
|
export function isPointing(state) {
|
|
48
66
|
return state.mode === 'point' && (state.phase === 'active' || state.phase === 'processing');
|
|
@@ -122,8 +140,9 @@ export function createFeedbackSession(options) {
|
|
|
122
140
|
const signals = anchor?.['signals'];
|
|
123
141
|
const found = signals !== null && typeof signals === 'object' && !Array.isArray(signals) ? signals.source : undefined;
|
|
124
142
|
const source = typeof found === 'string' ? found : undefined;
|
|
143
|
+
const feedbackId = markedId(signals);
|
|
125
144
|
return Object.freeze({ id: note.id, number: index + 1, text: note.text, label: labelOf(note), ...(anchor ? { fallback: String(anchor['fallback']) } : {}),
|
|
126
|
-
...(source !== undefined ? { source } : {}), ...(note.from ? { from: note.from } : {}), ...(note.recorded ? { recorded: true } : {}) });
|
|
145
|
+
...(source !== undefined ? { source } : {}), ...(feedbackId !== undefined ? { feedbackId } : {}), ...(note.from ? { from: note.from } : {}), ...(note.recorded ? { recorded: true } : {}) });
|
|
127
146
|
});
|
|
128
147
|
const open = bubble ? list.find(note => note.id === bubble.noteId) : undefined;
|
|
129
148
|
const { bubble: _bubble, problem: _problem, hover: _hover, ...base } = { ...state.getSnapshot(), ...change };
|
|
@@ -729,6 +748,12 @@ export function createFeedbackSession(options) {
|
|
|
729
748
|
subscribe: state.subscribe,
|
|
730
749
|
start,
|
|
731
750
|
resume,
|
|
751
|
+
pick: element => {
|
|
752
|
+
if (state.getSnapshot().using || pickRefusal(element, root) !== undefined)
|
|
753
|
+
return;
|
|
754
|
+
onPick(element);
|
|
755
|
+
},
|
|
756
|
+
reposition: () => publish(),
|
|
732
757
|
done,
|
|
733
758
|
discard,
|
|
734
759
|
setBubbleText: text => { if (bubble) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hachej/boring-feedback",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@hachej/boring-ui-kit": "^0.4.
|
|
56
|
-
"@hachej/boring-files": "^0.4.
|
|
57
|
-
"@hachej/boring-agent": "^0.4.
|
|
55
|
+
"@hachej/boring-ui-kit": "^0.4.3",
|
|
56
|
+
"@hachej/boring-files": "^0.4.3",
|
|
57
|
+
"@hachej/boring-agent": "^0.4.3",
|
|
58
58
|
"@earendil-works/pi-durable": "~1.2.0",
|
|
59
59
|
"@earendil-works/pi-ai": "~1.2.0",
|
|
60
60
|
"@earendil-works/chord": "~1.2.0",
|