makethisbetter 1.1.2 → 1.1.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/makethisbetter.cjs.js +2 -2
- package/dist/makethisbetter.cjs.js.map +1 -1
- package/dist/makethisbetter.esm.js +24 -19
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +2 -2
- package/dist/makethisbetter.js.map +1 -1
- package/dist/popup/clarify.d.ts +1 -0
- package/dist/popup/clarify.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/widget/controller.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/popup/clarify.test.ts +103 -0
- package/src/popup/clarify.ts +11 -3
- package/src/types.ts +1 -0
- package/src/widget/controller.test.ts +37 -0
- package/src/widget/controller.ts +5 -1
|
@@ -410,12 +410,12 @@ class wt {
|
|
|
410
410
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
|
411
411
|
</svg>
|
|
412
412
|
</div>
|
|
413
|
-
<button class="mtb-clarify-skip">${
|
|
413
|
+
<button class="mtb-clarify-skip">${L(t.clarify.skip)}</button>
|
|
414
414
|
</div>
|
|
415
415
|
<div class="mtb-clarify-messages"></div>
|
|
416
416
|
<div class="mtb-clarify-footer">
|
|
417
|
-
<input class="mtb-clarify-input" type="text" placeholder="${
|
|
418
|
-
<button class="mtb-clarify-send" disabled>${
|
|
417
|
+
<input class="mtb-clarify-input" type="text" placeholder="${L(t.clarify.placeholder)}" />
|
|
418
|
+
<button class="mtb-clarify-send" disabled>${L(t.clarify.send)}</button>
|
|
419
419
|
</div>
|
|
420
420
|
`;
|
|
421
421
|
}
|
|
@@ -426,7 +426,7 @@ class wt {
|
|
|
426
426
|
const e = this.inputEl.value.trim().length > 0;
|
|
427
427
|
this.sendBtn.disabled = !e || this.sending;
|
|
428
428
|
}), this.inputEl.addEventListener("keydown", (e) => {
|
|
429
|
-
e.key === "Enter" && (e.preventDefault(), this.sendMessage(t));
|
|
429
|
+
e.isComposing || e.keyCode === 229 || e.key === "Enter" && (e.preventDefault(), this.sendMessage(t));
|
|
430
430
|
}), this.sendBtn.addEventListener("click", () => this.sendMessage(t));
|
|
431
431
|
}
|
|
432
432
|
async startConversation() {
|
|
@@ -434,7 +434,7 @@ class wt {
|
|
|
434
434
|
try {
|
|
435
435
|
const t = await this.apiClient.startClarification(this.feedbackId);
|
|
436
436
|
if (this.destroyed) return;
|
|
437
|
-
this.
|
|
437
|
+
this.renderConversation(t.messages, t.done), t.done ? this.handleDone() : this.startPolling();
|
|
438
438
|
} catch {
|
|
439
439
|
if (this.destroyed) return;
|
|
440
440
|
this.onDone();
|
|
@@ -447,7 +447,7 @@ class wt {
|
|
|
447
447
|
try {
|
|
448
448
|
const s = await this.apiClient.startClarification(this.feedbackId, e);
|
|
449
449
|
if (this.destroyed) return;
|
|
450
|
-
this.
|
|
450
|
+
this.renderConversation(s.messages, s.done), s.done ? this.handleDone() : this.startPolling();
|
|
451
451
|
} catch {
|
|
452
452
|
if (this.destroyed) return;
|
|
453
453
|
this.onDone();
|
|
@@ -466,7 +466,7 @@ class wt {
|
|
|
466
466
|
try {
|
|
467
467
|
const t = await this.apiClient.getClarification(this.feedbackId);
|
|
468
468
|
if (this.destroyed) return;
|
|
469
|
-
this.
|
|
469
|
+
this.renderConversation(t.messages, t.done), t.done && (this.stopPolling(), this.handleDone());
|
|
470
470
|
} catch {
|
|
471
471
|
if (this.destroyed) return;
|
|
472
472
|
this.stopPolling();
|
|
@@ -477,6 +477,11 @@ class wt {
|
|
|
477
477
|
this.destroyed || this.onDone();
|
|
478
478
|
}, xt);
|
|
479
479
|
}
|
|
480
|
+
renderConversation(t, e) {
|
|
481
|
+
this.renderMessages(t);
|
|
482
|
+
const s = t[t.length - 1];
|
|
483
|
+
!e && (!s || s.role === "user") && this.showThinking();
|
|
484
|
+
}
|
|
480
485
|
renderMessages(t) {
|
|
481
486
|
this.messagesEl.innerHTML = "";
|
|
482
487
|
for (const e of t)
|
|
@@ -495,7 +500,7 @@ class wt {
|
|
|
495
500
|
this.destroyed = !0, this.stopPolling(), this.doneTimer !== null && (clearTimeout(this.doneTimer), this.doneTimer = null), this.el.remove();
|
|
496
501
|
}
|
|
497
502
|
}
|
|
498
|
-
function
|
|
503
|
+
function L(i) {
|
|
499
504
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
500
505
|
}
|
|
501
506
|
const kt = 5e3;
|
|
@@ -563,7 +568,7 @@ function Y(i, t = {}) {
|
|
|
563
568
|
const e = t.width || Ct(i), s = t.height || Mt(i);
|
|
564
569
|
return { width: e, height: s };
|
|
565
570
|
}
|
|
566
|
-
function
|
|
571
|
+
function Tt() {
|
|
567
572
|
let i, t;
|
|
568
573
|
try {
|
|
569
574
|
t = process;
|
|
@@ -573,7 +578,7 @@ function Lt() {
|
|
|
573
578
|
return e && (i = parseInt(e, 10), Number.isNaN(i) && (i = 1)), i || window.devicePixelRatio || 1;
|
|
574
579
|
}
|
|
575
580
|
const d = 16384;
|
|
576
|
-
function
|
|
581
|
+
function Lt(i) {
|
|
577
582
|
(i.width > d || i.height > d) && (i.width > d && i.height > d ? i.width > i.height ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d) : i.width > d ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d));
|
|
578
583
|
}
|
|
579
584
|
function C(i) {
|
|
@@ -913,12 +918,12 @@ async function ae(i, t) {
|
|
|
913
918
|
p(r.cssRules || []).forEach((n, o) => {
|
|
914
919
|
if (n.type === CSSRule.IMPORT_RULE) {
|
|
915
920
|
let a = o + 1;
|
|
916
|
-
const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((
|
|
921
|
+
const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((T) => {
|
|
917
922
|
try {
|
|
918
|
-
r.insertRule(
|
|
923
|
+
r.insertRule(T, T.startsWith("@import") ? a += 1 : r.cssRules.length);
|
|
919
924
|
} catch (it) {
|
|
920
925
|
console.error("Error inserting rule from remote css", {
|
|
921
|
-
rule:
|
|
926
|
+
rule: T,
|
|
922
927
|
error: it
|
|
923
928
|
});
|
|
924
929
|
}
|
|
@@ -990,8 +995,8 @@ async function pe(i, t = {}) {
|
|
|
990
995
|
return await ue(r, t), await Z(r, t), oe(r, t), await Dt(r, e, s);
|
|
991
996
|
}
|
|
992
997
|
async function fe(i, t = {}) {
|
|
993
|
-
const { width: e, height: s } = Y(i, t), r = await pe(i, t), n = await C(r), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio ||
|
|
994
|
-
return o.width = c * l, o.height = u * l, t.skipAutoScale ||
|
|
998
|
+
const { width: e, height: s } = Y(i, t), r = await pe(i, t), n = await C(r), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Tt(), c = t.canvasWidth || e, u = t.canvasHeight || s;
|
|
999
|
+
return o.width = c * l, o.height = u * l, t.skipAutoScale || Lt(o), o.style.width = `${c}`, o.style.height = `${u}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
|
|
995
1000
|
}
|
|
996
1001
|
async function me(i, t = {}) {
|
|
997
1002
|
return (await fe(i, t)).toDataURL();
|
|
@@ -1095,7 +1100,7 @@ class Ee {
|
|
|
1095
1100
|
this.unsubscribe?.(), this.unsubscribe = null;
|
|
1096
1101
|
}
|
|
1097
1102
|
}
|
|
1098
|
-
const Se = 3, Ce = 1e3, Me = 3,
|
|
1103
|
+
const Se = 3, Ce = 1e3, Me = 3, Te = 5e3, Le = 500, Ae = 500, De = 300, Pe = /* @__PURE__ */ new Set([
|
|
1099
1104
|
"A",
|
|
1100
1105
|
"BUTTON",
|
|
1101
1106
|
"INPUT",
|
|
@@ -1178,7 +1183,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1178
1183
|
handleNavigation() {
|
|
1179
1184
|
const t = Date.now();
|
|
1180
1185
|
this.navTimestamps.push(t);
|
|
1181
|
-
const e = t -
|
|
1186
|
+
const e = t - Te;
|
|
1182
1187
|
this.navTimestamps = this.navTimestamps.filter((s) => s > e), this.navTimestamps.length >= Me && (this.navTimestamps = [], this.emitIfReady({
|
|
1183
1188
|
signal: "rapid_navigation",
|
|
1184
1189
|
timestamp: t
|
|
@@ -1194,7 +1199,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1194
1199
|
target: y(e),
|
|
1195
1200
|
timestamp: Date.now()
|
|
1196
1201
|
});
|
|
1197
|
-
},
|
|
1202
|
+
}, Le));
|
|
1198
1203
|
}
|
|
1199
1204
|
handleFormInvalid(t) {
|
|
1200
1205
|
const e = t.target;
|
|
@@ -1955,7 +1960,7 @@ class N {
|
|
|
1955
1960
|
);
|
|
1956
1961
|
try {
|
|
1957
1962
|
const a = await this.apiClient.submitFeedback(o, r);
|
|
1958
|
-
this.popup?.destroy(), this.popup = null, this.session?.destroy(), this.session = null, this.recordingManager?.destroy(), this.recordingManager = null, this.showClarify(a.id, a.project_id);
|
|
1963
|
+
this.popup?.destroy(), this.popup = null, this.session?.destroy(), this.session = null, this.recordingManager?.destroy(), this.recordingManager = null, a.ai_clarify_available === !1 ? this.showSuccess(a.project_id) : this.showClarify(a.id, a.project_id);
|
|
1959
1964
|
} catch {
|
|
1960
1965
|
this.popup?.setLoading(!1), this.popup?.setError(this.messages.error.submit);
|
|
1961
1966
|
}
|