@heypointerhq/sdk 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +127 -2
- package/dist/author/capture.d.ts +53 -0
- package/dist/author/draft.d.ts +81 -0
- package/dist/author/flow.d.ts +31 -0
- package/dist/author/global.d.ts +1 -0
- package/dist/author/index.d.ts +49 -0
- package/dist/author/labels.d.ts +73 -0
- package/dist/author/panel.d.ts +61 -0
- package/dist/author/policy.d.ts +21 -0
- package/dist/author-import.d.ts +1 -0
- package/dist/author-import.iife.d.ts +1 -0
- package/dist/author-loader.d.ts +17 -0
- package/dist/author.js +750 -0
- package/dist/chunk-element.js +896 -0
- package/dist/chunk-theme.js +319 -0
- package/dist/client.d.ts +32 -0
- package/dist/contrast.d.ts +5 -0
- package/dist/element.d.ts +43 -0
- package/dist/element.js +1 -0
- package/dist/global.d.ts +2 -0
- package/dist/heypointer.author.js +2 -0
- package/dist/heypointer.global.js +2 -0
- package/dist/highlight.d.ts +21 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3 -0
- package/dist/labels.d.ts +81 -0
- package/dist/player.d.ts +193 -0
- package/dist/recorder.d.ts +12 -0
- package/dist/spotlight.d.ts +28 -0
- package/dist/targeting/index.d.ts +26 -0
- package/dist/targeting/watch.d.ts +6 -0
- package/dist/theme.d.ts +32 -0
- package/dist/types.d.ts +5 -0
- package/dist/validate.d.ts +6 -0
- package/package.json +58 -4
package/dist/author.js
ADDED
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { a as e, f as t, i as n, n as r, o as i, r as a, t as o, u as s } from "./chunk-theme.js";
|
|
2
|
+
// src/author/flow.ts
|
|
3
|
+
var c = 100, l = 120, u = 72, d = /^(send|submit|delete|remove|pay|purchase|buy|publish|transfer|confirm|deploy|cancel)\b/i, f = (e) => !!e && d.test(e.trim()), p = (e) => e.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").replace(/\s+/g, " ").trim(), m = (e) => p(e).replace(/["“”]/g, "'"), h = (e) => e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "flow", g = (e) => [...e.matchAll(/["“]([^"”]+)["”]/g)].map((e) => e[1]), _ = (e) => [...e.matchAll(/"([^"]+)"|“([^”]+)”/g)].map((e) => (e[1] ?? e[2] ?? "").trim()).filter(Boolean)[0] ?? "", v = (e) => /[.!?]$/.test(e.trim()) ? e.trim() : `${e.trim()}.`;
|
|
4
|
+
function y(e, t = !1) {
|
|
5
|
+
let n = v(e), r = g(n).some((e) => f(e));
|
|
6
|
+
return (t || r) && !/\bconsequential\b/i.test(n) ? `${n} This is a consequential action.` : n;
|
|
7
|
+
}
|
|
8
|
+
function b(e, t = {}) {
|
|
9
|
+
let n = [`# PRD: ${e.title}`, ""];
|
|
10
|
+
return t.note && n.push(t.note, ""), e.steps.forEach((e, r) => n.push(`${r + 1}. ${y(e, t.consequential?.has(r))}`)), `${n.join("\n")}\n`;
|
|
11
|
+
}
|
|
12
|
+
function ee(e, t) {
|
|
13
|
+
let n = [];
|
|
14
|
+
return p(e.title) || n.push(t), e.steps.length === 0 && n.push("a flow needs at least one step"), e.steps.forEach((e, t) => {
|
|
15
|
+
_(e) || n.push(`step ${t + 1} names no control: put the visible label in quotes, e.g. Click "Change plan"`);
|
|
16
|
+
}), n;
|
|
17
|
+
}
|
|
18
|
+
function x(e) {
|
|
19
|
+
let t = e.split("/").map((e) => {
|
|
20
|
+
let t = e;
|
|
21
|
+
try {
|
|
22
|
+
t = decodeURIComponent(e);
|
|
23
|
+
} catch {}
|
|
24
|
+
return /^\d{4,}$/.test(t) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(t) || /^[0-9a-f]{16,}$/i.test(t) || t.length > 40 ? ":id" : p(t).replace(/[^\w.~:-]/g, "_");
|
|
25
|
+
}).join("/") || "/";
|
|
26
|
+
return t.startsWith("/") ? t : `/${t}`;
|
|
27
|
+
}
|
|
28
|
+
// src/author/policy.ts
|
|
29
|
+
var S = /pass|token|secret|otp|card|cvv|cvc|iban|ssn|pin\b/i, te = /^(cc-|one-time-code|current-password|new-password)/i, C = (e) => e && e.nodeType === 1 ? e.tagName.toLowerCase() : "", w = (e) => (e.getAttribute("type") ?? "").toLowerCase();
|
|
30
|
+
function T(e) {
|
|
31
|
+
let t = C(e);
|
|
32
|
+
return t !== "input" && t !== "textarea" && t !== "select" ? !1 : t === "input" && w(e) === "password" || (e.getAttribute("autocomplete") ?? "").split(/\s+/).some((e) => te.test(e)) ? !0 : S.test(e.getAttribute("name") ?? "") || S.test(e.id);
|
|
33
|
+
}
|
|
34
|
+
var ne = "input, select, textarea";
|
|
35
|
+
function E(e) {
|
|
36
|
+
return m((e.matches(ne) ? e.getAttribute("aria-label") || Array.from(e.labels ?? []).map((e) => e.textContent ?? "").join(" ") : n(e)) ?? "").slice(0, 144);
|
|
37
|
+
}
|
|
38
|
+
var re = /[^\s@]+@[^\s@]+\.[a-z]{2,}/i, ie = /\d[\d\s().-]{4,}\d/, D = /[$€£¥]\s?\d|\d[.,]\d{2}\b/, O = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i, k = /^(?:[A-Z][\p{L}'’-]+)(?:\s+[A-Z][\p{L}'’-]+){1,3}$/u, ae = "tr, td, th, li, [role=\"row\"], [role=\"gridcell\"], [role=\"cell\"], [role=\"listitem\"], [role=\"option\"], article, [role=\"article\"]";
|
|
39
|
+
function A(e, t) {
|
|
40
|
+
return !!(re.test(e) || ie.test(e) || D.test(e) || O.test(e) || t?.closest(ae) && (k.test(e) || /\d/.test(e)));
|
|
41
|
+
}
|
|
42
|
+
var oe = "button, a[href], summary, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], input[type=\"image\"], input[type=\"checkbox\"], input[type=\"radio\"], [role=\"button\"], [role=\"link\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"tab\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"option\"]", j = (e) => e.disabled === !0 || e.getAttribute("aria-disabled") === "true" || !!e.closest("fieldset:disabled"), M = (t) => e(t) && !j(t), se = /* @__PURE__ */ new Set([
|
|
43
|
+
"text",
|
|
44
|
+
"search",
|
|
45
|
+
"email",
|
|
46
|
+
"tel",
|
|
47
|
+
"url",
|
|
48
|
+
"number",
|
|
49
|
+
"password",
|
|
50
|
+
"date",
|
|
51
|
+
"datetime-local",
|
|
52
|
+
"month",
|
|
53
|
+
"week",
|
|
54
|
+
"time",
|
|
55
|
+
""
|
|
56
|
+
]), ce = (e) => C(e) === "textarea" || C(e) === "input" && se.has(w(e));
|
|
57
|
+
function N(e) {
|
|
58
|
+
for (let t = e.parentElement; t; t = t.parentElement) {
|
|
59
|
+
let e = t.getAttribute("role");
|
|
60
|
+
if (!t.matches("dialog, form, nav, section, aside, [role=\"dialog\"], [role=\"alertdialog\"], [role=\"region\"], [role=\"form\"], [role=\"navigation\"], [role=\"menu\"], [role=\"toolbar\"]") && !t.hasAttribute("aria-label")) continue;
|
|
61
|
+
let n = t.getAttribute("aria-label") ?? "", r = t.getAttribute("aria-labelledby");
|
|
62
|
+
if (!n && r && (n = r.split(/\s+/).map((e) => t.ownerDocument.getElementById(e)?.textContent ?? "").join(" ")), n || e !== "dialog" && t.tagName !== "DIALOG" || (n = t.querySelector("h1, h2, h3")?.textContent ?? ""), n = m(n).slice(0, 40), n) return n;
|
|
63
|
+
}
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
// src/author/capture.ts
|
|
67
|
+
var le = "tr, td, th, li, [role=\"row\"], [role=\"gridcell\"], [role=\"cell\"], [role=\"listitem\"]", ue = 400, P = (e) => {
|
|
68
|
+
if (e.parentElement) return e.parentElement;
|
|
69
|
+
let t = e.getRootNode();
|
|
70
|
+
return t.nodeType === 11 && t.host ? t.host : null;
|
|
71
|
+
}, F = class {
|
|
72
|
+
constructor(e) {
|
|
73
|
+
s(this, "o", void 0), s(this, "docs", /* @__PURE__ */ new Set()), s(this, "lastKey", ""), s(this, "lastAt", 0), s(this, "lastTyped", null), s(this, "lastPath", ""), s(this, "timer", void 0), s(this, "observer", void 0), s(this, "frameLoads", /* @__PURE__ */ new Map()), s(this, "onClick", (e) => {
|
|
74
|
+
let t = this.accept(e);
|
|
75
|
+
if (!t) return;
|
|
76
|
+
let n = this.control(t.target), r = !1;
|
|
77
|
+
if (!n && this.o.recordRows() && (n = t.target.closest(le), r = !!n), !n || j(n) || !M(n)) return;
|
|
78
|
+
let i = r ? E(n).slice(0, 72) : E(n);
|
|
79
|
+
this.emit({
|
|
80
|
+
kind: "click",
|
|
81
|
+
label: i,
|
|
82
|
+
sensitive: !1,
|
|
83
|
+
pageData: r || A(i, n),
|
|
84
|
+
context: N(n),
|
|
85
|
+
el: n
|
|
86
|
+
}, `click:${i}`);
|
|
87
|
+
}), s(this, "onInput", (e) => {
|
|
88
|
+
let t = this.accept(e);
|
|
89
|
+
if (!t || !ce(t.target)) return;
|
|
90
|
+
let n = t.target;
|
|
91
|
+
if (this.lastTyped === n || !M(n)) return;
|
|
92
|
+
let r = E(n);
|
|
93
|
+
this.emit({
|
|
94
|
+
kind: "type",
|
|
95
|
+
label: r,
|
|
96
|
+
sensitive: T(n),
|
|
97
|
+
pageData: !1,
|
|
98
|
+
context: N(n),
|
|
99
|
+
el: n
|
|
100
|
+
}, `type:${r}`), this.lastTyped = n;
|
|
101
|
+
}), s(this, "onChange", (e) => {
|
|
102
|
+
let t = this.accept(e);
|
|
103
|
+
if (!t) return;
|
|
104
|
+
let n = t.target;
|
|
105
|
+
if (!(C(n) === "select" || C(n) === "input" && w(n) === "file") || !M(n)) return;
|
|
106
|
+
let r = E(n);
|
|
107
|
+
this.emit({
|
|
108
|
+
kind: "select",
|
|
109
|
+
label: r,
|
|
110
|
+
sensitive: T(n),
|
|
111
|
+
pageData: !1,
|
|
112
|
+
context: N(n),
|
|
113
|
+
el: n
|
|
114
|
+
}, `select:${r}`);
|
|
115
|
+
}), s(this, "onSubmit", (e) => {
|
|
116
|
+
let t = this.accept(e);
|
|
117
|
+
if (!t || e.submitter) return;
|
|
118
|
+
let n = t.target.closest("form")?.querySelector("button[type=\"submit\"], button:not([type]), input[type=\"submit\"]");
|
|
119
|
+
if (!n || !M(n)) return;
|
|
120
|
+
let r = E(n);
|
|
121
|
+
this.emit({
|
|
122
|
+
kind: "click",
|
|
123
|
+
label: r,
|
|
124
|
+
sensitive: !1,
|
|
125
|
+
pageData: A(r, n),
|
|
126
|
+
context: N(n),
|
|
127
|
+
el: n
|
|
128
|
+
}, `click:${r}`);
|
|
129
|
+
}), this.o = e;
|
|
130
|
+
}
|
|
131
|
+
start() {
|
|
132
|
+
this.attach(document), this.scanFrames(document), this.lastPath = x(location.pathname), this.observer = new MutationObserver((e) => {
|
|
133
|
+
for (let t of e) for (let e of Array.from(t.addedNodes)) e instanceof Element && this.scanFrames(e.tagName === "IFRAME" ? e.ownerDocument : e);
|
|
134
|
+
}), this.observer.observe(document.documentElement, {
|
|
135
|
+
childList: !0,
|
|
136
|
+
subtree: !0
|
|
137
|
+
}), this.timer = setInterval(() => this.checkRoute(), 500);
|
|
138
|
+
}
|
|
139
|
+
stop() {
|
|
140
|
+
this.observer?.disconnect(), this.timer && clearInterval(this.timer);
|
|
141
|
+
for (let [e, t] of this.frameLoads) e.removeEventListener("load", t);
|
|
142
|
+
this.frameLoads.clear();
|
|
143
|
+
for (let e of this.docs) this.detach(e);
|
|
144
|
+
this.docs.clear();
|
|
145
|
+
}
|
|
146
|
+
checkRoute() {
|
|
147
|
+
if (!this.o.isRecording()) return;
|
|
148
|
+
let e = x(location.pathname);
|
|
149
|
+
e !== this.lastPath && (this.lastPath = e, this.o.onPage(e));
|
|
150
|
+
}
|
|
151
|
+
syncRoute() {
|
|
152
|
+
this.lastPath = x(location.pathname);
|
|
153
|
+
}
|
|
154
|
+
scanFrames(e) {
|
|
155
|
+
let t = C(e) === "iframe" ? [e] : Array.from(e.querySelectorAll("iframe"));
|
|
156
|
+
for (let e of t) {
|
|
157
|
+
if (!this.frameLoads.has(e)) {
|
|
158
|
+
let t = () => this.attachFrame(e);
|
|
159
|
+
e.addEventListener("load", t), this.frameLoads.set(e, t);
|
|
160
|
+
}
|
|
161
|
+
this.attachFrame(e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
attachFrame(e) {
|
|
165
|
+
try {
|
|
166
|
+
let t = e.contentDocument;
|
|
167
|
+
t && t.defaultView && !this.docs.has(t) && this.attach(t);
|
|
168
|
+
} catch {}
|
|
169
|
+
}
|
|
170
|
+
attach(e) {
|
|
171
|
+
e.addEventListener("click", this.onClick, !0), e.addEventListener("input", this.onInput, !0), e.addEventListener("change", this.onChange, !0), e.addEventListener("submit", this.onSubmit, !0), this.docs.add(e);
|
|
172
|
+
}
|
|
173
|
+
detach(e) {
|
|
174
|
+
e.removeEventListener("click", this.onClick, !0), e.removeEventListener("input", this.onInput, !0), e.removeEventListener("change", this.onChange, !0), e.removeEventListener("submit", this.onSubmit, !0);
|
|
175
|
+
}
|
|
176
|
+
accept(e) {
|
|
177
|
+
if (!this.o.isRecording() || !e.isTrusted && !this.o.acceptUntrusted) return null;
|
|
178
|
+
let t = e.composedPath();
|
|
179
|
+
if (this.o.isOwn(t)) return null;
|
|
180
|
+
let n = t[0], r = n?.nodeType === 1 ? n : n?.nodeType === 3 ? n.parentElement : null;
|
|
181
|
+
return r ? {
|
|
182
|
+
path: t,
|
|
183
|
+
target: r
|
|
184
|
+
} : null;
|
|
185
|
+
}
|
|
186
|
+
emit(e, t) {
|
|
187
|
+
let n = Date.now();
|
|
188
|
+
t === this.lastKey && n - this.lastAt < ue || (this.lastKey = t, this.lastAt = n, e.kind !== "type" && (this.lastTyped = null), this.o.onStep(e));
|
|
189
|
+
}
|
|
190
|
+
control(e) {
|
|
191
|
+
for (let t = e, n = 0; t && n < 10; t = P(t), n++) if (C(t) === "label") {
|
|
192
|
+
if (t.control) return null;
|
|
193
|
+
} else if (t.matches(oe)) return t;
|
|
194
|
+
let t = null, n = e;
|
|
195
|
+
for (let e = 0; n && e < 4; n = P(n), e++) if (n.nodeType === 1 && n.ownerDocument.defaultView?.getComputedStyle(n).cursor === "pointer") t = n;
|
|
196
|
+
else if (t) break;
|
|
197
|
+
return t && E(t).length <= 72 ? t : null;
|
|
198
|
+
}
|
|
199
|
+
}, I = {
|
|
200
|
+
click: (e) => `Click "${e}".`,
|
|
201
|
+
type: (e) => `Enter your ${e.toLowerCase().slice(0, 30).trim()} in "${e}".`,
|
|
202
|
+
select: (e) => `Choose an option in "${e}".`
|
|
203
|
+
};
|
|
204
|
+
function L(e, t) {
|
|
205
|
+
let n = m(t).slice(0, 72).trim();
|
|
206
|
+
return n ? I[e](n) : e === "click" ? "Click the control." : e === "type" ? "Enter a value." : "Choose an option.";
|
|
207
|
+
}
|
|
208
|
+
var R = (e) => e.entries.filter((e) => e.t === "step"), z = (e) => e.consequential || f(_(e.text));
|
|
209
|
+
function B(e) {
|
|
210
|
+
let t = R(e), n = e.entries.filter((e) => e.t === "note").map((e) => e.text), r = ["Recorded with HeyPointer author mode. Review every step before publishing.", n.length ? `Pages visited while recording: ${[...new Set(n)].join(", ")}.` : ""].filter(Boolean).join(" "), i = /* @__PURE__ */ new Set();
|
|
211
|
+
return t.forEach((e, t) => e.consequential && i.add(t)), b({
|
|
212
|
+
title: p(e.title),
|
|
213
|
+
steps: t.map((e) => e.text)
|
|
214
|
+
}, {
|
|
215
|
+
consequential: i,
|
|
216
|
+
note: r
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
var V = (e, t) => ee({
|
|
220
|
+
title: e.title,
|
|
221
|
+
steps: R(e).map((e) => e.text)
|
|
222
|
+
}, t), H = (e) => `${h(e.title)}.md`, de = class {
|
|
223
|
+
constructor(e) {
|
|
224
|
+
s(this, "draft", void 0), s(this, "nextId", 1), s(this, "listeners", /* @__PURE__ */ new Set()), this.draft = e ?? {
|
|
225
|
+
title: "",
|
|
226
|
+
entries: []
|
|
227
|
+
}, this.nextId = this.draft.entries.reduce((e, t) => Math.max(e, t.id), 0) + 1;
|
|
228
|
+
}
|
|
229
|
+
subscribe(e) {
|
|
230
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
231
|
+
}
|
|
232
|
+
emit() {
|
|
233
|
+
for (let e of this.listeners) e();
|
|
234
|
+
}
|
|
235
|
+
get stepCount() {
|
|
236
|
+
return R(this.draft).length;
|
|
237
|
+
}
|
|
238
|
+
get full() {
|
|
239
|
+
return this.stepCount >= 100;
|
|
240
|
+
}
|
|
241
|
+
setTitle(e) {
|
|
242
|
+
this.draft.title = p(e).slice(0, 80), this.emit();
|
|
243
|
+
}
|
|
244
|
+
addStep(e) {
|
|
245
|
+
if (this.full) return null;
|
|
246
|
+
let t = {
|
|
247
|
+
...e,
|
|
248
|
+
t: "step",
|
|
249
|
+
id: this.nextId++,
|
|
250
|
+
text: e.text.slice(0, 120)
|
|
251
|
+
};
|
|
252
|
+
return this.draft.entries.push(t), this.emit(), t;
|
|
253
|
+
}
|
|
254
|
+
addNote(e) {
|
|
255
|
+
let t = this.draft.entries[this.draft.entries.length - 1];
|
|
256
|
+
(t?.t !== "note" || t.text !== e) && (this.draft.entries.push({
|
|
257
|
+
t: "note",
|
|
258
|
+
id: this.nextId++,
|
|
259
|
+
text: e
|
|
260
|
+
}), this.emit());
|
|
261
|
+
}
|
|
262
|
+
find(e) {
|
|
263
|
+
return this.draft.entries.find((t) => t.id === e);
|
|
264
|
+
}
|
|
265
|
+
editText(e, t, n = !1) {
|
|
266
|
+
let r = this.find(e);
|
|
267
|
+
return r?.t === "step" ? (r.text = p(t).slice(0, 120), n || this.emit(), r) : null;
|
|
268
|
+
}
|
|
269
|
+
setStatus(e, t, n) {
|
|
270
|
+
let r = this.find(e);
|
|
271
|
+
r?.t === "step" && (r.status = t, n !== void 0 && (r.pageData = n), this.emit());
|
|
272
|
+
}
|
|
273
|
+
toggleConsequential(e) {
|
|
274
|
+
let t = this.find(e);
|
|
275
|
+
t?.t === "step" && (t.consequential = !t.consequential, this.emit());
|
|
276
|
+
}
|
|
277
|
+
move(e, t) {
|
|
278
|
+
let n = this.draft.entries, r = n.filter((e) => e.t === "step"), i = r.findIndex((t) => t.id === e), a = i + t;
|
|
279
|
+
if (i < 0 || a < 0 || a >= r.length) return;
|
|
280
|
+
let o = n.indexOf(r[i]), s = n.indexOf(r[a]);
|
|
281
|
+
[n[o], n[s]] = [n[s], n[o]], this.emit();
|
|
282
|
+
}
|
|
283
|
+
remove(e) {
|
|
284
|
+
this.draft.entries = this.draft.entries.filter((t) => t.id !== e), this.emit();
|
|
285
|
+
}
|
|
286
|
+
undo() {
|
|
287
|
+
let e = this.draft.entries, t = e.length - 1;
|
|
288
|
+
for (; t >= 0 && e[t].t === "note";) t--;
|
|
289
|
+
return t < 0 ? !1 : (e.length = t, this.emit(), !0);
|
|
290
|
+
}
|
|
291
|
+
clear() {
|
|
292
|
+
this.draft = {
|
|
293
|
+
title: "",
|
|
294
|
+
entries: []
|
|
295
|
+
}, this.emit();
|
|
296
|
+
}
|
|
297
|
+
}, U = "heypointer:author:draft:v1", W = "heypointer:author:active:v1", fe = (e) => !!e && typeof e == "object" && [
|
|
298
|
+
"unique",
|
|
299
|
+
"ambiguous",
|
|
300
|
+
"noname",
|
|
301
|
+
"notfound",
|
|
302
|
+
"unchecked"
|
|
303
|
+
].includes(e.kind);
|
|
304
|
+
function pe(e) {
|
|
305
|
+
try {
|
|
306
|
+
let t = e?.getItem(U);
|
|
307
|
+
if (!t) return null;
|
|
308
|
+
let n = JSON.parse(t);
|
|
309
|
+
if (!n.draft || typeof n.draft.title != "string" || !Array.isArray(n.draft.entries)) return null;
|
|
310
|
+
let r = [];
|
|
311
|
+
for (let e of n.draft.entries.slice(0, 300)) e?.t === "note" && typeof e.text == "string" ? r.push({
|
|
312
|
+
t: "note",
|
|
313
|
+
id: Number(e.id) || r.length + 1,
|
|
314
|
+
text: p(e.text).slice(0, 120)
|
|
315
|
+
}) : e?.t === "step" && typeof e.text == "string" && [
|
|
316
|
+
"click",
|
|
317
|
+
"type",
|
|
318
|
+
"select"
|
|
319
|
+
].includes(e.kind) && fe(e.status) && r.push({
|
|
320
|
+
t: "step",
|
|
321
|
+
id: Number(e.id) || r.length + 1,
|
|
322
|
+
kind: e.kind,
|
|
323
|
+
text: p(e.text).slice(0, 120),
|
|
324
|
+
consequential: e.consequential === !0,
|
|
325
|
+
status: e.status,
|
|
326
|
+
pageData: e.pageData === !0,
|
|
327
|
+
sensitive: e.sensitive === !0,
|
|
328
|
+
context: typeof e.context == "string" ? p(e.context).slice(0, 40) : ""
|
|
329
|
+
});
|
|
330
|
+
return {
|
|
331
|
+
draft: {
|
|
332
|
+
title: p(n.draft.title).slice(0, 80),
|
|
333
|
+
entries: r
|
|
334
|
+
},
|
|
335
|
+
recording: n.recording === !0
|
|
336
|
+
};
|
|
337
|
+
} catch {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function me(e, t) {
|
|
342
|
+
try {
|
|
343
|
+
e?.setItem(U, JSON.stringify(t)), e?.setItem(W, "1");
|
|
344
|
+
} catch {}
|
|
345
|
+
}
|
|
346
|
+
function G(e) {
|
|
347
|
+
try {
|
|
348
|
+
e?.removeItem(U), e?.removeItem(W);
|
|
349
|
+
} catch {}
|
|
350
|
+
}
|
|
351
|
+
function K() {
|
|
352
|
+
try {
|
|
353
|
+
return typeof sessionStorage > "u" ? null : sessionStorage;
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// src/author/labels.ts
|
|
359
|
+
var q = {
|
|
360
|
+
authorDialogName: "HeyPointer author mode",
|
|
361
|
+
authorTitle: "Record steps",
|
|
362
|
+
authorMinimize: "Minimize",
|
|
363
|
+
authorClose: "Close author mode",
|
|
364
|
+
authorMove: "Move the panel to the other side",
|
|
365
|
+
authorSteps: "Steps ({count})",
|
|
366
|
+
authorAbout: "Privacy and shortcuts",
|
|
367
|
+
authorExpand: "Expand",
|
|
368
|
+
authorFlowTitle: "Flow title",
|
|
369
|
+
authorFlowTitlePlaceholder: "e.g. Add a product to the cart",
|
|
370
|
+
authorRecord: "Record",
|
|
371
|
+
authorPause: "Pause",
|
|
372
|
+
authorResume: "Resume",
|
|
373
|
+
authorStop: "Stop and review",
|
|
374
|
+
authorUndo: "Undo last step",
|
|
375
|
+
authorRows: "Record clicks on table rows and cells (they usually contain page data)",
|
|
376
|
+
authorStatusIdle: "Not recording. Press Record, then use your app the way a person would.",
|
|
377
|
+
authorStatusRecording: "Recording. {count} steps so far.",
|
|
378
|
+
authorStatusPaused: "Paused. {count} steps so far.",
|
|
379
|
+
authorStatusReview: "Review the draft. Nothing is sent anywhere.",
|
|
380
|
+
authorEmpty: "No steps yet. Click, type or choose something in your app.",
|
|
381
|
+
authorStepText: "Step {n} text",
|
|
382
|
+
authorMoveUp: "Move step {n} up",
|
|
383
|
+
authorMoveDown: "Move step {n} down",
|
|
384
|
+
authorDelete: "Delete step {n}",
|
|
385
|
+
authorDeleteNote: "Delete note",
|
|
386
|
+
authorConsequential: "Needs confirmation",
|
|
387
|
+
authorConsequentialAuto: "Needs confirmation (added automatically because of the label)",
|
|
388
|
+
authorChipUnique: "Unique control",
|
|
389
|
+
authorChipAmbiguous: "Ambiguous: {count} matches",
|
|
390
|
+
authorChipNoName: "No accessible name",
|
|
391
|
+
authorChipPageData: "Contains page data",
|
|
392
|
+
authorChipNotFound: "Not found by the guide",
|
|
393
|
+
authorChipUnchecked: "Not on this page",
|
|
394
|
+
authorChipSensitive: "Sensitive field",
|
|
395
|
+
authorHintAmbiguous: "The guide will not guess between {count} controls. Give this one an aria-label or visible text that is unique.",
|
|
396
|
+
authorHintNoName: "Add an aria-label or visible text so the guide can find this control.",
|
|
397
|
+
authorHintPageData: "This text looks like data from the page (a name, an email or a number). Change it so it names the control, not the data.",
|
|
398
|
+
authorHintNotFound: "The guide would not find a control with this exact text. Check the text, or give the control a role and a label.",
|
|
399
|
+
authorHintUnchecked: "This control is not on the current page, so it was not checked.",
|
|
400
|
+
authorHintSensitive: "Only the field label is recorded. What is typed here is never captured.",
|
|
401
|
+
authorAddContext: "Add context ({context})",
|
|
402
|
+
authorRecheck: "Re-check all",
|
|
403
|
+
authorNote: "Now on {path}",
|
|
404
|
+
authorPreview: "Preview",
|
|
405
|
+
authorProblems: "Fix these before copying:",
|
|
406
|
+
authorTitleRequired: "Give the flow a title.",
|
|
407
|
+
authorCopy: "Copy Markdown",
|
|
408
|
+
authorCopied: "Copied to the clipboard.",
|
|
409
|
+
authorCopyFailed: "Could not copy. Select the text and copy it yourself.",
|
|
410
|
+
authorDownload: "Download {file}",
|
|
411
|
+
authorKeepRecording: "Keep recording",
|
|
412
|
+
authorDiscard: "Discard draft",
|
|
413
|
+
authorDiscardConfirm: "Discard this draft? The recorded steps are lost.",
|
|
414
|
+
authorNextHeading: "Then, from your project folder:",
|
|
415
|
+
authorPrivacy: "Nothing leaves this page. Typed values are never recorded, but control labels can contain page data, so read every step before you share it.",
|
|
416
|
+
authorLimit: "You reached {max} steps, the most one flow can have. Stop and review.",
|
|
417
|
+
authorShortcut: "Alt+Shift+G moves focus to this panel."
|
|
418
|
+
}, he = /\{(\w+)\}/g, J = (e) => [...new Set([...e.matchAll(he)].map((e) => e[1]))];
|
|
419
|
+
function ge(e) {
|
|
420
|
+
let t = { ...q };
|
|
421
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return t;
|
|
422
|
+
for (let [n, r] of Object.entries(e)) {
|
|
423
|
+
if (!n.startsWith("author") || !Object.prototype.hasOwnProperty.call(q, n)) continue;
|
|
424
|
+
let e = n;
|
|
425
|
+
if (typeof r != "string" || !r.trim() || r.length > 300) continue;
|
|
426
|
+
let i = J(r);
|
|
427
|
+
J(q[e]).filter((e) => !i.includes(e)).length || (t[e] = r);
|
|
428
|
+
}
|
|
429
|
+
return t;
|
|
430
|
+
}
|
|
431
|
+
var _e = (e, n, r) => t(e[n], r), Y = ":host{all:initial;pointer-events:none;--a-accent:var(--hp-accent,#087ea4);--a-accent-fg:var(--hp-accent-fg,#fff);--a-bg:var(--hp-bg,#fff);--a-fg:var(--hp-fg,#172b3a);--a-muted:var(--hp-muted,#334155);--a-border:var(--hp-border,#64748b);--a-warn-bg:var(--hp-warn-bg,#fef3c7);--a-warn-bd:var(--hp-warn-border,#92400e);--a-err-bg:var(--hp-err-bg,#fee2e2);--a-err-bd:var(--hp-err-border,#b91c1c);--a-ok-bg:#dcfce7;--a-ok-fg:#14532d;--a-focus:var(--hp-focus,#1e3a8a);--a-halo:var(--hp-halo,#fff);--a-radius:var(--hp-radius,12px);--a-rec:#b91c1c;font-family:var(--hp-font,system-ui, sans-serif);font-size:var(--hp-font-size,14px);color:var(--a-fg);line-height:1.45}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])){--a-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--a-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--a-bg:var(--hp-dark-bg,#0f172a);--a-fg:var(--hp-dark-fg,#f1f5f9);--a-muted:var(--hp-dark-muted,#cbd5e1);--a-border:var(--hp-dark-border,#94a3b8);--a-warn-bg:var(--hp-dark-warn-bg,#422006);--a-warn-bd:var(--hp-dark-warn-border,#fbbf24);--a-err-bg:var(--hp-dark-err-bg,#450a0a);--a-err-bd:var(--hp-dark-err-border,#f87171);--a-ok-bg:#14532d;--a-ok-fg:#bbf7d0;--a-focus:var(--hp-dark-focus,#fff);--a-halo:var(--hp-dark-halo,#1e3a8a);--a-rec:#f87171}}:host([data-scheme=dark]){--a-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--a-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--a-bg:var(--hp-dark-bg,#0f172a);--a-fg:var(--hp-dark-fg,#f1f5f9);--a-muted:var(--hp-dark-muted,#cbd5e1);--a-border:var(--hp-dark-border,#94a3b8);--a-warn-bg:var(--hp-dark-warn-bg,#422006);--a-warn-bd:var(--hp-dark-warn-border,#fbbf24);--a-err-bg:var(--hp-dark-err-bg,#450a0a);--a-err-bd:var(--hp-dark-err-border,#f87171);--a-ok-bg:#14532d;--a-ok-fg:#bbf7d0;--a-focus:var(--hp-dark-focus,#fff);--a-halo:var(--hp-dark-halo,#1e3a8a);--a-rec:#f87171}*,:before,:after{box-sizing:border-box}.panel{pointer-events:auto;z-index:2147483647;background:var(--a-bg);max-block-size:min(82dvh,44rem);inline-size:min(400px,100vw - 32px);color:var(--a-fg);border:1px solid var(--a-border);border-radius:var(--a-radius);flex-direction:column;display:flex;position:fixed;inset-block-end:16px;inset-inline-start:16px;overflow:hidden;box-shadow:0 8px 30px #0005}.head{border-block-end:1px solid var(--a-border);justify-content:space-between;align-items:center;gap:8px;padding:10px 12px;display:flex}.panel[data-min] .head{border-block-end:0}.panel[data-min] .body{display:none}h2{align-items:center;gap:8px;margin:0;font-size:15px;display:flex}.dot{background:var(--a-border);border-radius:50%;flex:none;block-size:10px;inline-size:10px}.panel[data-mode=recording] .dot{background:var(--a-rec);animation:1.4s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.panel[data-mode=recording] .dot{animation:none}}.body{flex-direction:column;gap:10px;padding:12px;display:flex;overflow:auto}.status{color:var(--a-muted);margin:0}.row{flex-wrap:wrap;gap:8px;display:flex}.field{flex-direction:column;gap:4px;display:flex}.field>span{font-weight:600}.check{color:var(--a-muted);align-items:flex-start;gap:8px;display:flex}.check input{flex:none;block-size:16px;inline-size:16px;margin-block-start:3px}button,input[type=text]{font:inherit;color:var(--a-fg);background:var(--a-bg);border:1px solid var(--a-border);border-radius:8px;min-block-size:36px;padding:6px 10px}input[type=text]{inline-size:100%}button{cursor:pointer}button.primary{background:var(--a-accent);color:var(--a-accent-fg);border-color:var(--a-accent);font-weight:600}button.rec{background:var(--a-rec);color:#fff;border-color:var(--a-rec);font-weight:600}:host([data-scheme=dark]) button.rec{color:#450a0a}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])) button.rec{color:#450a0a}}button.icon{min-inline-size:36px;padding:4px 8px}button:disabled{opacity:.55;cursor:not-allowed}button:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--a-focus);outline-offset:2px;box-shadow:0 0 0 4px var(--a-halo)}@media (pointer:coarse){button,input[type=text]{min-block-size:44px}button.icon{min-inline-size:44px}}ol.steps{flex-direction:column;gap:8px;margin:0;padding:0;list-style:none;display:flex}li.step,li.note{border:1px solid var(--a-border);border-radius:10px;flex-direction:column;gap:6px;padding:8px;display:flex}li.note{color:var(--a-muted);border-style:dashed;flex-direction:row;justify-content:space-between;align-items:center}.chips{flex-wrap:wrap;gap:6px;display:flex}.chip{border:1px solid #0000;border-radius:999px;padding:1px 8px;font-size:12px;font-weight:600}.chip.ok{background:var(--a-ok-bg);color:var(--a-ok-fg);border-color:var(--a-ok-fg)}.chip.warn{background:var(--a-warn-bg);color:var(--a-fg);border-color:var(--a-warn-bd)}.chip.err{background:var(--a-err-bg);color:var(--a-fg);border-color:var(--a-err-bd)}.chip.info{color:var(--a-muted);border-color:var(--a-border);background:0 0}.hint{color:var(--a-muted);margin:0;font-size:13px}.acts{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.acts .check{flex:auto;font-size:13px}.problems{background:var(--a-err-bg);border:1px solid var(--a-err-bd);border-radius:8px;margin:0;padding:8px 8px 8px 24px}pre{background:color-mix(in srgb, var(--a-fg) 7%, var(--a-bg));border:1px solid var(--a-border);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;max-block-size:14rem;margin:0;padding:8px;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;overflow:auto}code{font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.cmds{flex-direction:column;gap:4px;display:flex}.cmds code{background:color-mix(in srgb, var(--a-fg) 7%, var(--a-bg));overflow-wrap:anywhere;border-radius:6px;padding:4px 6px;display:block}.small{color:var(--a-muted);margin:0;font-size:12px}.sr{clip:rect(0 0 0 0);white-space:nowrap;block-size:1px;inline-size:1px;position:absolute;overflow:hidden}[hidden]{display:none!important}.flush{padding:0;overflow:visible}.h3{margin:0;font-size:14px}:host([data-side=end]) .panel{inset-inline:auto 16px}details{border:1px solid var(--a-border);border-radius:10px;padding:0 8px}details>summary{cursor:pointer;padding:8px 0;font-weight:600}details[open]>summary{border-block-end:1px solid var(--a-border);margin-block-end:8px}details>ol.steps{max-block-size:34dvh;padding-block-end:8px;overflow:auto}details .small{padding-block-end:8px}.panel[data-mode=recording] .body{gap:8px;padding-block:8px}";
|
|
432
|
+
// src/author/panel.ts
|
|
433
|
+
function X(e, t = {}, ...n) {
|
|
434
|
+
let r = document.createElement(e);
|
|
435
|
+
for (let [e, n] of Object.entries(t)) n !== !1 && r.setAttribute(e, n === !0 ? "" : n);
|
|
436
|
+
for (let e of n) e && r.append(e);
|
|
437
|
+
return r;
|
|
438
|
+
}
|
|
439
|
+
function ve(e) {
|
|
440
|
+
try {
|
|
441
|
+
let t = new CSSStyleSheet();
|
|
442
|
+
t.replaceSync(Y), e.adoptedStyleSheets = [t];
|
|
443
|
+
} catch {
|
|
444
|
+
let t = document.createElement("style");
|
|
445
|
+
t.textContent = Y, e.prepend(t);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
var Z = class {
|
|
449
|
+
constructor(e, t, n) {
|
|
450
|
+
s(this, "api", void 0), s(this, "labels", void 0), s(this, "host", void 0), s(this, "root", void 0), s(this, "panel", void 0), s(this, "live", void 0), s(this, "minimized", !1), s(this, "side", "start"), s(this, "stepsOpen", !1), s(this, "copiedNote", ""), s(this, "unsub", void 0), s(this, "pendingFocus", ""), s(this, "onKey", (e) => {
|
|
451
|
+
e.altKey && e.shiftKey && e.code === "KeyG" && (e.preventDefault(), this.minimized = !1, this.render(), this.focus("rec"));
|
|
452
|
+
}), this.api = e, this.labels = t, this.host = document.createElement("div"), this.host.setAttribute("data-heypointer-author", ""), this.host.style.pointerEvents = "none", (n.dir === "ltr" || n.dir === "rtl") && this.host.setAttribute("dir", n.dir), n.lang && this.host.setAttribute("lang", n.lang), (n.scheme === "light" || n.scheme === "dark") && this.host.setAttribute("data-scheme", n.scheme);
|
|
453
|
+
for (let [e, t] of Object.entries(n.themeVars ?? {})) this.host.style.setProperty(e, t);
|
|
454
|
+
this.root = this.host.attachShadow({ mode: "open" }), this.panel = X("section", {
|
|
455
|
+
class: "panel",
|
|
456
|
+
role: "dialog",
|
|
457
|
+
part: "author-panel"
|
|
458
|
+
}), this.live = X("div", {
|
|
459
|
+
class: "sr",
|
|
460
|
+
role: "status",
|
|
461
|
+
"aria-live": "polite"
|
|
462
|
+
}), this.root.append(this.panel, this.live), ve(this.root), (n.mountTo ?? document.body).appendChild(this.host), this.unsub = e.store.subscribe(() => this.render()), document.addEventListener("keydown", this.onKey, !0), this.render();
|
|
463
|
+
}
|
|
464
|
+
setLabels(e) {
|
|
465
|
+
this.labels = e, this.render();
|
|
466
|
+
}
|
|
467
|
+
destroy() {
|
|
468
|
+
this.unsub(), document.removeEventListener("keydown", this.onKey, !0), this.host.remove();
|
|
469
|
+
}
|
|
470
|
+
focus(e) {
|
|
471
|
+
this.pendingFocus = e, this.applyFocus();
|
|
472
|
+
}
|
|
473
|
+
t(e, t) {
|
|
474
|
+
return _e(this.labels, e, t);
|
|
475
|
+
}
|
|
476
|
+
applyFocus() {
|
|
477
|
+
if (!this.pendingFocus) return;
|
|
478
|
+
let e = this.root.querySelector(`[data-k="${this.pendingFocus}"]`);
|
|
479
|
+
e && (e.focus(), this.pendingFocus = "");
|
|
480
|
+
}
|
|
481
|
+
announce(e) {
|
|
482
|
+
this.live.textContent = e;
|
|
483
|
+
}
|
|
484
|
+
render() {
|
|
485
|
+
let e = this.api.mode(), t = this.root.activeElement, n = t?.getAttribute("data-k") ?? "", r = t instanceof HTMLInputElement && t.type === "text" ? [t.selectionStart, t.selectionEnd] : null, i = this.api.store, a = i.stepCount;
|
|
486
|
+
this.panel.setAttribute("aria-label", this.t("authorDialogName")), this.panel.setAttribute("data-mode", e), this.minimized ? this.panel.setAttribute("data-min", "") : this.panel.removeAttribute("data-min");
|
|
487
|
+
let o = e === "recording" ? this.t("authorStatusRecording", { count: a }) : e === "paused" ? this.t("authorStatusPaused", { count: a }) : e === "review" ? this.t("authorStatusReview") : this.t("authorStatusIdle"), s = i.full ? ` ${this.t("authorLimit", { max: 100 })}` : "";
|
|
488
|
+
this.announce(o + s);
|
|
489
|
+
let c = X("div", { class: "head" }, X("h2", {}, X("span", {
|
|
490
|
+
class: "dot",
|
|
491
|
+
"aria-hidden": "true"
|
|
492
|
+
}), this.t("authorTitle")), X("div", { class: "acts" }, this.button(this.minimized ? "▢" : "–", "min", () => {
|
|
493
|
+
this.minimized = !this.minimized, this.render();
|
|
494
|
+
}, "icon", {
|
|
495
|
+
"aria-label": this.minimized ? this.t("authorExpand") : this.t("authorMinimize"),
|
|
496
|
+
"aria-expanded": String(!this.minimized)
|
|
497
|
+
}), this.button("⇄", "side", () => {
|
|
498
|
+
this.side = this.side === "start" ? "end" : "start", this.render();
|
|
499
|
+
}, "icon", { "aria-label": this.t("authorMove") }), this.button("✕", "close", () => this.api.close(), "icon", { "aria-label": this.t("authorClose") }))), l = X("div", { class: "body" });
|
|
500
|
+
l.append(X("p", { class: "status" }, o + s)), e !== "recording" && l.append(this.titleField()), l.append(e === "review" ? this.reviewView() : this.editView(e)), e !== "recording" && (l.append(X("p", { class: "small" }, this.t("authorPrivacy"))), l.append(X("details", {}, X("summary", {}, this.t("authorAbout")), X("p", { class: "small" }, this.t("authorShortcut"))))), this.side === "end" ? this.host.setAttribute("data-side", "end") : this.host.removeAttribute("data-side"), this.panel.replaceChildren(c, l), n && (this.pendingFocus = n), this.applyFocus();
|
|
501
|
+
let u = this.root.activeElement;
|
|
502
|
+
if (r && u instanceof HTMLInputElement && u.type === "text") try {
|
|
503
|
+
u.setSelectionRange(r[0] ?? 0, r[1] ?? 0);
|
|
504
|
+
} catch {}
|
|
505
|
+
}
|
|
506
|
+
button(e, t, n, r = "", i = {}) {
|
|
507
|
+
let a = X("button", {
|
|
508
|
+
type: "button",
|
|
509
|
+
"data-k": t,
|
|
510
|
+
...r ? { class: r } : {},
|
|
511
|
+
...i
|
|
512
|
+
}, e);
|
|
513
|
+
return a.addEventListener("click", n), a;
|
|
514
|
+
}
|
|
515
|
+
titleField() {
|
|
516
|
+
let e = X("input", {
|
|
517
|
+
type: "text",
|
|
518
|
+
"data-k": "title",
|
|
519
|
+
maxlength: "80",
|
|
520
|
+
placeholder: this.t("authorFlowTitlePlaceholder"),
|
|
521
|
+
autocomplete: "off",
|
|
522
|
+
part: "author-title"
|
|
523
|
+
});
|
|
524
|
+
return e.value = this.api.store.draft.title, e.addEventListener("input", () => this.api.store.draft.title = e.value), e.addEventListener("change", () => {
|
|
525
|
+
this.api.store.setTitle(e.value);
|
|
526
|
+
}), X("label", { class: "field" }, X("span", {}, this.t("authorFlowTitle")), e);
|
|
527
|
+
}
|
|
528
|
+
editView(e) {
|
|
529
|
+
let t = this.api.store, n = X("div", { class: "body flush" }), r = X("div", { class: "row" });
|
|
530
|
+
e === "recording" ? r.append(this.button(this.t("authorPause"), "rec", () => this.api.pause())) : r.append(this.button(e === "paused" ? this.t("authorResume") : this.t("authorRecord"), "rec", () => this.api.record(), "rec")), r.append(this.button(this.t("authorStop"), "stop", () => this.api.stop(), "primary", t.stepCount === 0 ? { disabled: !0 } : {}), this.button(this.t("authorUndo"), "undo", () => t.undo(), "", t.draft.entries.length === 0 ? { disabled: !0 } : {})), n.append(r);
|
|
531
|
+
let i = X("input", {
|
|
532
|
+
type: "checkbox",
|
|
533
|
+
"data-k": "rows"
|
|
534
|
+
});
|
|
535
|
+
if (i.checked = this.api.recordRows(), i.addEventListener("change", () => this.api.setRecordRows(i.checked)), n.append(X("label", { class: "check" }, i, X("span", {}, this.t("authorRows")))), t.draft.entries.length === 0) n.append(X("p", { class: "hint" }, this.t("authorEmpty")));
|
|
536
|
+
else {
|
|
537
|
+
let r = X("details", {
|
|
538
|
+
"data-k": "steps",
|
|
539
|
+
...e !== "recording" || this.stepsOpen ? { open: !0 } : {}
|
|
540
|
+
}, X("summary", {}, this.t("authorSteps", { count: t.stepCount })), this.list());
|
|
541
|
+
r.addEventListener("toggle", () => {
|
|
542
|
+
e === "recording" && (this.stepsOpen = r.open);
|
|
543
|
+
}), n.append(r);
|
|
544
|
+
}
|
|
545
|
+
return t.stepCount > 0 && n.append(X("div", { class: "row" }, this.button(this.t("authorRecheck"), "recheck", () => this.api.recheckAll()))), n;
|
|
546
|
+
}
|
|
547
|
+
list() {
|
|
548
|
+
let e = X("ol", {
|
|
549
|
+
class: "steps",
|
|
550
|
+
"aria-label": this.t("authorTitle")
|
|
551
|
+
}), t = 0;
|
|
552
|
+
for (let n of this.api.store.draft.entries) e.append(n.t === "note" ? this.noteItem(n) : this.stepItem(n, ++t));
|
|
553
|
+
return e;
|
|
554
|
+
}
|
|
555
|
+
noteItem(e) {
|
|
556
|
+
return X("li", { class: "note" }, X("span", {}, this.t("authorNote", { path: e.text })), this.button("✕", `note-${e.id}`, () => this.api.store.remove(e.id), "icon", { "aria-label": this.t("authorDeleteNote") }));
|
|
557
|
+
}
|
|
558
|
+
chips(e) {
|
|
559
|
+
let t = X("div", { class: "chips" }), n = [], r = (e, r, i) => {
|
|
560
|
+
t.append(X("span", {
|
|
561
|
+
class: `chip ${e}`,
|
|
562
|
+
part: "author-chip"
|
|
563
|
+
}, r)), i && n.push(X("p", { class: "hint" }, i));
|
|
564
|
+
}, i = e.status;
|
|
565
|
+
return i.kind === "unique" ? r("ok", this.t("authorChipUnique")) : i.kind === "ambiguous" ? r("err", this.t("authorChipAmbiguous", { count: i.count }), this.t("authorHintAmbiguous", { count: i.count })) : i.kind === "noname" ? r("err", this.t("authorChipNoName"), this.t("authorHintNoName")) : i.kind === "notfound" ? r("warn", this.t("authorChipNotFound"), this.t("authorHintNotFound")) : r("info", this.t("authorChipUnchecked"), this.t("authorHintUnchecked")), e.pageData && r("warn", this.t("authorChipPageData"), this.t("authorHintPageData")), e.sensitive && r("info", this.t("authorChipSensitive"), this.t("authorHintSensitive")), {
|
|
566
|
+
chips: t,
|
|
567
|
+
hints: n
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
stepItem(e, t) {
|
|
571
|
+
let { chips: n, hints: r } = this.chips(e), i = X("input", {
|
|
572
|
+
type: "text",
|
|
573
|
+
"data-k": `s${e.id}-text`,
|
|
574
|
+
maxlength: "120",
|
|
575
|
+
"aria-label": this.t("authorStepText", { n: t }),
|
|
576
|
+
autocomplete: "off",
|
|
577
|
+
part: "author-step"
|
|
578
|
+
});
|
|
579
|
+
i.value = e.text, i.addEventListener("input", () => this.api.store.editText(e.id, i.value, !0)), i.addEventListener("change", () => this.api.edited(e.id));
|
|
580
|
+
let a = z(e) && !e.consequential, o = X("input", {
|
|
581
|
+
type: "checkbox",
|
|
582
|
+
"data-k": `s${e.id}-gate`
|
|
583
|
+
});
|
|
584
|
+
o.checked = z(e), o.disabled = a, o.addEventListener("change", () => this.api.store.toggleConsequential(e.id));
|
|
585
|
+
let s = X("div", { class: "acts" }, X("label", { class: "check" }, o, X("span", {}, a ? this.t("authorConsequentialAuto") : this.t("authorConsequential"))), this.button("▲", `s${e.id}-up`, () => {
|
|
586
|
+
this.pendingFocus = `s${e.id}-up`, this.api.store.move(e.id, -1);
|
|
587
|
+
}, "icon", { "aria-label": this.t("authorMoveUp", { n: t }) }), this.button("▼", `s${e.id}-down`, () => {
|
|
588
|
+
this.pendingFocus = `s${e.id}-down`, this.api.store.move(e.id, 1);
|
|
589
|
+
}, "icon", { "aria-label": this.t("authorMoveDown", { n: t }) }), this.button("✕", `s${e.id}-del`, () => this.api.store.remove(e.id), "icon", { "aria-label": this.t("authorDelete", { n: t }) })), c = [];
|
|
590
|
+
return e.status.kind === "ambiguous" && e.context && c.push(this.button(this.t("authorAddContext", { context: e.context }), `s${e.id}-ctx`, () => this.api.addContext(e.id))), X("li", {
|
|
591
|
+
class: "step",
|
|
592
|
+
part: "author-item"
|
|
593
|
+
}, n, i, ...r, s, ...c);
|
|
594
|
+
}
|
|
595
|
+
reviewView() {
|
|
596
|
+
let e = this.api.store, t = X("div", { class: "body flush" }), n = V(e.draft, this.t("authorTitleRequired")), r = B(e.draft), i = H(e.draft);
|
|
597
|
+
if (t.append(X("h3", { class: "h3" }, this.t("authorPreview"))), n.length) {
|
|
598
|
+
let e = X("ul", {
|
|
599
|
+
class: "problems",
|
|
600
|
+
role: "alert"
|
|
601
|
+
});
|
|
602
|
+
for (let t of n) e.append(X("li", {}, t));
|
|
603
|
+
t.append(X("p", { class: "hint" }, this.t("authorProblems")), e);
|
|
604
|
+
}
|
|
605
|
+
let a = X("pre", {
|
|
606
|
+
tabindex: "0",
|
|
607
|
+
"aria-label": this.t("authorPreview"),
|
|
608
|
+
part: "author-preview"
|
|
609
|
+
});
|
|
610
|
+
a.append(X("code", {}, r)), t.append(a);
|
|
611
|
+
let o = X("div", { class: "row" }, this.button(this.t("authorCopy"), "copy", () => void this.copy(r), "primary", n.length ? { disabled: !0 } : {}), this.button(this.t("authorDownload", { file: i }), "download", () => this.download(i, r), "", n.length ? { disabled: !0 } : {}));
|
|
612
|
+
return t.append(o), this.copiedNote && t.append(X("p", {
|
|
613
|
+
class: "hint",
|
|
614
|
+
role: "status"
|
|
615
|
+
}, this.copiedNote)), t.append(X("p", { class: "hint" }, this.t("authorNextHeading")), X("div", { class: "cmds" }, X("code", {}, `heypointer flows import ${i} --publish`), X("code", {}, "heypointer scan ."))), t.append(X("div", { class: "row" }, this.button(this.t("authorKeepRecording"), "keep", () => {
|
|
616
|
+
this.copiedNote = "", this.api.keepRecording();
|
|
617
|
+
}), this.button(this.t("authorDiscard"), "discard", () => {
|
|
618
|
+
confirm(this.t("authorDiscardConfirm")) && this.api.discard();
|
|
619
|
+
}))), t;
|
|
620
|
+
}
|
|
621
|
+
async copy(e) {
|
|
622
|
+
try {
|
|
623
|
+
await navigator.clipboard.writeText(e), this.copiedNote = this.t("authorCopied");
|
|
624
|
+
} catch {
|
|
625
|
+
this.copiedNote = this.t("authorCopyFailed");
|
|
626
|
+
}
|
|
627
|
+
this.pendingFocus = "copy", this.render();
|
|
628
|
+
}
|
|
629
|
+
download(e, t) {
|
|
630
|
+
let n = URL.createObjectURL(new Blob([t], { type: "text/markdown;charset=utf-8" })), r = X("a", {
|
|
631
|
+
href: n,
|
|
632
|
+
download: e
|
|
633
|
+
});
|
|
634
|
+
this.root.append(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
635
|
+
}
|
|
636
|
+
}, Q = null;
|
|
637
|
+
function $(e, t) {
|
|
638
|
+
if (!e) return { kind: "noname" };
|
|
639
|
+
if (e.length > 72) return { kind: "notfound" };
|
|
640
|
+
let n = i({
|
|
641
|
+
selectors: [],
|
|
642
|
+
text: e
|
|
643
|
+
});
|
|
644
|
+
return n.status === "ambiguous" ? {
|
|
645
|
+
kind: "ambiguous",
|
|
646
|
+
count: n.count
|
|
647
|
+
} : n.status === "missing" ? t ? { kind: "notfound" } : { kind: "unchecked" } : t && !(n.element === t || t.contains(n.element) || n.element.contains(t)) ? { kind: "notfound" } : { kind: "unique" };
|
|
648
|
+
}
|
|
649
|
+
function ye(e = {}) {
|
|
650
|
+
if (Q && !Q.destroyed) return Q;
|
|
651
|
+
let t = ge(e.labels), n = e.persist === !1 ? null : e.storage === void 0 ? K() : e.storage, i = pe(n), s = new de(i?.draft);
|
|
652
|
+
e.title && !s.draft.title && (s.draft.title = p(e.title).slice(0, 80));
|
|
653
|
+
let c = i ? i.recording ? "recording" : "paused" : "idle", l = !!e.recordRows, u = () => {
|
|
654
|
+
c === "review" || c === "idle" && s.draft.entries.length === 0 || me(n, {
|
|
655
|
+
draft: s.draft,
|
|
656
|
+
recording: c === "recording"
|
|
657
|
+
});
|
|
658
|
+
}, d = (e) => {
|
|
659
|
+
c = e, u(), v.render();
|
|
660
|
+
}, f = new F({
|
|
661
|
+
isRecording: () => c === "recording",
|
|
662
|
+
isOwn: (e) => e.includes(v.host),
|
|
663
|
+
recordRows: () => l,
|
|
664
|
+
acceptUntrusted: !!e.acceptUntrusted,
|
|
665
|
+
onPage: (e) => s.addNote(e),
|
|
666
|
+
onStep: (e) => {
|
|
667
|
+
let t = $(e.label, e.el);
|
|
668
|
+
(!s.addStep({
|
|
669
|
+
kind: e.kind,
|
|
670
|
+
text: L(e.kind, e.label),
|
|
671
|
+
consequential: !1,
|
|
672
|
+
status: t,
|
|
673
|
+
pageData: e.pageData,
|
|
674
|
+
sensitive: e.sensitive,
|
|
675
|
+
context: e.context
|
|
676
|
+
}) || s.full) && d("paused");
|
|
677
|
+
}
|
|
678
|
+
}), m = (e) => {
|
|
679
|
+
let t = s.find(e);
|
|
680
|
+
if (t?.t !== "step") return;
|
|
681
|
+
let n = _(t.text);
|
|
682
|
+
s.setStatus(e, $(n), A(n));
|
|
683
|
+
}, h = {
|
|
684
|
+
store: s,
|
|
685
|
+
mode: () => c,
|
|
686
|
+
recordRows: () => l,
|
|
687
|
+
setRecordRows: (e) => {
|
|
688
|
+
l = e;
|
|
689
|
+
},
|
|
690
|
+
record: () => {
|
|
691
|
+
s.full || (s.draft.entries.length === 0 && s.addNote(x(location.pathname)), f.syncRoute(), d("recording"));
|
|
692
|
+
},
|
|
693
|
+
pause: () => d("paused"),
|
|
694
|
+
stop: () => d("review"),
|
|
695
|
+
keepRecording: () => {
|
|
696
|
+
f.syncRoute(), d("recording");
|
|
697
|
+
},
|
|
698
|
+
close: () => {
|
|
699
|
+
(!s.draft.entries.length || confirm(t.authorDiscardConfirm)) && Q?.stop();
|
|
700
|
+
},
|
|
701
|
+
discard: () => {
|
|
702
|
+
s.clear(), G(n), c = "idle", v.render();
|
|
703
|
+
},
|
|
704
|
+
edited: (e) => m(e),
|
|
705
|
+
recheckAll: () => {
|
|
706
|
+
for (let e of s.draft.entries) e.t === "step" && m(e.id);
|
|
707
|
+
},
|
|
708
|
+
addContext: (e) => {
|
|
709
|
+
let t = s.find(e);
|
|
710
|
+
if (t?.t !== "step" || !t.context) return;
|
|
711
|
+
let n = `${t.text.replace(/[.!?]$/, "")} in the ${t.context} area.`;
|
|
712
|
+
n.length > 120 || (s.editText(e, n), m(e));
|
|
713
|
+
}
|
|
714
|
+
}, g = o.includes(e.colorScheme) ? e.colorScheme : "auto", v = new Z(h, t, {
|
|
715
|
+
mountTo: e.mountTo,
|
|
716
|
+
dir: e.dir,
|
|
717
|
+
lang: e.lang,
|
|
718
|
+
scheme: g,
|
|
719
|
+
themeVars: a(r(e.theme).theme)
|
|
720
|
+
});
|
|
721
|
+
if (s.subscribe(() => {
|
|
722
|
+
u(), e.onChange?.(s.draft);
|
|
723
|
+
}), f.start(), i?.recording) {
|
|
724
|
+
let e = x(location.pathname);
|
|
725
|
+
s.addNote(e), f.syncRoute();
|
|
726
|
+
}
|
|
727
|
+
e.autoRecord && c === "idle" && h.record(), u(), v.render();
|
|
728
|
+
let y = {
|
|
729
|
+
destroyed: !1,
|
|
730
|
+
get mode() {
|
|
731
|
+
return c;
|
|
732
|
+
},
|
|
733
|
+
stop() {
|
|
734
|
+
y.destroyed || (y.destroyed = !0, f.stop(), v.destroy(), G(n), Q = null);
|
|
735
|
+
},
|
|
736
|
+
getDraft: () => JSON.parse(JSON.stringify(s.draft)),
|
|
737
|
+
toMarkdown: () => B(s.draft),
|
|
738
|
+
pause: () => h.pause(),
|
|
739
|
+
resume: () => h.record()
|
|
740
|
+
};
|
|
741
|
+
return Q = y, y;
|
|
742
|
+
}
|
|
743
|
+
function be(e = K()) {
|
|
744
|
+
try {
|
|
745
|
+
return e?.getItem(W) === "1";
|
|
746
|
+
} catch {
|
|
747
|
+
return !1;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
export { q as AUTHOR_LABELS, u as MAX_LABEL, c as MAX_STEPS, l as MAX_STEP_TEXT, be as authorWasActive, $ as classify, b as renderFlow, h as slug, ye as startAuthoring, y as stepSentence };
|