@yam8d/m8-sdk 0.5.6 → 0.5.7
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 +805 -805
- package/dist/index.js +709 -689
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types/fxInsight.d.ts +39 -15
package/dist/index.js
CHANGED
|
@@ -517,11 +517,11 @@ var D = (e) => {
|
|
|
517
517
|
let { terminated: n, data: r } = await e();
|
|
518
518
|
if (r && t.dispatch(r, r.byteLength), n) break;
|
|
519
519
|
}
|
|
520
|
-
},
|
|
520
|
+
}, ee = {
|
|
521
521
|
serial: "Web Serial",
|
|
522
522
|
usb: "WebUSB",
|
|
523
523
|
midi: "Web MIDI"
|
|
524
|
-
},
|
|
524
|
+
}, k = () => {
|
|
525
525
|
let e = "requestMIDIAccess" in navigator, t = "serial" in navigator, n = "usb" in navigator;
|
|
526
526
|
if (!e && !t && !n) return { browserSupport: !1 };
|
|
527
527
|
let r = async (e) => {
|
|
@@ -609,7 +609,7 @@ var D = (e) => {
|
|
|
609
609
|
available: o,
|
|
610
610
|
connect: async ({ transport: e = "auto", prompt: s = !0 } = {}) => {
|
|
611
611
|
let c = e === "auto" ? t ? "serial" : n ? "usb" : "midi" : e;
|
|
612
|
-
if (!o[c]) throw Error(`This browser does not support ${
|
|
612
|
+
if (!o[c]) throw Error(`This browser does not support ${ee[c]}`);
|
|
613
613
|
let l = await (c === "serial" ? i(s) : c === "usb" ? r(s) : a(s)), u = d(), f = !1, p = O(l.reader, u);
|
|
614
614
|
return {
|
|
615
615
|
transport: l.transport,
|
|
@@ -624,26 +624,26 @@ var D = (e) => {
|
|
|
624
624
|
};
|
|
625
625
|
}
|
|
626
626
|
};
|
|
627
|
-
},
|
|
627
|
+
}, te = async (e, { maxAttempts: t = 3, retryDelayMs: n = 1500 } = {}) => {
|
|
628
628
|
for (let r = 1; r <= t; r++) try {
|
|
629
629
|
return await e();
|
|
630
630
|
} catch (e) {
|
|
631
631
|
console.warn(`Connection attempt ${r}/${t} failed:`, e), r < t ? await new Promise((e) => setTimeout(e, n)) : console.error("Could not connect to M8 after all attempts:", e);
|
|
632
632
|
}
|
|
633
|
-
},
|
|
633
|
+
}, A = {
|
|
634
634
|
autoGainControl: !1,
|
|
635
635
|
channelCount: { ideal: 2 },
|
|
636
636
|
echoCancellation: !1,
|
|
637
637
|
noiseSuppression: !1
|
|
638
|
-
},
|
|
638
|
+
}, j = async () => {
|
|
639
639
|
let e = (await navigator.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" && e.label.includes("M8") && e.deviceId !== "default" && e.deviceId !== "communications");
|
|
640
640
|
return e.length > 1 && console.warn("Suspicious: More than one M8 audio input found"), e[0] ?? null;
|
|
641
|
-
},
|
|
641
|
+
}, M = async () => navigator.mediaDevices?.enumerateDevices ? j() : null, N = async ({ requireM8: e = !1 } = {}) => {
|
|
642
642
|
if (!navigator.mediaDevices?.getUserMedia) throw Error("Audio capture is not supported in this browser");
|
|
643
|
-
let t = await
|
|
643
|
+
let t = await M();
|
|
644
644
|
if (!t) {
|
|
645
|
-
let n = await navigator.mediaDevices.getUserMedia({ audio:
|
|
646
|
-
if (t = await
|
|
645
|
+
let n = await navigator.mediaDevices.getUserMedia({ audio: A });
|
|
646
|
+
if (t = await M(), !t) {
|
|
647
647
|
if (!e) return n;
|
|
648
648
|
for (let e of n.getTracks()) e.stop();
|
|
649
649
|
throw Error("No M8 audio input found (is the M8 connected over USB?)");
|
|
@@ -651,10 +651,10 @@ var D = (e) => {
|
|
|
651
651
|
for (let e of n.getTracks()) e.stop();
|
|
652
652
|
}
|
|
653
653
|
return navigator.mediaDevices.getUserMedia({ audio: {
|
|
654
|
-
...
|
|
654
|
+
...A,
|
|
655
655
|
deviceId: { exact: t.deviceId }
|
|
656
656
|
} });
|
|
657
|
-
},
|
|
657
|
+
}, P = () => {
|
|
658
658
|
let e = null, t = null, n = null, r = null, i = (e) => {
|
|
659
659
|
if (e.state !== "suspended" || typeof window > "u") return;
|
|
660
660
|
let t = () => {
|
|
@@ -666,7 +666,7 @@ var D = (e) => {
|
|
|
666
666
|
let r = e;
|
|
667
667
|
e = null, t = null, n = null, await r?.close().catch(() => void 0);
|
|
668
668
|
}, o = async (r) => {
|
|
669
|
-
let o = await
|
|
669
|
+
let o = await N({ requireM8: r }), s = new AudioContext(), c = s.createMediaStreamSource(o), l = s.createMediaStreamDestination();
|
|
670
670
|
c.connect(s.destination), c.connect(l), e = s, t = o, n = l.stream;
|
|
671
671
|
for (let e of o.getAudioTracks()) e.addEventListener("ended", () => {
|
|
672
672
|
t === o && a();
|
|
@@ -688,12 +688,12 @@ var D = (e) => {
|
|
|
688
688
|
return e.length <= 0 ? null : new MediaStream(e.map((e) => e.clone()));
|
|
689
689
|
}
|
|
690
690
|
};
|
|
691
|
-
},
|
|
691
|
+
}, ne = [
|
|
692
692
|
"up",
|
|
693
693
|
"down",
|
|
694
694
|
"left",
|
|
695
695
|
"right"
|
|
696
|
-
],
|
|
696
|
+
], re = 64, F = (e) => `${e.x},${e.y},${e.w},${e.h}`, ie = (e) => {
|
|
697
697
|
let [t, n, r, i] = e.split(",").map(Number);
|
|
698
698
|
return [
|
|
699
699
|
t,
|
|
@@ -706,22 +706,22 @@ var D = (e) => {
|
|
|
706
706
|
w: r,
|
|
707
707
|
h: i
|
|
708
708
|
} : null;
|
|
709
|
-
},
|
|
709
|
+
}, ae = () => ({
|
|
710
710
|
cells: /* @__PURE__ */ new Map(),
|
|
711
711
|
moves: /* @__PURE__ */ new Map(),
|
|
712
712
|
unreachable: /* @__PURE__ */ new Set(),
|
|
713
713
|
suspects: /* @__PURE__ */ new Set()
|
|
714
|
-
}),
|
|
714
|
+
}), oe = (e = {}) => {
|
|
715
715
|
let t = /* @__PURE__ */ new Map(), n = () => e.onChange?.(), r = (e) => {
|
|
716
716
|
let n = t.get(e);
|
|
717
|
-
for (n ? t.delete(e) : n =
|
|
717
|
+
for (n ? t.delete(e) : n = ae(), t.set(e, n); t.size > re;) {
|
|
718
718
|
let e = t.keys().next().value;
|
|
719
719
|
if (e === void 0) break;
|
|
720
720
|
t.delete(e);
|
|
721
721
|
}
|
|
722
722
|
return n;
|
|
723
723
|
}, i = (e, t) => {
|
|
724
|
-
let n =
|
|
724
|
+
let n = F(t);
|
|
725
725
|
return !e.cells.has(n) && (e.cells.set(n, {
|
|
726
726
|
x: t.x,
|
|
727
727
|
y: t.y,
|
|
@@ -732,11 +732,11 @@ var D = (e) => {
|
|
|
732
732
|
if (e.data?.version === 1) for (let t of e.data.layouts ?? []) {
|
|
733
733
|
let e = r(t.key);
|
|
734
734
|
for (let n of t.cells ?? []) {
|
|
735
|
-
let t =
|
|
735
|
+
let t = ie(n);
|
|
736
736
|
t && i(e, t);
|
|
737
737
|
}
|
|
738
738
|
for (let [n, r, i] of t.moves ?? []) {
|
|
739
|
-
if (!
|
|
739
|
+
if (!ne.includes(r)) continue;
|
|
740
740
|
let t = e.moves.get(n) ?? {};
|
|
741
741
|
t[r] = i, e.moves.set(n, t);
|
|
742
742
|
}
|
|
@@ -751,7 +751,7 @@ var D = (e) => {
|
|
|
751
751
|
recordMove: (e, t, a, o) => {
|
|
752
752
|
let s = r(e);
|
|
753
753
|
i(s, t), o && i(s, o);
|
|
754
|
-
let c =
|
|
754
|
+
let c = F(t), l = o ? F(o) : null, u = s.moves.get(c) ?? {};
|
|
755
755
|
u[a] !== l && (u[a] = l, s.moves.set(c, u), n());
|
|
756
756
|
},
|
|
757
757
|
markUnreachable: (e, t) => {
|
|
@@ -763,7 +763,7 @@ var D = (e) => {
|
|
|
763
763
|
layouts: [...t.entries()].map(([e, t]) => ({
|
|
764
764
|
key: e,
|
|
765
765
|
cells: [...t.cells.keys()],
|
|
766
|
-
moves: [...t.moves.entries()].flatMap(([e, t]) =>
|
|
766
|
+
moves: [...t.moves.entries()].flatMap(([e, t]) => ne.filter((e) => t[e] !== void 0).map((n) => [
|
|
767
767
|
e,
|
|
768
768
|
n,
|
|
769
769
|
t[n] ?? null
|
|
@@ -773,13 +773,13 @@ var D = (e) => {
|
|
|
773
773
|
}))
|
|
774
774
|
})
|
|
775
775
|
};
|
|
776
|
-
},
|
|
776
|
+
}, se = (e, t, n) => t === "up" ? n.y > e.y : t === "down" ? n.y < e.y : t === "left" ? n.x > e.x : n.x < e.x, ce = 1.01, le = (e, t, n, r) => Math.min(t, r) - Math.max(e, n), ue = (e, t, n) => {
|
|
777
777
|
let r = t.x + t.w / 2, i = t.y + t.h / 2, a = null;
|
|
778
778
|
for (let [o, s] of e.cells) {
|
|
779
779
|
let e = s.x + s.w / 2 - r, c = s.y + s.h / 2 - i, l, u;
|
|
780
780
|
if (n === "up" || n === "down") {
|
|
781
|
-
if (l = n === "down" ? c : -c, u = Math.abs(e),
|
|
782
|
-
} else if (l = n === "right" ? e : -e, u = Math.abs(c),
|
|
781
|
+
if (l = n === "down" ? c : -c, u = Math.abs(e), le(t.x, t.x + t.w, s.x, s.x + s.w) <= 0) continue;
|
|
782
|
+
} else if (l = n === "right" ? e : -e, u = Math.abs(c), le(t.y, t.y + t.h, s.y, s.y + s.h) < Math.min(t.h, s.h) / 2) continue;
|
|
783
783
|
l < Math.min(t.h, s.h) / 2 || (!a || l < a.along - .5 || Math.abs(l - a.along) <= .5 && u < a.across) && (a = {
|
|
784
784
|
id: o,
|
|
785
785
|
along: l,
|
|
@@ -787,7 +787,7 @@ var D = (e) => {
|
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
return a?.id ?? null;
|
|
790
|
-
},
|
|
790
|
+
}, de = (e, t, n, r = /* @__PURE__ */ new Set(), i = () => !1) => {
|
|
791
791
|
if (n(t)) return [];
|
|
792
792
|
let a = /* @__PURE__ */ new Map([[t, 0]]), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set([t]);
|
|
793
793
|
for (; c.size > 0;) {
|
|
@@ -810,15 +810,15 @@ var D = (e) => {
|
|
|
810
810
|
return e;
|
|
811
811
|
}
|
|
812
812
|
let d = e.cells.get(l), f = e.moves.get(l) ?? {};
|
|
813
|
-
for (let t of
|
|
813
|
+
for (let t of ne) {
|
|
814
814
|
if (r.has(`${l}:${t}`) || d && i(d, t)) continue;
|
|
815
815
|
let n = f[t];
|
|
816
816
|
if (n === null) continue;
|
|
817
|
-
let p = n === void 0, m = p ? d ?
|
|
817
|
+
let p = n === void 0, m = p ? d ? ue(e, d, t) : null : n;
|
|
818
818
|
if (!m || s.has(m)) continue;
|
|
819
819
|
let h = e.cells.get(m);
|
|
820
|
-
if (!p && d && h &&
|
|
821
|
-
let g = u + (p ?
|
|
820
|
+
if (!p && d && h && se(d, t, h)) continue;
|
|
821
|
+
let g = u + (p ? ce : 1);
|
|
822
822
|
g < (a.get(m) ?? Infinity) && (a.set(m, g), o.set(m, {
|
|
823
823
|
from: l,
|
|
824
824
|
dir: t,
|
|
@@ -827,7 +827,7 @@ var D = (e) => {
|
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
return null;
|
|
830
|
-
},
|
|
830
|
+
}, I = {
|
|
831
831
|
version: "1.0",
|
|
832
832
|
description: "Semantic mapping of M8 tracker views: defines the structure of each grid view so cursor position + line text can be interpreted as typed field values.",
|
|
833
833
|
notes: {
|
|
@@ -994,8 +994,8 @@ var D = (e) => {
|
|
|
994
994
|
},
|
|
995
995
|
relativeCommands: { description: "Relative commands add to the instrument parameter's current value (01-7F add, 80-FF subtract) and keep accumulating until a note is triggered with a RET command or with an instrument number in the I column; that resets every parameter to the instrument's own value." }
|
|
996
996
|
}
|
|
997
|
-
},
|
|
998
|
-
let n = e ?
|
|
997
|
+
}, fe = 3, pe = 1.5, me = 12, he = 34, ge = Object.fromEntries(Object.entries(I.views).flatMap(([e, t]) => t.rowField ? [[e, t.rowField.width]] : [])), _e = (e, t) => {
|
|
998
|
+
let n = e ? ge[e] : void 0;
|
|
999
999
|
if (!n) return null;
|
|
1000
1000
|
let r = -1, i = -1;
|
|
1001
1001
|
return t.forEach((e, t) => {
|
|
@@ -1005,12 +1005,12 @@ var D = (e) => {
|
|
|
1005
1005
|
last: i,
|
|
1006
1006
|
numberWidth: n
|
|
1007
1007
|
};
|
|
1008
|
-
},
|
|
1008
|
+
}, ve = [
|
|
1009
1009
|
"song",
|
|
1010
1010
|
"chain",
|
|
1011
1011
|
"phrase"
|
|
1012
|
-
],
|
|
1013
|
-
let r = e ?
|
|
1012
|
+
], ye = Object.fromEntries(Object.entries(I.views).flatMap(([e, t]) => ve.includes(e) && t.columns ? [[e, t.columns]] : [])), be = (e) => !!e && e in ye, xe = (e, t, n) => {
|
|
1013
|
+
let r = e ? ye[e] : void 0;
|
|
1014
1014
|
if (!r || !t) return null;
|
|
1015
1015
|
let i = {
|
|
1016
1016
|
cells: /* @__PURE__ */ new Map(),
|
|
@@ -1023,7 +1023,7 @@ var D = (e) => {
|
|
|
1023
1023
|
y: e * n.cellH + n.offY,
|
|
1024
1024
|
w: t.width * n.cellW,
|
|
1025
1025
|
h: n.cellH
|
|
1026
|
-
}, a =
|
|
1026
|
+
}, a = F(r);
|
|
1027
1027
|
return i.cells.set(a, r), a;
|
|
1028
1028
|
};
|
|
1029
1029
|
for (let e = t.first; e <= t.last; e++) r.forEach((n, o) => {
|
|
@@ -1031,7 +1031,7 @@ var D = (e) => {
|
|
|
1031
1031
|
e > t.first && (s.up = a(e - 1, n)), e < t.last && (s.down = a(e + 1, n)), o > 0 && (s.left = a(e, r[o - 1])), o < r.length - 1 && (s.right = a(e, r[o + 1])), i.moves.set(a(e, n), s);
|
|
1032
1032
|
});
|
|
1033
1033
|
return i;
|
|
1034
|
-
},
|
|
1034
|
+
}, Se = (e, t) => {
|
|
1035
1035
|
let n = Math.round((e.x - t.offX) / t.cellW), r = Math.round((e.y - t.offY) / t.cellH), i = Math.max(1, Math.round(e.w / t.cellW));
|
|
1036
1036
|
return {
|
|
1037
1037
|
x: n * t.cellW + t.offX,
|
|
@@ -1039,15 +1039,15 @@ var D = (e) => {
|
|
|
1039
1039
|
w: i * t.cellW,
|
|
1040
1040
|
h: t.cellH
|
|
1041
1041
|
};
|
|
1042
|
-
},
|
|
1042
|
+
}, Ce = (e, t) => Math.round((e.y - t.offY) / t.cellH), we = (e, t) => Math.round(e / t.cellW) >= 40 ? he : null, Te = (e, t) => e.map((e, n) => {
|
|
1043
1043
|
let r = (t === null ? e : e.slice(0, t)).trim().split(/\s+/)[0] ?? "";
|
|
1044
1044
|
return r.length >= 2 && /[g-z]/i.test(r) ? `${n}${r.toLowerCase()}` : "";
|
|
1045
|
-
}).filter(Boolean).join(" "),
|
|
1045
|
+
}).filter(Boolean).join(" "), Ee = (e, t, n) => ({
|
|
1046
1046
|
x: t * n.cellW + n.offX,
|
|
1047
1047
|
y: e * n.cellH + n.offY,
|
|
1048
1048
|
w: n.cellW,
|
|
1049
1049
|
h: n.cellH
|
|
1050
|
-
}),
|
|
1050
|
+
}), De = (e, t, n, r = () => !1) => {
|
|
1051
1051
|
let i = [];
|
|
1052
1052
|
return e.forEach((e, a) => {
|
|
1053
1053
|
let o = [...` ${(n === null ? e : e.slice(0, n)).slice(1)}`].map((e, t) => e !== " " && r(a, t) ? " " : e).join("");
|
|
@@ -1067,19 +1067,19 @@ var D = (e) => {
|
|
|
1067
1067
|
});
|
|
1068
1068
|
}
|
|
1069
1069
|
}), i;
|
|
1070
|
-
},
|
|
1071
|
-
let r =
|
|
1070
|
+
}, Oe = (e, t, n) => {
|
|
1071
|
+
let r = Ce(e, n), i = Math.round((e.x - n.offX) / n.cellW), a = Math.floor((e.x + e.w - 1 - n.offX) / n.cellW);
|
|
1072
1072
|
return (t[r] ?? "").slice(Math.max(0, i), a + 1).trim().length > 0;
|
|
1073
|
-
},
|
|
1073
|
+
}, ke = (e, t, n, r) => Math.max(0, Math.min(t, r) - Math.max(e, n)), Ae = (e, t, n) => ke(e.x, e.x + e.w, t.x, t.x + t.w) >= Math.min(n.cellW, t.w) / 2, je = (e, t, n) => ke(e.y, e.y + e.h, t.y, t.y + t.h) >= Math.min(n.cellH, t.h) / 2, Me = (e, t, n) => Ae(e, t, n) && je(e, t, n), Ne = (e) => ({
|
|
1074
1074
|
x: e.x + e.w / 2,
|
|
1075
1075
|
y: e.y + e.h / 2
|
|
1076
|
-
}),
|
|
1077
|
-
let n =
|
|
1076
|
+
}), Pe = (e, t) => {
|
|
1077
|
+
let n = Ne(e), r = Ne(t), i = Math.max(0, Math.abs(n.x - r.x) - (e.w + t.w) / 2 + fe), a = Math.max(0, Math.abs(n.y - r.y) - (e.h + t.h) / 2 + fe);
|
|
1078
1078
|
return Math.hypot(i, a) + .01 * Math.hypot(n.x - r.x, n.y - r.y);
|
|
1079
|
-
},
|
|
1079
|
+
}, Fe = (e, t) => ({
|
|
1080
1080
|
dx: Math.max(0, t.x - e.x, e.x - (t.x + t.w)),
|
|
1081
1081
|
dy: Math.max(0, t.y - e.y, e.y - (t.y + t.h))
|
|
1082
|
-
}),
|
|
1082
|
+
}), Ie = (e) => ({
|
|
1083
1083
|
kind: "point",
|
|
1084
1084
|
rect: {
|
|
1085
1085
|
x: e.x,
|
|
@@ -1087,22 +1087,22 @@ var D = (e) => {
|
|
|
1087
1087
|
w: 1,
|
|
1088
1088
|
h: 1
|
|
1089
1089
|
}
|
|
1090
|
-
}),
|
|
1090
|
+
}), Le = (e, t, n) => e.kind === "cell" && F(t) === e.id || Me(t, e.rect, n), Re = (e, t, n, r, i = null) => {
|
|
1091
1091
|
let a = (e) => !i || e >= i.first && e <= i.last, o = [];
|
|
1092
|
-
for (let [r, i] of e?.cells ?? []) a(
|
|
1092
|
+
for (let [r, i] of e?.cells ?? []) a(Ce(i, n)) && Oe(i, t, n) && o.push({
|
|
1093
1093
|
id: r,
|
|
1094
1094
|
rect: i
|
|
1095
1095
|
});
|
|
1096
1096
|
let s = (e, t) => {
|
|
1097
|
-
let r =
|
|
1098
|
-
return o.some((e) =>
|
|
1097
|
+
let r = Ee(e, t, n);
|
|
1098
|
+
return o.some((e) => Me(e.rect, r, n));
|
|
1099
1099
|
}, c = (e) => !!i && e.col === 1 && e.text.length <= i.numberWidth;
|
|
1100
1100
|
return {
|
|
1101
1101
|
cells: o,
|
|
1102
|
-
runs:
|
|
1102
|
+
runs: De(t, n, r, s).filter((e) => a(e.row) && !c(e))
|
|
1103
1103
|
};
|
|
1104
|
-
},
|
|
1105
|
-
let { cells: c, runs: l } =
|
|
1104
|
+
}, ze = (e, t, n, r, i, a = null, o = /* @__PURE__ */ new Set(), s = !1) => {
|
|
1105
|
+
let { cells: c, runs: l } = Re(t, n, r, i, a), u = c.map((e) => ({
|
|
1106
1106
|
goal: {
|
|
1107
1107
|
kind: "cell",
|
|
1108
1108
|
...e
|
|
@@ -1116,7 +1116,7 @@ var D = (e) => {
|
|
|
1116
1116
|
goal: {
|
|
1117
1117
|
kind: "text",
|
|
1118
1118
|
key: n.key,
|
|
1119
|
-
rect:
|
|
1119
|
+
rect: Ee(n.row, i, r),
|
|
1120
1120
|
run: n.rect,
|
|
1121
1121
|
row: n.row
|
|
1122
1122
|
},
|
|
@@ -1126,25 +1126,25 @@ var D = (e) => {
|
|
|
1126
1126
|
let d = n[Math.floor((e.y - r.offY) / r.cellH)] ?? "", f = (e) => e > 0 && (d[e] ?? " ") !== " ", p = Math.floor((e.x - r.offX) / r.cellW);
|
|
1127
1127
|
for (; f(p) && (f(p + 1) || f(p + 2));) p += f(p + 1) ? 1 : 2;
|
|
1128
1128
|
let m = (t) => {
|
|
1129
|
-
let { dx: n, dy: i } =
|
|
1130
|
-
if (i > 0 || n >
|
|
1129
|
+
let { dx: n, dy: i } = Fe(e, t);
|
|
1130
|
+
if (i > 0 || n > me * r.cellW) return !1;
|
|
1131
1131
|
let a = Math.round((t.x - r.offX) / r.cellW);
|
|
1132
1132
|
if (a <= p) return !0;
|
|
1133
1133
|
for (let e = p + 1; e < a; e++) if (f(e)) return !1;
|
|
1134
1134
|
return !0;
|
|
1135
1135
|
}, h = u.some(({ area: e }) => m(e)), g = u.some(({ goal: e }) => e.kind === "cell"), _ = null;
|
|
1136
1136
|
for (let { goal: t, area: n } of u) {
|
|
1137
|
-
let { dx: r, dy: i } =
|
|
1137
|
+
let { dx: r, dy: i } = Fe(e, n);
|
|
1138
1138
|
if (h && !m(n) || s && !h && g && t.kind !== "cell") continue;
|
|
1139
|
-
let a = n.x > e.x, o = Math.hypot(r, i *
|
|
1139
|
+
let a = n.x > e.x, o = Math.hypot(r, i * pe) - (t.kind === "cell" ? .001 : 0) - (a ? .5 : 0), c = Ne(n), l = Math.hypot(c.x - e.x, c.y - e.y);
|
|
1140
1140
|
(!_ || o < _.score - 1e-6 || Math.abs(o - _.score) <= 1e-6 && l < _.tie) && (_ = {
|
|
1141
1141
|
goal: t,
|
|
1142
1142
|
score: o,
|
|
1143
1143
|
tie: l
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
1146
|
-
return _?.goal ??
|
|
1147
|
-
},
|
|
1146
|
+
return _?.goal ?? Ie(e);
|
|
1147
|
+
}, L = {
|
|
1148
1148
|
Left: 128,
|
|
1149
1149
|
Up: 64,
|
|
1150
1150
|
Down: 32,
|
|
@@ -1153,22 +1153,22 @@ var D = (e) => {
|
|
|
1153
1153
|
Right: 4,
|
|
1154
1154
|
Opt: 2,
|
|
1155
1155
|
Edit: 1
|
|
1156
|
-
},
|
|
1156
|
+
}, Be = ({ left: e, right: t, up: n, down: r, shift: i, play: a, opt: o, edit: s }) => {
|
|
1157
1157
|
let c = 0;
|
|
1158
|
-
return e && (c |=
|
|
1159
|
-
},
|
|
1160
|
-
up:
|
|
1161
|
-
down:
|
|
1162
|
-
left:
|
|
1163
|
-
right:
|
|
1164
|
-
},
|
|
1165
|
-
if (e &
|
|
1166
|
-
let t = Object.keys(
|
|
1158
|
+
return e && (c |= L.Left), t && (c |= L.Right), n && (c |= L.Up), r && (c |= L.Down), i && (c |= L.Shift), a && (c |= L.Play), o && (c |= L.Opt), s && (c |= L.Edit), c;
|
|
1159
|
+
}, Ve = {
|
|
1160
|
+
up: L.Up,
|
|
1161
|
+
down: L.Down,
|
|
1162
|
+
left: L.Left,
|
|
1163
|
+
right: L.Right
|
|
1164
|
+
}, He = L.Up | L.Down | L.Left | L.Right, Ue = L.Edit | L.Opt | L.Shift | L.Play, We = He | L.Edit | L.Opt | L.Shift, Ge = 48, Ke = 40, qe = 16, Je = 4, Ye = 150, Xe = 300, Ze = 200, Qe = (e, t) => !!e && !!t && e.x === t.x && e.y === t.y && e.w === t.w && e.h === t.h, $e = (e) => {
|
|
1165
|
+
if (e & Ue) return null;
|
|
1166
|
+
let t = Object.keys(Ve).filter((t) => e & Ve[t]);
|
|
1167
1167
|
return t.length === 1 ? t[0] : null;
|
|
1168
|
-
},
|
|
1169
|
-
let i = null, a = 0, o = 0, s = !1, c = null, l = null, u = () => t.get("cellMetrics"), d = () =>
|
|
1168
|
+
}, et = ({ bus: e, store: t, getScreenLines: n = () => [], cursorMap: r = oe() }) => {
|
|
1169
|
+
let i = null, a = 0, o = 0, s = !1, c = null, l = null, u = () => t.get("cellMetrics"), d = () => we(t.get("systemInfo")?.screenWidth ?? 480, u()), f = () => {
|
|
1170
1170
|
let e = t.get("cursorRect");
|
|
1171
|
-
return e ?
|
|
1171
|
+
return e ? Se(e, u()) : null;
|
|
1172
1172
|
}, p = () => {
|
|
1173
1173
|
let e = t.get("viewName");
|
|
1174
1174
|
if (!e || t.get("selectionMode")) return null;
|
|
@@ -1177,38 +1177,38 @@ var D = (e) => {
|
|
|
1177
1177
|
e,
|
|
1178
1178
|
r?.model ?? t.get("deviceModel") ?? "?",
|
|
1179
1179
|
r?.fontMode ?? t.get("fontMode") ?? "?",
|
|
1180
|
-
|
|
1180
|
+
Te(n(), d())
|
|
1181
1181
|
].join("|");
|
|
1182
1182
|
}, m = () => {
|
|
1183
1183
|
c &&= (clearTimeout(c), null);
|
|
1184
|
-
}, h = (e =
|
|
1184
|
+
}, h = (e = Ye) => {
|
|
1185
1185
|
m(), c = setTimeout(() => {
|
|
1186
1186
|
c = null, D("timeout");
|
|
1187
1187
|
}, e);
|
|
1188
1188
|
}, g = (e) => {
|
|
1189
1189
|
if (!i) return;
|
|
1190
1190
|
let { resolve: t } = i;
|
|
1191
|
-
i.goal, f(), i = null, m(), s = !1, o = a & ~
|
|
1191
|
+
i.goal, f(), i = null, m(), s = !1, o = a & ~We, t(e);
|
|
1192
1192
|
}, _ = (t) => {
|
|
1193
|
-
e.commands.sendKeys(o |
|
|
1194
|
-
}, v = (e, t, n) => e.goal.kind === "cell" ? t === e.goal.id : !!n &&
|
|
1193
|
+
e.commands.sendKeys(o | Ve[t]), e.commands.sendKeys(o);
|
|
1194
|
+
}, v = (e, t, n) => e.goal.kind === "cell" ? t === e.goal.id : !!n && Le(e.goal, n, u()), y = (e, t) => {
|
|
1195
1195
|
let n = [], r = e.y + e.h / 2, i = e.x + e.w / 2;
|
|
1196
|
-
return
|
|
1196
|
+
return je(e, t.rect, u()) || n.push(t.rect.y + t.rect.h / 2 < r ? "up" : "down"), Ae(e, t.rect, u()) || n.push(t.rect.x + t.rect.w / 2 < i ? "left" : "right"), n;
|
|
1197
1197
|
}, b = (e, t, n) => {
|
|
1198
1198
|
if (!e.grid) return !1;
|
|
1199
|
-
let r =
|
|
1199
|
+
let r = Ce(t, u());
|
|
1200
1200
|
return n === "up" && r <= e.grid.first || n === "down" && r >= e.grid.last;
|
|
1201
1201
|
}, x = (e) => e.fixed ?? (e.layoutKey ? r.get(e.layoutKey) : void 0), S = (e, t) => {
|
|
1202
|
-
let n =
|
|
1202
|
+
let n = F(t), r = x(e);
|
|
1203
1203
|
if (r) {
|
|
1204
|
-
let t =
|
|
1205
|
-
if (t && !(t.guessed && (e.explored >=
|
|
1204
|
+
let t = de(r, n, (t) => v(e, t, r.cells.get(t)), e.distrust, (t, n) => b(e, t, n))?.[0];
|
|
1205
|
+
if (t && !(t.guessed && (e.explored >= Ke || e.tried.has(`${n}:${t.dir}`)))) return {
|
|
1206
1206
|
dir: t.dir,
|
|
1207
1207
|
expected: t.to,
|
|
1208
1208
|
guessed: t.guessed
|
|
1209
1209
|
};
|
|
1210
1210
|
}
|
|
1211
|
-
let i = r?.moves.get(n) ?? {}, a =
|
|
1211
|
+
let i = r?.moves.get(n) ?? {}, a = Pe(t, e.goal.rect), o = null;
|
|
1212
1212
|
for (let s of y(t, e.goal)) {
|
|
1213
1213
|
let c = `${n}:${s}`;
|
|
1214
1214
|
if (e.tried.has(c) || b(e, t, s)) continue;
|
|
@@ -1220,12 +1220,12 @@ var D = (e) => {
|
|
|
1220
1220
|
};
|
|
1221
1221
|
else if (l !== void 0) {
|
|
1222
1222
|
let n = r?.cells.get(l);
|
|
1223
|
-
if (n && !
|
|
1223
|
+
if (n && !se(t, s, n) && Pe(n, e.goal.rect) < a) return {
|
|
1224
1224
|
dir: s,
|
|
1225
1225
|
expected: l,
|
|
1226
1226
|
guessed: !1
|
|
1227
1227
|
};
|
|
1228
|
-
} else return e.explored >=
|
|
1228
|
+
} else return e.explored >= Ke ? null : {
|
|
1229
1229
|
dir: s,
|
|
1230
1230
|
expected: void 0,
|
|
1231
1231
|
guessed: !0
|
|
@@ -1233,7 +1233,7 @@ var D = (e) => {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
return o;
|
|
1235
1235
|
}, C = (e, t, n) => {
|
|
1236
|
-
_(n.dir), e.steps += 1, n.guessed && (e.explored += 1), e.tried.add(`${
|
|
1236
|
+
_(n.dir), e.steps += 1, n.guessed && (e.explored += 1), e.tried.add(`${F(t)}:${n.dir}`), e.pending = {
|
|
1237
1237
|
from: t,
|
|
1238
1238
|
dir: n.dir,
|
|
1239
1239
|
expected: n.expected,
|
|
@@ -1241,16 +1241,16 @@ var D = (e) => {
|
|
|
1241
1241
|
}, s = !0, n.dir, n.expected, h();
|
|
1242
1242
|
}, w = (e, t, i) => {
|
|
1243
1243
|
if (e.phase === "seek") {
|
|
1244
|
-
if (e.goal.kind === "text" &&
|
|
1244
|
+
if (e.goal.kind === "text" && Me(t, e.goal.run, u())) {
|
|
1245
1245
|
g(!0);
|
|
1246
1246
|
return;
|
|
1247
1247
|
}
|
|
1248
1248
|
if (i && e.goal.kind === "text" && e.layoutKey) {
|
|
1249
|
-
let { row: i, run: a } = e.goal, o =
|
|
1249
|
+
let { row: i, run: a } = e.goal, o = je(t, a, u()), s = a.x + a.w / 2 < t.x + t.w / 2, c = Ce(t, u()), l = i < c ? "up" : "down", f = Math.abs(i - c) === 1 && x(e)?.moves.get(F(t))?.[l] === null, p = o || f ? Re(x(e), n(), u(), d(), e.grid).runs.filter((e) => e.row === i).filter((e) => !o || (s ? e.rect.x + e.rect.w <= t.x + 3 : e.rect.x >= t.x + t.w - 3)).map((e) => e.key) : [];
|
|
1250
1250
|
p.includes(e.goal.key) || p.push(e.goal.key);
|
|
1251
1251
|
for (let t of p) e.failedTexts.add(t), e.grid || r.markUnreachable(e.layoutKey, t);
|
|
1252
|
-
let m =
|
|
1253
|
-
if (e.goals <
|
|
1252
|
+
let m = ze(e.point, x(e), n(), u(), d(), e.grid, e.failedTexts, !0);
|
|
1253
|
+
if (e.goals < Je && m.kind !== "point" && m.rect !== e.goal.rect) {
|
|
1254
1254
|
e.goal, e.goal = m, e.goals += 1, e.explored = 0, e.tried.clear(), T(e);
|
|
1255
1255
|
return;
|
|
1256
1256
|
}
|
|
@@ -1260,13 +1260,13 @@ var D = (e) => {
|
|
|
1260
1260
|
y: e.point.y,
|
|
1261
1261
|
w: 1,
|
|
1262
1262
|
h: 1
|
|
1263
|
-
}, o =
|
|
1264
|
-
if (o.length > 0) for (let e of o)
|
|
1265
|
-
else for (let t of e.visited.values())
|
|
1266
|
-
if (!
|
|
1263
|
+
}, o = Re(x(e), n(), u(), d(), e.grid).cells, s = t;
|
|
1264
|
+
if (o.length > 0) for (let e of o) Pe(e.rect, a) < Pe(s, a) - 1e-6 && (s = e.rect);
|
|
1265
|
+
else for (let t of e.visited.values()) Pe(t, e.goal.rect) < Pe(s, e.goal.rect) - 1e-6 && (s = t);
|
|
1266
|
+
if (!Qe(s, t)) {
|
|
1267
1267
|
e.goal, e.phase = "return", e.goal = {
|
|
1268
1268
|
kind: "cell",
|
|
1269
|
-
id:
|
|
1269
|
+
id: F(s),
|
|
1270
1270
|
rect: s
|
|
1271
1271
|
}, e.steps = 0, e.explored = 0, e.tried.clear(), T(e);
|
|
1272
1272
|
return;
|
|
@@ -1280,23 +1280,23 @@ var D = (e) => {
|
|
|
1280
1280
|
g(!1);
|
|
1281
1281
|
return;
|
|
1282
1282
|
}
|
|
1283
|
-
if (
|
|
1283
|
+
if (Le(e.goal, t, u())) {
|
|
1284
1284
|
g(e.phase === "seek");
|
|
1285
1285
|
return;
|
|
1286
1286
|
}
|
|
1287
|
-
if (e.steps >= (e.phase === "seek" ?
|
|
1287
|
+
if (e.steps >= (e.phase === "seek" ? Ge : qe)) {
|
|
1288
1288
|
w(e, t, !1);
|
|
1289
1289
|
return;
|
|
1290
1290
|
}
|
|
1291
1291
|
let n = S(e, t);
|
|
1292
|
-
n ? C(e, t, n) : w(e, t, e.explored <
|
|
1292
|
+
n ? C(e, t, n) : w(e, t, e.explored < Ke);
|
|
1293
1293
|
}
|
|
1294
1294
|
let E = (e, t, n) => {
|
|
1295
1295
|
e.pending = null, m(), s = !1;
|
|
1296
1296
|
let i = p();
|
|
1297
1297
|
e.layoutKey && i === e.layoutKey && !e.fixed && r.recordMove(e.layoutKey, t.from, t.dir, n);
|
|
1298
|
-
let a = n ?
|
|
1299
|
-
!t.guessed && t.expected !== void 0 && a !== t.expected && e.distrust.add(`${
|
|
1298
|
+
let a = n ? F(n) : null;
|
|
1299
|
+
!t.guessed && t.expected !== void 0 && a !== t.expected && e.distrust.add(`${F(t.from)}:${t.dir}`), n && e.visited.set(F(n), n);
|
|
1300
1300
|
};
|
|
1301
1301
|
function D(e) {
|
|
1302
1302
|
let n = i;
|
|
@@ -1305,12 +1305,12 @@ var D = (e) => {
|
|
|
1305
1305
|
if (!r) g(!1);
|
|
1306
1306
|
else {
|
|
1307
1307
|
if (n.pending) {
|
|
1308
|
-
if (!
|
|
1308
|
+
if (!Qe(n.pending.from, r)) E(n, n.pending, r);
|
|
1309
1309
|
else if (e === "timeout" && !n.pending.graced) {
|
|
1310
|
-
n.pending.graced = !0, h(
|
|
1310
|
+
n.pending.graced = !0, h(Xe);
|
|
1311
1311
|
return;
|
|
1312
1312
|
} else if (e === "timeout") {
|
|
1313
|
-
let e = `${
|
|
1313
|
+
let e = `${F(n.pending.from)}:${n.pending.dir}`;
|
|
1314
1314
|
n.grid && !n.retried.has(e) ? (n.retried.add(e), n.tried.delete(e), n.pending = null, s = !1) : E(n, n.pending, null);
|
|
1315
1315
|
} else return;
|
|
1316
1316
|
}
|
|
@@ -1322,32 +1322,32 @@ var D = (e) => {
|
|
|
1322
1322
|
l = null, s && (s = !1, i.pending && h());
|
|
1323
1323
|
return;
|
|
1324
1324
|
}
|
|
1325
|
-
o = a & ~
|
|
1326
|
-
let t =
|
|
1325
|
+
o = a & ~We;
|
|
1326
|
+
let t = $e(a);
|
|
1327
1327
|
t ? (!l || l.dir !== t || l.releasedAt !== null) && (l = {
|
|
1328
1328
|
dir: t,
|
|
1329
1329
|
from: f(),
|
|
1330
1330
|
layoutKey: p(),
|
|
1331
1331
|
releasedAt: null
|
|
1332
1332
|
}) : a === 0 && l ? l.releasedAt ??= Date.now() : l = null;
|
|
1333
|
-
},
|
|
1333
|
+
}, ee = () => {
|
|
1334
1334
|
if (i) {
|
|
1335
1335
|
D("rect");
|
|
1336
1336
|
return;
|
|
1337
1337
|
}
|
|
1338
1338
|
let e = f(), a = p();
|
|
1339
|
-
if (!e || !a ||
|
|
1339
|
+
if (!e || !a || be(t.get("viewName"))) {
|
|
1340
1340
|
l = null;
|
|
1341
1341
|
return;
|
|
1342
1342
|
}
|
|
1343
1343
|
let o = l;
|
|
1344
|
-
if (o?.from && o.layoutKey === a && (o.releasedAt === null || Date.now() - o.releasedAt <=
|
|
1344
|
+
if (o?.from && o.layoutKey === a && (o.releasedAt === null || Date.now() - o.releasedAt <= Ze)) {
|
|
1345
1345
|
let t = n();
|
|
1346
|
-
!
|
|
1346
|
+
!Qe(o.from, e) && Oe(o.from, t, u()) && Oe(e, t, u()) && r.recordMove(a, o.from, o.dir, e), o.from = e;
|
|
1347
1347
|
} else l = null;
|
|
1348
1348
|
};
|
|
1349
1349
|
e.protocol.eventBus.on("key", O);
|
|
1350
|
-
let
|
|
1350
|
+
let k = t.sub("cursorRect", ee);
|
|
1351
1351
|
return {
|
|
1352
1352
|
navigateTo: (e) => new Promise((s) => {
|
|
1353
1353
|
let m = f();
|
|
@@ -1360,8 +1360,8 @@ var D = (e) => {
|
|
|
1360
1360
|
let e = i;
|
|
1361
1361
|
i = null, e.resolve(!1);
|
|
1362
1362
|
}
|
|
1363
|
-
let _ = p(), v = n(), y =
|
|
1364
|
-
_ && !x &&
|
|
1363
|
+
let _ = p(), v = n(), y = _e(t.get("viewName"), v), b = _ ? xe(t.get("viewName"), y, u()) : null, x = b?.cells.has(F(m)) ? b : null, S = x ?? (_ ? r.get(_) : void 0), C = t.get("selectionMode") ? Ie(e) : ze(e, S, v, u(), d(), y);
|
|
1364
|
+
_ && !x && Oe(m, v, u()) && r.recordCell(_, m), g || (o = a & ~We), l = null;
|
|
1365
1365
|
let w = {
|
|
1366
1366
|
point: e,
|
|
1367
1367
|
grid: y,
|
|
@@ -1376,7 +1376,7 @@ var D = (e) => {
|
|
|
1376
1376
|
tried: /* @__PURE__ */ new Set(),
|
|
1377
1377
|
retried: /* @__PURE__ */ new Set(),
|
|
1378
1378
|
distrust: /* @__PURE__ */ new Set(),
|
|
1379
|
-
visited: /* @__PURE__ */ new Map([[
|
|
1379
|
+
visited: /* @__PURE__ */ new Map([[F(m), m]]),
|
|
1380
1380
|
failedTexts: /* @__PURE__ */ new Set(),
|
|
1381
1381
|
pending: g ? {
|
|
1382
1382
|
...g,
|
|
@@ -1388,26 +1388,26 @@ var D = (e) => {
|
|
|
1388
1388
|
i = w, g ? c || h() : T(w);
|
|
1389
1389
|
}),
|
|
1390
1390
|
dispose: () => {
|
|
1391
|
-
g(!1), e.protocol.eventBus.off("key", O),
|
|
1391
|
+
g(!1), e.protocol.eventBus.off("key", O), k();
|
|
1392
1392
|
}
|
|
1393
1393
|
};
|
|
1394
|
-
},
|
|
1394
|
+
}, R = (e) => e?.trim().toLowerCase() ?? "", tt = /\.m[a-z0-9]{2}$/i, nt = (e) => [
|
|
1395
1395
|
e.viewName ?? "",
|
|
1396
1396
|
e.viewTitle ?? "",
|
|
1397
1397
|
e.cursorPos?.x ?? "",
|
|
1398
1398
|
e.cursorPos?.y ?? "",
|
|
1399
1399
|
e.textUnderCursor ?? "",
|
|
1400
1400
|
e.currentLine ?? ""
|
|
1401
|
-
].join("|"),
|
|
1402
|
-
let t =
|
|
1401
|
+
].join("|"), rt = (e) => e.textUnderCursor?.trim() || e.currentLine?.trim() || null, it = (e) => {
|
|
1402
|
+
let t = R(e.viewName), n = R(e.viewTitle);
|
|
1403
1403
|
return t.includes("load") || t.includes("save") || n.includes("load") || n.includes("save");
|
|
1404
|
-
},
|
|
1404
|
+
}, at = (e) => R(e) === "/..", ot = (e) => !!e?.trim().startsWith("/"), st = (e) => !!e && !ot(e) && tt.test(e.trim()), ct = (e) => {
|
|
1405
1405
|
let t = e?.trim() ?? "";
|
|
1406
1406
|
if (!t) return [];
|
|
1407
|
-
let n =
|
|
1407
|
+
let n = R(t), r = R(t.replace(tt, ""));
|
|
1408
1408
|
return Array.from(new Set([n, r].filter(Boolean)));
|
|
1409
|
-
},
|
|
1410
|
-
let n = (t) => e[t]?.trim() ?? "", r = t.cursorPos?.y ?? null, i =
|
|
1409
|
+
}, lt = (e) => at(e) ? "parent" : ot(e) ? /^\/[^/]+$/.test(e.trim()) ? "dir" : "other" : st(e) ? "file" : "other", ut = (e, t) => {
|
|
1410
|
+
let n = (t) => e[t]?.trim() ?? "", r = t.cursorPos?.y ?? null, i = R(t.viewTitle), a = 0, o = e.length - 1;
|
|
1411
1411
|
if (r !== null && n(r)) {
|
|
1412
1412
|
for (a = r; a > 0 && n(a - 1);) --a;
|
|
1413
1413
|
for (o = r; o < e.length - 1 && n(o + 1);) o += 1;
|
|
@@ -1415,11 +1415,11 @@ var D = (e) => {
|
|
|
1415
1415
|
let s = [];
|
|
1416
1416
|
for (let e = a; e <= o; e += 1) {
|
|
1417
1417
|
let t = n(e);
|
|
1418
|
-
!t || i &&
|
|
1418
|
+
!t || i && R(t) === i || s.push({
|
|
1419
1419
|
row: e,
|
|
1420
1420
|
text: t,
|
|
1421
|
-
key:
|
|
1422
|
-
kind:
|
|
1421
|
+
key: R(t),
|
|
1422
|
+
kind: lt(t)
|
|
1423
1423
|
});
|
|
1424
1424
|
}
|
|
1425
1425
|
let c = t.textUnderCursor?.trim();
|
|
@@ -1430,7 +1430,7 @@ var D = (e) => {
|
|
|
1430
1430
|
hasParent: s.some((e) => e.kind === "parent"),
|
|
1431
1431
|
consistent: !c || r === null || n(r).includes(c)
|
|
1432
1432
|
};
|
|
1433
|
-
},
|
|
1433
|
+
}, dt = (e, t) => {
|
|
1434
1434
|
if (t.length === 0) return {
|
|
1435
1435
|
order: e,
|
|
1436
1436
|
consistent: !0
|
|
@@ -1464,26 +1464,26 @@ var D = (e) => {
|
|
|
1464
1464
|
order: i,
|
|
1465
1465
|
consistent: !0
|
|
1466
1466
|
};
|
|
1467
|
-
},
|
|
1467
|
+
}, ft = (e) => e.split(/[^a-z0-9]+/).filter((e) => e.length >= 3), pt = /* @__PURE__ */ new Set([
|
|
1468
1468
|
"load",
|
|
1469
1469
|
"save",
|
|
1470
1470
|
"select",
|
|
1471
1471
|
"create",
|
|
1472
1472
|
"directory",
|
|
1473
1473
|
"new"
|
|
1474
|
-
]),
|
|
1475
|
-
target:
|
|
1476
|
-
title:
|
|
1477
|
-
}),
|
|
1474
|
+
]), mt = (e, t) => ({
|
|
1475
|
+
target: ft(R(e).replace(tt, "")),
|
|
1476
|
+
title: ft(R(t)).filter((e) => !pt.has(e))
|
|
1477
|
+
}), ht = (e, t) => {
|
|
1478
1478
|
let n = e.replace(/^\//, "");
|
|
1479
1479
|
if (n.length < 3) return 0;
|
|
1480
1480
|
let r = (e) => e.includes(n) || n.includes(e);
|
|
1481
1481
|
return t.target.some(r) ? 2 : +!!t.title.some(r);
|
|
1482
|
-
},
|
|
1482
|
+
}, z = (e) => new Promise((t) => setTimeout(t, e)), gt = ({ getKeySink: e, store: t, debugLog: n, getScreenLines: r }) => {
|
|
1483
1483
|
let i = () => !!e(), a = (t) => {
|
|
1484
1484
|
e()?.sendKeys(t);
|
|
1485
1485
|
}, o = async (e, t = 50) => {
|
|
1486
|
-
a(e), await
|
|
1486
|
+
a(e), await z(t), a(0), await z(t);
|
|
1487
1487
|
}, s = (e, n = 500) => new Promise((r) => {
|
|
1488
1488
|
let i = !1, a = null, o = null, s = (e) => {
|
|
1489
1489
|
i || (i = !0, o !== null && clearTimeout(o), a?.(), r(e));
|
|
@@ -1521,21 +1521,21 @@ var D = (e) => {
|
|
|
1521
1521
|
}),
|
|
1522
1522
|
getFileBrowserSnapshot: c,
|
|
1523
1523
|
waitForFileBrowserSnapshotChange: (e, n = 500) => new Promise((r) => {
|
|
1524
|
-
let i = !1, a = null, o = null, s = null, l = null, u = null, d = null, f =
|
|
1524
|
+
let i = !1, a = null, o = null, s = null, l = null, u = null, d = null, f = nt(e), p = (e) => {
|
|
1525
1525
|
i || (i = !0, d !== null && clearTimeout(d), a?.(), o?.(), s?.(), l?.(), u?.(), r(e));
|
|
1526
1526
|
}, m = () => {
|
|
1527
1527
|
let e = c();
|
|
1528
|
-
|
|
1528
|
+
nt(e) !== f && p(e);
|
|
1529
1529
|
}, h = c();
|
|
1530
|
-
|
|
1530
|
+
nt(h) === f ? (a = t.sub("textUnderCursor", m), o = t.sub("currentLine", m), s = t.sub("cursorPos", m), l = t.sub("viewName", m), u = t.sub("viewTitle", m), d = setTimeout(() => {
|
|
1531
1531
|
p(c());
|
|
1532
1532
|
}, n)) : p(h);
|
|
1533
1533
|
}),
|
|
1534
1534
|
getScreenLines: r
|
|
1535
1535
|
};
|
|
1536
|
-
},
|
|
1536
|
+
}, B = (e, t) => {
|
|
1537
1537
|
t === void 0 ? console.log("[M8SDK browseFile]", e) : console.log("[M8SDK browseFile]", e, t);
|
|
1538
|
-
},
|
|
1538
|
+
}, _t = 8, vt = 8, yt = 64, bt = 512, xt = () => ({
|
|
1539
1539
|
order: [],
|
|
1540
1540
|
kinds: /* @__PURE__ */ new Map(),
|
|
1541
1541
|
names: /* @__PURE__ */ new Map(),
|
|
@@ -1545,52 +1545,52 @@ var D = (e) => {
|
|
|
1545
1545
|
sorted: !1,
|
|
1546
1546
|
visited: /* @__PURE__ */ new Set(),
|
|
1547
1547
|
rejected: /* @__PURE__ */ new Set()
|
|
1548
|
-
}),
|
|
1548
|
+
}), St = (e) => e === "up" ? "down" : "up", Ct = (e) => {
|
|
1549
1549
|
let { hasBus: t, pressAndRelease: n, getFileBrowserSnapshot: r, waitForFileBrowserSnapshotChange: i, getScreenLines: a } = e, o = /* @__PURE__ */ new Map(), s = null, c = null;
|
|
1550
1550
|
return async (e, l = !0) => {
|
|
1551
1551
|
if (!t()) return !1;
|
|
1552
|
-
let u =
|
|
1552
|
+
let u = R(e);
|
|
1553
1553
|
if (!u) return !1;
|
|
1554
|
-
let d =
|
|
1555
|
-
|
|
1554
|
+
let d = tt.test(u), f = mt(e, r().viewTitle);
|
|
1555
|
+
B("start", {
|
|
1556
1556
|
targetText: e,
|
|
1557
1557
|
normalizedTarget: u,
|
|
1558
1558
|
exact: l
|
|
1559
1559
|
});
|
|
1560
|
-
let p = () =>
|
|
1560
|
+
let p = () => it(r()), m = async (e, t = 350) => {
|
|
1561
1561
|
let a = r();
|
|
1562
1562
|
await n(e, 35);
|
|
1563
1563
|
let o = await i(a, t);
|
|
1564
1564
|
return {
|
|
1565
|
-
changed:
|
|
1565
|
+
changed: nt(o) !== nt(a),
|
|
1566
1566
|
snapshot: o
|
|
1567
1567
|
};
|
|
1568
|
-
}, h = (e) => e === "up" ?
|
|
1568
|
+
}, h = (e) => e === "up" ? L.Up : L.Down, g = (e) => L.Opt | h(e), _ = async () => {
|
|
1569
1569
|
let e = r();
|
|
1570
|
-
|
|
1571
|
-
}, v = (e) =>
|
|
1570
|
+
B("apply alphabetical sort"), await n(L.Shift | L.Opt, 35), await z(180), await i(e, 300);
|
|
1571
|
+
}, v = (e) => st(e) ? ct(e).some((e) => l ? e === u : e.includes(u)) : !1, y = (e) => {
|
|
1572
1572
|
let t = e.trim();
|
|
1573
|
-
return d ? t : t.replace(
|
|
1574
|
-
}, b = (e) =>
|
|
1573
|
+
return d ? t : t.replace(tt, "");
|
|
1574
|
+
}, b = (e) => R(y(e)), x = y(e), S = async () => {
|
|
1575
1575
|
for (let e = 0;; e += 1) {
|
|
1576
|
-
let t =
|
|
1576
|
+
let t = ut(a(), r());
|
|
1577
1577
|
if (t.consistent || e >= 2) return t;
|
|
1578
|
-
await
|
|
1578
|
+
await z(40);
|
|
1579
1579
|
}
|
|
1580
1580
|
}, C = (e, t) => {
|
|
1581
|
-
let n = t.entries.map((e) => e.key), i =
|
|
1581
|
+
let n = t.entries.map((e) => e.key), i = dt(e.order, n);
|
|
1582
1582
|
e.order = i.order, i.consistent || (e.top = !1, e.bottom = !1);
|
|
1583
1583
|
for (let n of t.entries) e.kinds.set(n.key, n.kind), e.names.set(n.key, n.text);
|
|
1584
|
-
let a =
|
|
1584
|
+
let a = R(r().viewName);
|
|
1585
1585
|
if (t.hasParent) e.hasParent = !0, e.top = !0;
|
|
1586
1586
|
else if (e.hasParent && n.length > 0) {
|
|
1587
1587
|
let e = o.get(a);
|
|
1588
1588
|
(e === void 0 || n.length < e) && o.set(a, n.length);
|
|
1589
1589
|
}
|
|
1590
|
-
n.length < Math.max(
|
|
1590
|
+
n.length < Math.max(vt, o.get(a) ?? 0) && (e.top = !0, e.bottom = !0);
|
|
1591
1591
|
}, w = async (e, t, n) => {
|
|
1592
1592
|
let r = (await m(g(n), 280)).changed, i = r, a = !1;
|
|
1593
|
-
if (!r && s !== !0) for (let e = 0; e <
|
|
1593
|
+
if (!r && s !== !0) for (let e = 0; e < _t; e += 1) {
|
|
1594
1594
|
if (!(await m(h(n), 250)).changed) {
|
|
1595
1595
|
a = !0;
|
|
1596
1596
|
break;
|
|
@@ -1598,11 +1598,11 @@ var D = (e) => {
|
|
|
1598
1598
|
i = !0, s = !1;
|
|
1599
1599
|
}
|
|
1600
1600
|
else r || (a = !0);
|
|
1601
|
-
if (a && (n === "up" ? e.top = !0 : e.bottom = !0,
|
|
1601
|
+
if (a && (n === "up" ? e.top = !0 : e.bottom = !0, B("end of list", { direction: n })), !i) return null;
|
|
1602
1602
|
let o = await S();
|
|
1603
1603
|
C(e, o);
|
|
1604
1604
|
let c = t.cursorKey ? e.order.indexOf(t.cursorKey) : -1, l = o.cursorKey ? e.order.indexOf(o.cursorKey) : -1, u = Math.abs(l - c);
|
|
1605
|
-
return r && c >= 0 && l >= 0 && u > 0 && u <
|
|
1605
|
+
return r && c >= 0 && l >= 0 && u > 0 && u < _t && (s = !0), o;
|
|
1606
1606
|
}, T = (e, t, n) => {
|
|
1607
1607
|
if (n === "/..") return "up";
|
|
1608
1608
|
let r = e.order.indexOf(n), i = t.cursorKey ? e.order.indexOf(t.cursorKey) : -1;
|
|
@@ -1616,7 +1616,7 @@ var D = (e) => {
|
|
|
1616
1616
|
let t = n.row - r.cursorRow;
|
|
1617
1617
|
if (t === 0) return r;
|
|
1618
1618
|
let i = t < 0 ? "up" : "down";
|
|
1619
|
-
if (!(await m(Math.abs(t) >=
|
|
1619
|
+
if (!(await m(Math.abs(t) >= _t ? g(i) : h(i), 250)).changed) return null;
|
|
1620
1620
|
r = await S(), C(e, r);
|
|
1621
1621
|
continue;
|
|
1622
1622
|
}
|
|
@@ -1624,61 +1624,61 @@ var D = (e) => {
|
|
|
1624
1624
|
let o = await w(e, r, i);
|
|
1625
1625
|
if (o) r = o;
|
|
1626
1626
|
else if (a) return null;
|
|
1627
|
-
else a = !0, i =
|
|
1627
|
+
else a = !0, i = St(i);
|
|
1628
1628
|
}
|
|
1629
1629
|
return null;
|
|
1630
1630
|
}, D = async (e, t) => {
|
|
1631
1631
|
let n = t.cursorRow ?? 0, i = t.entries.filter((t) => t.kind === "file" && !e.rejected.has(t.key) && v(t.text)).sort((e, t) => Math.abs(e.row - n) - Math.abs(t.row - n))[0];
|
|
1632
1632
|
if (!i) return "none";
|
|
1633
|
-
let a = await E(e, i.key, t), o =
|
|
1634
|
-
return a && v(o) ? (
|
|
1633
|
+
let a = await E(e, i.key, t), o = rt(r());
|
|
1634
|
+
return a && v(o) ? (B("match found", {
|
|
1635
1635
|
entry: o,
|
|
1636
1636
|
y: a.cursorRow
|
|
1637
|
-
}), await m(
|
|
1637
|
+
}), await m(L.Edit, 500), "found") : (B("match not reachable", { candidate: i.text }), e.rejected.add(i.key), "failed");
|
|
1638
1638
|
}, O = (e) => e.order.filter((t) => e.kinds.get(t) === "file").map((t) => {
|
|
1639
1639
|
let n = e.names.get(t) ?? "";
|
|
1640
1640
|
return {
|
|
1641
1641
|
ci: b(n),
|
|
1642
1642
|
raw: y(n)
|
|
1643
1643
|
};
|
|
1644
|
-
}),
|
|
1644
|
+
}), ee = (e) => {
|
|
1645
1645
|
if (!e.sorted) return;
|
|
1646
1646
|
let t = O(e);
|
|
1647
1647
|
if (t.some((e, n) => n > 0 && (t[n - 1].ci > e.ci || t[n - 1].raw > e.raw))) {
|
|
1648
|
-
e.sorted = !1,
|
|
1648
|
+
e.sorted = !1, B("listing is not alphabetical, order hints disabled");
|
|
1649
1649
|
return;
|
|
1650
1650
|
}
|
|
1651
1651
|
let n = e.order.map((t) => {
|
|
1652
1652
|
let n = (e.names.get(t) ?? "").trim();
|
|
1653
1653
|
return {
|
|
1654
1654
|
kind: e.kinds.get(t),
|
|
1655
|
-
ci:
|
|
1655
|
+
ci: R(n).replace(/^\//, ""),
|
|
1656
1656
|
raw: n.replace(/^\//, "")
|
|
1657
1657
|
};
|
|
1658
1658
|
}), r = n.findIndex((e) => e.kind === "file");
|
|
1659
1659
|
r < 0 || (n.slice(r).some((e) => e.kind === "dir") ? c = !1 : n.some((e, t) => e.kind === "dir" && n.slice(t + 1).some((t) => t.kind === "file" && e.ci > t.ci && e.raw > t.raw)) && c === null && (c = !0));
|
|
1660
|
-
},
|
|
1660
|
+
}, k = (e) => !l || !e.sorted || c !== !0 || !e.top || e.bottom ? !1 : O(e).some((e) => /^[a-z0-9]/.test(e.ci) && e.ci > u && e.raw > x && e.raw > u), te = (e, t) => {
|
|
1661
1661
|
if (!l || !e.sorted) return null;
|
|
1662
1662
|
let n = t.entries.filter((e) => e.kind === "file").map((e) => b(e.text)), r = n[0], i = n[n.length - 1];
|
|
1663
1663
|
return r === void 0 || i === void 0 ? null : u < r ? "up" : u > i ? "down" : null;
|
|
1664
|
-
},
|
|
1664
|
+
}, A = (e, t) => e.top === e.bottom ? te(e, t) ?? "up" : e.top ? "down" : "up", j = (e, t) => {
|
|
1665
1665
|
let n = t.cursorKey ? e.order.indexOf(t.cursorKey) : -1, r = null;
|
|
1666
1666
|
for (let [i, a] of e.kinds) {
|
|
1667
1667
|
if (a !== "dir" || e.visited.has(i)) continue;
|
|
1668
|
-
let o = t.entries.find((e) => e.key === i), s = e.order.indexOf(i), c = o && t.cursorRow !== null ? Math.abs(o.row - t.cursorRow) : 100 + (n >= 0 && s >= 0 ? Math.abs(s - n) : 500), l =
|
|
1668
|
+
let o = t.entries.find((e) => e.key === i), s = e.order.indexOf(i), c = o && t.cursorRow !== null ? Math.abs(o.row - t.cursorRow) : 100 + (n >= 0 && s >= 0 ? Math.abs(s - n) : 500), l = ht(i, f) * 1e4 - c;
|
|
1669
1669
|
(!r || l > r.rank) && (r = {
|
|
1670
1670
|
key: i,
|
|
1671
1671
|
rank: l
|
|
1672
1672
|
});
|
|
1673
1673
|
}
|
|
1674
1674
|
return r?.key ?? null;
|
|
1675
|
-
},
|
|
1676
|
-
if (e >
|
|
1675
|
+
}, M = async (e, t) => await E(e, "/..", t) ? (B("navigate to parent directory"), (await m(L.Edit, 500)).changed && p()) : (B("parent directory entry unreachable"), !1), N = async (e) => {
|
|
1676
|
+
if (e > yt || !p()) return B("search aborted", {
|
|
1677
1677
|
depth: e,
|
|
1678
1678
|
active: p()
|
|
1679
1679
|
}), "aborted";
|
|
1680
|
-
let t =
|
|
1681
|
-
C(t, n),
|
|
1680
|
+
let t = xt(), n = await S();
|
|
1681
|
+
C(t, n), B("search directory", {
|
|
1682
1682
|
depth: e,
|
|
1683
1683
|
entries: n.entries.length,
|
|
1684
1684
|
complete: t.top && t.bottom
|
|
@@ -1686,42 +1686,42 @@ var D = (e) => {
|
|
|
1686
1686
|
for (let r = 0;; r += 1) {
|
|
1687
1687
|
let i = await D(t, n);
|
|
1688
1688
|
if (i === "found") return "found";
|
|
1689
|
-
if (i === "failed" && (n = await S(), C(t, n)),
|
|
1690
|
-
let a = await w(t, n,
|
|
1689
|
+
if (i === "failed" && (n = await S(), C(t, n)), ee(t), k(t) && (B("rest of listing is past the target", { depth: e }), t.bottom = !0), t.top && t.bottom || r >= bt) break;
|
|
1690
|
+
let a = await w(t, n, A(t, n));
|
|
1691
1691
|
a && (n = a);
|
|
1692
1692
|
}
|
|
1693
1693
|
for (;;) {
|
|
1694
|
-
let r =
|
|
1694
|
+
let r = j(t, n);
|
|
1695
1695
|
if (!r) break;
|
|
1696
1696
|
if (t.visited.add(r), !await E(t, r, n)) {
|
|
1697
|
-
|
|
1697
|
+
B("directory unreachable", { directory: r }), n = await S(), C(t, n);
|
|
1698
1698
|
continue;
|
|
1699
1699
|
}
|
|
1700
|
-
|
|
1700
|
+
B("enter directory", {
|
|
1701
1701
|
directory: r,
|
|
1702
1702
|
depth: e
|
|
1703
1703
|
});
|
|
1704
|
-
let i = await m(
|
|
1704
|
+
let i = await m(L.Edit, 500);
|
|
1705
1705
|
if (!p()) return "aborted";
|
|
1706
1706
|
if (!i.changed) {
|
|
1707
1707
|
n = await S(), C(t, n);
|
|
1708
1708
|
continue;
|
|
1709
1709
|
}
|
|
1710
|
-
let a = await
|
|
1710
|
+
let a = await N(e + 1);
|
|
1711
1711
|
if (a !== "missed") return a;
|
|
1712
1712
|
n = await S(), C(t, n);
|
|
1713
1713
|
}
|
|
1714
|
-
return e === 0 || await
|
|
1714
|
+
return e === 0 || await M(t, n) ? "missed" : "aborted";
|
|
1715
1715
|
};
|
|
1716
1716
|
if (!p()) return console.warn("[M8SDK] browseFile requires a file browser view (load/save)"), !1;
|
|
1717
1717
|
if (a().length === 0) return console.warn("[M8SDK] browseFile needs the screen reader, which is not available"), !1;
|
|
1718
|
-
let
|
|
1719
|
-
return
|
|
1718
|
+
let P = await N(0);
|
|
1719
|
+
return P !== "found" && B("search failed", {
|
|
1720
1720
|
targetText: e,
|
|
1721
|
-
outcome:
|
|
1722
|
-
}),
|
|
1721
|
+
outcome: P
|
|
1722
|
+
}), P === "found";
|
|
1723
1723
|
};
|
|
1724
|
-
},
|
|
1724
|
+
}, wt = (e) => {
|
|
1725
1725
|
if (!e) return null;
|
|
1726
1726
|
let t = e.trim();
|
|
1727
1727
|
if (t === "--") return 0;
|
|
@@ -1729,7 +1729,7 @@ var D = (e) => {
|
|
|
1729
1729
|
if (!n) return null;
|
|
1730
1730
|
let r = parseInt(n[0], 16);
|
|
1731
1731
|
return Number.isNaN(r) ? null : r;
|
|
1732
|
-
},
|
|
1732
|
+
}, Tt = (e) => {
|
|
1733
1733
|
if (!e) return null;
|
|
1734
1734
|
let t = e.trim();
|
|
1735
1735
|
if (t === "--") return 0;
|
|
@@ -1737,11 +1737,11 @@ var D = (e) => {
|
|
|
1737
1737
|
if (!n) return null;
|
|
1738
1738
|
let r = Number.parseInt(n[0], 10);
|
|
1739
1739
|
return Number.isNaN(r) ? null : r;
|
|
1740
|
-
},
|
|
1740
|
+
}, Et = /[+-]?\d+\.\d+/g, Dt = (e) => {
|
|
1741
1741
|
if (!e) return [];
|
|
1742
1742
|
let t = [];
|
|
1743
|
-
|
|
1744
|
-
let n =
|
|
1743
|
+
Et.lastIndex = 0;
|
|
1744
|
+
let n = Et.exec(e);
|
|
1745
1745
|
for (; n !== null;) {
|
|
1746
1746
|
let r = n[0], i = r.startsWith("-"), a = i || r.startsWith("+") ? r.slice(1) : r, o = a.indexOf("."), s = a.slice(0, o), c = a.slice(o + 1), l = Number.parseInt(s || "0", 10), u = Number.parseInt(c || "0", 10), d = 10 ** c.length, f = d > 0 ? 100 / d : 1, p = l * 100 + u * 100 / d;
|
|
1747
1747
|
!Number.isNaN(l) && !Number.isNaN(u) && t.push({
|
|
@@ -1752,16 +1752,16 @@ var D = (e) => {
|
|
|
1752
1752
|
decScale: d,
|
|
1753
1753
|
tickHundredths: f,
|
|
1754
1754
|
ticks: (i ? -1 : 1) * Math.round(p / f)
|
|
1755
|
-
}), n =
|
|
1755
|
+
}), n = Et.exec(e);
|
|
1756
1756
|
}
|
|
1757
1757
|
return t;
|
|
1758
|
-
},
|
|
1758
|
+
}, Ot = (e, t) => {
|
|
1759
1759
|
if (e.length <= 1) return 0;
|
|
1760
1760
|
let n = t?.trim() ?? "";
|
|
1761
1761
|
if (!n) return 0;
|
|
1762
1762
|
let r = e.findIndex((e) => e.raw === n || e.raw.replace(/^[+-]/, "") === n || `${e.negative ? "-" : ""}${e.intDigits}` === n || e.intDigits === n || e.decDigits === n);
|
|
1763
1763
|
return r >= 0 ? r : 0;
|
|
1764
|
-
},
|
|
1764
|
+
}, kt = (e, t) => {
|
|
1765
1765
|
if (!e) return null;
|
|
1766
1766
|
let n = t?.trim() ?? "";
|
|
1767
1767
|
if (!n) return null;
|
|
@@ -1775,13 +1775,13 @@ var D = (e) => {
|
|
|
1775
1775
|
if (r && !t) return "dec";
|
|
1776
1776
|
}
|
|
1777
1777
|
return null;
|
|
1778
|
-
},
|
|
1778
|
+
}, At = (e, t) => t.length === 1 ? e.raw === t || e.raw.replace(/^[+-]/, "") === t : e.raw === t || e.raw.replace(/^[+-]/, "") === t || `${e.negative ? "-" : ""}${e.intDigits}` === t || e.intDigits === t || e.decDigits === t, jt = (e, t, n) => {
|
|
1779
1779
|
let r = n?.trim() ?? "";
|
|
1780
|
-
return !r || !e[t] ||
|
|
1781
|
-
},
|
|
1780
|
+
return !r || !e[t] || At(e[t], r) ? !1 : e.some((e, n) => n !== t && At(e, r));
|
|
1781
|
+
}, V = (e, t) => {
|
|
1782
1782
|
let n = Math.round(e * t), r = n < 0 ? "-" : "", i = Math.abs(n), a = Math.floor(i / 100);
|
|
1783
1783
|
return `${r}${a}.${(i - a * 100).toString().padStart(2, "0")}`;
|
|
1784
|
-
},
|
|
1784
|
+
}, Mt = [
|
|
1785
1785
|
"C-",
|
|
1786
1786
|
"C#",
|
|
1787
1787
|
"D-",
|
|
@@ -1794,35 +1794,35 @@ var D = (e) => {
|
|
|
1794
1794
|
"A-",
|
|
1795
1795
|
"A#",
|
|
1796
1796
|
"B-"
|
|
1797
|
-
],
|
|
1797
|
+
], H = (e) => {
|
|
1798
1798
|
if (!e) return null;
|
|
1799
1799
|
let t = e.trim().toUpperCase().match(/([A-G][#-][0-9A-F])/);
|
|
1800
1800
|
if (!t) return null;
|
|
1801
|
-
let n = t[1], r = n.slice(0, 2), i = Number.parseInt(n.slice(2, 3), 16), a =
|
|
1801
|
+
let n = t[1], r = n.slice(0, 2), i = Number.parseInt(n.slice(2, 3), 16), a = Mt.indexOf(r);
|
|
1802
1802
|
return a < 0 || Number.isNaN(i) ? null : {
|
|
1803
1803
|
label: n,
|
|
1804
1804
|
noteName: r,
|
|
1805
1805
|
octave: i,
|
|
1806
1806
|
semitoneIndex: i * 12 + a
|
|
1807
1807
|
};
|
|
1808
|
-
},
|
|
1808
|
+
}, Nt = (e) => {
|
|
1809
1809
|
let { store: t, debugLog: n, hasBus: r, sendKeys: i, pressAndRelease: a, waitForTextUnderCursorChange: o, waitForCurrentLineChange: s } = e;
|
|
1810
1810
|
return async (e) => {
|
|
1811
1811
|
if (!r() || !Number.isFinite(e)) return !1;
|
|
1812
1812
|
let c = 0, l = 1, u = [], d = () => {
|
|
1813
|
-
let e =
|
|
1813
|
+
let e = Dt(t.get("currentLine"));
|
|
1814
1814
|
if (u = e, !e.length) return null;
|
|
1815
1815
|
c = Math.min(c, e.length - 1);
|
|
1816
1816
|
let n = e[c];
|
|
1817
1817
|
return n.tickHundredths > 0 && (l = n.tickHundredths), n;
|
|
1818
|
-
}, f =
|
|
1818
|
+
}, f = Dt(t.get("currentLine"));
|
|
1819
1819
|
if (!f.length) return console.warn("[M8SDK] Could not find a float value like \"440.00\" or \"-10.69\" on the current line:", t.get("currentLine")), !1;
|
|
1820
|
-
c =
|
|
1820
|
+
c = Ot(f, t.get("textUnderCursor")), f.length > 1 && n("[M8SDK] Multiple float values on line, editing:", f[c]?.raw);
|
|
1821
1821
|
let p = f[c];
|
|
1822
1822
|
l = p.tickHundredths;
|
|
1823
1823
|
let m = Math.round(Math.round(e * 100) / l);
|
|
1824
|
-
if (p.ticks === m) return n("[M8SDK] Already at target float value:",
|
|
1825
|
-
n("[M8SDK] Setting float value from",
|
|
1824
|
+
if (p.ticks === m) return n("[M8SDK] Already at target float value:", V(m, l)), !0;
|
|
1825
|
+
n("[M8SDK] Setting float value from", V(p.ticks, l), "to", V(m, l)), await a(L.Edit), await z(80);
|
|
1826
1826
|
let h = () => ({
|
|
1827
1827
|
upDown: {
|
|
1828
1828
|
mag: null,
|
|
@@ -1836,19 +1836,19 @@ var D = (e) => {
|
|
|
1836
1836
|
full: h(),
|
|
1837
1837
|
int: h(),
|
|
1838
1838
|
dec: h()
|
|
1839
|
-
}, _ = p.decScale, v = Date.now(), y =
|
|
1839
|
+
}, _ = p.decScale, v = Date.now(), y = kt(p, t.get("textUnderCursor")) ?? "int";
|
|
1840
1840
|
n("[M8SDK] Float cursor focus:", y);
|
|
1841
|
-
let b = !1, x = !1, S = p.ticks, C = null, w = p.ticks, T = Math.abs(p.ticks - m), E = 0, D = !1, O = !1,
|
|
1842
|
-
let n = e === "upDown" ?
|
|
1843
|
-
return
|
|
1844
|
-
},
|
|
1845
|
-
let a = g[y][e], o =
|
|
1846
|
-
for (let e = 0; e < r; e++) i(o), await
|
|
1841
|
+
let b = !1, x = !1, S = p.ticks, C = null, w = p.ticks, T = Math.abs(p.ticks - m), E = 0, D = !1, O = !1, ee = (e, t) => {
|
|
1842
|
+
let n = e === "upDown" ? L.Up : L.Right, r = e === "upDown" ? L.Down : L.Left;
|
|
1843
|
+
return L.Edit | (t >= 0 ? n : r);
|
|
1844
|
+
}, k = async (e, n, r) => {
|
|
1845
|
+
let a = g[y][e], o = ee(e, n * a.bias), c = t.get("currentLine");
|
|
1846
|
+
for (let e = 0; e < r; e++) i(o), await z(22);
|
|
1847
1847
|
await s(c, 350);
|
|
1848
|
-
},
|
|
1849
|
-
let n = () =>
|
|
1848
|
+
}, te = async (e) => {
|
|
1849
|
+
let n = () => kt(d(), t.get("textUnderCursor"));
|
|
1850
1850
|
if (n() === e) return y = e, !0;
|
|
1851
|
-
let r = t.get("textUnderCursor"), i = e === "dec" ?
|
|
1851
|
+
let r = t.get("textUnderCursor"), i = e === "dec" ? L.Right : L.Left, s = e === "dec" ? L.Left : L.Right;
|
|
1852
1852
|
if (await a(i, 35), await o(r, 250), n() === e) return y = e, !0;
|
|
1853
1853
|
await a(s, 35), await o(r, 250);
|
|
1854
1854
|
let c = n() === e;
|
|
@@ -1860,7 +1860,7 @@ var D = (e) => {
|
|
|
1860
1860
|
console.warn("[M8SDK] Float value no longer parseable while editing:", t.get("currentLine")), O = !0;
|
|
1861
1861
|
break;
|
|
1862
1862
|
}
|
|
1863
|
-
if (
|
|
1863
|
+
if (jt(u, c, t.get("textUnderCursor"))) {
|
|
1864
1864
|
console.warn("[M8SDK] Float cursor drifted to another field, aborting to avoid editing the wrong value"), x = !0, O = !0;
|
|
1865
1865
|
break;
|
|
1866
1866
|
}
|
|
@@ -1878,8 +1878,8 @@ var D = (e) => {
|
|
|
1878
1878
|
}
|
|
1879
1879
|
if (C = S, S = e.ticks, y !== "full" && !b) {
|
|
1880
1880
|
let e = i >= _ ? "int" : "dec";
|
|
1881
|
-
if (e !== y && !await
|
|
1882
|
-
if (
|
|
1881
|
+
if (e !== y && !await te(e)) {
|
|
1882
|
+
if (jt(u, c, t.get("textUnderCursor"))) {
|
|
1883
1883
|
console.warn("[M8SDK] Float cursor drifted to another field, aborting to avoid editing the wrong value"), x = !0, O = !0;
|
|
1884
1884
|
break;
|
|
1885
1885
|
}
|
|
@@ -1888,21 +1888,21 @@ var D = (e) => {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
let s = g[y], f = y === "int" ? Math.max(32, 3 * _) : y === "full" ? _ : 8, p, h = 1;
|
|
1890
1890
|
s.upDown.mag !== null && s.upDown.mag > 0 && i >= s.upDown.mag ? (p = "upDown", h = Math.min(Math.max(1, Math.floor(i / s.upDown.mag)), 96)) : s.upDown.mag === null && i >= f ? (p = "upDown", h = 1) : s.leftRight.mag !== null && s.leftRight.mag > 0 ? (p = "leftRight", h = Math.min(Math.max(1, Math.floor(i / s.leftRight.mag)), 96)) : (p = "leftRight", h = 1);
|
|
1891
|
-
let v = r > 0 ? 1 : -1,
|
|
1892
|
-
await
|
|
1893
|
-
let
|
|
1894
|
-
if (!
|
|
1891
|
+
let v = r > 0 ? 1 : -1, ee = e.ticks, A = y, j = p;
|
|
1892
|
+
await k(p, v, h);
|
|
1893
|
+
let M = d();
|
|
1894
|
+
if (!M) {
|
|
1895
1895
|
O = !0;
|
|
1896
1896
|
break;
|
|
1897
1897
|
}
|
|
1898
|
-
let
|
|
1899
|
-
if (
|
|
1900
|
-
E += 1, E >= 4 && (console.warn(`[M8SDK] Float value stopped reacting at ${
|
|
1898
|
+
let N = M.ticks - ee;
|
|
1899
|
+
if (N === 0) {
|
|
1900
|
+
E += 1, E >= 4 && (console.warn(`[M8SDK] Float value stopped reacting at ${V(M.ticks, l)} (target ${V(m, l)} may be out of range)`), O = !0);
|
|
1901
1901
|
continue;
|
|
1902
1902
|
}
|
|
1903
1903
|
E = 0;
|
|
1904
|
-
let
|
|
1905
|
-
|
|
1904
|
+
let P = g[A][j];
|
|
1905
|
+
P.mag = Math.max(1, Math.round(Math.abs(N) / h)), Math.sign(N) !== Math.sign(r) && (n(`[M8SDK] Float ${j} arrows move oppositely in '${A}' focus, inverting mapping`), P.bias *= -1, C = null);
|
|
1906
1906
|
}
|
|
1907
1907
|
if (!D && !x) {
|
|
1908
1908
|
let e = Date.now();
|
|
@@ -1910,20 +1910,20 @@ var D = (e) => {
|
|
|
1910
1910
|
let e = d();
|
|
1911
1911
|
if (!e || e.ticks === w) break;
|
|
1912
1912
|
let t = w - e.ticks, n = Math.abs(t);
|
|
1913
|
-
y !== "full" && !b && n >= _ != (y === "int") && (await
|
|
1913
|
+
y !== "full" && !b && n >= _ != (y === "int") && (await te(n >= _ ? "int" : "dec") || (b = !0));
|
|
1914
1914
|
let r = g[y], i, a = 1;
|
|
1915
1915
|
r.upDown.mag !== null && r.upDown.mag > 0 && n >= r.upDown.mag ? (i = "upDown", a = Math.min(Math.max(1, Math.floor(n / r.upDown.mag)), 16)) : r.leftRight.mag !== null && r.leftRight.mag > 0 ? (i = "leftRight", a = Math.min(Math.max(1, Math.floor(n / r.leftRight.mag)), 16)) : i = "leftRight";
|
|
1916
1916
|
let o = e.ticks;
|
|
1917
|
-
await
|
|
1917
|
+
await k(i, t > 0 ? 1 : -1, a);
|
|
1918
1918
|
let s = d();
|
|
1919
1919
|
if (!s || s.ticks === o) break;
|
|
1920
1920
|
}
|
|
1921
1921
|
}
|
|
1922
|
-
x || await a(
|
|
1923
|
-
let
|
|
1924
|
-
return n(`[M8SDK] Float setting ${
|
|
1922
|
+
x || await a(L.Edit);
|
|
1923
|
+
let A = d(), j = !!A && A.ticks === m;
|
|
1924
|
+
return n(`[M8SDK] Float setting ${j ? "succeeded" : "failed"}: "${A?.raw ?? "N/A"}" (${A ? V(A.ticks, l) : "N/A"})`), j;
|
|
1925
1925
|
};
|
|
1926
|
-
},
|
|
1926
|
+
}, Pt = {
|
|
1927
1927
|
song: [
|
|
1928
1928
|
{
|
|
1929
1929
|
to: "project",
|
|
@@ -2376,7 +2376,7 @@ var D = (e) => {
|
|
|
2376
2376
|
via: "exit",
|
|
2377
2377
|
keys: [2, 0]
|
|
2378
2378
|
}]
|
|
2379
|
-
},
|
|
2379
|
+
}, Ft = { views: /* @__PURE__ */ "chain.effectsettings.groove.instmods.inst.instrumentpool.mixer.phrase.project.scale.song.table.mixeq.limiterscope.mixscope.modfxeq.delayeq.reverbeq.loadinstrument.selectsavedirectory.createdirectory.systemsettings.midisettings.midimapping.renderaudio.timestats.themesettings.loadproject".split(".") }, It = (e) => {
|
|
2380
2380
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2381
2381
|
for (let [r, i] of Object.entries(e)) {
|
|
2382
2382
|
let e = r.toLowerCase(), a = [], o = /* @__PURE__ */ new Map();
|
|
@@ -2406,20 +2406,20 @@ var D = (e) => {
|
|
|
2406
2406
|
graph: t,
|
|
2407
2407
|
edgeKeys: n
|
|
2408
2408
|
};
|
|
2409
|
-
},
|
|
2410
|
-
if (!
|
|
2411
|
-
let e = Array.isArray(
|
|
2412
|
-
|
|
2409
|
+
}, Lt = null, Rt = null, zt = () => (Lt ??= It(Pt), Lt), Bt = () => {
|
|
2410
|
+
if (!Rt) {
|
|
2411
|
+
let e = Array.isArray(Ft.views) ? Ft.views : [];
|
|
2412
|
+
Rt = new Set(e.map((e) => String(e).trim().toLowerCase()).filter((e) => !!e));
|
|
2413
2413
|
}
|
|
2414
|
-
return
|
|
2415
|
-
},
|
|
2414
|
+
return Rt;
|
|
2415
|
+
}, Vt = 50, Ht = {
|
|
2416
2416
|
x: 0,
|
|
2417
2417
|
y: 0,
|
|
2418
2418
|
w: 1,
|
|
2419
2419
|
h: 1
|
|
2420
|
-
},
|
|
2420
|
+
}, Ut = class {
|
|
2421
2421
|
constructor() {
|
|
2422
|
-
this.assemblies = [], this.selectionRectSamples = [], this.lastCursor =
|
|
2422
|
+
this.assemblies = [], this.selectionRectSamples = [], this.lastCursor = Ht, this.lastSelectionCursor = null, this.lastCursorColor = null, this.lastSelectionMode = !1, this.lastSelectionSeenAt = 0, this.ASSEMBLY_TIMEOUT = 100, this.SELECTION_SAMPLE_WINDOW = 50, this.SELECTION_HOLD_DURATION = 150;
|
|
2423
2423
|
}
|
|
2424
2424
|
processRect(e) {
|
|
2425
2425
|
if (!e) return {
|
|
@@ -2611,7 +2611,7 @@ var D = (e) => {
|
|
|
2611
2611
|
].filter((e) => e.foundVert || e.foundTip).length >= 2;
|
|
2612
2612
|
}
|
|
2613
2613
|
buildCursorFromAssembly(e) {
|
|
2614
|
-
if (!e.tr || !e.bl || !e.br) return
|
|
2614
|
+
if (!e.tr || !e.bl || !e.br) return Ht;
|
|
2615
2615
|
let t = e.tr.x - e.tl.x - 1, n = e.bl.y - e.tl.y - 1;
|
|
2616
2616
|
return {
|
|
2617
2617
|
x: e.tl.x + 1,
|
|
@@ -2628,19 +2628,19 @@ var D = (e) => {
|
|
|
2628
2628
|
h: 1
|
|
2629
2629
|
}, this.lastSelectionCursor = null, this.lastSelectionMode = !1, this.lastSelectionSeenAt = 0;
|
|
2630
2630
|
}
|
|
2631
|
-
},
|
|
2631
|
+
}, Wt = (e) => e ? `#${[
|
|
2632
2632
|
e.r,
|
|
2633
2633
|
e.g,
|
|
2634
2634
|
e.b
|
|
2635
2635
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}` : null;
|
|
2636
|
-
function
|
|
2637
|
-
let n = new
|
|
2636
|
+
function Gt(e, t) {
|
|
2637
|
+
let n = new Ut();
|
|
2638
2638
|
class r {
|
|
2639
2639
|
constructor() {
|
|
2640
2640
|
this.rowChars = /* @__PURE__ */ new Map(), this.timer = null, this.knownViews = [], this.earlyAccepted = !1;
|
|
2641
2641
|
}
|
|
2642
2642
|
init() {
|
|
2643
|
-
this.knownViews = Array.from(
|
|
2643
|
+
this.knownViews = Array.from(Bt());
|
|
2644
2644
|
}
|
|
2645
2645
|
normForCompare(e) {
|
|
2646
2646
|
return e = e.includes("live") ? "song" : e, e.toLowerCase().trim().replace(/[{}]/g, "0");
|
|
@@ -2684,7 +2684,7 @@ function Ut(e, t) {
|
|
|
2684
2684
|
bg: e.background
|
|
2685
2685
|
}), this.tryEarlyAccept(o), this.timer && clearTimeout(this.timer), this.timer = setTimeout(() => {
|
|
2686
2686
|
this.emitStable();
|
|
2687
|
-
},
|
|
2687
|
+
}, Vt)));
|
|
2688
2688
|
}
|
|
2689
2689
|
reset() {
|
|
2690
2690
|
this.rowChars.clear(), this.timer &&= (clearTimeout(this.timer), null), this.earlyAccepted = !1;
|
|
@@ -2763,7 +2763,7 @@ function Ut(e, t) {
|
|
|
2763
2763
|
let e = this.grid.get(i), a = [], o = [];
|
|
2764
2764
|
for (let n = 0; n < t; n += 1) {
|
|
2765
2765
|
let t = e?.get(n);
|
|
2766
|
-
a.push(
|
|
2766
|
+
a.push(Wt(t?.fg)), o.push(Wt(t?.bg));
|
|
2767
2767
|
}
|
|
2768
2768
|
n.push(a), r.push(o);
|
|
2769
2769
|
}
|
|
@@ -2790,7 +2790,7 @@ function Ut(e, t) {
|
|
|
2790
2790
|
if (!e) return;
|
|
2791
2791
|
Date.now() < s && console.log(`[rect] type=${e.type} pos=(${e.pos.x},${e.pos.y}) size=${e.size.width}x${e.size.height}`);
|
|
2792
2792
|
let { cellW: r, cellH: i, offX: a, offY: o } = t.get("cellMetrics"), { cursor: c, cursorColor: l, selectionMode: u } = n.processRect(e);
|
|
2793
|
-
l &&
|
|
2793
|
+
l && Wt(l) !== Wt(t.get("cursorColor")) && t.set("cursorColor", l);
|
|
2794
2794
|
let { x: d, y: f, w: p, h: m } = c, h = Math.round((d - a) / r), g = Math.round((f - o) / i), _ = t.get("cursorPos"), v = t.get("selectionMode");
|
|
2795
2795
|
if (u) {
|
|
2796
2796
|
let e = t.get("cursorRect");
|
|
@@ -2846,7 +2846,7 @@ function Ut(e, t) {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
//#endregion
|
|
2848
2848
|
//#region src/engine/host/hostState.ts
|
|
2849
|
-
var
|
|
2849
|
+
var Kt = (e) => {
|
|
2850
2850
|
let t = e.get("macroStatus");
|
|
2851
2851
|
return {
|
|
2852
2852
|
viewName: e.get("viewName"),
|
|
@@ -2868,13 +2868,13 @@ var Wt = (e) => {
|
|
|
2868
2868
|
macroCurrentStep: t.currentStep,
|
|
2869
2869
|
macroSequenceLength: t.sequenceLength
|
|
2870
2870
|
};
|
|
2871
|
-
},
|
|
2871
|
+
}, qt = (e, t, n) => {
|
|
2872
2872
|
let r = e.get("cellMetrics");
|
|
2873
2873
|
return {
|
|
2874
2874
|
x: t * r.cellW + r.offX + r.cellW / 2,
|
|
2875
2875
|
y: n * r.cellH + r.offY + r.cellH / 2
|
|
2876
2876
|
};
|
|
2877
|
-
},
|
|
2877
|
+
}, Jt = (e) => Be({
|
|
2878
2878
|
left: e.includes("left"),
|
|
2879
2879
|
right: e.includes("right"),
|
|
2880
2880
|
up: e.includes("up"),
|
|
@@ -2883,11 +2883,11 @@ var Wt = (e) => {
|
|
|
2883
2883
|
play: e.includes("play"),
|
|
2884
2884
|
opt: e.includes("opt"),
|
|
2885
2885
|
edit: e.includes("edit")
|
|
2886
|
-
}),
|
|
2886
|
+
}), Yt = ({ io: e, editors: t, setValueFloat: n, browseFile: r, navigateToView: i, navigateTo: a, enableMidiTransport: o, getScreenCellColors: s }) => {
|
|
2887
2887
|
let { debugLog: c, hasBus: l, sendKeys: u, pressAndRelease: d, store: f, getScreenLines: p } = e, m = (e, t, n) => async (...r) => l() ? n(...r) : (console.warn(`[M8SDK] ${e}: no bus connection`), t);
|
|
2888
2888
|
return {
|
|
2889
2889
|
navigateToView: m("navigateToView", !1, async (e) => (c("[M8SDK] Executing navigateToView:", e), i(e))),
|
|
2890
|
-
navigateTo: m("navigateTo", !1, async (e, t) => a(
|
|
2890
|
+
navigateTo: m("navigateTo", !1, async (e, t) => a(qt(f, e, t))),
|
|
2891
2891
|
setValueToHex: m("setValueToHex", !1, async (e) => (c("[M8SDK] Executing setValueToHex:", e), t.setValueToHex(e))),
|
|
2892
2892
|
setValueToInt: m("setValueToInt", !1, async (e) => (c("[M8SDK] Executing setValueToInt:", e), t.setValueToInt(e))),
|
|
2893
2893
|
setValueFloat: m("setValueFloat", !1, async (e) => (c("[M8SDK] Executing setValueFloat:", e), n(e))),
|
|
@@ -2902,15 +2902,15 @@ var Wt = (e) => {
|
|
|
2902
2902
|
exact: t
|
|
2903
2903
|
}), r(e, t))),
|
|
2904
2904
|
sendKeyDown: m("sendKeyDown", void 0, async (e) => {
|
|
2905
|
-
c("[M8SDK] Executing sendKeyDown:", e), u(
|
|
2905
|
+
c("[M8SDK] Executing sendKeyDown:", e), u(Jt(e));
|
|
2906
2906
|
}),
|
|
2907
2907
|
sendKeyUp: m("sendKeyUp", void 0, async () => {
|
|
2908
2908
|
c("[M8SDK] Executing sendKeyUp"), u(0);
|
|
2909
2909
|
}),
|
|
2910
2910
|
sendKeyPress: m("sendKeyPress", void 0, async (e) => {
|
|
2911
|
-
c("[M8SDK] Executing sendKeyPress:", e), await d(
|
|
2911
|
+
c("[M8SDK] Executing sendKeyPress:", e), await d(Jt(e));
|
|
2912
2912
|
}),
|
|
2913
|
-
getState: async () =>
|
|
2913
|
+
getState: async () => Kt(f),
|
|
2914
2914
|
getScreen: async () => ({
|
|
2915
2915
|
width: 40,
|
|
2916
2916
|
height: 24,
|
|
@@ -2924,7 +2924,7 @@ var Wt = (e) => {
|
|
|
2924
2924
|
}),
|
|
2925
2925
|
enableMidiTransport: async () => o()
|
|
2926
2926
|
};
|
|
2927
|
-
},
|
|
2927
|
+
}, Xt = 6, Zt = (e) => {
|
|
2928
2928
|
let t = null, n = 0, r = null, i = null, a = (e) => performance.timeOrigin + e, o = (t) => {
|
|
2929
2929
|
let o = t.data;
|
|
2930
2930
|
if (!o || o.length === 0) return;
|
|
@@ -2935,7 +2935,7 @@ var Wt = (e) => {
|
|
|
2935
2935
|
let e = s - r;
|
|
2936
2936
|
e > 0 && e < 200 && (i = i == null ? e : i * .9 + e * .1);
|
|
2937
2937
|
}
|
|
2938
|
-
r = s, n += 1, n %
|
|
2938
|
+
r = s, n += 1, n % Xt === 0 && e({
|
|
2939
2939
|
kind: "clock",
|
|
2940
2940
|
ticks: n,
|
|
2941
2941
|
at: s,
|
|
@@ -3013,40 +3013,40 @@ var Wt = (e) => {
|
|
|
3013
3013
|
c += 1, s = null, t?.removeEventListener("midimessage", o), t = null;
|
|
3014
3014
|
}
|
|
3015
3015
|
};
|
|
3016
|
-
},
|
|
3016
|
+
}, Qt = (e, t) => {
|
|
3017
3017
|
let n = [], r = e, i = t;
|
|
3018
3018
|
for (; r !== i;) {
|
|
3019
3019
|
let e = i - r, t = Math.abs(e), a = e > 0 ? 1 : -1;
|
|
3020
3020
|
if (t >= 16) {
|
|
3021
|
-
let e = Math.floor(t / 16), o = a > 0 ?
|
|
3021
|
+
let e = Math.floor(t / 16), o = a > 0 ? L.Up : L.Down, s = L.Edit | o, c = Math.min(e, 10);
|
|
3022
3022
|
for (let e = 0; e < c && (n.push(s), n.push(0), r += a * 16, r !== i); e++);
|
|
3023
3023
|
} else if (t > 0) {
|
|
3024
|
-
let e = a > 0 ?
|
|
3024
|
+
let e = a > 0 ? L.Right : L.Left, t = L.Edit | e;
|
|
3025
3025
|
n.push(t), n.push(0), r += a * 1;
|
|
3026
3026
|
} else break;
|
|
3027
3027
|
}
|
|
3028
3028
|
return n;
|
|
3029
|
-
},
|
|
3029
|
+
}, $t = (e, t) => {
|
|
3030
3030
|
let n = [], r = e;
|
|
3031
3031
|
for (; r !== t;) {
|
|
3032
3032
|
let e = t - r, i = e > 0 ? 1 : -1;
|
|
3033
3033
|
if (Math.abs(e) >= 12) {
|
|
3034
|
-
let e = i > 0 ?
|
|
3035
|
-
n.push(
|
|
3034
|
+
let e = i > 0 ? L.Up : L.Down;
|
|
3035
|
+
n.push(L.Edit | e), n.push(0), r += i * 12;
|
|
3036
3036
|
} else {
|
|
3037
|
-
let e = i > 0 ?
|
|
3038
|
-
n.push(
|
|
3037
|
+
let e = i > 0 ? L.Right : L.Left;
|
|
3038
|
+
n.push(L.Edit | e), n.push(0), r += i;
|
|
3039
3039
|
}
|
|
3040
3040
|
if (n.length > 2048) break;
|
|
3041
3041
|
}
|
|
3042
3042
|
return n;
|
|
3043
|
-
},
|
|
3043
|
+
}, en = (e) => {
|
|
3044
3044
|
let { store: t, debugLog: n, hasBus: r, sendKeys: i, pressAndRelease: a, waitForTextUnderCursorChange: o } = e;
|
|
3045
3045
|
return {
|
|
3046
3046
|
setValueToHex: async (e) => {
|
|
3047
3047
|
if (!r()) return !1;
|
|
3048
3048
|
e = Math.max(0, Math.min(255, e));
|
|
3049
|
-
let s = t.get("textUnderCursor"), c =
|
|
3049
|
+
let s = t.get("textUnderCursor"), c = wt(s), l = s?.trim() === "--";
|
|
3050
3050
|
if (c === null) return console.warn("[M8SDK] Could not parse current value under cursor:", s), !1;
|
|
3051
3051
|
if (c === e && !l) return n("[M8SDK] Already at target value:", e.toString(16).padStart(2, "0").toUpperCase()), !0;
|
|
3052
3052
|
n(`[M8SDK] Setting value from "${s?.trim() ?? "N/A"}" (${c.toString(16).padStart(2, "0").toUpperCase()}) to ${e.toString(16).padStart(2, "0").toUpperCase()}`);
|
|
@@ -3054,60 +3054,60 @@ var Wt = (e) => {
|
|
|
3054
3054
|
if (l) {
|
|
3055
3055
|
n("[M8SDK] Initial value is \"--\", pressing edit to recall last value");
|
|
3056
3056
|
let e = s;
|
|
3057
|
-
await a(
|
|
3058
|
-
let r = t.get("textUnderCursor"), i =
|
|
3059
|
-
if (n(`[M8SDK] After edit press, value is now: "${r?.trim() ?? "N/A"}" (${i?.toString(16).padStart(2, "0").toUpperCase() ?? "N/A"})`), i === null) return console.warn("[M8SDK] Failed to read value after edit press on \"--\""), await a(
|
|
3057
|
+
await a(L.Edit), await o(e, 250);
|
|
3058
|
+
let r = t.get("textUnderCursor"), i = wt(r);
|
|
3059
|
+
if (n(`[M8SDK] After edit press, value is now: "${r?.trim() ?? "N/A"}" (${i?.toString(16).padStart(2, "0").toUpperCase() ?? "N/A"})`), i === null) return console.warn("[M8SDK] Failed to read value after edit press on \"--\""), await a(L.Edit), !1;
|
|
3060
3060
|
u = i;
|
|
3061
3061
|
} else {
|
|
3062
3062
|
let e = s;
|
|
3063
|
-
await a(
|
|
3063
|
+
await a(L.Edit), await o(e, 250);
|
|
3064
3064
|
}
|
|
3065
|
-
let d =
|
|
3065
|
+
let d = Qt(u, e);
|
|
3066
3066
|
n(`[M8SDK] Precalculated ${d.length / 2} key presses from ${u.toString(16).padStart(2, "0").toUpperCase()} to ${e.toString(16).padStart(2, "0").toUpperCase()}`);
|
|
3067
|
-
for (let e of d) i(e), await
|
|
3067
|
+
for (let e of d) i(e), await z(30);
|
|
3068
3068
|
await o(s, 250);
|
|
3069
|
-
let f = t.get("textUnderCursor"), p =
|
|
3069
|
+
let f = t.get("textUnderCursor"), p = wt(f);
|
|
3070
3070
|
if (p !== e) {
|
|
3071
3071
|
n("[M8SDK] Precomputation missed target, falling back to iterative mode");
|
|
3072
3072
|
let r = p ?? u, i = Date.now();
|
|
3073
3073
|
for (; r !== e && Date.now() - i < 5e3;) {
|
|
3074
3074
|
let i = e - r, s = Math.abs(i), c = i > 0 ? 1 : -1, l = t.get("textUnderCursor");
|
|
3075
3075
|
if (s >= 16) {
|
|
3076
|
-
let e = c > 0 ?
|
|
3076
|
+
let e = c > 0 ? L.Up : L.Down, t = L.Edit | e;
|
|
3077
3077
|
await a(t);
|
|
3078
3078
|
} else if (s > 0) {
|
|
3079
|
-
let e = c > 0 ?
|
|
3079
|
+
let e = c > 0 ? L.Right : L.Left, t = L.Edit | e;
|
|
3080
3080
|
await a(t);
|
|
3081
3081
|
}
|
|
3082
3082
|
await o(l, 250);
|
|
3083
|
-
let u =
|
|
3083
|
+
let u = wt(t.get("textUnderCursor"));
|
|
3084
3084
|
u !== null && (r = u, n(`[M8SDK] Iterative: current value: ${r.toString(16).padStart(2, "0").toUpperCase()}`));
|
|
3085
3085
|
}
|
|
3086
|
-
p =
|
|
3086
|
+
p = wt(t.get("textUnderCursor"));
|
|
3087
3087
|
}
|
|
3088
|
-
await a(
|
|
3088
|
+
await a(L.Edit);
|
|
3089
3089
|
let m = p === e;
|
|
3090
3090
|
return n(`[M8SDK] Value setting ${m ? "succeeded" : "failed"}. Final value: "${f?.trim() ?? "N/A"}" (${p?.toString(16).padStart(2, "0").toUpperCase() ?? "N/A"})`), m;
|
|
3091
3091
|
},
|
|
3092
3092
|
setValueToInt: async (e) => {
|
|
3093
3093
|
if (!r()) return !1;
|
|
3094
3094
|
e = Math.floor(e);
|
|
3095
|
-
let n = t.get("textUnderCursor"), i =
|
|
3095
|
+
let n = t.get("textUnderCursor"), i = Tt(n);
|
|
3096
3096
|
if (i === null) return console.warn("[M8SDK] Could not parse current integer value under cursor:", n), !1;
|
|
3097
3097
|
if (i === e) return !0;
|
|
3098
|
-
await a(
|
|
3098
|
+
await a(L.Edit), await o(n, 250);
|
|
3099
3099
|
let s = i, c = i, l = Math.abs(i - e), u = null, d = Date.now();
|
|
3100
3100
|
for (; s !== e && Date.now() - d < 5e3;) {
|
|
3101
3101
|
let n = e - s, r = Math.abs(n), i = n > 0 ? 1 : -1, d = t.get("textUnderCursor"), f = s;
|
|
3102
3102
|
if (r >= 16) {
|
|
3103
|
-
let e = i > 0 ?
|
|
3104
|
-
await a(
|
|
3103
|
+
let e = i > 0 ? L.Up : L.Down;
|
|
3104
|
+
await a(L.Edit | e, 35);
|
|
3105
3105
|
} else {
|
|
3106
|
-
let e = i > 0 ?
|
|
3107
|
-
await a(
|
|
3106
|
+
let e = i > 0 ? L.Right : L.Left;
|
|
3107
|
+
await a(L.Edit | e, 35);
|
|
3108
3108
|
}
|
|
3109
3109
|
await o(d, 250);
|
|
3110
|
-
let p =
|
|
3110
|
+
let p = Tt(t.get("textUnderCursor"));
|
|
3111
3111
|
if (p === null || p === s) break;
|
|
3112
3112
|
let m = Math.abs(p - e);
|
|
3113
3113
|
m < l && (l = m, c = p);
|
|
@@ -3120,19 +3120,19 @@ var Wt = (e) => {
|
|
|
3120
3120
|
for (; s !== c && Date.now() - e < 1500;) {
|
|
3121
3121
|
let e = c - s, n = Math.abs(e), r = e > 0 ? 1 : -1, i = t.get("textUnderCursor");
|
|
3122
3122
|
if (n >= 16) {
|
|
3123
|
-
let e = r > 0 ?
|
|
3124
|
-
await a(
|
|
3123
|
+
let e = r > 0 ? L.Up : L.Down;
|
|
3124
|
+
await a(L.Edit | e, 35);
|
|
3125
3125
|
} else {
|
|
3126
|
-
let e = r > 0 ?
|
|
3127
|
-
await a(
|
|
3126
|
+
let e = r > 0 ? L.Right : L.Left;
|
|
3127
|
+
await a(L.Edit | e, 35);
|
|
3128
3128
|
}
|
|
3129
3129
|
await o(i, 250);
|
|
3130
|
-
let l =
|
|
3130
|
+
let l = Tt(t.get("textUnderCursor"));
|
|
3131
3131
|
if (l === null || l === s) break;
|
|
3132
3132
|
s = l;
|
|
3133
3133
|
}
|
|
3134
3134
|
}
|
|
3135
|
-
return await a(
|
|
3135
|
+
return await a(L.Edit), Tt(t.get("textUnderCursor")) === e;
|
|
3136
3136
|
},
|
|
3137
3137
|
setNote: async (e) => {
|
|
3138
3138
|
if (!r()) return !1;
|
|
@@ -3140,27 +3140,27 @@ var Wt = (e) => {
|
|
|
3140
3140
|
if (s === "---" || s === "OFF") {
|
|
3141
3141
|
let e = t.get("textUnderCursor"), r = e?.trim().toUpperCase() ?? "";
|
|
3142
3142
|
if (r === s) return !0;
|
|
3143
|
-
if (await a(
|
|
3143
|
+
if (await a(L.Opt | L.Edit), await o(e, 250), s === "OFF" && r !== "---") {
|
|
3144
3144
|
let e = t.get("textUnderCursor");
|
|
3145
|
-
e?.trim().toUpperCase() === "---" && (await a(
|
|
3145
|
+
e?.trim().toUpperCase() === "---" && (await a(L.Opt | L.Edit), await o(e, 250));
|
|
3146
3146
|
}
|
|
3147
3147
|
let i = t.get("textUnderCursor")?.trim().toUpperCase();
|
|
3148
3148
|
return n("[M8SDK] setNote special value result:", i), i === s;
|
|
3149
3149
|
}
|
|
3150
|
-
let c =
|
|
3150
|
+
let c = H(e);
|
|
3151
3151
|
if (!c) return console.warn("[M8SDK] Invalid note format. Expected like C-1, C#1, D#A, ---, OFF:", e), !1;
|
|
3152
3152
|
let l = t.get("textUnderCursor");
|
|
3153
|
-
(l?.trim() === "---" || l?.trim().toUpperCase() === "OFF") && (n("[M8SDK] Initial note is \"---\" or \"OFF\", priming with edit key"), await a(
|
|
3154
|
-
let u =
|
|
3153
|
+
(l?.trim() === "---" || l?.trim().toUpperCase() === "OFF") && (n("[M8SDK] Initial note is \"---\" or \"OFF\", priming with edit key"), await a(L.Edit), await o(l, 250), l = t.get("textUnderCursor"));
|
|
3154
|
+
let u = H(l);
|
|
3155
3155
|
if (!u) return console.warn("[M8SDK] Could not parse current note under cursor:", l), !1;
|
|
3156
3156
|
if (u.semitoneIndex === c.semitoneIndex) return !0;
|
|
3157
|
-
await a(
|
|
3158
|
-
let d =
|
|
3157
|
+
await a(L.Edit), await o(l, 250);
|
|
3158
|
+
let d = $t(u.semitoneIndex, c.semitoneIndex);
|
|
3159
3159
|
if (d.length > 0) {
|
|
3160
|
-
for (let e of d) i(e), await
|
|
3160
|
+
for (let e of d) i(e), await z(25);
|
|
3161
3161
|
await o(l, 280);
|
|
3162
|
-
let e =
|
|
3163
|
-
if (e?.semitoneIndex === c.semitoneIndex) return await a(
|
|
3162
|
+
let e = H(t.get("textUnderCursor"));
|
|
3163
|
+
if (e?.semitoneIndex === c.semitoneIndex) return await a(L.Edit), !0;
|
|
3164
3164
|
u = e ?? u;
|
|
3165
3165
|
}
|
|
3166
3166
|
let f = /* @__PURE__ */ new Set();
|
|
@@ -3169,42 +3169,42 @@ var Wt = (e) => {
|
|
|
3169
3169
|
for (; Date.now() - p < 7e3;) {
|
|
3170
3170
|
let e = c.semitoneIndex - u.semitoneIndex;
|
|
3171
3171
|
if (e === 0) break;
|
|
3172
|
-
let n = Math.abs(e) >= 12, r = e > 0, i = n ? r ?
|
|
3173
|
-
await a(
|
|
3174
|
-
let m =
|
|
3172
|
+
let n = Math.abs(e) >= 12, r = e > 0, i = n ? r ? L.Up : L.Down : r ? L.Right : L.Left, s = n ? r ? L.Down : L.Up : r ? L.Left : L.Right, l = u, d = Math.abs(l.semitoneIndex - c.semitoneIndex), p = t.get("textUnderCursor");
|
|
3173
|
+
await a(L.Edit | i, 35), await o(p, 250);
|
|
3174
|
+
let m = H(t.get("textUnderCursor"));
|
|
3175
3175
|
if (!m || m.label === l.label) break;
|
|
3176
3176
|
if (u = m, Math.abs(u.semitoneIndex - c.semitoneIndex) > d) {
|
|
3177
3177
|
let e = t.get("textUnderCursor");
|
|
3178
|
-
await a(
|
|
3179
|
-
let n =
|
|
3178
|
+
await a(L.Edit | s, 35), await o(e, 250);
|
|
3179
|
+
let n = H(t.get("textUnderCursor"));
|
|
3180
3180
|
n && (u = n);
|
|
3181
3181
|
break;
|
|
3182
3182
|
}
|
|
3183
3183
|
if (f.has(u.label)) break;
|
|
3184
3184
|
f.add(u.label);
|
|
3185
3185
|
}
|
|
3186
|
-
return await a(
|
|
3186
|
+
return await a(L.Edit), H(t.get("textUnderCursor"))?.semitoneIndex === c.semitoneIndex;
|
|
3187
3187
|
},
|
|
3188
3188
|
setValueToString: async (e, i = !0, s = !1) => {
|
|
3189
3189
|
if (!r()) return !1;
|
|
3190
|
-
let c =
|
|
3190
|
+
let c = R(e);
|
|
3191
3191
|
if (!c) return !1;
|
|
3192
3192
|
let l = () => s ? t.get("currentLine") : t.get("textUnderCursor"), u = (e) => {
|
|
3193
|
-
let t =
|
|
3193
|
+
let t = R(e);
|
|
3194
3194
|
return t ? i ? t === c : t.includes(c) : !1;
|
|
3195
3195
|
};
|
|
3196
3196
|
if (u(l())) return !0;
|
|
3197
3197
|
let d = t.get("textUnderCursor");
|
|
3198
|
-
d?.trim() === "---" && (n("[M8SDK] Initial string value is \"---\", priming with edit key"), await a(
|
|
3198
|
+
d?.trim() === "---" && (n("[M8SDK] Initial string value is \"---\", priming with edit key"), await a(L.Edit), await o(d, 250));
|
|
3199
3199
|
let f = t.get("textUnderCursor");
|
|
3200
|
-
if (await a(
|
|
3200
|
+
if (await a(L.Edit), await o(f, 250), u(l())) return await a(L.Edit), !0;
|
|
3201
3201
|
let p = t.get("textUnderCursor"), m = 0, h = Date.now(), g = [];
|
|
3202
3202
|
for (let e = 0; e < 512; e++) {
|
|
3203
3203
|
if (Date.now() - h > 2e3) {
|
|
3204
3204
|
n("[M8SDK] Timeout reached while seeking bottom of list");
|
|
3205
3205
|
break;
|
|
3206
3206
|
}
|
|
3207
|
-
let t =
|
|
3207
|
+
let t = R(p);
|
|
3208
3208
|
if (t) {
|
|
3209
3209
|
if (e < 4) g.push(t);
|
|
3210
3210
|
else if (g.includes(t)) {
|
|
@@ -3213,26 +3213,26 @@ var Wt = (e) => {
|
|
|
3213
3213
|
}
|
|
3214
3214
|
}
|
|
3215
3215
|
let r = p;
|
|
3216
|
-
await a(
|
|
3216
|
+
await a(L.Edit | L.Down, 35);
|
|
3217
3217
|
let i = await o(r, 250);
|
|
3218
|
-
if (
|
|
3218
|
+
if (R(i) === R(p) ? m += 1 : (m = 0, p = i), m > 1) break;
|
|
3219
3219
|
}
|
|
3220
3220
|
let _ = /* @__PURE__ */ new Set();
|
|
3221
3221
|
for (let e = 0; e < 1024; e++) {
|
|
3222
3222
|
let e = l();
|
|
3223
|
-
if (u(e)) return await a(
|
|
3224
|
-
let n =
|
|
3223
|
+
if (u(e)) return await a(L.Edit), !0;
|
|
3224
|
+
let n = R(e);
|
|
3225
3225
|
if (n) {
|
|
3226
3226
|
if (_.has(n)) break;
|
|
3227
3227
|
_.add(n);
|
|
3228
3228
|
}
|
|
3229
3229
|
let r = t.get("textUnderCursor");
|
|
3230
|
-
if (await a(
|
|
3230
|
+
if (await a(L.Edit | L.Right, 35), R(await o(r, 250)) === n) break;
|
|
3231
3231
|
}
|
|
3232
|
-
return await a(
|
|
3232
|
+
return await a(L.Edit), !1;
|
|
3233
3233
|
}
|
|
3234
3234
|
};
|
|
3235
|
-
},
|
|
3235
|
+
}, tn = ({ bus: e, store: t, cancelOnKeydown: n = !1 }) => {
|
|
3236
3236
|
let r = [], i = null, a = !1, o = () => {
|
|
3237
3237
|
a && u("preempted by keyboard");
|
|
3238
3238
|
}, s = () => {
|
|
@@ -3280,7 +3280,7 @@ var Wt = (e) => {
|
|
|
3280
3280
|
r = [], i = null, c();
|
|
3281
3281
|
}
|
|
3282
3282
|
};
|
|
3283
|
-
},
|
|
3283
|
+
}, nn = () => ({
|
|
3284
3284
|
viewName: null,
|
|
3285
3285
|
viewTitle: null,
|
|
3286
3286
|
minimapKey: null,
|
|
@@ -3303,9 +3303,9 @@ var Wt = (e) => {
|
|
|
3303
3303
|
},
|
|
3304
3304
|
systemInfo: null,
|
|
3305
3305
|
macroStatus: { running: !1 }
|
|
3306
|
-
}),
|
|
3306
|
+
}), rn = (e = {}) => {
|
|
3307
3307
|
let t = {
|
|
3308
|
-
...
|
|
3308
|
+
...nn(),
|
|
3309
3309
|
...e
|
|
3310
3310
|
}, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
3311
3311
|
return {
|
|
@@ -3328,8 +3328,8 @@ var Wt = (e) => {
|
|
|
3328
3328
|
}),
|
|
3329
3329
|
snapshot: () => ({ ...t })
|
|
3330
3330
|
};
|
|
3331
|
-
},
|
|
3332
|
-
function
|
|
3331
|
+
}, an = () => 0, on = () => 1;
|
|
3332
|
+
function sn(e, t, n, r = an, i = on) {
|
|
3333
3333
|
let a = t.trim(), o = n.trim();
|
|
3334
3334
|
if (!e.has(a) || !e.has(o)) return null;
|
|
3335
3335
|
let s = /* @__PURE__ */ new Set([a]), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
@@ -3374,29 +3374,29 @@ function an(e, t, n, r = nn, i = rn) {
|
|
|
3374
3374
|
}
|
|
3375
3375
|
//#endregion
|
|
3376
3376
|
//#region src/engine/viewNavigation.ts
|
|
3377
|
-
var
|
|
3378
|
-
let n = !!t?.shift, r =
|
|
3379
|
-
up: (n ? r : 0) |
|
|
3380
|
-
down: (n ? r : 0) |
|
|
3381
|
-
left: (n ? r : 0) |
|
|
3382
|
-
right: (n ? r : 0) |
|
|
3377
|
+
var cn = 20, ln = 700, un = 80, dn = 4e3, fn = 120, pn = (e, t) => {
|
|
3378
|
+
let n = !!t?.shift, r = L.Shift, i = {
|
|
3379
|
+
up: (n ? r : 0) | L.Up,
|
|
3380
|
+
down: (n ? r : 0) | L.Down,
|
|
3381
|
+
left: (n ? r : 0) | L.Left,
|
|
3382
|
+
right: (n ? r : 0) | L.Right
|
|
3383
3383
|
}, a = [];
|
|
3384
3384
|
n && a.push(r);
|
|
3385
3385
|
for (let t of e) a.push(i[t], n ? r : 0);
|
|
3386
3386
|
return a.push(0), a;
|
|
3387
|
-
},
|
|
3387
|
+
}, mn = (e) => [{
|
|
3388
3388
|
from: e,
|
|
3389
3389
|
to: "",
|
|
3390
3390
|
kind: "exit",
|
|
3391
|
-
keys: [
|
|
3391
|
+
keys: [L.Opt, 0]
|
|
3392
3392
|
}, {
|
|
3393
3393
|
from: e,
|
|
3394
3394
|
to: "",
|
|
3395
3395
|
kind: "shift",
|
|
3396
3396
|
dir: "up",
|
|
3397
|
-
keys: [
|
|
3398
|
-
}],
|
|
3399
|
-
let i =
|
|
3397
|
+
keys: [L.Shift | L.Up, 0]
|
|
3398
|
+
}], hn = (e) => `${e.kind}:${e.dir ?? ""}:${e.keys.join(",")}:${e.cursor ? `${e.cursor.x},${e.cursor.y}` : ""}`, gn = (e) => e[e.length - 1] === 0 ? e.slice() : [...e, 0], _n = "#goal", vn = (e, t) => `${e}<${t}`, yn = (e) => new Promise((t) => setTimeout(t, e)), bn = ({ store: e, runner: t, getScreenLines: n, moveCursor: r }) => {
|
|
3399
|
+
let i = Bt(), a = null, o = 0, s = null, c = 0, l = /* @__PURE__ */ new Map(), u = "", d = e.get("viewName") || "", f = e.sub("viewName", () => {
|
|
3400
3400
|
let t = e.get("viewName") || "";
|
|
3401
3401
|
t && t !== d && (d && (u = d), d = t);
|
|
3402
3402
|
}), p = null, m = null, h = () => {
|
|
@@ -3404,11 +3404,11 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3404
3404
|
}, g = (e) => {
|
|
3405
3405
|
let t = (e || "").toLowerCase().trim();
|
|
3406
3406
|
return i.has(t) || console.warn("Target not in viewlist", { goal: t }), t;
|
|
3407
|
-
}, _ = (e, t) => `${e.from}<${t}|${
|
|
3407
|
+
}, _ = (e, t) => `${e.from}<${t}|${hn(e)}`, v = (e, t) => {
|
|
3408
3408
|
let n = /* @__PURE__ */ new Map();
|
|
3409
|
-
for (let t of
|
|
3409
|
+
for (let t of zt().graph.get(e) ?? []) {
|
|
3410
3410
|
if (t.kind === "button" && !r) continue;
|
|
3411
|
-
let e =
|
|
3411
|
+
let e = hn(t);
|
|
3412
3412
|
n.set(e, [...n.get(e) ?? [], t]);
|
|
3413
3413
|
}
|
|
3414
3414
|
let i = [];
|
|
@@ -3432,11 +3432,11 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3432
3432
|
}
|
|
3433
3433
|
return i;
|
|
3434
3434
|
}, y = (e, t, n) => {
|
|
3435
|
-
let r = /* @__PURE__ */ new Map([[
|
|
3436
|
-
for (r.set(
|
|
3437
|
-
let [e, t] = i.shift(), a = r.get(
|
|
3435
|
+
let r = /* @__PURE__ */ new Map([[_n, []]]), i = [[e, t]];
|
|
3436
|
+
for (r.set(vn(e, t), []); i.length;) {
|
|
3437
|
+
let [e, t] = i.shift(), a = r.get(vn(e, t));
|
|
3438
3438
|
if (e === n) a.push({
|
|
3439
|
-
to:
|
|
3439
|
+
to: _n,
|
|
3440
3440
|
weight: 0,
|
|
3441
3441
|
nav: {
|
|
3442
3442
|
from: e,
|
|
@@ -3446,7 +3446,7 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3446
3446
|
}
|
|
3447
3447
|
});
|
|
3448
3448
|
else for (let n of v(e, t)) {
|
|
3449
|
-
let t =
|
|
3449
|
+
let t = vn(n.to, e);
|
|
3450
3450
|
a.push({
|
|
3451
3451
|
to: t,
|
|
3452
3452
|
weight: n.weight,
|
|
@@ -3456,10 +3456,10 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3456
3456
|
}
|
|
3457
3457
|
return r;
|
|
3458
3458
|
}, b = (e, t) => {
|
|
3459
|
-
let n =
|
|
3459
|
+
let n = sn(y(e, u, t), vn(e, u), _n);
|
|
3460
3460
|
if (n?.edges.length) return n.edges[0].nav;
|
|
3461
|
-
let r =
|
|
3462
|
-
return r.length && !r.some((e) => e.kind === "exit") ? null :
|
|
3461
|
+
let r = zt().graph.get(e) ?? [];
|
|
3462
|
+
return r.length && !r.some((e) => e.kind === "exit") ? null : mn(e).find((e) => !l.has(_(e, u)) && !l.has(_(e, "*"))) ?? null;
|
|
3463
3463
|
}, x = (e) => {
|
|
3464
3464
|
let t = e.cursor;
|
|
3465
3465
|
if (!e.label || !n) return t;
|
|
@@ -3504,12 +3504,12 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3504
3504
|
}), E();
|
|
3505
3505
|
}, T = async (n, i) => {
|
|
3506
3506
|
let a = x(n.edge);
|
|
3507
|
-
S(a) || (await Promise.race([r(a.x, a.y),
|
|
3507
|
+
S(a) || (await Promise.race([r(a.x, a.y), yn(dn)]), await yn(fn)), i === c && p === n && (e.get("viewName") !== n.from || !S(a) ? (console.warn("Navigation: button not reached", {
|
|
3508
3508
|
from: n.from,
|
|
3509
3509
|
to: n.edge.to,
|
|
3510
3510
|
cell: a,
|
|
3511
3511
|
cursor: e.get("cursorPos")
|
|
3512
|
-
}), w(e.get("viewName") === n.from ? n.from : e.get("viewName") || "")) : (n.phase = "keys", t.cancel("navigation button"), t.start(
|
|
3512
|
+
}), w(e.get("viewName") === n.from ? n.from : e.get("viewName") || "")) : (n.phase = "keys", t.cancel("navigation button"), t.start(gn(n.edge.keys))));
|
|
3513
3513
|
}, E = () => {
|
|
3514
3514
|
let n = a, r = e.get("viewName") || "";
|
|
3515
3515
|
if (!n) return;
|
|
@@ -3524,7 +3524,7 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3524
3524
|
}), C(!0);
|
|
3525
3525
|
return;
|
|
3526
3526
|
}
|
|
3527
|
-
if (o >=
|
|
3527
|
+
if (o >= cn) {
|
|
3528
3528
|
console.warn("Navigation aborted: max steps reached", {
|
|
3529
3529
|
startTitle: r,
|
|
3530
3530
|
goalTitle: n,
|
|
@@ -3559,15 +3559,15 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3559
3559
|
T(s, c);
|
|
3560
3560
|
return;
|
|
3561
3561
|
}
|
|
3562
|
-
let l = i.keys.length ?
|
|
3562
|
+
let l = i.keys.length ? gn(i.keys) : pn([i.dir], { shift: !0 });
|
|
3563
3563
|
t.cancel("iterative navigation step"), t.start(l);
|
|
3564
3564
|
}, D = () => {
|
|
3565
3565
|
if (p?.phase !== "keys") return;
|
|
3566
3566
|
let n = e.get("macroStatus").running, r = e.get("viewName") || "", i = !!r && r !== p.from;
|
|
3567
3567
|
(!n || i) && (h(), m = n ? setTimeout(() => {
|
|
3568
3568
|
t.cancel("navigation: no release echo"), t.start([0]), w(e.get("viewName") || "");
|
|
3569
|
-
},
|
|
3570
|
-
}, O = e.sub("viewName", D),
|
|
3569
|
+
}, ln) : setTimeout(() => w(e.get("viewName") || ""), i ? un : ln));
|
|
3570
|
+
}, O = e.sub("viewName", D), ee = e.sub("macroStatus", D);
|
|
3571
3571
|
return {
|
|
3572
3572
|
navigateToView: (t) => new Promise((n) => {
|
|
3573
3573
|
let r = g(t);
|
|
@@ -3577,10 +3577,10 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3577
3577
|
}), E()) : n(!1);
|
|
3578
3578
|
}),
|
|
3579
3579
|
dispose: () => {
|
|
3580
|
-
f(), O(),
|
|
3580
|
+
f(), O(), ee(), c += 1, C(!1);
|
|
3581
3581
|
}
|
|
3582
3582
|
};
|
|
3583
|
-
},
|
|
3583
|
+
}, xn = /* @__PURE__ */ new Set([
|
|
3584
3584
|
"macroStatus",
|
|
3585
3585
|
"deviceModel",
|
|
3586
3586
|
"fontMode",
|
|
@@ -3588,35 +3588,35 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3588
3588
|
"titleColor",
|
|
3589
3589
|
"backgroundColor",
|
|
3590
3590
|
"minimapKey"
|
|
3591
|
-
]),
|
|
3592
|
-
let n = t.store ??
|
|
3591
|
+
]), Sn = (e, t = {}) => {
|
|
3592
|
+
let n = t.store ?? rn(), r = (...e) => {
|
|
3593
3593
|
t.debug && console.log(...e);
|
|
3594
3594
|
}, i = /* @__PURE__ */ new Map(), a = (e, t) => {
|
|
3595
3595
|
for (let n of [...i.get(e) ?? []]) n(t);
|
|
3596
|
-
}, o =
|
|
3596
|
+
}, o = Gt(e.protocol.eventBus, n), s = tn({
|
|
3597
3597
|
bus: e,
|
|
3598
3598
|
store: n,
|
|
3599
3599
|
cancelOnKeydown: t.cancelMacroOnKeydown
|
|
3600
|
-
}), c =
|
|
3600
|
+
}), c = et({
|
|
3601
3601
|
bus: e,
|
|
3602
3602
|
store: n,
|
|
3603
3603
|
getScreenLines: o.getScreenLines,
|
|
3604
|
-
cursorMap: t.cursorMap ??
|
|
3605
|
-
}), l =
|
|
3604
|
+
cursorMap: t.cursorMap ?? oe()
|
|
3605
|
+
}), l = bn({
|
|
3606
3606
|
store: n,
|
|
3607
3607
|
runner: s,
|
|
3608
3608
|
getScreenLines: o.getScreenLines,
|
|
3609
|
-
moveCursor: (e, t) => c.navigateTo(
|
|
3610
|
-
}), u =
|
|
3609
|
+
moveCursor: (e, t) => c.navigateTo(qt(n, e, t))
|
|
3610
|
+
}), u = Zt((e) => a("transport", e)), d = gt({
|
|
3611
3611
|
getKeySink: () => e.commands,
|
|
3612
3612
|
store: n,
|
|
3613
3613
|
debugLog: r,
|
|
3614
3614
|
getScreenLines: o.getScreenLines
|
|
3615
|
-
}), f =
|
|
3615
|
+
}), f = Yt({
|
|
3616
3616
|
io: d,
|
|
3617
|
-
editors:
|
|
3618
|
-
setValueFloat:
|
|
3619
|
-
browseFile:
|
|
3617
|
+
editors: en(d),
|
|
3618
|
+
setValueFloat: Nt(d),
|
|
3619
|
+
browseFile: Ct(d),
|
|
3620
3620
|
navigateToView: (e) => l.navigateToView(e),
|
|
3621
3621
|
navigateTo: (e) => c.navigateTo(e),
|
|
3622
3622
|
enableMidiTransport: () => u.enable(),
|
|
@@ -3646,7 +3646,7 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3646
3646
|
};
|
|
3647
3647
|
(!_ || _.textUnderCursor !== e.textUnderCursor || _.currentLine !== e.currentLine) && (_ = e, r("[M8SDK] Text updated:", e.textUnderCursor, e.currentLine), a("textUpdated", e));
|
|
3648
3648
|
}
|
|
3649
|
-
[...e].some((e) =>
|
|
3649
|
+
[...e].some((e) => xn.has(e)) && a("stateChanged", Kt(n));
|
|
3650
3650
|
}, y = n.subAll((e) => {
|
|
3651
3651
|
p.add(e), m || (m = !0, queueMicrotask(v));
|
|
3652
3652
|
}), b = (e) => {
|
|
@@ -3659,7 +3659,7 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3659
3659
|
macro: s,
|
|
3660
3660
|
navigateTo: (e) => c.navigateTo(e),
|
|
3661
3661
|
navigateToView: (e) => l.navigateToView(e),
|
|
3662
|
-
getState: () =>
|
|
3662
|
+
getState: () => Kt(n),
|
|
3663
3663
|
getScreenLines: o.getScreenLines,
|
|
3664
3664
|
getScreenCellColors: o.getScreenCellColors,
|
|
3665
3665
|
on: (e, t) => {
|
|
@@ -3672,7 +3672,7 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3672
3672
|
e.protocol.eventBus.off("key", b), y(), l.dispose(), c.dispose(), s.dispose(), u.disable(), o.dispose(), i.clear();
|
|
3673
3673
|
}
|
|
3674
3674
|
};
|
|
3675
|
-
},
|
|
3675
|
+
}, Cn = {
|
|
3676
3676
|
version: "1.0",
|
|
3677
3677
|
description: "Layouts of the non-grid ('parameter') views: which text at which column is an instrument type, name, parameter, option or action. Column positions were measured on the manual's screenshots (font mode 0, 40 columns) and cross-checked with the phrase view grid; descriptions come from the manual.",
|
|
3678
3678
|
notes: {
|
|
@@ -3692,23 +3692,23 @@ var on = 20, sn = 700, cn = 80, ln = 4e3, un = 120, dn = (e, t) => {
|
|
|
3692
3692
|
EXTERN: "external",
|
|
3693
3693
|
MIDI: "midiout"
|
|
3694
3694
|
}
|
|
3695
|
-
},
|
|
3696
|
-
for (let [e, t] of Object.entries(
|
|
3695
|
+
}, wn = Cn.views, Tn = Cn.instrumentTypes, En = Cn.instrumentTypeNames, Dn = {};
|
|
3696
|
+
for (let [e, t] of Object.entries(wn)) {
|
|
3697
3697
|
let { extends: n, ...r } = t;
|
|
3698
|
-
|
|
3699
|
-
...
|
|
3698
|
+
Dn[e] = n ? {
|
|
3699
|
+
...wn[n],
|
|
3700
3700
|
...r
|
|
3701
3701
|
} : r;
|
|
3702
3702
|
}
|
|
3703
|
-
function
|
|
3704
|
-
return
|
|
3703
|
+
function On(e) {
|
|
3704
|
+
return Dn[e] ?? null;
|
|
3705
3705
|
}
|
|
3706
|
-
var
|
|
3707
|
-
function
|
|
3708
|
-
let n = e.width ?? e.text?.length ?? 1, r =
|
|
3706
|
+
var U = (e, t, n) => t >= e.length ? "" : e.slice(t, t + n);
|
|
3707
|
+
function kn(e, t) {
|
|
3708
|
+
let n = e.width ?? e.text?.length ?? 1, r = U(t, e.x, n);
|
|
3709
3709
|
return e.text == null ? e.regex != null && new RegExp(e.regex, "i").test(r) : r.toUpperCase() === e.text.toUpperCase();
|
|
3710
3710
|
}
|
|
3711
|
-
function
|
|
3711
|
+
function An(e, t) {
|
|
3712
3712
|
let n = e.sections;
|
|
3713
3713
|
if (!n) return null;
|
|
3714
3714
|
for (let e of t) {
|
|
@@ -3717,57 +3717,57 @@ function On(e, t) {
|
|
|
3717
3717
|
}
|
|
3718
3718
|
return null;
|
|
3719
3719
|
}
|
|
3720
|
-
function
|
|
3720
|
+
function jn(e, t, n) {
|
|
3721
3721
|
let r = e.zones?.find((e) => e.id === t);
|
|
3722
3722
|
if (!e.slotLabel || !r) return null;
|
|
3723
3723
|
let i = RegExp(`^${e.slotLabel}$`, "i");
|
|
3724
3724
|
for (let e of n) {
|
|
3725
|
-
let t =
|
|
3725
|
+
let t = U(e, r.labelX, r.labelWidth).trim();
|
|
3726
3726
|
if (i.test(t)) return t.toUpperCase();
|
|
3727
3727
|
}
|
|
3728
3728
|
return null;
|
|
3729
3729
|
}
|
|
3730
|
-
function
|
|
3730
|
+
function Mn(e) {
|
|
3731
3731
|
let t = e.toUpperCase().replace(/[^A-Z]/g, "");
|
|
3732
3732
|
if (!t) return null;
|
|
3733
|
-
let n = Object.keys(
|
|
3734
|
-
return n ?
|
|
3733
|
+
let n = Object.keys(En).find((e) => t.startsWith(e));
|
|
3734
|
+
return n ? En[n] : null;
|
|
3735
3735
|
}
|
|
3736
|
-
function
|
|
3736
|
+
function Nn(e) {
|
|
3737
3737
|
for (let t of e) if (t.toUpperCase().startsWith("TYPE")) {
|
|
3738
|
-
let e =
|
|
3738
|
+
let e = U(t, 8, 13).trim();
|
|
3739
3739
|
return e ? {
|
|
3740
3740
|
text: e,
|
|
3741
|
-
key:
|
|
3741
|
+
key: Mn(e)
|
|
3742
3742
|
} : null;
|
|
3743
3743
|
}
|
|
3744
3744
|
return null;
|
|
3745
3745
|
}
|
|
3746
|
-
function
|
|
3747
|
-
let t =
|
|
3746
|
+
function Pn(e) {
|
|
3747
|
+
let t = Tn[e];
|
|
3748
3748
|
return t ? {
|
|
3749
3749
|
name: t.name,
|
|
3750
3750
|
description: t.description
|
|
3751
3751
|
} : null;
|
|
3752
3752
|
}
|
|
3753
|
-
function
|
|
3753
|
+
function Fn(e, t, n) {
|
|
3754
3754
|
let r = t.replace(/^MOD\d$/, "MOD#").replace(/^CC[A-J]$/, "CC#");
|
|
3755
3755
|
if (e.vocabulary) return e.vocabulary[r] ?? null;
|
|
3756
3756
|
if (e.vocabularyFrom !== "instrumentTypes") return null;
|
|
3757
|
-
let i = n ? [n, "common"] : ["common", ...Object.keys(
|
|
3757
|
+
let i = n ? [n, "common"] : ["common", ...Object.keys(Tn).filter((e) => e !== "common")];
|
|
3758
3758
|
for (let e of i) {
|
|
3759
|
-
let t =
|
|
3759
|
+
let t = Tn[e]?.params[r];
|
|
3760
3760
|
if (t) return t;
|
|
3761
3761
|
}
|
|
3762
3762
|
return null;
|
|
3763
3763
|
}
|
|
3764
|
-
var
|
|
3764
|
+
var In = (e) => e.toLowerCase().replace(/[^a-z0-9]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^[^a-z]+/, ""), Ln = /^[A-Z][A-Z0-9.:#/ -]*$/, Rn = {
|
|
3765
3765
|
RATIO: "ratio",
|
|
3766
3766
|
"LEV/FB": "levFb",
|
|
3767
3767
|
MOD: "mod"
|
|
3768
|
-
},
|
|
3769
|
-
function
|
|
3770
|
-
let r =
|
|
3768
|
+
}, zn = /^(?:-----|[1-4]>[A-Z]{3})$/i;
|
|
3769
|
+
function Bn(e, t, n) {
|
|
3770
|
+
let r = U(t, 0, e.x).trim().toUpperCase(), i = e.letters.map((t, n) => ({
|
|
3771
3771
|
letter: t,
|
|
3772
3772
|
x: e.x + n * e.step
|
|
3773
3773
|
})), a = (e, t, n, i, a) => ({
|
|
@@ -3780,10 +3780,10 @@ function Rn(e, t, n) {
|
|
|
3780
3780
|
paramLabel: r || e,
|
|
3781
3781
|
operator: a
|
|
3782
3782
|
}
|
|
3783
|
-
}), o =
|
|
3783
|
+
}), o = Rn[r];
|
|
3784
3784
|
if (o) {
|
|
3785
3785
|
let t = n.params[r];
|
|
3786
|
-
return t ? i.map(({ letter: i, x: s }) => a(o, s, e.width, r === "MOD" ?
|
|
3786
|
+
return t ? i.map(({ letter: i, x: s }) => a(o, s, e.width, r === "MOD" ? Vn(t, 1, n) : t, i)) : null;
|
|
3787
3787
|
}
|
|
3788
3788
|
if (r) return null;
|
|
3789
3789
|
if (/^\s+[A-D] \S/i.test(t)) {
|
|
@@ -3806,10 +3806,10 @@ function Rn(e, t, n) {
|
|
|
3806
3806
|
}
|
|
3807
3807
|
return r.length ? r : null;
|
|
3808
3808
|
}
|
|
3809
|
-
let s = i.map(({ x: n }) =>
|
|
3810
|
-
return c && s.every((e) =>
|
|
3809
|
+
let s = i.map(({ x: n }) => U(t, n, e.width).trim()), c = n.params.MOD;
|
|
3810
|
+
return c && s.every((e) => zn.test(e)) && !U(t, 0, e.x).trim() ? i.map(({ letter: t, x: r }) => a("mod2", r, e.width, Vn(c, 2, n), t)) : null;
|
|
3811
3811
|
}
|
|
3812
|
-
function
|
|
3812
|
+
function Vn(e, t, n) {
|
|
3813
3813
|
let r = {};
|
|
3814
3814
|
for (let [e, t] of Object.entries(n.operatorDestinations ?? {})) for (let n = 1; n <= 4; n += 1) r[`${n}>${e}`] = `MOD${n} ${e}: ${t}`;
|
|
3815
3815
|
return {
|
|
@@ -3820,8 +3820,8 @@ function zn(e, t, n) {
|
|
|
3820
3820
|
options: r
|
|
3821
3821
|
};
|
|
3822
3822
|
}
|
|
3823
|
-
var
|
|
3824
|
-
function
|
|
3823
|
+
var Hn = /^(CC[A-J])(?: CC:VAL)? +(?=\S)/i, Un = 6;
|
|
3824
|
+
function Wn(e, t, n) {
|
|
3825
3825
|
if (e.kind === "browser") {
|
|
3826
3826
|
let r = n.entryText?.trim() || t.trim();
|
|
3827
3827
|
return r ? {
|
|
@@ -3859,12 +3859,12 @@ function Hn(e, t, n) {
|
|
|
3859
3859
|
}]
|
|
3860
3860
|
};
|
|
3861
3861
|
}
|
|
3862
|
-
for (let r of e.rows ?? []) if (!(r.section && n.section && r.section !== n.section) && r.match.every((e) =>
|
|
3862
|
+
for (let r of e.rows ?? []) if (!(r.section && n.section && r.section !== n.section) && r.match.every((e) => kn(e, t))) return {
|
|
3863
3863
|
rowId: r.id,
|
|
3864
3864
|
cells: r.cells
|
|
3865
3865
|
};
|
|
3866
3866
|
if (e.operators && n.instrumentKey === e.operators.instrument) {
|
|
3867
|
-
let n =
|
|
3867
|
+
let n = Bn(e.operators, t, Tn[e.operators.instrument]);
|
|
3868
3868
|
if (n) return {
|
|
3869
3869
|
rowId: "operators",
|
|
3870
3870
|
cells: n
|
|
@@ -3872,11 +3872,11 @@ function Hn(e, t, n) {
|
|
|
3872
3872
|
}
|
|
3873
3873
|
let r = e.zones ?? [], i = [];
|
|
3874
3874
|
return r.forEach((a, o) => {
|
|
3875
|
-
let s =
|
|
3876
|
-
if (u && (s = u[1].toUpperCase(), c = u[0].length, l =
|
|
3877
|
-
let d = r[o + 1], f = d != null &&
|
|
3878
|
-
if (!
|
|
3879
|
-
let m =
|
|
3875
|
+
let s = U(t, a.labelX, a.labelWidth).trim().toUpperCase(), c = a.x, l = null, u = o === 0 ? Hn.exec(t) : null;
|
|
3876
|
+
if (u && (s = u[1].toUpperCase(), c = u[0].length, l = Un), !Ln.test(s)) return;
|
|
3877
|
+
let d = r[o + 1], f = d != null && U(t, d.labelX - 1, 1).trim() === "" && Ln.test(U(t, d.labelX, d.labelWidth).trim().toUpperCase()), p = l ?? (d && f ? Math.max(1, d.labelX - 1 - c) : a.width);
|
|
3878
|
+
if (!U(t, c, p).trim()) return;
|
|
3879
|
+
let m = Fn(e, s, n.instrumentKey), h = In(s) || a.id, g = i.some((e) => e.key === h) ? `${h}${a.id[0].toUpperCase()}${a.id.slice(1)}` : h;
|
|
3880
3880
|
i.push({
|
|
3881
3881
|
x: c,
|
|
3882
3882
|
width: p,
|
|
@@ -3898,19 +3898,19 @@ function Hn(e, t, n) {
|
|
|
3898
3898
|
cells: i
|
|
3899
3899
|
};
|
|
3900
3900
|
}
|
|
3901
|
-
var
|
|
3901
|
+
var W = {
|
|
3902
3902
|
hexValue: null,
|
|
3903
3903
|
numericValue: null,
|
|
3904
3904
|
values: null,
|
|
3905
3905
|
text: null
|
|
3906
3906
|
};
|
|
3907
|
-
function
|
|
3907
|
+
function Gn(e) {
|
|
3908
3908
|
return /^[0-9A-F]{2}$/i.test(e) ? "hex" : /^[0-9A-F]{2}:[0-9A-F]{2}$/i.test(e) ? "hexPair" : /^[+-]?\d+([.,]\d+)?$/.test(e) ? "float" : /^[0-9A-F]{2}\S/i.test(e) ? "hexOption" : "text";
|
|
3909
3909
|
}
|
|
3910
|
-
function
|
|
3910
|
+
function Kn(e, t) {
|
|
3911
3911
|
let n = e.trim();
|
|
3912
|
-
if (!n) return
|
|
3913
|
-
switch (t === "auto" ?
|
|
3912
|
+
if (!n) return W;
|
|
3913
|
+
switch (t === "auto" ? Gn(n) : t) {
|
|
3914
3914
|
case "hex": {
|
|
3915
3915
|
let e = /^([0-9A-F]{2})/i.exec(n), t = e ? parseInt(e[1], 16) : null;
|
|
3916
3916
|
return {
|
|
@@ -3923,7 +3923,7 @@ function Wn(e, t) {
|
|
|
3923
3923
|
case "hexOption": {
|
|
3924
3924
|
let e = /^([0-9A-F]{2})\s?(.*)$/i.exec(n);
|
|
3925
3925
|
if (!e) return {
|
|
3926
|
-
...
|
|
3926
|
+
...W,
|
|
3927
3927
|
text: n
|
|
3928
3928
|
};
|
|
3929
3929
|
let t = parseInt(e[1], 16);
|
|
@@ -3937,7 +3937,7 @@ function Wn(e, t) {
|
|
|
3937
3937
|
case "hexPair": {
|
|
3938
3938
|
let e = /^([0-9A-F]{2})[:/]([0-9A-F]{2})/i.exec(n);
|
|
3939
3939
|
if (!e) return {
|
|
3940
|
-
...
|
|
3940
|
+
...W,
|
|
3941
3941
|
text: n
|
|
3942
3942
|
};
|
|
3943
3943
|
let t = [parseInt(e[1], 16), parseInt(e[2], 16)];
|
|
@@ -3951,7 +3951,7 @@ function Wn(e, t) {
|
|
|
3951
3951
|
case "decimal": {
|
|
3952
3952
|
let e = parseInt(n, 10);
|
|
3953
3953
|
return Number.isNaN(e) ? {
|
|
3954
|
-
...
|
|
3954
|
+
...W,
|
|
3955
3955
|
text: n
|
|
3956
3956
|
} : {
|
|
3957
3957
|
hexValue: null,
|
|
@@ -3963,7 +3963,7 @@ function Wn(e, t) {
|
|
|
3963
3963
|
case "decimalPair": {
|
|
3964
3964
|
let e = /^(\d+):(\d+)/.exec(n);
|
|
3965
3965
|
if (!e) return {
|
|
3966
|
-
...
|
|
3966
|
+
...W,
|
|
3967
3967
|
text: n
|
|
3968
3968
|
};
|
|
3969
3969
|
let t = [parseInt(e[1], 10), parseInt(e[2], 10)];
|
|
@@ -3977,7 +3977,7 @@ function Wn(e, t) {
|
|
|
3977
3977
|
case "float": {
|
|
3978
3978
|
let e = parseFloat(n.replace(",", "."));
|
|
3979
3979
|
return Number.isNaN(e) ? {
|
|
3980
|
-
...
|
|
3980
|
+
...W,
|
|
3981
3981
|
text: n
|
|
3982
3982
|
} : {
|
|
3983
3983
|
hexValue: null,
|
|
@@ -3987,12 +3987,12 @@ function Wn(e, t) {
|
|
|
3987
3987
|
};
|
|
3988
3988
|
}
|
|
3989
3989
|
default: return {
|
|
3990
|
-
...
|
|
3990
|
+
...W,
|
|
3991
3991
|
text: n
|
|
3992
3992
|
};
|
|
3993
3993
|
}
|
|
3994
3994
|
}
|
|
3995
|
-
function
|
|
3995
|
+
function qn(e, t) {
|
|
3996
3996
|
if (!e || !t) return null;
|
|
3997
3997
|
let n = t.toUpperCase().trim();
|
|
3998
3998
|
if (e[n]) return e[n];
|
|
@@ -4001,28 +4001,28 @@ function Gn(e, t) {
|
|
|
4001
4001
|
}
|
|
4002
4002
|
//#endregion
|
|
4003
4003
|
//#region src/fxCommands.ts
|
|
4004
|
-
var
|
|
4005
|
-
function
|
|
4006
|
-
let t =
|
|
4007
|
-
return t.length === 0 || t.length ===
|
|
4004
|
+
var Jn = I.fxCommands, Yn = I.instrumentFx.types, Xn = Object.entries(Yn).filter(([, e]) => e.verified).map(([e]) => e);
|
|
4005
|
+
function Zn(e) {
|
|
4006
|
+
let t = Xn.filter((t) => Yn[t].commands.includes(e));
|
|
4007
|
+
return t.length === 0 || t.length === Xn.length ? null : t;
|
|
4008
4008
|
}
|
|
4009
|
-
function
|
|
4009
|
+
function Qn(e) {
|
|
4010
4010
|
let t = e.toUpperCase();
|
|
4011
4011
|
for (let e of [
|
|
4012
4012
|
"sequencer",
|
|
4013
4013
|
"instrument",
|
|
4014
4014
|
"mixer"
|
|
4015
4015
|
]) {
|
|
4016
|
-
let n =
|
|
4016
|
+
let n = Jn[e][t];
|
|
4017
4017
|
if (n) return {
|
|
4018
4018
|
description: n.description,
|
|
4019
4019
|
category: e,
|
|
4020
4020
|
relative: n.relative === !0,
|
|
4021
|
-
instrumentTypes: e === "instrument" ?
|
|
4021
|
+
instrumentTypes: e === "instrument" ? Zn(t) : null,
|
|
4022
4022
|
slot: null
|
|
4023
4023
|
};
|
|
4024
4024
|
}
|
|
4025
|
-
let n = /^([A-Z]{2})([1-4])$/.exec(t), r = n ?
|
|
4025
|
+
let n = /^([A-Z]{2})([1-4])$/.exec(t), r = n ? Jn.modulation[n[1]] : void 0;
|
|
4026
4026
|
if (n && r) return {
|
|
4027
4027
|
description: r.description.replace("modulator N", `modulator ${n[2]}`),
|
|
4028
4028
|
category: "modulation",
|
|
@@ -4031,25 +4031,22 @@ function Xn(e) {
|
|
|
4031
4031
|
slot: Number(n[2])
|
|
4032
4032
|
};
|
|
4033
4033
|
}
|
|
4034
|
-
function
|
|
4035
|
-
return
|
|
4034
|
+
function G(e) {
|
|
4035
|
+
return Qn(e)?.relative === !0;
|
|
4036
4036
|
}
|
|
4037
|
-
function
|
|
4038
|
-
let t =
|
|
4037
|
+
function $n(e) {
|
|
4038
|
+
let t = Yn[e.toLowerCase()];
|
|
4039
4039
|
return t ? {
|
|
4040
4040
|
type: e.toLowerCase(),
|
|
4041
4041
|
verified: t.verified,
|
|
4042
4042
|
commands: [...t.commands]
|
|
4043
4043
|
} : null;
|
|
4044
4044
|
}
|
|
4045
|
-
var
|
|
4046
|
-
function
|
|
4047
|
-
return
|
|
4048
|
-
}
|
|
4049
|
-
function nr(e) {
|
|
4050
|
-
return e > 127 ? `−${J(256 - e)}` : `+${J(e)}`;
|
|
4045
|
+
var er = I.instrumentFx.relativeCommands.description, K = (e) => e.toString(16).toUpperCase().padStart(2, "0"), q = (e) => e.toString(16).toUpperCase(), tr = (e) => e === 1 ? "once" : e === 2 ? "twice" : `${e} times`, J = (e) => e > 127 ? e - 256 : e, Y = (e) => `${e > 0 ? "+" : e < 0 ? "−" : "±"}${Math.abs(e)}`, nr = (e) => Y(J(e)), X = 4, rr = 1020, ir = (e) => J(e);
|
|
4046
|
+
function ar(e) {
|
|
4047
|
+
return Y(ir(e) / X);
|
|
4051
4048
|
}
|
|
4052
|
-
var
|
|
4049
|
+
var or = [
|
|
4053
4050
|
"C-",
|
|
4054
4051
|
"C#",
|
|
4055
4052
|
"D-",
|
|
@@ -4063,16 +4060,16 @@ var rr = [
|
|
|
4063
4060
|
"A#",
|
|
4064
4061
|
"B-"
|
|
4065
4062
|
];
|
|
4066
|
-
function
|
|
4063
|
+
function sr(e) {
|
|
4067
4064
|
let t = /^([A-G])([#-])(\d)$/.exec((e ?? "").trim().toUpperCase());
|
|
4068
4065
|
if (!t) return null;
|
|
4069
|
-
let n =
|
|
4066
|
+
let n = or.indexOf(`${t[1]}${t[2]}`);
|
|
4070
4067
|
return n < 0 ? null : Number(t[3]) * 12 + n;
|
|
4071
4068
|
}
|
|
4072
|
-
function
|
|
4073
|
-
return `${
|
|
4069
|
+
function cr(e) {
|
|
4070
|
+
return `${or[(e % 12 + 12) % 12]}${Math.floor(e / 12)}`;
|
|
4074
4071
|
}
|
|
4075
|
-
var
|
|
4072
|
+
var lr = [
|
|
4076
4073
|
"C",
|
|
4077
4074
|
"C#",
|
|
4078
4075
|
"D",
|
|
@@ -4085,14 +4082,14 @@ var or = [
|
|
|
4085
4082
|
"A",
|
|
4086
4083
|
"A#",
|
|
4087
4084
|
"B"
|
|
4088
|
-
],
|
|
4089
|
-
function
|
|
4090
|
-
return e ===
|
|
4085
|
+
], ur = 6;
|
|
4086
|
+
function dr(e) {
|
|
4087
|
+
return e === ur ? "one row per step" : ur % e === 0 ? `${ur / e} rows per step` : e % ur === 0 ? `one row every ${e / ur} steps` : "";
|
|
4091
4088
|
}
|
|
4092
|
-
function
|
|
4089
|
+
function fr(e, t) {
|
|
4093
4090
|
if (e === 0) return `${t} moves one row each time the instrument is triggered`;
|
|
4094
4091
|
if (e <= 251) {
|
|
4095
|
-
let n =
|
|
4092
|
+
let n = dr(e);
|
|
4096
4093
|
return `${t} moves one row every ${e} tick${e === 1 ? "" : "s"}${n ? ` (${n})` : ""}`;
|
|
4097
4094
|
}
|
|
4098
4095
|
return [
|
|
@@ -4102,12 +4099,12 @@ function lr(e, t) {
|
|
|
4102
4099
|
`${t} moves one row every 5 ms (200 Hz)`
|
|
4103
4100
|
][e - 252] ?? null;
|
|
4104
4101
|
}
|
|
4105
|
-
function
|
|
4102
|
+
function pr(e, t, n = {}) {
|
|
4106
4103
|
let r = e.toUpperCase(), i = t >> 4, a = t & 15, o = (e) => `${e} tick${e === 1 ? "" : "s"}`;
|
|
4107
4104
|
switch (r) {
|
|
4108
4105
|
case "ARP": {
|
|
4109
|
-
let e =
|
|
4110
|
-
return e == null ? `plays the note, then ${t}` : `${t}: ${
|
|
4106
|
+
let e = sr(n.note), t = `+${i} and +${a} semitones`;
|
|
4107
|
+
return e == null ? `plays the note, then ${t}` : `${t}: ${cr(e)} ${cr(e + i)} ${cr(e + a)}`;
|
|
4111
4108
|
}
|
|
4112
4109
|
case "ARC": return `arp mode ${i}, speed ${o(a)}`;
|
|
4113
4110
|
case "CHA": return n.inTable ? `everything left of it plays with probability ${t}/255 (00 never, FF always)` : `${i}/15 chance for what is left of it, ${a}/15 for what is right (0 never, F always)`;
|
|
@@ -4115,16 +4112,16 @@ function ur(e, t, n = {}) {
|
|
|
4115
4112
|
case "KIL": return `stops the note after ${o(t)}`;
|
|
4116
4113
|
case "OFF": return `note off after ${o(t)}`;
|
|
4117
4114
|
case "PSL": return `portamento over ${o(t)}`;
|
|
4118
|
-
case "GRV": return `track uses groove ${
|
|
4119
|
-
case "GGR": return `all tracks use groove ${
|
|
4120
|
-
case "INS": return `switches to instrument ${
|
|
4121
|
-
case "TBL": return `instrument uses table ${
|
|
4122
|
-
case "TBX": return t === 0 ? "stops the auxiliary table" : `plays table ${
|
|
4123
|
-
case "THO": return n.inTable ? `every column of the table jumps to row ${
|
|
4124
|
-
case "HOP": return n.inTable ? a === n.row ? i === 0 ? `this column stops on row ${
|
|
4115
|
+
case "GRV": return `track uses groove ${K(t)}`;
|
|
4116
|
+
case "GGR": return `all tracks use groove ${K(t)}`;
|
|
4117
|
+
case "INS": return `switches to instrument ${K(t)}`;
|
|
4118
|
+
case "TBL": return `instrument uses table ${K(t)}`;
|
|
4119
|
+
case "TBX": return t === 0 ? "stops the auxiliary table" : `plays table ${K(t)} alongside the instrument table`;
|
|
4120
|
+
case "THO": return n.inTable ? `every column of the table jumps to row ${q(a)}` : `the instrument's table jumps to row ${q(a)} (the aux table when a TBX is on this step)`;
|
|
4121
|
+
case "HOP": return n.inTable ? a === n.row ? i === 0 ? `this column stops on row ${q(a)}` : `holds this column on row ${q(a)} ${tr(i)}` : i === 0 ? `always jumps back to row ${q(a)}: the rows in between loop` : `jumps to row ${q(a)} ${tr(i)}, then the column runs on past it` : t === 255 ? "stops this track" : `jumps to row ${q(a)} of the next phrase`;
|
|
4125
4122
|
case "REP": return !n.inTable || t === 0 ? null : `plays the command above it ${t} more time${t === 1 ? "" : "s"}, one row each`;
|
|
4126
|
-
case "RTO": return n.inTable ? `repeats the relative command above it until it has added ${t > 127 ? `${
|
|
4127
|
-
case "RMX": return `tracks to its left (selection ${
|
|
4123
|
+
case "RTO": return n.inTable ? `repeats the relative command above it until it has added ${t > 127 ? `${K(t)} (${J(t)})` : K(t)} in total` : null;
|
|
4124
|
+
case "RMX": return `tracks to its left (selection ${q(i)}) jump to phrase row ${q(a)}`;
|
|
4128
4125
|
case "RND": return `randomises the previous FX: left range ${i}, right range ${a} (0 none, F full)`;
|
|
4129
4126
|
case "RNL": return `randomises the FX to its left: left range ${i}, right range ${a} (0 none, F full)`;
|
|
4130
4127
|
case "RET": return a === 0 ? `single retrig after ${o(i)}` : `retrigs every ${o(a)}, volume ${i < 8 ? "falls" : "rises"} on each retrig (ramp ${i})`;
|
|
@@ -4133,76 +4130,92 @@ function ur(e, t, n = {}) {
|
|
|
4133
4130
|
case "PBN": return t < 128 ? `pitch slides up by ${t}` : `pitch slides down by ${256 - t}`;
|
|
4134
4131
|
case "SCA":
|
|
4135
4132
|
case "SCG": {
|
|
4136
|
-
let e =
|
|
4133
|
+
let e = lr[i];
|
|
4137
4134
|
return `${r === "SCA" ? "track" : "song"} scale ${a.toString(16).toUpperCase()}${e ? `, key ${e}` : ""}`;
|
|
4138
4135
|
}
|
|
4139
|
-
case "SNG": return `moves the song position by ${
|
|
4140
|
-
case "SED": return `random seed ${
|
|
4141
|
-
case "NXT": return `plays instrument ${
|
|
4136
|
+
case "SNG": return `moves the song position by ${Y(J(t))} row(s)`;
|
|
4137
|
+
case "SED": return `random seed ${K(t)}`;
|
|
4138
|
+
case "NXT": return `plays instrument ${K(t)} on the next track`;
|
|
4142
4139
|
case "MTT": {
|
|
4143
4140
|
if (n.inTable) return "no effect in a table";
|
|
4144
|
-
let e =
|
|
4145
|
-
return e < 0 && n.row === 0 ? "no effect: a row cannot be moved earlier on the first step" : e === 0 ? "no timing shift" : `shifts the row by ${
|
|
4141
|
+
let e = J(t);
|
|
4142
|
+
return e < 0 && n.row === 0 ? "no effect: a row cannot be moved earlier on the first step" : e === 0 ? "no timing shift" : `shifts the row by ${Y(e)}/8 tick`;
|
|
4146
4143
|
}
|
|
4147
4144
|
case "TPO": return `${t} BPM`;
|
|
4148
|
-
case "TSP": return `transposes the song by ${
|
|
4149
|
-
case "TIC": return
|
|
4145
|
+
case "TSP": return `transposes the song by ${Y(J(t))} semitones`;
|
|
4146
|
+
case "TIC": return fr(t, n.inTable ? "this column" : "the instrument's table");
|
|
4150
4147
|
case "XRZ": return t > 0 ? "reverb freeze on" : "reverb freeze off";
|
|
4151
4148
|
}
|
|
4152
|
-
if (
|
|
4153
|
-
let e =
|
|
4154
|
-
return r === "PIT" ? e === 0 ? "no change" : `${
|
|
4149
|
+
if (G(r)) {
|
|
4150
|
+
let e = J(t);
|
|
4151
|
+
return r === "PIT" ? e === 0 ? "no change" : `${Y(e)} semitones` : e === 0 ? "no change" : Y(e);
|
|
4155
4152
|
}
|
|
4156
4153
|
return null;
|
|
4157
4154
|
}
|
|
4158
|
-
function
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4155
|
+
function mr(e, t, n, r) {
|
|
4156
|
+
if (t) return {
|
|
4157
|
+
q: e + n,
|
|
4158
|
+
held: null
|
|
4159
|
+
};
|
|
4160
|
+
let i = e + n, a = null;
|
|
4161
|
+
if (r != null) {
|
|
4162
|
+
let t = r * X;
|
|
4163
|
+
(n > 0 && i >= t && e <= t || n < 0 && i <= t && e >= t) && (i = t, a = "limit");
|
|
4164
|
+
}
|
|
4165
|
+
return i >= rr && n > 0 ? (i = rr, a = "max") : i <= 0 && n < 0 && (i = 0, a = "min"), {
|
|
4166
|
+
q: i,
|
|
4167
|
+
held: a
|
|
4163
4168
|
};
|
|
4164
4169
|
}
|
|
4165
|
-
function
|
|
4166
|
-
let i = null, a =
|
|
4167
|
-
for (let n = 0; n <=
|
|
4168
|
-
let
|
|
4169
|
-
if (
|
|
4170
|
-
let e =
|
|
4171
|
-
e === "REP" ? t ? !i && !r ?
|
|
4170
|
+
function hr(e, t, n, r = !1) {
|
|
4171
|
+
let i = null, a = !1, o = null, s = null, c = null, l = r, u = null, d = null, f = "none", p = Math.min(n, e.length - 1);
|
|
4172
|
+
for (let n = 0; n <= p; n += 1) {
|
|
4173
|
+
let p = e[n].fields[`fx${t}cmd`], m = e[n].fields[`fx${t}val`];
|
|
4174
|
+
if (f = "none", p && !p.isEmpty) {
|
|
4175
|
+
let e = p.rawValue.toUpperCase(), t = m && !m.isEmpty ? m.hexValue : null;
|
|
4176
|
+
e === "REP" ? t ? !i && !r ? f = "orphan" : (f = l ? "repChange" : "rep", l || (d = n), l = !0, s = t, o != null && ({q: o, held: u} = mr(o, a, ir(s), c))) : (f = "repStop", l = !1, s = null, u = null) : e === "RTO" ? (f = "rto", c = t) : (f = l ? "replace" : "set", i = {
|
|
4172
4177
|
cmd: e,
|
|
4173
4178
|
value: t,
|
|
4174
4179
|
step: n
|
|
4175
|
-
}, a = t,
|
|
4176
|
-
} else
|
|
4180
|
+
}, a = G(e), o = t == null ? null : (a ? J(t) : t) * X, l = !1, s = null, c = null, u = null, d = null);
|
|
4181
|
+
} else l && (f = "continue", o != null && s != null && ({q: o, held: u} = mr(o, a, ir(s), c)));
|
|
4177
4182
|
}
|
|
4183
|
+
let m = l && o != null;
|
|
4178
4184
|
return {
|
|
4179
4185
|
lane: t,
|
|
4180
4186
|
step: n,
|
|
4181
|
-
event:
|
|
4187
|
+
event: f,
|
|
4182
4188
|
source: i,
|
|
4183
|
-
active:
|
|
4184
|
-
increment:
|
|
4185
|
-
limit:
|
|
4186
|
-
value:
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4189
|
+
active: l,
|
|
4190
|
+
increment: s,
|
|
4191
|
+
limit: c,
|
|
4192
|
+
value: m && !a && o != null ? Math.floor(o / X) : null,
|
|
4193
|
+
offset: m && a && o != null ? o / X : null,
|
|
4194
|
+
held: l ? u : null,
|
|
4195
|
+
atLimit: l && u === "limit",
|
|
4196
|
+
repStartStep: d,
|
|
4197
|
+
carried: l && !i
|
|
4190
4198
|
};
|
|
4191
4199
|
}
|
|
4192
|
-
function
|
|
4193
|
-
let t = e.source, n =
|
|
4200
|
+
function gr(e) {
|
|
4201
|
+
let t = e.source, n = e.increment == null ? "" : ar(e.increment), r = e.limit == null ? "" : `, or at the RTO value ${K(e.limit)} (${e.limit})`, i = () => {
|
|
4202
|
+
if (e.offset != null) return `${t?.cmd} is ${Y(e.offset)} from the instrument's own value on this row`;
|
|
4203
|
+
if (e.value == null) return `${t?.cmd} has no value to shift`;
|
|
4204
|
+
let n = e.held === "limit" ? ", held at the RTO value" : e.held === "max" ? ", it cannot go above FF" : e.held === "min" ? ", it cannot go below 00" : "";
|
|
4205
|
+
return `${t?.cmd} is ${K(e.value)} (${e.value}) on this row${n}`;
|
|
4206
|
+
};
|
|
4194
4207
|
switch (e.event) {
|
|
4195
4208
|
case "rep":
|
|
4196
|
-
case "repChange": return e.carried ? `REP ${
|
|
4197
|
-
case "continue": return e.carried ? "REP from a previous phrase is still active in this lane (^^)" : `REP still active
|
|
4198
|
-
case "repStop": return t ? `REP00 stops the
|
|
4199
|
-
case "orphan": return "REP has no earlier command in this lane of the phrase to
|
|
4200
|
-
case "rto": return e.
|
|
4201
|
-
case "replace": return t ? `replaces the running REP (${t.cmd} is no longer
|
|
4209
|
+
case "repChange": return e.carried ? `REP ${n} per row continues the shift from the previous phrase` : `${e.event === "rep" ? "shifts" : "now shifts"} ${t?.cmd} by ${n} per row: ${i()}; it stops at 00 and FF${r}, without wrapping`;
|
|
4210
|
+
case "continue": return e.carried ? "REP from a previous phrase is still active in this lane (^^)" : `REP still active (${n} per row since step ${e.repStartStep?.toString(16).toUpperCase()}): ${i()}`;
|
|
4211
|
+
case "repStop": return t ? `REP00 stops the shifting of ${t.cmd}` : "REP00 stops the shifting";
|
|
4212
|
+
case "orphan": return "REP has no earlier command in this lane of the phrase to shift";
|
|
4213
|
+
case "rto": return e.limit == null ? "sets the value a REP stops at" : `sets the value a REP stops at: ${K(e.limit)} (${e.limit}), an absolute value, not a shift`;
|
|
4214
|
+
case "replace": return t ? `replaces the running REP (${t.cmd} is no longer shifted)` : null;
|
|
4202
4215
|
default: return null;
|
|
4203
4216
|
}
|
|
4204
4217
|
}
|
|
4205
|
-
function
|
|
4218
|
+
function _r(e) {
|
|
4206
4219
|
let t = e.fields.inst;
|
|
4207
4220
|
return t && !t.isEmpty ? "instrument" : [
|
|
4208
4221
|
1,
|
|
@@ -4213,10 +4226,10 @@ function mr(e) {
|
|
|
4213
4226
|
return n != null && !n.isEmpty && n.rawValue.toUpperCase() === "RET";
|
|
4214
4227
|
}) ? "ret" : null;
|
|
4215
4228
|
}
|
|
4216
|
-
function
|
|
4229
|
+
function vr(e, t, n = null) {
|
|
4217
4230
|
let r = {}, i = null, a = null, o = Math.min(t, e.length - 1);
|
|
4218
4231
|
for (let t = 0; t <= o; t += 1) {
|
|
4219
|
-
let o =
|
|
4232
|
+
let o = _r(e[t]);
|
|
4220
4233
|
if (o) {
|
|
4221
4234
|
for (let e of Object.keys(r)) delete r[e];
|
|
4222
4235
|
i = t, a = o;
|
|
@@ -4226,10 +4239,10 @@ function hr(e, t, n = null) {
|
|
|
4226
4239
|
2,
|
|
4227
4240
|
3
|
|
4228
4241
|
]) {
|
|
4229
|
-
let s =
|
|
4230
|
-
if (!c || s.carried || !
|
|
4242
|
+
let s = hr(e, o, t, n === o), c = s.source;
|
|
4243
|
+
if (!c || s.carried || !G(c.cmd)) continue;
|
|
4231
4244
|
let l = null, u = !1;
|
|
4232
|
-
if (s.event === "set" || s.event === "replace" ? l = c.value : (s.event === "rep" || s.event === "repChange" || s.event === "continue") && (l = s.
|
|
4245
|
+
if (s.event === "set" || s.event === "replace" ? l = c.value == null ? null : J(c.value) : (s.event === "rep" || s.event === "repChange" || s.event === "continue") && s.increment != null && c.value != null && (l = ir(s.increment) / X, u = !0), l == null) continue;
|
|
4233
4246
|
let d = r[c.cmd];
|
|
4234
4247
|
d || (d = {
|
|
4235
4248
|
cmd: c.cmd,
|
|
@@ -4238,26 +4251,26 @@ function hr(e, t, n = null) {
|
|
|
4238
4251
|
resetStep: i,
|
|
4239
4252
|
resetBy: a,
|
|
4240
4253
|
viaRep: !1
|
|
4241
|
-
}, r[c.cmd] = d), d.total +=
|
|
4254
|
+
}, r[c.cmd] = d), d.total += l, d.count += 1, d.viaRep ||= u;
|
|
4242
4255
|
}
|
|
4243
4256
|
}
|
|
4244
4257
|
return r;
|
|
4245
4258
|
}
|
|
4246
|
-
var
|
|
4247
|
-
function
|
|
4259
|
+
var yr = (e) => Y(e);
|
|
4260
|
+
function br(e) {
|
|
4248
4261
|
if (e.resetStep == null) return "the start of this phrase (earlier state unknown)";
|
|
4249
4262
|
let t = e.resetStep.toString(16).toUpperCase();
|
|
4250
4263
|
return e.resetBy === "ret" ? `the RET on step ${t}` : `the instrument number on step ${t}`;
|
|
4251
4264
|
}
|
|
4252
|
-
var
|
|
4253
|
-
function
|
|
4254
|
-
if (!e || e.count <= 1) return `relative: ${
|
|
4255
|
-
let t = e.viaRep ? ",
|
|
4256
|
-
return `relative: ${e.cmd} ${n} over ${e.count}
|
|
4265
|
+
var xr = "stays until a note with an instrument number (I) or a RET resets it";
|
|
4266
|
+
function Sr(e) {
|
|
4267
|
+
if (!e || e.count <= 1) return `relative: ${xr}`;
|
|
4268
|
+
let t = e.viaRep ? ", REP steps included" : "", n = e.total === 0 ? "has had no net effect" : `has moved by ${yr(e.total)}`;
|
|
4269
|
+
return `relative: ${e.cmd} ${n} over ${e.count} rows since ${br(e)}${t}; ${xr}`;
|
|
4257
4270
|
}
|
|
4258
|
-
function
|
|
4271
|
+
function Cr(e) {
|
|
4259
4272
|
let t = Object.values(e).filter((e) => e.total !== 0);
|
|
4260
|
-
return t.length ? `triggers the instrument again: resets the relative changes still in force (${t.map((e) => `${e.cmd} ${
|
|
4273
|
+
return t.length ? `triggers the instrument again: resets the relative changes still in force (${t.map((e) => `${e.cmd} ${yr(e.total)}`).join(", ")})` : null;
|
|
4261
4274
|
}
|
|
4262
4275
|
//#endregion
|
|
4263
4276
|
//#region src/scaleInsight.ts
|
|
@@ -4274,7 +4287,7 @@ var Z = [
|
|
|
4274
4287
|
"A",
|
|
4275
4288
|
"A#",
|
|
4276
4289
|
"B"
|
|
4277
|
-
],
|
|
4290
|
+
], wr = [
|
|
4278
4291
|
{
|
|
4279
4292
|
name: "Major (Ionian)",
|
|
4280
4293
|
steps: [
|
|
@@ -4492,7 +4505,7 @@ var Z = [
|
|
|
4492
4505
|
11
|
|
4493
4506
|
]
|
|
4494
4507
|
}
|
|
4495
|
-
],
|
|
4508
|
+
], Tr = [
|
|
4496
4509
|
"the root",
|
|
4497
4510
|
"a minor 2nd",
|
|
4498
4511
|
"a major 2nd",
|
|
@@ -4506,26 +4519,26 @@ var Z = [
|
|
|
4506
4519
|
"a minor 7th",
|
|
4507
4520
|
"a major 7th"
|
|
4508
4521
|
];
|
|
4509
|
-
function
|
|
4522
|
+
function Er(e) {
|
|
4510
4523
|
let t = e.replace(/[-\s]/g, "").toUpperCase();
|
|
4511
4524
|
return Z.includes(t) ? t : null;
|
|
4512
4525
|
}
|
|
4513
|
-
function
|
|
4526
|
+
function Dr(e) {
|
|
4514
4527
|
let t = Z.indexOf(e);
|
|
4515
|
-
return t <= 0 ? t === 0 ? "the first row (the scale root)" : e : `${
|
|
4528
|
+
return t <= 0 ? t === 0 ? "the first row (the scale root)" : e : `${Tr[t]} (+${t} semitones above C)`;
|
|
4516
4529
|
}
|
|
4517
|
-
function
|
|
4530
|
+
function Or(e) {
|
|
4518
4531
|
let t = new Set(e);
|
|
4519
4532
|
if (t.size === 0) return [];
|
|
4520
4533
|
let n = [];
|
|
4521
|
-
for (let e of
|
|
4534
|
+
for (let e of wr) if (e.steps.length === t.size) for (let r = 0; r < 12; r += 1) e.steps.every((e) => t.has((e + r) % 12)) && n.push({
|
|
4522
4535
|
root: r,
|
|
4523
4536
|
name: e.name
|
|
4524
4537
|
});
|
|
4525
4538
|
return n.sort((e, t) => e.root - t.root), n.map((e) => e.root === 0 ? e.name : `${e.name} from ${Z[e.root]}`);
|
|
4526
4539
|
}
|
|
4527
|
-
function
|
|
4528
|
-
let t = e.filter((e) => e.enabled === !0), n = t.map((e) => e.interval), r =
|
|
4540
|
+
function kr(e) {
|
|
4541
|
+
let t = e.filter((e) => e.enabled === !0), n = t.map((e) => e.interval), r = Or(t.map((e) => e.semitone)), i = e.filter((e) => e.enabled === !0 && e.offset != null && e.offset !== 0).map((e) => ({
|
|
4529
4542
|
interval: e.interval,
|
|
4530
4543
|
offset: e.offset
|
|
4531
4544
|
}));
|
|
@@ -4534,47 +4547,47 @@ function Er(e) {
|
|
|
4534
4547
|
enabled: n,
|
|
4535
4548
|
shapes: r,
|
|
4536
4549
|
detuned: i,
|
|
4537
|
-
summary:
|
|
4550
|
+
summary: Ar({
|
|
4538
4551
|
enabled: n,
|
|
4539
4552
|
shapes: r,
|
|
4540
4553
|
detuned: i
|
|
4541
4554
|
}).join(" — ")
|
|
4542
4555
|
};
|
|
4543
4556
|
}
|
|
4544
|
-
function
|
|
4557
|
+
function Ar(e) {
|
|
4545
4558
|
let { enabled: t, shapes: n, detuned: r } = e;
|
|
4546
4559
|
if (!t.length) return ["no notes enabled"];
|
|
4547
4560
|
let i = n[0] ?? `${t.length} notes, custom scale`;
|
|
4548
|
-
return r.length && (i += `; detuned: ${r.map((e) => `${e.interval} ${
|
|
4561
|
+
return r.length && (i += `; detuned: ${r.map((e) => `${e.interval} ${jr(e.offset)}`).join(", ")}`), [t.join(" "), i];
|
|
4549
4562
|
}
|
|
4550
|
-
function
|
|
4563
|
+
function jr(e) {
|
|
4551
4564
|
return `${e > 0 ? "+" : e < 0 ? "−" : ""}${Math.abs(e).toFixed(2)} st`;
|
|
4552
4565
|
}
|
|
4553
4566
|
//#endregion
|
|
4554
4567
|
//#region src/viewContext.ts
|
|
4555
|
-
var
|
|
4568
|
+
var Mr = /* @__PURE__ */ new Set([
|
|
4556
4569
|
"--",
|
|
4557
4570
|
"---",
|
|
4558
4571
|
"---00",
|
|
4559
4572
|
"----",
|
|
4560
4573
|
"-"
|
|
4561
4574
|
]);
|
|
4562
|
-
function
|
|
4563
|
-
return !e ||
|
|
4575
|
+
function Nr(e) {
|
|
4576
|
+
return !e || Mr.has(e) || /^-+$/.test(e);
|
|
4564
4577
|
}
|
|
4565
|
-
function
|
|
4578
|
+
function Pr(e) {
|
|
4566
4579
|
let t = e.trim();
|
|
4567
|
-
if (!t ||
|
|
4580
|
+
if (!t || Nr(t)) return null;
|
|
4568
4581
|
let n = parseInt(t, 16);
|
|
4569
4582
|
return Number.isNaN(n) ? null : n;
|
|
4570
4583
|
}
|
|
4571
|
-
function
|
|
4584
|
+
function Fr(e, t, n) {
|
|
4572
4585
|
return t >= e.length ? "" : e.slice(t, Math.min(t + n, e.length));
|
|
4573
4586
|
}
|
|
4574
|
-
function
|
|
4575
|
-
return
|
|
4587
|
+
function Ir(e) {
|
|
4588
|
+
return Lr(e);
|
|
4576
4589
|
}
|
|
4577
|
-
function
|
|
4590
|
+
function Lr(e) {
|
|
4578
4591
|
if (!e) return {
|
|
4579
4592
|
viewId: null,
|
|
4580
4593
|
isUnsaved: !1,
|
|
@@ -4587,7 +4600,7 @@ function Pr(e) {
|
|
|
4587
4600
|
marker: r
|
|
4588
4601
|
};
|
|
4589
4602
|
}
|
|
4590
|
-
function
|
|
4603
|
+
function Rr(e) {
|
|
4591
4604
|
return e.length > 0 && /^[^a-zA-Z0-9 ]/.test(e[0]) ? {
|
|
4592
4605
|
line: e.slice(1),
|
|
4593
4606
|
offset: 1
|
|
@@ -4596,12 +4609,12 @@ function Fr(e) {
|
|
|
4596
4609
|
offset: 0
|
|
4597
4610
|
};
|
|
4598
4611
|
}
|
|
4599
|
-
function
|
|
4600
|
-
let n =
|
|
4612
|
+
function zr(e, t) {
|
|
4613
|
+
let n = Fr(t, e.x, e.width).trim();
|
|
4601
4614
|
n.includes("^") && (e.type === "fxCommand" || e.type === "fxValue") && (n = "");
|
|
4602
|
-
let r =
|
|
4615
|
+
let r = Nr(n);
|
|
4603
4616
|
if (e.format) {
|
|
4604
|
-
let t = r ? null :
|
|
4617
|
+
let t = r ? null : Kn(n, e.format), i = e.type === "name" || e.type === "fileEntry", a = t?.text != null && !i ? t.text.toUpperCase() : t?.text ?? null;
|
|
4605
4618
|
return {
|
|
4606
4619
|
key: e.key,
|
|
4607
4620
|
label: e.label,
|
|
@@ -4616,8 +4629,8 @@ function Ir(e, t) {
|
|
|
4616
4629
|
values: t?.values ?? null,
|
|
4617
4630
|
parts: e.parts,
|
|
4618
4631
|
unit: e.unit,
|
|
4619
|
-
valueDescription: !r &&
|
|
4620
|
-
fileKind: e.type === "fileEntry" ?
|
|
4632
|
+
valueDescription: !r && qn(e.options, a ?? n) || void 0,
|
|
4633
|
+
fileKind: e.type === "fileEntry" ? Br(n) : void 0
|
|
4621
4634
|
};
|
|
4622
4635
|
}
|
|
4623
4636
|
let i = [
|
|
@@ -4637,7 +4650,7 @@ function Ir(e, t) {
|
|
|
4637
4650
|
if (a.includes(e.type)) {
|
|
4638
4651
|
let e = parseInt(n, 10);
|
|
4639
4652
|
o = Number.isNaN(e) ? null : e;
|
|
4640
|
-
} else o =
|
|
4653
|
+
} else o = Pr(n);
|
|
4641
4654
|
}
|
|
4642
4655
|
return {
|
|
4643
4656
|
key: e.key,
|
|
@@ -4649,20 +4662,20 @@ function Ir(e, t) {
|
|
|
4649
4662
|
meta: e.meta
|
|
4650
4663
|
};
|
|
4651
4664
|
}
|
|
4652
|
-
function
|
|
4665
|
+
function Br(e) {
|
|
4653
4666
|
if (e === "/..") return "parent";
|
|
4654
4667
|
if (e.startsWith("/")) return "directory";
|
|
4655
4668
|
let t = /\.([a-z0-9]+)$/i.exec(e)?.[1]?.toLowerCase();
|
|
4656
4669
|
return t === "m8i" ? "instrumentPreset" : t === "wav" ? "sample" : t?.startsWith("m8") ? "m8file" : "file";
|
|
4657
4670
|
}
|
|
4658
|
-
function
|
|
4659
|
-
let n =
|
|
4671
|
+
function Vr(e, t) {
|
|
4672
|
+
let n = Fr(e, t.x, t.width).trim();
|
|
4660
4673
|
if (!n) return null;
|
|
4661
|
-
if (t.parse === "hex") return
|
|
4674
|
+
if (t.parse === "hex") return Pr(n);
|
|
4662
4675
|
let r = parseInt(n, 10);
|
|
4663
4676
|
return Number.isNaN(r) ? null : r;
|
|
4664
4677
|
}
|
|
4665
|
-
function
|
|
4678
|
+
function Hr(e, t) {
|
|
4666
4679
|
for (let n of e) if (t >= n.x && t < n.x + n.width) return n;
|
|
4667
4680
|
let n = null, r = 2;
|
|
4668
4681
|
for (let i of e) {
|
|
@@ -4671,9 +4684,9 @@ function zr(e, t) {
|
|
|
4671
4684
|
}
|
|
4672
4685
|
return n;
|
|
4673
4686
|
}
|
|
4674
|
-
function
|
|
4687
|
+
function Ur(e, t) {
|
|
4675
4688
|
let n = {};
|
|
4676
|
-
for (let r of e.columns ?? []) n[r.key] =
|
|
4689
|
+
for (let r of e.columns ?? []) n[r.key] = zr(r, t);
|
|
4677
4690
|
for (let e of Object.keys(n)) {
|
|
4678
4691
|
let t = /^fx(\d)cmd$/.exec(e)?.[1], r = t ? n[`fx${t}val`] : void 0;
|
|
4679
4692
|
r && n[e].isEmpty && (n[`fx${t}val`] = {
|
|
@@ -4682,27 +4695,27 @@ function Br(e, t) {
|
|
|
4682
4695
|
});
|
|
4683
4696
|
}
|
|
4684
4697
|
return {
|
|
4685
|
-
rowIndex: e.rowField ?
|
|
4698
|
+
rowIndex: e.rowField ? Vr(t, e.rowField) : null,
|
|
4686
4699
|
rowKey: e.rowField?.key ?? "row",
|
|
4687
4700
|
rowId: null,
|
|
4688
4701
|
fields: n
|
|
4689
4702
|
};
|
|
4690
4703
|
}
|
|
4691
|
-
var
|
|
4692
|
-
function
|
|
4704
|
+
var Wr = (e) => e.replace(/\s+/g, ""), Gr = 1, Q = (e) => e.slice(1);
|
|
4705
|
+
function Kr(e, t) {
|
|
4693
4706
|
if (!t || !e.cursorPos || !e.currentLine) return !1;
|
|
4694
4707
|
let n = t.lines[e.cursorPos.y];
|
|
4695
|
-
return n != null &&
|
|
4708
|
+
return n != null && Wr(n) === Wr(e.currentLine);
|
|
4696
4709
|
}
|
|
4697
|
-
var
|
|
4698
|
-
function
|
|
4699
|
-
let n =
|
|
4710
|
+
var qr = 16, Jr = 4, Yr = 21;
|
|
4711
|
+
function Xr(e, t) {
|
|
4712
|
+
let n = I.views[e];
|
|
4700
4713
|
if (n?.type !== "grid" || !n.rowField) return [];
|
|
4701
|
-
let r = [], i = Math.min(
|
|
4702
|
-
for (let e =
|
|
4714
|
+
let r = [], i = Math.min(Yr, t.lines.length - 1);
|
|
4715
|
+
for (let e = Jr; e <= i; e += 1) {
|
|
4703
4716
|
let i = Q(t.lines[e] ?? ""), a = n.rowField;
|
|
4704
|
-
if (i.length <= a.x + a.width || !
|
|
4705
|
-
let o =
|
|
4717
|
+
if (i.length <= a.x + a.width || !Zr(i[a.x + a.width])) continue;
|
|
4718
|
+
let o = Ur(n, i);
|
|
4706
4719
|
o.rowIndex != null && r.push({
|
|
4707
4720
|
...o,
|
|
4708
4721
|
screenRow: e
|
|
@@ -4710,11 +4723,11 @@ function qr(e, t) {
|
|
|
4710
4723
|
}
|
|
4711
4724
|
return r;
|
|
4712
4725
|
}
|
|
4713
|
-
var
|
|
4714
|
-
function
|
|
4715
|
-
let n =
|
|
4726
|
+
var Zr = (e) => e === " " || /^[^a-zA-Z0-9-]$/.test(e);
|
|
4727
|
+
function Qr(e, t) {
|
|
4728
|
+
let n = I.views[e];
|
|
4716
4729
|
if (n?.type !== "grid") return null;
|
|
4717
|
-
let r =
|
|
4730
|
+
let r = Xr(e, t), i = (e) => !!e && e !== " " && Zr(e);
|
|
4718
4731
|
if (e === "song") return {
|
|
4719
4732
|
tracks: (n.columns ?? []).filter((e) => e.type === "chainRef").map((e) => r.find((n) => i(Q(t.lines[n.screenRow] ?? "")[e.x - 1]))?.rowIndex ?? null),
|
|
4720
4733
|
row: null
|
|
@@ -4728,25 +4741,25 @@ function Yr(e, t) {
|
|
|
4728
4741
|
row: null
|
|
4729
4742
|
};
|
|
4730
4743
|
}
|
|
4731
|
-
function
|
|
4744
|
+
function $r(e, t, n, r) {
|
|
4732
4745
|
let i = (t.cursorPos?.y ?? -1) - r;
|
|
4733
4746
|
if (i < 0) return null;
|
|
4734
4747
|
let a = [], o = null;
|
|
4735
|
-
for (let t = 0; t <
|
|
4748
|
+
for (let t = 0; t < qr; t += 1) {
|
|
4736
4749
|
let r = n.lines[i + t];
|
|
4737
4750
|
if (r == null) return null;
|
|
4738
|
-
let s = Q(r), c =
|
|
4751
|
+
let s = Q(r), c = Ur(e, s);
|
|
4739
4752
|
if (c.rowIndex !== t) return null;
|
|
4740
4753
|
a.push(c);
|
|
4741
4754
|
let l = s.indexOf("^^");
|
|
4742
|
-
o == null && l >= 0 && (o =
|
|
4755
|
+
o == null && l >= 0 && (o = ei(e, l));
|
|
4743
4756
|
}
|
|
4744
4757
|
return {
|
|
4745
4758
|
steps: a,
|
|
4746
4759
|
carriedRepLane: o
|
|
4747
4760
|
};
|
|
4748
4761
|
}
|
|
4749
|
-
function
|
|
4762
|
+
function ei(e, t) {
|
|
4750
4763
|
let n = [];
|
|
4751
4764
|
for (let r = 1; r <= 3; r += 1) {
|
|
4752
4765
|
let i = e.columns?.find((e) => e.key === `fx${r}cmd`), a = e.columns?.find((e) => e.key === `fx${r}val`);
|
|
@@ -4760,8 +4773,8 @@ function Zr(e, t) {
|
|
|
4760
4773
|
let r = Math.min(...n.map((e) => e.dist)), i = n.filter((e) => e.dist === r);
|
|
4761
4774
|
return r <= 1 && i.length === 1 ? i[0].lane : null;
|
|
4762
4775
|
}
|
|
4763
|
-
function
|
|
4764
|
-
let t =
|
|
4776
|
+
function ti(e) {
|
|
4777
|
+
let t = Er(e.fields.interval?.rawValue ?? "");
|
|
4765
4778
|
if (!t) return null;
|
|
4766
4779
|
let n = e.fields.en?.rawValue.toUpperCase(), r = parseFloat(e.fields.offset?.rawValue ?? "");
|
|
4767
4780
|
return {
|
|
@@ -4771,15 +4784,15 @@ function Qr(e) {
|
|
|
4771
4784
|
offset: Number.isNaN(r) ? null : r
|
|
4772
4785
|
};
|
|
4773
4786
|
}
|
|
4774
|
-
function
|
|
4787
|
+
function ni(e, t) {
|
|
4775
4788
|
let n = /* @__PURE__ */ new Map();
|
|
4776
4789
|
for (let r of t.lines) {
|
|
4777
|
-
let t =
|
|
4790
|
+
let t = Ur(e, Q(r)), i = ti(t), a = t.fields.en?.rawValue.toUpperCase();
|
|
4778
4791
|
!i || a !== "ON" && a !== "OFF" && a !== "--" || n.has(i.interval) || n.set(i.interval, i);
|
|
4779
4792
|
}
|
|
4780
4793
|
return n.size === Z.length ? Z.map((e) => n.get(e)) : null;
|
|
4781
4794
|
}
|
|
4782
|
-
function
|
|
4795
|
+
function ri(e, t, n, r) {
|
|
4783
4796
|
let i = {
|
|
4784
4797
|
...r,
|
|
4785
4798
|
isGridView: !1,
|
|
@@ -4796,40 +4809,40 @@ function ei(e, t, n, r) {
|
|
|
4796
4809
|
resetsRelative: null,
|
|
4797
4810
|
scaleNote: null,
|
|
4798
4811
|
scale: null
|
|
4799
|
-
}, a = e.cursorPos, o = a ? a.x - 1 : 0, s = a &&
|
|
4812
|
+
}, a = e.cursorPos, o = a ? a.x - 1 : 0, s = a && Kr(e, t) ? t : null, c = s && a ? Q(s.lines[a.y] ?? "") : e.currentLine ?? "";
|
|
4800
4813
|
if (!c.trim()) return i;
|
|
4801
|
-
let l = s && a ? s.lines.slice(0, a.y + 1).reverse().map(Q) : [c], u = r.viewName === "inst" ?
|
|
4814
|
+
let l = s && a ? s.lines.slice(0, a.y + 1).reverse().map(Q) : [c], u = r.viewName === "inst" ? Nn(s ? s.lines.map(Q) : [c]) : null, d = {
|
|
4802
4815
|
instrumentKey: u?.key ?? null,
|
|
4803
4816
|
entryText: e.textUnderCursor
|
|
4804
4817
|
};
|
|
4805
4818
|
if (!s && a && n.kind == null) for (let e = 0; e <= Math.min(o, 24); e += 1) {
|
|
4806
4819
|
let t = " ".repeat(e) + c;
|
|
4807
|
-
if (
|
|
4820
|
+
if (Wn(n, t, {
|
|
4808
4821
|
...d,
|
|
4809
|
-
section:
|
|
4822
|
+
section: An(n, [t])
|
|
4810
4823
|
}).cells.some((e) => o >= e.x && o < e.x + e.width)) {
|
|
4811
4824
|
c = t;
|
|
4812
4825
|
break;
|
|
4813
4826
|
}
|
|
4814
4827
|
}
|
|
4815
|
-
let f =
|
|
4828
|
+
let f = An(n, s ? l : [c]), { rowId: p, cells: m } = Wn(n, c, {
|
|
4816
4829
|
...d,
|
|
4817
4830
|
section: f
|
|
4818
4831
|
}), h = {};
|
|
4819
|
-
for (let e of m) h[e.key] =
|
|
4832
|
+
for (let e of m) h[e.key] = zr(e, c);
|
|
4820
4833
|
let g = {
|
|
4821
4834
|
rowIndex: null,
|
|
4822
4835
|
rowKey: "param",
|
|
4823
4836
|
rowId: p,
|
|
4824
4837
|
fields: h
|
|
4825
|
-
}, _ = null, v = a ?
|
|
4838
|
+
}, _ = null, v = a ? Hr(m, o) : null;
|
|
4826
4839
|
v && (_ = {
|
|
4827
4840
|
...h[v.key],
|
|
4828
4841
|
viewName: r.viewName,
|
|
4829
4842
|
rowIndex: null
|
|
4830
4843
|
});
|
|
4831
4844
|
let y = v?.meta?.zone;
|
|
4832
|
-
return s && typeof y == "string" && (f =
|
|
4845
|
+
return s && typeof y == "string" && (f = jn(n, y, l) ?? f), {
|
|
4833
4846
|
...i,
|
|
4834
4847
|
section: f,
|
|
4835
4848
|
instrumentType: u,
|
|
@@ -4838,10 +4851,10 @@ function ei(e, t, n, r) {
|
|
|
4838
4851
|
lineText: c.trim()
|
|
4839
4852
|
};
|
|
4840
4853
|
}
|
|
4841
|
-
function
|
|
4854
|
+
function ii(e, t) {
|
|
4842
4855
|
let n = e.viewName;
|
|
4843
4856
|
if (!n) return null;
|
|
4844
|
-
let r =
|
|
4857
|
+
let r = I.views[n] ?? null, i = r?.type === "grid", a = r?.title ?? null, o = r?.description ?? null, { viewId: s, isUnsaved: c } = Lr(e.viewTitle), l = {
|
|
4845
4858
|
viewName: n,
|
|
4846
4859
|
viewTitle: a,
|
|
4847
4860
|
viewDescription: o,
|
|
@@ -4860,8 +4873,8 @@ function ti(e, t) {
|
|
|
4860
4873
|
resetsRelative: null,
|
|
4861
4874
|
scaleNote: null,
|
|
4862
4875
|
scale: null
|
|
4863
|
-
}, d = r?.type === "parameter" ?
|
|
4864
|
-
if (d) return
|
|
4876
|
+
}, d = r?.type === "parameter" ? On(n) : null;
|
|
4877
|
+
if (d) return ri(e, t, d, l);
|
|
4865
4878
|
if (!i || !r) return {
|
|
4866
4879
|
...u,
|
|
4867
4880
|
isGridView: !1,
|
|
@@ -4875,11 +4888,11 @@ function ti(e, t) {
|
|
|
4875
4888
|
row: null,
|
|
4876
4889
|
activeField: null
|
|
4877
4890
|
};
|
|
4878
|
-
let { line: p } =
|
|
4879
|
-
if (g) return
|
|
4891
|
+
let { line: p } = Rr(f), m = e.cursorPos ? e.cursorPos.x - 1 : 0, h = Ur(r, p), g = n === "scale" && !Er(h.fields.interval?.rawValue ?? "") ? On(n) : null;
|
|
4892
|
+
if (g) return ri(e, t, g, l);
|
|
4880
4893
|
let _ = null;
|
|
4881
4894
|
if (e.cursorPos) {
|
|
4882
|
-
let e =
|
|
4895
|
+
let e = Hr(r.columns ?? [], m);
|
|
4883
4896
|
if (e) {
|
|
4884
4897
|
let t = h.fields[e.key];
|
|
4885
4898
|
t && (_ = {
|
|
@@ -4890,20 +4903,20 @@ function ti(e, t) {
|
|
|
4890
4903
|
}
|
|
4891
4904
|
}
|
|
4892
4905
|
let v = null, y = null, b = null, x = null, S = null, C = null;
|
|
4893
|
-
if (
|
|
4906
|
+
if (Kr(e, t)) {
|
|
4894
4907
|
if (n === "phrase" && h.rowIndex != null) {
|
|
4895
|
-
let n =
|
|
4908
|
+
let n = $r(r, e, t, h.rowIndex);
|
|
4896
4909
|
if (n) {
|
|
4897
4910
|
v = n.steps, y = n.carriedRepLane;
|
|
4898
4911
|
let e = _ ? /^fx(\d)(cmd|val)$/.exec(_.key)?.[1] : void 0;
|
|
4899
|
-
e && (b =
|
|
4912
|
+
e && (b = hr(v, Number(e), h.rowIndex, y === Number(e))), x = vr(v, h.rowIndex, y), h.rowIndex > 0 && _r(h) && (S = vr(v, h.rowIndex - 1, y));
|
|
4900
4913
|
}
|
|
4901
4914
|
} else if (n === "scale") {
|
|
4902
|
-
let e =
|
|
4903
|
-
e && (C =
|
|
4915
|
+
let e = ni(r, t);
|
|
4916
|
+
e && (C = kr(e));
|
|
4904
4917
|
}
|
|
4905
4918
|
}
|
|
4906
|
-
let w = n === "scale" ?
|
|
4919
|
+
let w = n === "scale" ? ti(h) : null;
|
|
4907
4920
|
return {
|
|
4908
4921
|
...u,
|
|
4909
4922
|
isGridView: !0,
|
|
@@ -4919,25 +4932,25 @@ function ti(e, t) {
|
|
|
4919
4932
|
scale: C
|
|
4920
4933
|
};
|
|
4921
4934
|
}
|
|
4922
|
-
function
|
|
4923
|
-
if (e.isParameterView) return
|
|
4935
|
+
function ai(e) {
|
|
4936
|
+
if (e.isParameterView) return hi(e);
|
|
4924
4937
|
if (e.viewName === "scale") {
|
|
4925
|
-
let t =
|
|
4938
|
+
let t = gi(e);
|
|
4926
4939
|
if (t) return t;
|
|
4927
4940
|
}
|
|
4928
4941
|
if (!e.activeField) return $(["location", e.viewTitle ?? e.viewName]);
|
|
4929
|
-
let { activeField: t, row: n } = e, r = $(["field", `${t.label}: ${
|
|
4942
|
+
let { activeField: t, row: n } = e, r = $(["field", `${t.label}: ${oi(t, n)}`]), i = (t.type === "fxCommand" || t.type === "fxValue") && n ? ci(e, t, n) : [...di(e, t), ...fi(e, t)], a = i.length > 0;
|
|
4930
4943
|
if (t.type === "fxCommand" && !t.isEmpty) {
|
|
4931
|
-
let e = a && /^(REP|RTO)$/i.test(t.rawValue) ? void 0 :
|
|
4944
|
+
let e = a && /^(REP|RTO)$/i.test(t.rawValue) ? void 0 : Qn(t.rawValue);
|
|
4932
4945
|
e && r.push({
|
|
4933
4946
|
kind: "fxInfo",
|
|
4934
|
-
text: `(${
|
|
4947
|
+
text: `(${li(e)})`
|
|
4935
4948
|
});
|
|
4936
4949
|
}
|
|
4937
4950
|
if (t.type === "fxValue" && n) {
|
|
4938
4951
|
let e = t.key.replace("val", "cmd"), i = n.fields[e];
|
|
4939
4952
|
if (i && !i.isEmpty) {
|
|
4940
|
-
let e = a && /^(REP|RTO)$/i.test(i.rawValue) ? void 0 :
|
|
4953
|
+
let e = a && /^(REP|RTO)$/i.test(i.rawValue) ? void 0 : Qn(i.rawValue), t = e ? `${i.rawValue} (${li(e)})` : i.rawValue;
|
|
4941
4954
|
r.push({
|
|
4942
4955
|
kind: "fxTarget",
|
|
4943
4956
|
text: `for ${t}`
|
|
@@ -4956,8 +4969,15 @@ function ni(e) {
|
|
|
4956
4969
|
}
|
|
4957
4970
|
return r;
|
|
4958
4971
|
}
|
|
4959
|
-
function
|
|
4960
|
-
|
|
4972
|
+
function oi(e, t) {
|
|
4973
|
+
if (e.type === "fxValue" && !e.isEmpty && e.hexValue != null && t) {
|
|
4974
|
+
let n = t.fields[e.key.replace("val", "cmd")];
|
|
4975
|
+
if (n && !n.isEmpty && G(n.rawValue)) return `${e.rawValue.toUpperCase()}h (dec ${nr(e.hexValue)})`;
|
|
4976
|
+
}
|
|
4977
|
+
return vi(e);
|
|
4978
|
+
}
|
|
4979
|
+
function si(e) {
|
|
4980
|
+
return ai(e).map((e) => e.text).join(" — ");
|
|
4961
4981
|
}
|
|
4962
4982
|
function $(...e) {
|
|
4963
4983
|
return e.flatMap(([e, t]) => t ? [{
|
|
@@ -4965,33 +4985,33 @@ function $(...e) {
|
|
|
4965
4985
|
text: t
|
|
4966
4986
|
}] : []);
|
|
4967
4987
|
}
|
|
4968
|
-
function
|
|
4988
|
+
function ci(e, t, n) {
|
|
4969
4989
|
let r = /^fx(\d)/.exec(t.key)?.[1];
|
|
4970
4990
|
if (!r) return [];
|
|
4971
4991
|
let i = n.fields[`fx${r}cmd`], a = n.fields[`fx${r}val`];
|
|
4972
4992
|
if (!i || i.isEmpty) {
|
|
4973
4993
|
if (e.fxLane?.event !== "continue") return [];
|
|
4974
|
-
let t = e.fxLane.source?.cmd, n = t &&
|
|
4975
|
-
return $(["fxLane",
|
|
4994
|
+
let t = e.fxLane.source?.cmd, n = t && G(t) ? Sr(e.relativeFx?.[t]) : null;
|
|
4995
|
+
return $(["fxLane", gr(e.fxLane)], ["relative", n]);
|
|
4976
4996
|
}
|
|
4977
|
-
let o = i.rawValue.toUpperCase(), s = e.fxLane && e.fxLane.event !== "none" && e.fxLane.event !== "set" ?
|
|
4997
|
+
let o = i.rawValue.toUpperCase(), s = e.fxLane && e.fxLane.event !== "none" && e.fxLane.event !== "set" ? gr(e.fxLane) : null;
|
|
4978
4998
|
if ((o === "REP" || o === "RTO") && e.viewName !== "table") {
|
|
4979
|
-
let t = e.fxLane?.source?.cmd, n = o === "REP" && e.fxLane?.active && t &&
|
|
4999
|
+
let t = e.fxLane?.source?.cmd, n = o === "REP" && e.fxLane?.active && t && G(t) ? Sr(e.relativeFx?.[t]) : null;
|
|
4980
5000
|
return $(["fxLane", s], ["relative", n]);
|
|
4981
5001
|
}
|
|
4982
5002
|
if (!a || a.isEmpty || a.hexValue == null) return $(["fxLane", s]);
|
|
4983
|
-
let c = t.type === "fxCommand" ? `value ${
|
|
5003
|
+
let c = t.type === "fxCommand" ? `value ${a.rawValue.toUpperCase()}: ` : "", l = pr(o, a.hexValue, {
|
|
4984
5004
|
note: n.fields.note?.isEmpty ? null : n.fields.note?.rawValue,
|
|
4985
5005
|
inTable: e.viewName === "table",
|
|
4986
5006
|
row: n.rowIndex
|
|
4987
5007
|
}), u = null;
|
|
4988
|
-
return
|
|
5008
|
+
return G(o) ? u = Sr(e.relativeFx?.[o]) : o === "RET" && e.resetsRelative && (u = Cr(e.resetsRelative)), $(["meaning", l ? `${c}${l}` : null], ["fxLane", s], ["relative", u]);
|
|
4989
5009
|
}
|
|
4990
|
-
function
|
|
5010
|
+
function li(e) {
|
|
4991
5011
|
let t = e.description.replace(/\.$/, "");
|
|
4992
|
-
return e.instrumentTypes ? `${t}; offered by ${e.instrumentTypes.map((e) =>
|
|
5012
|
+
return e.instrumentTypes ? `${t}; offered by ${e.instrumentTypes.map((e) => ui[e] ?? e).join(", ")} instruments` : t;
|
|
4993
5013
|
}
|
|
4994
|
-
var
|
|
5014
|
+
var ui = {
|
|
4995
5015
|
sampler: "Sampler",
|
|
4996
5016
|
macrosynth: "Macrosynth",
|
|
4997
5017
|
fmsynth: "FM Synth",
|
|
@@ -5000,17 +5020,17 @@ var oi = {
|
|
|
5000
5020
|
external: "External",
|
|
5001
5021
|
midiout: "MIDI Out"
|
|
5002
5022
|
};
|
|
5003
|
-
function
|
|
5004
|
-
return t.type !== "instrumentRef" || t.isEmpty || !e.resetsRelative ? [] : $(["relative",
|
|
5023
|
+
function di(e, t) {
|
|
5024
|
+
return t.type !== "instrumentRef" || t.isEmpty || !e.resetsRelative ? [] : $(["relative", Cr(e.resetsRelative)]);
|
|
5005
5025
|
}
|
|
5006
|
-
function
|
|
5026
|
+
function fi(e, t) {
|
|
5007
5027
|
return e.viewName !== "table" || t.key !== "volume" || t.isEmpty || t.hexValue == null || t.hexValue > 127 ? [] : $(["meaning", `plays at ${Math.round(t.hexValue / 127 * 100)}% of the step's velocity`]);
|
|
5008
5028
|
}
|
|
5009
|
-
var
|
|
5029
|
+
var pi = {
|
|
5010
5030
|
MODFX: "ModFX",
|
|
5011
5031
|
DELAY: "Delay",
|
|
5012
5032
|
REVERB: "Reverb"
|
|
5013
|
-
},
|
|
5033
|
+
}, mi = {
|
|
5014
5034
|
parent: "goes up to the parent directory",
|
|
5015
5035
|
directory: "directory: [EDIT] opens it",
|
|
5016
5036
|
instrumentPreset: "instrument preset: [EDIT] selects it",
|
|
@@ -5018,30 +5038,30 @@ var li = {
|
|
|
5018
5038
|
m8file: "M8 file: [EDIT] selects it",
|
|
5019
5039
|
file: "file: [EDIT] selects it"
|
|
5020
5040
|
};
|
|
5021
|
-
function
|
|
5041
|
+
function hi(e) {
|
|
5022
5042
|
let t = `${e.viewTitle ?? e.viewName}${e.viewId ? ` ${e.viewId}` : ""}`, n = e.activeField;
|
|
5023
5043
|
if (!n) return $(["location", t], ["line", e.lineText]);
|
|
5024
|
-
let r = e.instrumentType?.key ?
|
|
5025
|
-
return $(["field", `${n.label}: ${
|
|
5044
|
+
let r = e.instrumentType?.key ? Pn(e.instrumentType.key) : null;
|
|
5045
|
+
return $(["field", `${n.label}: ${vi(n)}`], ["optionInfo", n.valueDescription], ["fieldInfo", n.description], ["fileInfo", n.fileKind && mi[n.fileKind]], ["instrument", e.instrumentType && `${r?.name ?? e.instrumentType.text} instrument`], ["section", e.section && (pi[e.section] ?? e.section)], ["location", t]);
|
|
5026
5046
|
}
|
|
5027
|
-
function
|
|
5047
|
+
function gi(e) {
|
|
5028
5048
|
let t = `${e.viewTitle ?? e.viewName}${e.viewId ? ` ${e.viewId}` : ""}`, n = e.activeField, r = e.scaleNote;
|
|
5029
5049
|
if (!n || !r) return e.lineText ? $(["location", t], ["line", e.lineText]) : null;
|
|
5030
5050
|
let { interval: i, enabled: a, offset: o } = r, s;
|
|
5031
5051
|
if (n.key === "offset") {
|
|
5032
|
-
let e = o == null ? `detune of ${i}` : o === 0 ? `${i} is not detuned` : `${i} is detuned by ${
|
|
5052
|
+
let e = o == null ? `detune of ${i}` : o === 0 ? `${i} is not detuned` : `${i} is detuned by ${jr(o)}`;
|
|
5033
5053
|
s = $(["field", `${n.label}: ${n.rawValue || "(empty)"}`], ["meaning", e], ["meaning", a === !1 ? "(note is OFF)" : null]);
|
|
5034
5054
|
} else {
|
|
5035
5055
|
let e = a === !0 ? "is in" : a === !1 ? "is not in" : "is not yet set in";
|
|
5036
|
-
s = $(["field", `${n.label}: ${n.key === "en" ? n.rawValue.toUpperCase() || "(unset)" : i}`], ["meaning", i], ["meaning",
|
|
5056
|
+
s = $(["field", `${n.label}: ${n.key === "en" ? n.rawValue.toUpperCase() || "(unset)" : i}`], ["meaning", i], ["meaning", Dr(i)], ["meaning", `${e} the scale`]);
|
|
5037
5057
|
}
|
|
5038
5058
|
if (e.scale) {
|
|
5039
|
-
let [t, n] =
|
|
5059
|
+
let [t, n] = Ar(e.scale);
|
|
5040
5060
|
s.push(...$(["scale", `Scale: ${t}`], ["scale", n]));
|
|
5041
5061
|
}
|
|
5042
5062
|
return [...s, ...$(["location", `${t} row ${i}`])];
|
|
5043
5063
|
}
|
|
5044
|
-
function
|
|
5064
|
+
function _i(e) {
|
|
5045
5065
|
let t = e.unit ?? "";
|
|
5046
5066
|
if (e.values && e.parts) {
|
|
5047
5067
|
let n = e.hexValue != null, r = e.values.map((e) => n ? e.toString(16).toUpperCase().padStart(2, "0") : String(e)), i = e.parts.map((e, n) => `${e} ${r[n] ?? "?"}${t}`).join(", ");
|
|
@@ -5049,7 +5069,7 @@ function pi(e) {
|
|
|
5049
5069
|
}
|
|
5050
5070
|
return e.hexValue == null ? e.numericValue == null ? e.text ?? e.rawValue : `${e.rawValue}${t}` : `${e.rawValue.slice(0, 2)}h (dec ${e.hexValue})${e.text ? ` ${e.text}` : ""}`;
|
|
5051
5071
|
}
|
|
5052
|
-
function
|
|
5072
|
+
function vi(e) {
|
|
5053
5073
|
if (e.isEmpty) return "(empty)";
|
|
5054
5074
|
let t = e.type === "name" || e.type === "fileEntry" ? e : {
|
|
5055
5075
|
...e,
|
|
@@ -5076,26 +5096,26 @@ function mi(e) {
|
|
|
5076
5096
|
case "fileEntry": return t.text ?? t.rawValue;
|
|
5077
5097
|
case "name": return `"${t.rawValue}"`;
|
|
5078
5098
|
case "option": return t.hexValue != null && t.text ? `${t.rawValue.slice(0, 2)} ${t.text}` : t.text ?? t.rawValue;
|
|
5079
|
-
case "parameter": return
|
|
5080
|
-
case "noteInterval": return `Interval ${
|
|
5099
|
+
case "parameter": return _i(t);
|
|
5100
|
+
case "noteInterval": return `Interval ${Er(t.rawValue) ?? t.rawValue}`;
|
|
5081
5101
|
case "semitoneOffset": return t.isEmpty ? "(empty)" : `${t.rawValue} st`;
|
|
5082
5102
|
default: return t.rawValue;
|
|
5083
5103
|
}
|
|
5084
5104
|
}
|
|
5085
5105
|
//#endregion
|
|
5086
5106
|
//#region src/client.ts
|
|
5087
|
-
var
|
|
5107
|
+
var yi = "yam8d-external-app", bi = 3e3, xi = (e) => {
|
|
5088
5108
|
let t = e.remoteHandle();
|
|
5089
5109
|
return {
|
|
5090
5110
|
call: (e, ...n) => t.call(e, ...n),
|
|
5091
5111
|
on: (e, n) => (t.addEventListener(e, n), () => t.removeEventListener(e, n)),
|
|
5092
5112
|
close: () => e.close()
|
|
5093
5113
|
};
|
|
5094
|
-
},
|
|
5114
|
+
}, Si = (e) => ({
|
|
5095
5115
|
call: (t, ...n) => e.methods[t](...n),
|
|
5096
5116
|
on: (t, n) => e.on(t, n),
|
|
5097
5117
|
close: () => e.dispose()
|
|
5098
|
-
}),
|
|
5118
|
+
}), Ci = (e) => {
|
|
5099
5119
|
let t = [];
|
|
5100
5120
|
return {
|
|
5101
5121
|
messenger: {
|
|
@@ -5109,21 +5129,21 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5109
5129
|
for (let e of t.splice(0)) e();
|
|
5110
5130
|
}
|
|
5111
5131
|
};
|
|
5112
|
-
},
|
|
5132
|
+
}, wi = () => {
|
|
5113
5133
|
if (typeof window > "u") return !1;
|
|
5114
5134
|
try {
|
|
5115
5135
|
return window.parent !== window;
|
|
5116
5136
|
} catch {
|
|
5117
5137
|
return !0;
|
|
5118
5138
|
}
|
|
5119
|
-
},
|
|
5139
|
+
}, Ti = (e) => e instanceof DOMException && (e.name === "NotFoundError" || e.name === "AbortError"), Ei = () => {
|
|
5120
5140
|
let e = typeof navigator > "u" ? null : navigator;
|
|
5121
5141
|
return {
|
|
5122
5142
|
serial: !!e && "serial" in e,
|
|
5123
5143
|
usb: !!e && "usb" in e,
|
|
5124
5144
|
midi: !!e && "requestMIDIAccess" in e
|
|
5125
5145
|
};
|
|
5126
|
-
},
|
|
5146
|
+
}, Di = () => ({
|
|
5127
5147
|
viewName: null,
|
|
5128
5148
|
viewTitle: null,
|
|
5129
5149
|
minimapKey: null,
|
|
@@ -5140,9 +5160,9 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5140
5160
|
fontMode: null,
|
|
5141
5161
|
systemInfo: null,
|
|
5142
5162
|
macroRunning: !1
|
|
5143
|
-
}),
|
|
5163
|
+
}), Oi = class {
|
|
5144
5164
|
constructor(e = {}) {
|
|
5145
|
-
this.backend = null, this.backendUnsubscribers = [], this.device = null, this._mode = null, this.audio = null, this.connecting = null, this.stateCallbacks = /* @__PURE__ */ new Set(), this.viewCallbacks = /* @__PURE__ */ new Set(), this.cursorCallbacks = /* @__PURE__ */ new Set(), this.textCallbacks = /* @__PURE__ */ new Set(), this.keyCallbacks = /* @__PURE__ */ new Set(), this.transportCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this._state =
|
|
5165
|
+
this.backend = null, this.backendUnsubscribers = [], this.device = null, this._mode = null, this.audio = null, this.connecting = null, this.stateCallbacks = /* @__PURE__ */ new Set(), this.viewCallbacks = /* @__PURE__ */ new Set(), this.cursorCallbacks = /* @__PURE__ */ new Set(), this.textCallbacks = /* @__PURE__ */ new Set(), this.keyCallbacks = /* @__PURE__ */ new Set(), this.transportCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this._state = Di(), this._screen = null, this.screenRefreshing = !1, this.screenDirty = !1, this.config = e;
|
|
5146
5166
|
}
|
|
5147
5167
|
get state() {
|
|
5148
5168
|
return this._state;
|
|
@@ -5164,11 +5184,11 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5164
5184
|
}
|
|
5165
5185
|
async resolveMode() {
|
|
5166
5186
|
let e = this.config.mode ?? "auto";
|
|
5167
|
-
if (e === "standalone" || e === "auto" && !
|
|
5187
|
+
if (e === "standalone" || e === "auto" && !wi()) {
|
|
5168
5188
|
await this.startStandalone();
|
|
5169
5189
|
return;
|
|
5170
5190
|
}
|
|
5171
|
-
let t = typeof window < "u" && window.name === "yam8d-external-app", n = e === "host" || t ? null : this.config.handshakeTimeoutMs ??
|
|
5191
|
+
let t = typeof window < "u" && window.name === "yam8d-external-app", n = e === "host" || t ? null : this.config.handshakeTimeoutMs ?? bi;
|
|
5172
5192
|
await this.handshake(n) || (this.config.debug && console.log("[M8 SDK] No yam8d host answered, switching to standalone mode"), await this.startStandalone());
|
|
5173
5193
|
}
|
|
5174
5194
|
async handshake(r) {
|
|
@@ -5180,10 +5200,10 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5180
5200
|
this.config.debug && (i = t(i, (e, ...t) => {
|
|
5181
5201
|
console.log("[M8 SDK]", e, ...t);
|
|
5182
5202
|
}));
|
|
5183
|
-
let a =
|
|
5203
|
+
let a = Ci(i), o = e(a.messenger, { ping: async () => "pong" }), s, c = new Promise((e) => {
|
|
5184
5204
|
r !== null && (s = setTimeout(() => e(null), r));
|
|
5185
5205
|
}), l = await Promise.race([o, c]);
|
|
5186
|
-
return clearTimeout(s), l ? (this._mode = "host", await this.attach(
|
|
5206
|
+
return clearTimeout(s), l ? (this._mode = "host", await this.attach(xi(l)), l.localHandle().emit("ready", void 0), !0) : (a.dispose(), !1);
|
|
5187
5207
|
}
|
|
5188
5208
|
async startStandalone() {
|
|
5189
5209
|
if (this._mode = "standalone", this.config.autoConnect !== !1) try {
|
|
@@ -5193,7 +5213,7 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5193
5213
|
}
|
|
5194
5214
|
}
|
|
5195
5215
|
async openDevice(e, t) {
|
|
5196
|
-
let n =
|
|
5216
|
+
let n = k();
|
|
5197
5217
|
if (!n.browserSupport) throw Error("This browser has no Web Serial, WebUSB or Web MIDI: the M8 cannot be reached from this page");
|
|
5198
5218
|
let r = e === "auto" && !t ? [
|
|
5199
5219
|
"serial",
|
|
@@ -5209,14 +5229,14 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5209
5229
|
});
|
|
5210
5230
|
break;
|
|
5211
5231
|
} catch (r) {
|
|
5212
|
-
if (a = r, t && !
|
|
5232
|
+
if (a = r, t && !Ti(r) && (i = await te(() => n.connect({
|
|
5213
5233
|
transport: e,
|
|
5214
5234
|
prompt: !1
|
|
5215
5235
|
}), { maxAttempts: 2 }), i)) break;
|
|
5216
5236
|
}
|
|
5217
5237
|
if (!i) throw a;
|
|
5218
|
-
let o =
|
|
5219
|
-
this.device = i, await this.attach(
|
|
5238
|
+
let o = Sn(i, { debug: this.config.debug });
|
|
5239
|
+
this.device = i, await this.attach(Si(o)), i.commands.resetScreen();
|
|
5220
5240
|
let s = i;
|
|
5221
5241
|
i.closed.then(() => {
|
|
5222
5242
|
this.device === s && (this.config.debug && console.log("[M8 SDK] Device connection ended"), this.device = null, this.detach());
|
|
@@ -5297,7 +5317,7 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5297
5317
|
await this.disconnectAudio(), await this.closeDevice();
|
|
5298
5318
|
}
|
|
5299
5319
|
async connectAudio() {
|
|
5300
|
-
await this.connect(), this._mode !== "host" && (this.audio ??=
|
|
5320
|
+
await this.connect(), this._mode !== "host" && (this.audio ??= P(), await this.audio.connect({ requireM8: !0 }));
|
|
5301
5321
|
}
|
|
5302
5322
|
async disconnectAudio() {
|
|
5303
5323
|
await this.audio?.disconnect();
|
|
@@ -5366,7 +5386,7 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5366
5386
|
}, e;
|
|
5367
5387
|
}
|
|
5368
5388
|
async captureSnapshot() {
|
|
5369
|
-
let [e, t] = await Promise.all([this.fetchState(), this.getScreen()]), n =
|
|
5389
|
+
let [e, t] = await Promise.all([this.fetchState(), this.getScreen()]), n = ii(e, t);
|
|
5370
5390
|
return {
|
|
5371
5391
|
capturedAt: Date.now(),
|
|
5372
5392
|
state: {
|
|
@@ -5379,8 +5399,8 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5379
5399
|
deviceModel: e.deviceModel
|
|
5380
5400
|
},
|
|
5381
5401
|
semantic: n,
|
|
5382
|
-
description: n ?
|
|
5383
|
-
descriptionParts: n ?
|
|
5402
|
+
description: n ? si(n) : null,
|
|
5403
|
+
descriptionParts: n ? ai(n) : null,
|
|
5384
5404
|
screen: t
|
|
5385
5405
|
};
|
|
5386
5406
|
}
|
|
@@ -5409,23 +5429,23 @@ var hi = "yam8d-external-app", gi = 3e3, _i = (e) => {
|
|
|
5409
5429
|
this.audio?.disconnect(), this.closeDevice(), this.detach(), this.stateCallbacks.clear(), this.viewCallbacks.clear(), this.cursorCallbacks.clear(), this.textCallbacks.clear(), this.keyCallbacks.clear(), this.transportCallbacks.clear(), this.connectionCallbacks.clear();
|
|
5410
5430
|
}
|
|
5411
5431
|
getSemanticContext() {
|
|
5412
|
-
return
|
|
5432
|
+
return ii(this._state, this._screen);
|
|
5413
5433
|
}
|
|
5414
5434
|
describeContext() {
|
|
5415
|
-
let e =
|
|
5416
|
-
return e ?
|
|
5435
|
+
let e = ii(this._state, this._screen);
|
|
5436
|
+
return e ? si(e) : null;
|
|
5417
5437
|
}
|
|
5418
5438
|
describeContextParts() {
|
|
5419
|
-
let e =
|
|
5420
|
-
return e ?
|
|
5439
|
+
let e = ii(this._state, this._screen);
|
|
5440
|
+
return e ? ai(e) : null;
|
|
5421
5441
|
}
|
|
5422
5442
|
};
|
|
5423
|
-
async function
|
|
5424
|
-
let t = new
|
|
5443
|
+
async function ki(e = {}) {
|
|
5444
|
+
let t = new Oi(e);
|
|
5425
5445
|
return await t.connect(), t;
|
|
5426
5446
|
}
|
|
5427
|
-
function
|
|
5428
|
-
let t = new
|
|
5447
|
+
function Ai(e = {}) {
|
|
5448
|
+
let t = new Oi(e);
|
|
5429
5449
|
return {
|
|
5430
5450
|
client: t,
|
|
5431
5451
|
connect: async () => {
|
|
@@ -5433,10 +5453,10 @@ function Ei(e = {}) {
|
|
|
5433
5453
|
}
|
|
5434
5454
|
};
|
|
5435
5455
|
}
|
|
5436
|
-
var
|
|
5437
|
-
createM8Client:
|
|
5438
|
-
createM8ClientSync:
|
|
5439
|
-
},
|
|
5456
|
+
var ji = {
|
|
5457
|
+
createM8Client: ki,
|
|
5458
|
+
createM8ClientSync: Ai
|
|
5459
|
+
}, Mi = [
|
|
5440
5460
|
{
|
|
5441
5461
|
role: "background",
|
|
5442
5462
|
label: "BACKGROUND"
|
|
@@ -5489,7 +5509,7 @@ var Di = {
|
|
|
5489
5509
|
role: "meterPeak",
|
|
5490
5510
|
label: "METER PEAK"
|
|
5491
5511
|
}
|
|
5492
|
-
],
|
|
5512
|
+
], Ni = "themesettings", Pi = (e) => e.replace(/\s+/g, "").toUpperCase(), Fi = (e) => Math.max(0, Math.min(255, Math.round(e))).toString(16).padStart(2, "0"), Ii = (e, t, n) => `#${Fi(e)}${Fi(t)}${Fi(n)}`, Li = (e, t, n) => {
|
|
5493
5513
|
let r = e / 256 * 6, i = t / 255, a = n / 255, o = Math.floor(r) % 6, s = r - Math.floor(r), c = a * (1 - i), l = a * (1 - s * i), u = a * (1 - (1 - s) * i), [d, f, p] = [
|
|
5494
5514
|
[
|
|
5495
5515
|
a,
|
|
@@ -5522,14 +5542,14 @@ var Di = {
|
|
|
5522
5542
|
l
|
|
5523
5543
|
]
|
|
5524
5544
|
][o];
|
|
5525
|
-
return
|
|
5526
|
-
},
|
|
5527
|
-
function
|
|
5545
|
+
return Ii(d * 255, f * 255, p * 255);
|
|
5546
|
+
}, Ri = new Map(Mi.map(({ role: e, label: t }) => [Pi(t), e]));
|
|
5547
|
+
function zi(e) {
|
|
5528
5548
|
let t = "rgb", n = null, r = {};
|
|
5529
5549
|
for (let i of e.lines) {
|
|
5530
5550
|
let e = i.replace(/[{}]/g, "0"), a = /^\s*MODE\s+([A-Z])\s+([A-Z])\s+([A-Z])\b/i.exec(e);
|
|
5531
5551
|
if (a) {
|
|
5532
|
-
t =
|
|
5552
|
+
t = Pi(a.slice(1).join("")) === "HSV" ? "hsv" : "rgb";
|
|
5533
5553
|
continue;
|
|
5534
5554
|
}
|
|
5535
5555
|
let o = /^\s*THEME\s+NAME\s+(\S.*?)\s*$/i.exec(e);
|
|
@@ -5540,23 +5560,23 @@ function Fi(e) {
|
|
|
5540
5560
|
}
|
|
5541
5561
|
let s = /^\s*([A-Z][A-Z:/. ]*?)\s+([0-9A-F]{2})\s+([0-9A-F]{2})\s+([0-9A-F]{2})(?:\s|$)/i.exec(e);
|
|
5542
5562
|
if (!s) continue;
|
|
5543
|
-
let c =
|
|
5563
|
+
let c = Ri.get(Pi(s[1]));
|
|
5544
5564
|
if (!c || r[c]) continue;
|
|
5545
5565
|
let [l, u, d] = s.slice(2, 5).map((e) => parseInt(e, 16));
|
|
5546
|
-
r[c] = t === "hsv" ?
|
|
5566
|
+
r[c] = t === "hsv" ? Li(l, u, d) : Ii(l, u, d);
|
|
5547
5567
|
}
|
|
5548
|
-
return
|
|
5568
|
+
return Mi.some(({ role: e }) => !r[e]) ? null : {
|
|
5549
5569
|
colors: r,
|
|
5550
5570
|
mode: t,
|
|
5551
5571
|
name: n
|
|
5552
5572
|
};
|
|
5553
5573
|
}
|
|
5554
|
-
var
|
|
5555
|
-
function
|
|
5556
|
-
let t = {}, n =
|
|
5574
|
+
var Bi = (e) => e ? Ii(e.r, e.g, e.b) : void 0;
|
|
5575
|
+
function Vi(e) {
|
|
5576
|
+
let t = {}, n = Bi(e.backgroundColor), r = Bi(e.titleColor);
|
|
5557
5577
|
return n && (t.background = n), r && (t.textTitles = r), t;
|
|
5558
5578
|
}
|
|
5559
5579
|
//#endregion
|
|
5560
|
-
export {
|
|
5580
|
+
export { L as M8KeyMask, A as M8_AUDIO_CAPTURE_CONSTRAINTS, Mi as M8_THEME_ROLES, Ni as M8_THEME_VIEW, er as RELATIVE_FX_RULE, Gr as SCREEN_MARGIN, yi as YAM8D_FRAME_NAME, P as createM8Audio, ki as createM8Client, Ai as createM8ClientSync, k as createM8Connection, Sn as createM8Engine, ji as default, si as describeContext, ai as describeContextParts, vi as formatFieldValue, Ei as getDeviceSupport, $n as getInstrumentFxCommands, N as getM8InputStream, ii as getSemanticContext, Qn as lookupFxCommand, Vi as observeThemeColors, Xr as parseGridScreen, zi as parseThemeScreen, Ir as parseViewTitle, Be as pressKeys, Qr as readPlayPositions };
|
|
5561
5581
|
|
|
5562
5582
|
//# sourceMappingURL=index.js.map
|