@hfd-sdk/keyboard-kit 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-lighting/index.d.ts +1 -1
- package/dist/ai-lighting/index.es.js +510 -568
- package/dist/assert-hfd-device.js +65 -0
- package/dist/music-v2/engine.d.ts +8 -0
- package/dist/music-v2/index.d.ts +12 -0
- package/dist/music-v2/index.es.js +1742 -0
- package/dist/music-v2/key-positions.d.ts +39 -0
- package/dist/music-v2/plugin-client.d.ts +16 -0
- package/dist/music-v2/system-audio.d.ts +18 -0
- package/dist/music-v2/types.d.ts +138 -0
- package/dist/music-v2/visualizers.d.ts +82 -0
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime-core.es.js +530 -528
- package/dist/runtime.es.js +18 -16
- package/dist/shared/color.d.ts +5 -0
- package/dist/shared/composables/useKeySampler.d.ts +2 -2
- package/dist/shared/hardware/build-music-data.d.ts +4 -4
- package/dist/shared/keyboard-config.d.ts +474 -0
- package/dist/shared/types.d.ts +3 -17
- package/package.json +62 -58
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as Y, o as xe, w as ae, t as D, r as M, e as be, f as _e, g as ee, h as te, i as j, j as ge, n as se, u as $, F as ve, k as fe, l as Ce, m as oe, s as ke, c as Ee, p as Me, q as He, v as he, x as Ve, y as Ne, z as Pe } from "../runtime-core.es.js";
|
|
2
2
|
import { serializePreset as Ke } from "../runtime.es.js";
|
|
3
|
-
import { deserializePreset as
|
|
4
|
-
|
|
3
|
+
import { deserializePreset as Mt } from "../runtime.es.js";
|
|
4
|
+
import { c as qe, g as Be, b as Fe, a as De } from "../assert-hfd-device.js";
|
|
5
|
+
const me = 40, We = 0.1, Oe = 3;
|
|
5
6
|
function J(e) {
|
|
6
7
|
return Math.round(e * 100) / 100;
|
|
7
8
|
}
|
|
@@ -14,346 +15,303 @@ function ye(e) {
|
|
|
14
15
|
rotation: J(e.rotation)
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
+
const $e = {
|
|
18
19
|
"scale-se": { x: 1, y: 1 },
|
|
19
20
|
"scale-sw": { x: -1, y: 1 },
|
|
20
21
|
"scale-ne": { x: 1, y: -1 },
|
|
21
22
|
"scale-nw": { x: -1, y: -1 }
|
|
22
|
-
},
|
|
23
|
+
}, je = {
|
|
23
24
|
"resize-e": { x: -1, y: 0 },
|
|
24
25
|
"resize-w": { x: 1, y: 0 },
|
|
25
26
|
"resize-n": { x: 0, y: 1 },
|
|
26
27
|
"resize-s": { x: 0, y: -1 }
|
|
27
|
-
},
|
|
28
|
+
}, Ge = {
|
|
28
29
|
"scale-se": { x: -1, y: -1 },
|
|
29
30
|
"scale-sw": { x: 1, y: -1 },
|
|
30
31
|
"scale-ne": { x: -1, y: 1 },
|
|
31
32
|
"scale-nw": { x: 1, y: 1 }
|
|
32
33
|
};
|
|
33
|
-
function
|
|
34
|
-
const t =
|
|
34
|
+
function Ue(e) {
|
|
35
|
+
const t = M({ x: 0, y: 0 }), a = M(1), i = M(1), s = M(0), d = M(!0), P = M(1), u = M({ width: 0, height: 0 }), y = Y(() => d.value ? a.value : i.value), k = Y(() => ({
|
|
35
36
|
left: `${t.value.x}px`,
|
|
36
37
|
top: `${t.value.y}px`,
|
|
37
|
-
transform: `translate(-50%, -50%) scale(${a.value}, ${
|
|
38
|
+
transform: `translate(-50%, -50%) scale(${a.value}, ${y.value}) rotate(${s.value}deg)`,
|
|
38
39
|
transformOrigin: "center center"
|
|
39
40
|
}));
|
|
40
|
-
let
|
|
41
|
-
function
|
|
41
|
+
let g = null;
|
|
42
|
+
function p() {
|
|
42
43
|
return {
|
|
43
|
-
width:
|
|
44
|
-
height:
|
|
44
|
+
width: D(e.canvasWidth),
|
|
45
|
+
height: D(e.canvasHeight)
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
const { width:
|
|
49
|
-
return !
|
|
48
|
+
function b(n, r) {
|
|
49
|
+
const { width: o, height: c } = p();
|
|
50
|
+
return !n || !r ? 1 : Math.min((o - me * 2) / n, (c - me * 2) / r, 1);
|
|
50
51
|
}
|
|
51
|
-
function x(
|
|
52
|
-
return Math.min(
|
|
52
|
+
function x(n) {
|
|
53
|
+
return Math.min(Oe, Math.max(We, n));
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
-
const { width:
|
|
55
|
+
function w(n, r) {
|
|
56
|
+
const { width: o, height: c } = p(), v = u.value.width * a.value / 2, f = u.value.height * y.value / 2;
|
|
56
57
|
return {
|
|
57
|
-
x: Math.max(
|
|
58
|
-
y: Math.max(
|
|
58
|
+
x: Math.max(v, Math.min(o - v, n)),
|
|
59
|
+
y: Math.max(f, Math.min(c - f, r))
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function L() {
|
|
62
63
|
return ye({
|
|
63
64
|
x: t.value.x,
|
|
64
65
|
y: t.value.y,
|
|
65
|
-
width:
|
|
66
|
-
height:
|
|
67
|
-
rotation:
|
|
66
|
+
width: u.value.width * a.value,
|
|
67
|
+
height: u.value.height * y.value,
|
|
68
|
+
rotation: s.value
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
function A(
|
|
71
|
-
if (!
|
|
72
|
-
const
|
|
73
|
-
a.value =
|
|
74
|
-
}
|
|
75
|
-
function
|
|
76
|
-
var
|
|
77
|
-
(
|
|
78
|
-
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
async function K(
|
|
83
|
-
if (!
|
|
84
|
-
if (
|
|
85
|
-
width:
|
|
86
|
-
height:
|
|
87
|
-
}, !
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
A(
|
|
71
|
+
function A(n) {
|
|
72
|
+
if (!u.value.width || !u.value.height) return;
|
|
73
|
+
const r = ye(n), o = x(r.width / u.value.width), c = x(r.height / u.value.height);
|
|
74
|
+
a.value = o, i.value = c, d.value = Math.abs(o - c) < 1e-3, s.value = r.rotation, t.value = w(r.x, r.y);
|
|
75
|
+
}
|
|
76
|
+
function _() {
|
|
77
|
+
var n;
|
|
78
|
+
(n = D(e.onLayoutChange)) == null || n(L());
|
|
79
|
+
}
|
|
80
|
+
function C() {
|
|
81
|
+
_();
|
|
82
|
+
}
|
|
83
|
+
async function K(n, r = !1) {
|
|
84
|
+
if (!n) return;
|
|
85
|
+
if (u.value = {
|
|
86
|
+
width: n.offsetWidth,
|
|
87
|
+
height: n.offsetHeight
|
|
88
|
+
}, !r) {
|
|
89
|
+
const f = D(e.initialLayout);
|
|
90
|
+
if (f) {
|
|
91
|
+
A(f);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const { width:
|
|
97
|
-
t.value = { x:
|
|
95
|
+
const o = b(u.value.width, u.value.height);
|
|
96
|
+
P.value = o, a.value = o, i.value = o, s.value = 0, d.value = !0;
|
|
97
|
+
const { width: c, height: v } = p();
|
|
98
|
+
t.value = { x: c / 2, y: v / 2 };
|
|
98
99
|
}
|
|
99
|
-
async function
|
|
100
|
-
await K(
|
|
100
|
+
async function q(n) {
|
|
101
|
+
await K(n, !0), _();
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
103
|
+
function h() {
|
|
104
|
+
d.value = !d.value, d.value && (i.value = a.value);
|
|
104
105
|
}
|
|
105
|
-
function
|
|
106
|
-
const
|
|
106
|
+
function z(n, r, o, c) {
|
|
107
|
+
const v = -s.value * Math.PI / 180, f = n - o, E = r - c;
|
|
107
108
|
return {
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
109
|
+
x: f * Math.cos(v) - E * Math.sin(v),
|
|
110
|
+
y: f * Math.sin(v) + E * Math.cos(v)
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
|
-
function V(
|
|
113
|
-
var
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
116
|
-
const
|
|
117
|
-
return { x:
|
|
113
|
+
function V(n, r) {
|
|
114
|
+
var v;
|
|
115
|
+
const o = (v = e.getOverlayEl) == null ? void 0 : v.call(e);
|
|
116
|
+
if (!o) return { x: n, y: r };
|
|
117
|
+
const c = o.getBoundingClientRect();
|
|
118
|
+
return { x: n - c.left, y: r - c.top };
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
return Math.atan2(
|
|
120
|
+
function F(n, r, o, c) {
|
|
121
|
+
return Math.atan2(r - c, n - o) * 180 / Math.PI;
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
123
|
+
function m(n, r, o, c, v) {
|
|
124
|
+
const f = v * Math.PI / 180;
|
|
124
125
|
return {
|
|
125
|
-
x:
|
|
126
|
-
y:
|
|
126
|
+
x: n + o * Math.cos(f) - c * Math.sin(f),
|
|
127
|
+
y: r + o * Math.sin(f) + c * Math.cos(f)
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
function W(n, r, o, c, v) {
|
|
131
|
+
const f = [
|
|
132
|
+
m(n, r, -o, -c, v),
|
|
133
|
+
m(n, r, o, -c, v),
|
|
134
|
+
m(n, r, -o, c, v),
|
|
135
|
+
m(n, r, o, c, v)
|
|
135
136
|
];
|
|
136
137
|
return {
|
|
137
|
-
minX: Math.min(...
|
|
138
|
-
minY: Math.min(...
|
|
139
|
-
maxX: Math.max(...
|
|
140
|
-
maxY: Math.max(...
|
|
138
|
+
minX: Math.min(...f.map((E) => E.x)),
|
|
139
|
+
minY: Math.min(...f.map((E) => E.y)),
|
|
140
|
+
maxX: Math.max(...f.map((E) => E.x)),
|
|
141
|
+
maxY: Math.max(...f.map((E) => E.y))
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
function le(r,
|
|
148
|
-
if (
|
|
149
|
-
return { scale:
|
|
150
|
-
if (!
|
|
151
|
-
return { scale:
|
|
152
|
-
let T = 0,
|
|
153
|
-
for (let
|
|
154
|
-
const N = (T +
|
|
155
|
-
|
|
144
|
+
function G(n, r, o, c, v, f, E) {
|
|
145
|
+
const I = f * o / 2, H = E * c / 2, T = m(n.x, n.y, -r.x * I, -r.y * H, v), S = W(T.x, T.y, I, H, v), { width: B, height: N } = p();
|
|
146
|
+
return S.minX >= 0 && S.minY >= 0 && S.maxX <= B && S.maxY <= N;
|
|
147
|
+
}
|
|
148
|
+
function le(n, r, o, c, v, f, E, I, H) {
|
|
149
|
+
if (G(n, r, v, f, E, I, H))
|
|
150
|
+
return { scale: v, scaleY: f };
|
|
151
|
+
if (!G(n, r, o, c, E, I, H))
|
|
152
|
+
return { scale: o, scaleY: c };
|
|
153
|
+
let T = 0, S = 1;
|
|
154
|
+
for (let B = 0; B < 20; B++) {
|
|
155
|
+
const N = (T + S) / 2, U = o + N * (v - o), Z = c + N * (f - c);
|
|
156
|
+
G(n, r, U, Z, E, I, H) ? T = N : S = N;
|
|
156
157
|
}
|
|
157
158
|
return {
|
|
158
|
-
scale:
|
|
159
|
-
scaleY:
|
|
159
|
+
scale: o + T * (v - o),
|
|
160
|
+
scaleY: c + T * (f - c)
|
|
160
161
|
};
|
|
161
162
|
}
|
|
162
|
-
function ne(r,
|
|
163
|
-
const
|
|
163
|
+
function ne(n, r, o, c, v, f, E, I) {
|
|
164
|
+
const H = u.value.width || 1, T = u.value.height || 1, S = H * f / 2, B = T * E / 2, N = m(
|
|
165
|
+
c,
|
|
164
166
|
v,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
), G = le(
|
|
167
|
+
n.x * S,
|
|
168
|
+
n.y * B,
|
|
169
|
+
I
|
|
170
|
+
), U = le(
|
|
170
171
|
N,
|
|
172
|
+
n,
|
|
173
|
+
f,
|
|
174
|
+
E,
|
|
171
175
|
r,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
l,
|
|
176
|
-
R,
|
|
177
|
-
_,
|
|
176
|
+
o,
|
|
177
|
+
I,
|
|
178
|
+
H,
|
|
178
179
|
T
|
|
179
|
-
), Z =
|
|
180
|
+
), Z = H * U.scale / 2, Ie = T * U.scaleY / 2, Ae = m(
|
|
180
181
|
N.x,
|
|
181
182
|
N.y,
|
|
182
|
-
-
|
|
183
|
-
-
|
|
184
|
-
|
|
183
|
+
-n.x * Z,
|
|
184
|
+
-n.y * Ie,
|
|
185
|
+
I
|
|
185
186
|
);
|
|
186
|
-
a.value =
|
|
187
|
-
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
190
|
-
let
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
|
|
187
|
+
a.value = U.scale, i.value = U.scaleY, t.value = Ae;
|
|
188
|
+
}
|
|
189
|
+
function ue(n, r, o, c, v, f, E) {
|
|
190
|
+
const I = $e[n], H = Ge[n], T = u.value.width || 1, S = u.value.height || 1;
|
|
191
|
+
let B, N;
|
|
192
|
+
if (d.value) {
|
|
193
|
+
const U = Math.max(T, S), Z = (r.x * I.x + r.y * I.y) / 2;
|
|
194
|
+
B = x(v + Z / U), N = B;
|
|
194
195
|
} else
|
|
195
|
-
|
|
196
|
-
ne(
|
|
197
|
-
}
|
|
198
|
-
function
|
|
199
|
-
const
|
|
200
|
-
let T =
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
B = x(v + r.x * I.x / T), N = x(f + r.y * I.y / S);
|
|
197
|
+
ne(H, B, N, o, c, v, f, E);
|
|
198
|
+
}
|
|
199
|
+
function ce(n, r, o, c, v, f, E) {
|
|
200
|
+
const I = u.value.width || 1, H = u.value.height || 1;
|
|
201
|
+
let T = v, S = f;
|
|
202
|
+
n === "resize-e" ? (T = x(v + r.x / I), d.value && (S = T)) : n === "resize-w" ? (T = x(v - r.x / I), d.value && (S = T)) : n === "resize-s" ? (S = x(f + r.y / H), d.value && (T = S)) : n === "resize-n" && (S = x(f - r.y / H), d.value && (T = S)), ne(
|
|
203
|
+
je[n],
|
|
203
204
|
T,
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
S,
|
|
206
|
+
o,
|
|
207
|
+
c,
|
|
206
208
|
v,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
P
|
|
209
|
+
f,
|
|
210
|
+
E
|
|
210
211
|
);
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
mode:
|
|
217
|
-
startLocalX:
|
|
218
|
-
startLocalY:
|
|
213
|
+
function X(n, r) {
|
|
214
|
+
r.preventDefault(), r.stopPropagation();
|
|
215
|
+
const o = V(r.clientX, r.clientY), c = F(o.x, o.y, t.value.x, t.value.y);
|
|
216
|
+
g = {
|
|
217
|
+
mode: n,
|
|
218
|
+
startLocalX: o.x,
|
|
219
|
+
startLocalY: o.y,
|
|
219
220
|
startPosX: t.value.x,
|
|
220
221
|
startPosY: t.value.y,
|
|
221
222
|
startScale: a.value,
|
|
222
|
-
startScaleY:
|
|
223
|
-
startRotation:
|
|
224
|
-
startAngle:
|
|
223
|
+
startScaleY: i.value,
|
|
224
|
+
startRotation: s.value,
|
|
225
|
+
startAngle: c
|
|
225
226
|
}, window.addEventListener("mousemove", re), window.addEventListener("mouseup", Q);
|
|
226
227
|
}
|
|
227
|
-
function re(
|
|
228
|
-
if (!
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
t.value =
|
|
228
|
+
function re(n) {
|
|
229
|
+
if (!g) return;
|
|
230
|
+
const r = V(n.clientX, n.clientY), { mode: o, startLocalX: c, startLocalY: v, startPosX: f, startPosY: E, startScale: I, startScaleY: H, startRotation: T, startAngle: S } = g;
|
|
231
|
+
if (o === "drag") {
|
|
232
|
+
t.value = w(f + (r.x - c), E + (r.y - v));
|
|
232
233
|
return;
|
|
233
234
|
}
|
|
234
|
-
if (
|
|
235
|
-
const N =
|
|
236
|
-
|
|
235
|
+
if (o.startsWith("rotate-")) {
|
|
236
|
+
const N = F(r.x, r.y, t.value.x, t.value.y);
|
|
237
|
+
s.value = T + (N - S);
|
|
237
238
|
return;
|
|
238
239
|
}
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
240
|
+
const B = z(r.x, r.y, c, v);
|
|
241
|
+
if (o.startsWith("scale-")) {
|
|
242
|
+
ue(
|
|
243
|
+
o,
|
|
244
|
+
B,
|
|
245
|
+
f,
|
|
246
|
+
E,
|
|
247
|
+
I,
|
|
248
|
+
H,
|
|
248
249
|
T
|
|
249
250
|
);
|
|
250
251
|
return;
|
|
251
252
|
}
|
|
252
|
-
(
|
|
253
|
+
(o === "resize-e" || o === "resize-w" || o === "resize-n" || o === "resize-s") && ce(o, B, f, E, I, H, T);
|
|
253
254
|
}
|
|
254
255
|
function Q() {
|
|
255
|
-
|
|
256
|
+
g && C(), g = null, window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", Q);
|
|
256
257
|
}
|
|
257
|
-
function de(
|
|
258
|
-
|
|
258
|
+
function de(n) {
|
|
259
|
+
X("drag", n);
|
|
259
260
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
261
|
+
function l(n, r) {
|
|
262
|
+
X(n, r);
|
|
262
263
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
264
|
+
function R(n, r) {
|
|
265
|
+
X(n, r);
|
|
265
266
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
267
|
+
function O(n, r) {
|
|
268
|
+
X(n, r);
|
|
268
269
|
}
|
|
269
270
|
return xe(() => {
|
|
270
271
|
Q();
|
|
271
272
|
}), ae(
|
|
272
|
-
() => [
|
|
273
|
+
() => [D(e.canvasWidth), D(e.canvasHeight)],
|
|
273
274
|
() => {
|
|
274
|
-
t.value =
|
|
275
|
+
t.value = w(t.value.x, t.value.y);
|
|
275
276
|
}
|
|
276
277
|
), {
|
|
277
|
-
lockAspectRatio:
|
|
278
|
-
rotation:
|
|
279
|
-
wrapperStyle:
|
|
278
|
+
lockAspectRatio: d,
|
|
279
|
+
rotation: s,
|
|
280
|
+
wrapperStyle: k,
|
|
280
281
|
applyFitScale: K,
|
|
281
|
-
getLayout:
|
|
282
|
-
resetKeyboardLayout:
|
|
283
|
-
toggleLockAspectRatio:
|
|
282
|
+
getLayout: L,
|
|
283
|
+
resetKeyboardLayout: q,
|
|
284
|
+
toggleLockAspectRatio: h,
|
|
284
285
|
onDragStart: de,
|
|
285
|
-
onResizeStart:
|
|
286
|
-
onScaleCornerStart:
|
|
287
|
-
onRotateStart:
|
|
286
|
+
onResizeStart: l,
|
|
287
|
+
onScaleCornerStart: R,
|
|
288
|
+
onRotateStart: O
|
|
288
289
|
};
|
|
289
290
|
}
|
|
290
|
-
function $e(e, t, a) {
|
|
291
|
-
var d, w;
|
|
292
|
-
const { keys: o, musicConfig: n } = e, c = o[t], k = c == null ? void 0 : c[a];
|
|
293
|
-
if (!k) return a;
|
|
294
|
-
let i = 0;
|
|
295
|
-
for (let y = 0; y < a; y++) {
|
|
296
|
-
const x = (d = n == null ? void 0 : n.keyOffset) == null ? void 0 : d.find((b) => {
|
|
297
|
-
var E;
|
|
298
|
-
return b.value === ((E = c[y]) == null ? void 0 : E.value);
|
|
299
|
-
});
|
|
300
|
-
x && (i += x.offsetX);
|
|
301
|
-
}
|
|
302
|
-
let f = a + i;
|
|
303
|
-
const m = (w = n == null ? void 0 : n.keyOffset) == null ? void 0 : w.find((y) => y.value === k.value);
|
|
304
|
-
return m && (f += m.offsetX), f;
|
|
305
|
-
}
|
|
306
291
|
function Xe(e) {
|
|
307
|
-
const { keys: t, musicConfig: a } = e, o = t.reduce((k, i) => Math.max(k, i.length), 0), n = (a == null ? void 0 : a.maxColOffset) || 0, c = o + n + 1;
|
|
308
|
-
return Array.from({ length: t.length }, () => Array.from({ length: c }, () => ({ r: 0, g: 0, b: 0 })));
|
|
309
|
-
}
|
|
310
|
-
function je(e, t) {
|
|
311
|
-
var k;
|
|
312
|
-
const { keys: a, musicConfig: o } = t, n = a.flatMap((i, f) => {
|
|
313
|
-
let m = 0;
|
|
314
|
-
return i.map((d, w) => {
|
|
315
|
-
let y = w + m;
|
|
316
|
-
if (o != null && o.keyOffset) {
|
|
317
|
-
const x = o.keyOffset.find((b) => b.value === d.value);
|
|
318
|
-
x && (y += x.offsetX, m += x.offsetX);
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
row: f,
|
|
322
|
-
col: y,
|
|
323
|
-
value: d.value
|
|
324
|
-
};
|
|
325
|
-
});
|
|
326
|
-
}), c = new Array(n.length * 4).fill(0);
|
|
327
|
-
for (let i = 0; i < n.length; i++) {
|
|
328
|
-
const f = n[i], m = ((k = e[f.row]) == null ? void 0 : k[f.col]) ?? { r: 0, g: 0, b: 0 }, d = i * 4;
|
|
329
|
-
c[d] = f.value, c[d + 1] = m.r, c[d + 2] = m.g, c[d + 3] = m.b;
|
|
330
|
-
}
|
|
331
|
-
return c;
|
|
332
|
-
}
|
|
333
|
-
function Ge(e) {
|
|
334
292
|
const t = e.length / 4;
|
|
335
293
|
if (!t) return { r: 0, g: 0, b: 0 };
|
|
336
|
-
let a = 0,
|
|
337
|
-
for (let
|
|
338
|
-
a += e[
|
|
294
|
+
let a = 0, i = 0, s = 0;
|
|
295
|
+
for (let d = 0; d < e.length; d += 4)
|
|
296
|
+
a += e[d] ?? 0, i += e[d + 1] ?? 0, s += e[d + 2] ?? 0;
|
|
339
297
|
return {
|
|
340
298
|
r: Math.round(a / t),
|
|
341
|
-
g: Math.round(
|
|
342
|
-
b: Math.round(
|
|
299
|
+
g: Math.round(i / t),
|
|
300
|
+
b: Math.round(s / t)
|
|
343
301
|
};
|
|
344
302
|
}
|
|
345
|
-
function
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
303
|
+
function Ye(e, t, a, i) {
|
|
304
|
+
const s = i.getBoundingClientRect(), d = t.width / a.width, P = t.height / a.height, u = (s.left - a.left) * d, y = (s.top - a.top) * P, k = u + s.width * d, g = y + s.height * P, p = Math.max(0, u), b = Math.max(0, y), x = Math.min(t.width, k), w = Math.min(t.height, g);
|
|
305
|
+
if (p >= x || b >= w)
|
|
348
306
|
return { r: 0, g: 0, b: 0 };
|
|
349
|
-
const
|
|
350
|
-
return
|
|
307
|
+
const L = Math.floor(p), A = Math.floor(b), _ = Math.max(1, Math.ceil(x - p)), C = Math.max(1, Math.ceil(w - b));
|
|
308
|
+
return Xe(e.getImageData(L, A, _, C).data);
|
|
351
309
|
}
|
|
352
310
|
function Le(e) {
|
|
353
311
|
const t = e.querySelector("slot");
|
|
354
312
|
if (t instanceof HTMLSlotElement) {
|
|
355
313
|
const a = t.assignedElements();
|
|
356
|
-
return a.length ? a.flatMap((
|
|
314
|
+
return a.length ? a.flatMap((i) => Le(i)) : [];
|
|
357
315
|
}
|
|
358
316
|
return [e];
|
|
359
317
|
}
|
|
@@ -366,19 +324,19 @@ function Te(e) {
|
|
|
366
324
|
}))
|
|
367
325
|
);
|
|
368
326
|
}
|
|
369
|
-
function
|
|
370
|
-
const { canvas: t, keyboardConfig: a, getKeyElements:
|
|
371
|
-
if (!
|
|
372
|
-
const
|
|
373
|
-
if (!
|
|
374
|
-
const
|
|
375
|
-
return
|
|
327
|
+
function Qe(e) {
|
|
328
|
+
const { canvas: t, keyboardConfig: a, getKeyElements: i } = e, s = i();
|
|
329
|
+
if (!s.length) return null;
|
|
330
|
+
const d = t.getContext("2d", { willReadFrequently: !0 });
|
|
331
|
+
if (!d) return null;
|
|
332
|
+
const P = qe(a), u = t.getBoundingClientRect();
|
|
333
|
+
return s.forEach(({ row: y, col: k, el: g }) => {
|
|
376
334
|
var x;
|
|
377
|
-
const
|
|
378
|
-
(x =
|
|
379
|
-
}),
|
|
335
|
+
const p = Be(a, y, k), b = Ye(d, t, u, g);
|
|
336
|
+
(x = P[y]) != null && x[p] && (P[y][p] = b);
|
|
337
|
+
}), P;
|
|
380
338
|
}
|
|
381
|
-
const
|
|
339
|
+
const Ze = { class: "relative" }, Je = ["onMousedown"], et = ["onMousedown"], tt = ["onMousedown"], at = /* @__PURE__ */ be({
|
|
382
340
|
__name: "keyboard-overlay.ce",
|
|
383
341
|
props: {
|
|
384
342
|
canvasWidth: { default: 800, type: Number },
|
|
@@ -388,22 +346,22 @@ const Qe = { class: "relative" }, Ze = ["onMousedown"], Je = ["onMousedown"], et
|
|
|
388
346
|
getKeyElements: { type: Function }
|
|
389
347
|
},
|
|
390
348
|
setup(e, { expose: t }) {
|
|
391
|
-
const a = e,
|
|
392
|
-
lockAspectRatio:
|
|
393
|
-
rotation:
|
|
394
|
-
wrapperStyle:
|
|
395
|
-
applyFitScale:
|
|
396
|
-
getLayout:
|
|
397
|
-
resetKeyboardLayout:
|
|
398
|
-
toggleLockAspectRatio:
|
|
399
|
-
onDragStart:
|
|
349
|
+
const a = e, i = M(null), s = M(null), {
|
|
350
|
+
lockAspectRatio: d,
|
|
351
|
+
rotation: P,
|
|
352
|
+
wrapperStyle: u,
|
|
353
|
+
applyFitScale: y,
|
|
354
|
+
getLayout: k,
|
|
355
|
+
resetKeyboardLayout: g,
|
|
356
|
+
toggleLockAspectRatio: p,
|
|
357
|
+
onDragStart: b,
|
|
400
358
|
onResizeStart: x,
|
|
401
|
-
onScaleCornerStart:
|
|
402
|
-
onRotateStart:
|
|
403
|
-
} =
|
|
359
|
+
onScaleCornerStart: w,
|
|
360
|
+
onRotateStart: L
|
|
361
|
+
} = Ue({
|
|
404
362
|
canvasWidth: () => a.canvasWidth,
|
|
405
363
|
canvasHeight: () => a.canvasHeight,
|
|
406
|
-
getOverlayEl: () =>
|
|
364
|
+
getOverlayEl: () => i.value,
|
|
407
365
|
initialLayout: () => a.initialLayout,
|
|
408
366
|
onLayoutChange: () => a.onLayoutChange
|
|
409
367
|
}), A = [
|
|
@@ -411,111 +369,111 @@ const Qe = { class: "relative" }, Ze = ["onMousedown"], Je = ["onMousedown"], et
|
|
|
411
369
|
{ mode: "resize-s", baseAngle: 0, className: "resize-s" },
|
|
412
370
|
{ mode: "resize-w", baseAngle: 90, className: "resize-w" },
|
|
413
371
|
{ mode: "resize-e", baseAngle: 90, className: "resize-e" }
|
|
414
|
-
],
|
|
372
|
+
], _ = [
|
|
415
373
|
{ mode: "scale-nw", baseAngle: 135, className: "corner-nw" },
|
|
416
374
|
{ mode: "scale-ne", baseAngle: 45, className: "corner-ne" },
|
|
417
375
|
{ mode: "scale-sw", baseAngle: 45, className: "corner-sw" },
|
|
418
376
|
{ mode: "scale-se", baseAngle: 135, className: "corner-se" }
|
|
419
|
-
],
|
|
377
|
+
], C = [
|
|
420
378
|
{ mode: "rotate-nw", className: "rotate-nw" },
|
|
421
379
|
{ mode: "rotate-ne", className: "rotate-ne" },
|
|
422
380
|
{ mode: "rotate-sw", className: "rotate-sw" },
|
|
423
381
|
{ mode: "rotate-se", className: "rotate-se" }
|
|
424
382
|
], K = ["ns-resize", "nesw-resize", "ew-resize", "nwse-resize"];
|
|
425
|
-
function
|
|
426
|
-
const
|
|
427
|
-
return K[
|
|
383
|
+
function q(V) {
|
|
384
|
+
const F = ((V + P.value) % 360 + 360) % 360, m = Math.round(F / 45) % 4;
|
|
385
|
+
return K[m];
|
|
428
386
|
}
|
|
429
|
-
function
|
|
387
|
+
function h() {
|
|
430
388
|
if (a.getKeyElements) return a.getKeyElements();
|
|
431
|
-
const V =
|
|
389
|
+
const V = s.value;
|
|
432
390
|
return V ? Te(V) : [];
|
|
433
391
|
}
|
|
434
|
-
function
|
|
435
|
-
|
|
392
|
+
function z() {
|
|
393
|
+
g(s.value);
|
|
436
394
|
}
|
|
437
|
-
return
|
|
438
|
-
|
|
395
|
+
return _e(() => {
|
|
396
|
+
y(s.value);
|
|
439
397
|
}), ae(
|
|
440
398
|
() => [a.canvasWidth, a.canvasHeight],
|
|
441
399
|
() => {
|
|
442
|
-
|
|
400
|
+
y(s.value);
|
|
443
401
|
}
|
|
444
402
|
), t({
|
|
445
|
-
getMountEl: () =>
|
|
446
|
-
getKeyElements:
|
|
447
|
-
getLayout:
|
|
448
|
-
resetLayout:
|
|
449
|
-
applyFitScale: () =>
|
|
450
|
-
}), (V,
|
|
403
|
+
getMountEl: () => s.value,
|
|
404
|
+
getKeyElements: h,
|
|
405
|
+
getLayout: k,
|
|
406
|
+
resetLayout: z,
|
|
407
|
+
applyFitScale: () => y(s.value)
|
|
408
|
+
}), (V, F) => (ee(), te("div", {
|
|
451
409
|
ref_key: "overlayRef",
|
|
452
|
-
ref:
|
|
410
|
+
ref: i,
|
|
453
411
|
class: "overlay-root",
|
|
454
412
|
part: "overlay-root"
|
|
455
413
|
}, [
|
|
456
|
-
|
|
414
|
+
j("div", {
|
|
457
415
|
class: "transform-wrapper",
|
|
458
416
|
part: "transform-wrapper",
|
|
459
|
-
style: oe($(
|
|
417
|
+
style: oe($(u))
|
|
460
418
|
}, [
|
|
461
|
-
|
|
462
|
-
|
|
419
|
+
j("div", Ze, [
|
|
420
|
+
j("button", {
|
|
463
421
|
type: "button",
|
|
464
422
|
class: "lock-btn",
|
|
465
423
|
part: "lock-button",
|
|
466
|
-
onMousedown:
|
|
424
|
+
onMousedown: F[0] || (F[0] = ge(() => {
|
|
467
425
|
}, ["stop"])),
|
|
468
|
-
onClick:
|
|
426
|
+
onClick: F[1] || (F[1] = ge(
|
|
469
427
|
//@ts-ignore
|
|
470
|
-
(...
|
|
428
|
+
(...m) => $(p) && $(p)(...m),
|
|
471
429
|
["stop"]
|
|
472
430
|
))
|
|
473
431
|
}, [
|
|
474
|
-
|
|
475
|
-
class: se(["lock-icon", $(
|
|
432
|
+
j("i", {
|
|
433
|
+
class: se(["lock-icon", $(d) ? "lock-icon--locked" : "lock-icon--open"])
|
|
476
434
|
}, null, 2)
|
|
477
435
|
], 32),
|
|
478
|
-
(ee(), te(ve, null, fe(
|
|
479
|
-
key:
|
|
480
|
-
class: se(["rotate-handle",
|
|
436
|
+
(ee(), te(ve, null, fe(C, (m) => j("div", {
|
|
437
|
+
key: m.mode,
|
|
438
|
+
class: se(["rotate-handle", m.className]),
|
|
481
439
|
part: "rotate-handle",
|
|
482
|
-
onMousedown: (
|
|
483
|
-
}, null, 42,
|
|
484
|
-
(ee(), te(ve, null, fe(A, (
|
|
485
|
-
key:
|
|
486
|
-
class: se(["resize-handle",
|
|
440
|
+
onMousedown: (W) => $(L)(m.mode, W)
|
|
441
|
+
}, null, 42, Je)), 64)),
|
|
442
|
+
(ee(), te(ve, null, fe(A, (m) => j("div", {
|
|
443
|
+
key: m.mode,
|
|
444
|
+
class: se(["resize-handle", m.className]),
|
|
487
445
|
part: "resize-handle",
|
|
488
|
-
style: oe({ cursor:
|
|
489
|
-
onMousedown: (
|
|
490
|
-
}, null, 46, Je)), 64)),
|
|
491
|
-
(ee(), te(ve, null, fe(H, (C) => X("div", {
|
|
492
|
-
key: C.mode,
|
|
493
|
-
class: se(["corner-handle", C.className]),
|
|
494
|
-
part: "corner-handle",
|
|
495
|
-
style: oe({ cursor: D(C.baseAngle) }),
|
|
496
|
-
onMousedown: (O) => $(b)(C.mode, O)
|
|
446
|
+
style: oe({ cursor: q(m.baseAngle) }),
|
|
447
|
+
onMousedown: (W) => $(x)(m.mode, W)
|
|
497
448
|
}, null, 46, et)), 64)),
|
|
498
|
-
|
|
449
|
+
(ee(), te(ve, null, fe(_, (m) => j("div", {
|
|
450
|
+
key: m.mode,
|
|
451
|
+
class: se(["corner-handle", m.className]),
|
|
452
|
+
part: "corner-handle",
|
|
453
|
+
style: oe({ cursor: q(m.baseAngle) }),
|
|
454
|
+
onMousedown: (W) => $(w)(m.mode, W)
|
|
455
|
+
}, null, 46, tt)), 64)),
|
|
456
|
+
j("div", {
|
|
499
457
|
ref_key: "mountRef",
|
|
500
|
-
ref:
|
|
458
|
+
ref: s,
|
|
501
459
|
class: "keyboard-mount",
|
|
502
460
|
part: "keyboard-mount",
|
|
503
|
-
onMousedown:
|
|
504
|
-
(...
|
|
461
|
+
onMousedown: F[2] || (F[2] = //@ts-ignore
|
|
462
|
+
(...m) => $(b) && $(b)(...m))
|
|
505
463
|
}, [
|
|
506
|
-
|
|
464
|
+
Ce(V.$slots, "keyboard", {}, void 0)
|
|
507
465
|
], 544)
|
|
508
466
|
])
|
|
509
467
|
], 4)
|
|
510
468
|
], 512));
|
|
511
469
|
}
|
|
512
|
-
}),
|
|
470
|
+
}), nt = `.overlay-root[data-v-1403efc7]{pointer-events:none;position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden}.transform-wrapper[data-v-1403efc7]{pointer-events:auto;position:absolute;-webkit-user-select:none;user-select:none}.lock-btn[data-v-1403efc7]{position:absolute;top:16px;right:-40px;z-index:20;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:9999px;border-style:none;--un-bg-opacity:1;background-color:rgb(22 22 22 / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity));--un-shadow:var(--un-shadow-inset) 0 4px 6px -1px var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 2px 4px -2px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.lock-btn[data-v-1403efc7]:hover{--un-bg-opacity:1;background-color:rgb(32 128 240 / var(--un-bg-opacity))}.lock-icon[data-v-1403efc7]{pointer-events:none;display:inline-block;font-size:24px}.lock-icon--locked[data-v-1403efc7],.lock-icon--open[data-v-1403efc7]{width:1em;height:1em;background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.lock-icon--locked[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E")}.lock-icon--open[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E")}.rotate-handle[data-v-1403efc7]{position:absolute;z-index:20;width:32px;height:32px;cursor:grab;--un-text-opacity:1;color:rgb(156 163 175 / var(--un-text-opacity));background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.rotate-nw[data-v-1403efc7]{top:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E")}.rotate-ne[data-v-1403efc7]{top:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E")}.rotate-sw[data-v-1403efc7]{bottom:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E")}.rotate-se[data-v-1403efc7]{bottom:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E")}.resize-handle[data-v-1403efc7]{position:absolute;z-index:10}.resize-n[data-v-1403efc7]{top:-4px;left:12px;right:12px;height:4px}.resize-s[data-v-1403efc7]{bottom:-4px;left:12px;right:12px;height:4px}.resize-w[data-v-1403efc7]{left:-4px;top:12px;bottom:12px;width:4px}.resize-e[data-v-1403efc7]{right:-4px;top:12px;bottom:12px;width:4px}.corner-handle[data-v-1403efc7]{position:absolute;z-index:20;width:16px;height:16px;border-radius:9999px;--un-bg-opacity:1;background-color:rgb(156 163 175 / var(--un-bg-opacity))}.corner-nw[data-v-1403efc7]{top:-8px;left:-8px}.corner-ne[data-v-1403efc7]{top:-8px;right:-8px}.corner-sw[data-v-1403efc7]{bottom:-8px;left:-8px}.corner-se[data-v-1403efc7]{bottom:-8px;right:-8px}.keyboard-mount[data-v-1403efc7]{position:relative;width:fit-content;cursor:move}`, ze = (e, t) => {
|
|
513
471
|
const a = e.__vccOpts || e;
|
|
514
|
-
for (const [
|
|
515
|
-
a[
|
|
472
|
+
for (const [i, s] of t)
|
|
473
|
+
a[i] = s;
|
|
516
474
|
return a;
|
|
517
|
-
},
|
|
518
|
-
function
|
|
475
|
+
}, Se = /* @__PURE__ */ ze(at, [["styles", [nt]], ["__scopeId", "data-v-1403efc7"]]);
|
|
476
|
+
function rt(e) {
|
|
519
477
|
var t, a;
|
|
520
478
|
if (e.default !== void 0) return e.default;
|
|
521
479
|
switch (e.type) {
|
|
@@ -529,265 +487,249 @@ function nt(e) {
|
|
|
529
487
|
return 0;
|
|
530
488
|
}
|
|
531
489
|
}
|
|
532
|
-
function
|
|
533
|
-
return Object.fromEntries((e.params ?? []).map((t) => [t.key,
|
|
490
|
+
function Re(e) {
|
|
491
|
+
return Object.fromEntries((e.params ?? []).map((t) => [t.key, rt(t)]));
|
|
534
492
|
}
|
|
535
493
|
function ie(e, t = {}) {
|
|
536
494
|
if (!e) return {};
|
|
537
|
-
const a =
|
|
538
|
-
for (const
|
|
539
|
-
|
|
495
|
+
const a = Re(e);
|
|
496
|
+
for (const i of e.params ?? [])
|
|
497
|
+
i.key in t && t[i.key] !== void 0 && (a[i.key] = t[i.key]);
|
|
540
498
|
return a;
|
|
541
499
|
}
|
|
542
|
-
const
|
|
500
|
+
const st = 50;
|
|
543
501
|
function pe(e, t, a) {
|
|
544
502
|
e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", e.clearRect(0, 0, t, a);
|
|
545
503
|
}
|
|
546
|
-
function
|
|
547
|
-
const
|
|
548
|
-
if (!
|
|
549
|
-
const
|
|
550
|
-
canvas2d:
|
|
504
|
+
function ot(e, t, a) {
|
|
505
|
+
const i = e.getContext("2d");
|
|
506
|
+
if (!i) return null;
|
|
507
|
+
const s = {
|
|
508
|
+
canvas2d: i,
|
|
551
509
|
width: e.width,
|
|
552
510
|
height: e.height
|
|
553
|
-
},
|
|
554
|
-
let
|
|
555
|
-
const
|
|
556
|
-
pe(
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
},
|
|
560
|
-
|
|
511
|
+
}, d = { ...Re(t), ...a }, P = t.initialize(s, d);
|
|
512
|
+
let u = 0, y = 0, k = 0, g = 0;
|
|
513
|
+
const p = (q) => {
|
|
514
|
+
pe(i, e.width, e.height), g || (g = q);
|
|
515
|
+
const h = k ? q - k : 16, z = q - g;
|
|
516
|
+
k = q, t.render(s, P, { deltaTime: h, elapsedTime: z }, d);
|
|
517
|
+
}, b = () => {
|
|
518
|
+
u && (cancelAnimationFrame(u), u = 0);
|
|
561
519
|
}, x = () => {
|
|
562
|
-
|
|
563
|
-
},
|
|
564
|
-
|
|
565
|
-
},
|
|
566
|
-
|
|
520
|
+
y && (Ee(y), y = 0);
|
|
521
|
+
}, w = (q) => {
|
|
522
|
+
p(q), u = requestAnimationFrame(w);
|
|
523
|
+
}, L = () => {
|
|
524
|
+
p(performance.now());
|
|
567
525
|
}, A = () => {
|
|
568
|
-
x(),
|
|
569
|
-
},
|
|
570
|
-
|
|
571
|
-
},
|
|
572
|
-
document.visibilityState === "visible" ? A() :
|
|
526
|
+
x(), b(), u = requestAnimationFrame(w);
|
|
527
|
+
}, _ = () => {
|
|
528
|
+
b(), x(), L(), y = ke(L, st);
|
|
529
|
+
}, C = () => {
|
|
530
|
+
document.visibilityState === "visible" ? A() : _();
|
|
573
531
|
}, K = () => {
|
|
574
|
-
|
|
532
|
+
C();
|
|
575
533
|
};
|
|
576
|
-
return document.addEventListener("visibilitychange", K),
|
|
577
|
-
document.removeEventListener("visibilitychange", K),
|
|
534
|
+
return document.addEventListener("visibilitychange", K), C(), () => {
|
|
535
|
+
document.removeEventListener("visibilitychange", K), b(), x(), t.shutdown(s, P), pe(i, e.width, e.height);
|
|
578
536
|
};
|
|
579
537
|
}
|
|
580
|
-
function
|
|
538
|
+
function it(e, t = {}) {
|
|
581
539
|
return ie(e, t);
|
|
582
540
|
}
|
|
583
|
-
function
|
|
584
|
-
const t =
|
|
585
|
-
var
|
|
586
|
-
return ((
|
|
541
|
+
function lt(e) {
|
|
542
|
+
const t = M(null), a = Y(() => D(e.canvasRef) ?? t.value), i = M(null), s = M({}), d = M(!1), P = Y(() => {
|
|
543
|
+
var h;
|
|
544
|
+
return ((h = i.value) == null ? void 0 : h.params) ?? [];
|
|
587
545
|
});
|
|
588
|
-
let
|
|
589
|
-
function
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
592
|
-
|
|
593
|
-
const V =
|
|
594
|
-
return V && (
|
|
546
|
+
let u = null;
|
|
547
|
+
function y() {
|
|
548
|
+
const h = i.value, z = a.value;
|
|
549
|
+
if (!h || !z) return !1;
|
|
550
|
+
u == null || u(), u = null;
|
|
551
|
+
const V = ot(z, h, s.value);
|
|
552
|
+
return V && (u = V, d.value = !0), !0;
|
|
595
553
|
}
|
|
596
|
-
function
|
|
597
|
-
|
|
554
|
+
function k() {
|
|
555
|
+
i.value && (y() || Me(() => y()));
|
|
598
556
|
}
|
|
599
|
-
function
|
|
600
|
-
|
|
557
|
+
function g(h, z) {
|
|
558
|
+
p(), i.value = h, z && (s.value = { ...z }), k();
|
|
601
559
|
}
|
|
602
|
-
function
|
|
603
|
-
|
|
560
|
+
function p() {
|
|
561
|
+
u == null || u(), u = null, d.value = !1;
|
|
604
562
|
}
|
|
605
|
-
function
|
|
606
|
-
|
|
563
|
+
function b(h) {
|
|
564
|
+
s.value = ie(i.value, { ...s.value, ...h }), k();
|
|
607
565
|
}
|
|
608
|
-
function x(
|
|
609
|
-
return
|
|
566
|
+
function x(h) {
|
|
567
|
+
return h.name ?? h.key;
|
|
610
568
|
}
|
|
611
|
-
function
|
|
612
|
-
return Number(
|
|
569
|
+
function w(h) {
|
|
570
|
+
return Number(s.value[h] ?? 0);
|
|
613
571
|
}
|
|
614
|
-
function
|
|
615
|
-
return String(
|
|
572
|
+
function L(h) {
|
|
573
|
+
return String(s.value[h] ?? "#000000");
|
|
616
574
|
}
|
|
617
|
-
function A(
|
|
618
|
-
const
|
|
619
|
-
return typeof
|
|
575
|
+
function A(h) {
|
|
576
|
+
const z = s.value[h];
|
|
577
|
+
return typeof z == "number" || typeof z == "string" ? z : 0;
|
|
620
578
|
}
|
|
621
|
-
function
|
|
622
|
-
return !!
|
|
579
|
+
function _(h) {
|
|
580
|
+
return !!s.value[h];
|
|
623
581
|
}
|
|
624
|
-
function
|
|
625
|
-
const
|
|
626
|
-
return Number.isInteger(
|
|
582
|
+
function C(h) {
|
|
583
|
+
const z = Number(h ?? 0);
|
|
584
|
+
return Number.isInteger(z) ? String(z) : z.toFixed(2).replace(/\.?0+$/, "");
|
|
627
585
|
}
|
|
628
|
-
function K(
|
|
629
|
-
|
|
586
|
+
function K(h, z) {
|
|
587
|
+
b({ [h]: z });
|
|
630
588
|
}
|
|
631
|
-
function
|
|
632
|
-
const
|
|
633
|
-
if (!
|
|
634
|
-
|
|
589
|
+
function q() {
|
|
590
|
+
const h = D(e.preset) ?? null, z = D(e.params) ?? {};
|
|
591
|
+
if (!h) {
|
|
592
|
+
i.value = null, s.value = {}, p();
|
|
635
593
|
return;
|
|
636
594
|
}
|
|
637
|
-
|
|
595
|
+
i.value = h, s.value = it(h, z), k();
|
|
638
596
|
}
|
|
639
|
-
return ae(() => ({ preset:
|
|
597
|
+
return ae(() => ({ preset: D(e.preset), params: D(e.params) }), q, {
|
|
640
598
|
immediate: !0,
|
|
641
599
|
deep: !0,
|
|
642
600
|
flush: "sync"
|
|
643
|
-
}), xe(
|
|
601
|
+
}), xe(p), {
|
|
644
602
|
internalCanvasRef: t,
|
|
645
603
|
canvasRef: a,
|
|
646
|
-
currentPreset:
|
|
647
|
-
paramValues:
|
|
648
|
-
paramFields:
|
|
649
|
-
isRunning:
|
|
604
|
+
currentPreset: i,
|
|
605
|
+
paramValues: s,
|
|
606
|
+
paramFields: P,
|
|
607
|
+
isRunning: d,
|
|
650
608
|
getParamLabel: x,
|
|
651
|
-
getSliderValue:
|
|
652
|
-
getColorValue:
|
|
609
|
+
getSliderValue: w,
|
|
610
|
+
getColorValue: L,
|
|
653
611
|
getSelectValue: A,
|
|
654
|
-
getSwitchValue:
|
|
655
|
-
formatSliderValue:
|
|
612
|
+
getSwitchValue: _,
|
|
613
|
+
formatSliderValue: C,
|
|
656
614
|
handleParamChange: K,
|
|
657
|
-
start:
|
|
658
|
-
stop:
|
|
659
|
-
updateParams:
|
|
615
|
+
start: g,
|
|
616
|
+
stop: p,
|
|
617
|
+
updateParams: b
|
|
660
618
|
};
|
|
661
619
|
}
|
|
662
|
-
const
|
|
620
|
+
const ut = 50;
|
|
663
621
|
function ct(e) {
|
|
664
|
-
const t = e.syncIntervalMs ??
|
|
665
|
-
let a = 0,
|
|
666
|
-
function
|
|
667
|
-
const
|
|
668
|
-
return
|
|
669
|
-
canvas:
|
|
622
|
+
const t = e.syncIntervalMs ?? ut;
|
|
623
|
+
let a = 0, i = !1, s = null;
|
|
624
|
+
function d() {
|
|
625
|
+
const g = e.getCanvas();
|
|
626
|
+
return g ? Qe({
|
|
627
|
+
canvas: g,
|
|
670
628
|
keyboardConfig: e.keyboardConfig,
|
|
671
629
|
getKeyElements: e.getKeyElements
|
|
672
630
|
}) : null;
|
|
673
631
|
}
|
|
674
|
-
async function
|
|
675
|
-
var
|
|
676
|
-
if ((
|
|
677
|
-
|
|
632
|
+
async function P(g) {
|
|
633
|
+
var p;
|
|
634
|
+
if ((p = e.onKeysRgbChange) == null || p.call(e, g), i) {
|
|
635
|
+
s = g;
|
|
678
636
|
return;
|
|
679
637
|
}
|
|
680
|
-
|
|
638
|
+
i = !0;
|
|
681
639
|
try {
|
|
682
|
-
const
|
|
683
|
-
await e.device.setMusicData(
|
|
640
|
+
const b = Fe(g, e.keyboardConfig);
|
|
641
|
+
await e.device.setMusicData(b, 0, e.isUSBDevice, e.lightingVersion);
|
|
684
642
|
} catch {
|
|
685
643
|
} finally {
|
|
686
|
-
if (
|
|
687
|
-
const
|
|
688
|
-
|
|
644
|
+
if (i = !1, s) {
|
|
645
|
+
const b = s;
|
|
646
|
+
s = null, P(b);
|
|
689
647
|
}
|
|
690
648
|
}
|
|
691
649
|
}
|
|
692
|
-
function
|
|
650
|
+
function u() {
|
|
693
651
|
if (e.enabled && !e.enabled.value) return;
|
|
694
|
-
const
|
|
695
|
-
|
|
652
|
+
const g = d();
|
|
653
|
+
g && P(g);
|
|
696
654
|
}
|
|
697
|
-
function
|
|
698
|
-
a || (a =
|
|
655
|
+
function y() {
|
|
656
|
+
a || (a = ke(u, t));
|
|
699
657
|
}
|
|
700
|
-
function
|
|
658
|
+
function k() {
|
|
701
659
|
a && (Ee(a), a = 0);
|
|
702
660
|
}
|
|
703
661
|
return e.enabled ? ae(
|
|
704
662
|
e.enabled,
|
|
705
|
-
(
|
|
706
|
-
|
|
663
|
+
(g) => {
|
|
664
|
+
g ? y() : k();
|
|
707
665
|
},
|
|
708
666
|
{ immediate: !0 }
|
|
709
|
-
) :
|
|
710
|
-
syncKeyColors:
|
|
711
|
-
startKeySync:
|
|
712
|
-
stopKeySync:
|
|
667
|
+
) : y(), He(k), {
|
|
668
|
+
syncKeyColors: u,
|
|
669
|
+
startKeySync: y,
|
|
670
|
+
stopKeySync: k
|
|
713
671
|
};
|
|
714
672
|
}
|
|
715
|
-
function
|
|
673
|
+
function dt(e) {
|
|
716
674
|
if (!e || typeof e != "object") return !1;
|
|
717
675
|
const t = e;
|
|
718
676
|
return !(typeof t.id != "string" || !t.id.trim() || typeof t.name != "string" || !t.name.trim() || typeof t.initialize != "function" || typeof t.render != "function" || typeof t.shutdown != "function" || t.params !== void 0 && (!Array.isArray(t.params) || !t.params.every((a) => a && typeof a == "object" && typeof a.key == "string")));
|
|
719
677
|
}
|
|
720
|
-
function
|
|
678
|
+
function vt(e) {
|
|
721
679
|
const t = new Function(`return (${e})`)();
|
|
722
|
-
if (!
|
|
680
|
+
if (!dt(t))
|
|
723
681
|
throw new Error("INVALID_PRESET");
|
|
724
682
|
return t;
|
|
725
683
|
}
|
|
726
684
|
function we(e = {}) {
|
|
727
|
-
var
|
|
728
|
-
const t = e.initialPresets ?? [], a = he(e.initialImported ?? []),
|
|
729
|
-
function
|
|
730
|
-
|
|
685
|
+
var b, x;
|
|
686
|
+
const t = e.initialPresets ?? [], a = he(e.initialImported ?? []), i = he([...t, ...a.value]), s = M(((b = t[0]) == null ? void 0 : b.id) ?? ((x = a.value[0]) == null ? void 0 : x.id) ?? ""), d = () => i.value.find((w) => w.id === s.value) ?? i.value[0] ?? null;
|
|
687
|
+
function P() {
|
|
688
|
+
i.value = [...t, ...a.value];
|
|
731
689
|
}
|
|
732
|
-
function
|
|
733
|
-
var
|
|
734
|
-
(
|
|
690
|
+
function u() {
|
|
691
|
+
var w;
|
|
692
|
+
(w = e.onPresetsChange) == null || w.call(e, a.value.map((L) => Ke(L)));
|
|
735
693
|
}
|
|
736
|
-
function
|
|
737
|
-
|
|
694
|
+
function y(w) {
|
|
695
|
+
i.value.some((L) => L.id === w) && (s.value = w);
|
|
738
696
|
}
|
|
739
|
-
function
|
|
740
|
-
return t.some((
|
|
697
|
+
function k(w) {
|
|
698
|
+
return t.some((L) => L.id === w);
|
|
741
699
|
}
|
|
742
|
-
async function
|
|
743
|
-
var
|
|
700
|
+
async function g(w) {
|
|
701
|
+
var L, A, _;
|
|
744
702
|
try {
|
|
745
|
-
const
|
|
746
|
-
return
|
|
703
|
+
const C = vt(w);
|
|
704
|
+
return i.value.some((K) => K.id === C.id) ? ((L = e.onImportPreset) == null || L.call(e, {
|
|
747
705
|
code: 1,
|
|
748
706
|
message: "Preset id already exists"
|
|
749
|
-
}), null) : (a.value = [...a.value,
|
|
707
|
+
}), null) : (a.value = [...a.value, C], P(), u(), s.value = C.id, (A = e.onImportPreset) == null || A.call(e, {
|
|
750
708
|
code: 0,
|
|
751
709
|
message: "Import success"
|
|
752
|
-
}),
|
|
710
|
+
}), C);
|
|
753
711
|
} catch {
|
|
754
|
-
return (
|
|
712
|
+
return (_ = e.onImportPreset) == null || _.call(e, {
|
|
755
713
|
code: 2,
|
|
756
714
|
message: "Invalid preset code"
|
|
757
715
|
}), null;
|
|
758
716
|
}
|
|
759
717
|
}
|
|
760
|
-
async function w
|
|
761
|
-
var
|
|
762
|
-
|
|
718
|
+
async function p(w) {
|
|
719
|
+
var L;
|
|
720
|
+
k(w) || (a.value = a.value.filter((A) => A.id !== w), P(), u(), s.value === w && (s.value = ((L = i.value[0]) == null ? void 0 : L.id) ?? ""));
|
|
763
721
|
}
|
|
764
722
|
return {
|
|
765
|
-
presetList:
|
|
766
|
-
selectedPresetId:
|
|
767
|
-
selectedPreset:
|
|
768
|
-
selectPreset:
|
|
769
|
-
isInitialPreset:
|
|
770
|
-
importPreset:
|
|
771
|
-
deleteImportedPreset:
|
|
723
|
+
presetList: i,
|
|
724
|
+
selectedPresetId: s,
|
|
725
|
+
selectedPreset: d,
|
|
726
|
+
selectPreset: y,
|
|
727
|
+
isInitialPreset: k,
|
|
728
|
+
importPreset: g,
|
|
729
|
+
deleteImportedPreset: p
|
|
772
730
|
};
|
|
773
731
|
}
|
|
774
|
-
const
|
|
775
|
-
function ft(e) {
|
|
776
|
-
if (!e || typeof e != "object") return !1;
|
|
777
|
-
const t = e;
|
|
778
|
-
return vt.every((a) => typeof t[a] == "function");
|
|
779
|
-
}
|
|
780
|
-
async function ht(e) {
|
|
781
|
-
if (!e)
|
|
782
|
-
throw new Error("[keyboard-kit] init.device is required");
|
|
783
|
-
if (!ft(e))
|
|
784
|
-
throw new Error("[keyboard-kit] init.device must be an @hfd-sdk/keyboard-sdk HFDDevice instance");
|
|
785
|
-
const { HFDDevice: t } = await import("@hfd-sdk/keyboard-sdk");
|
|
786
|
-
if (!(e instanceof t))
|
|
787
|
-
throw new Error("[keyboard-kit] init.device must be created via new HFDDevice() from @hfd-sdk/keyboard-sdk");
|
|
788
|
-
return e;
|
|
789
|
-
}
|
|
790
|
-
const gt = ["width", "height"], mt = /* @__PURE__ */ be({
|
|
732
|
+
const ft = ["width", "height"], ht = /* @__PURE__ */ be({
|
|
791
733
|
__name: "hfd-ai-lighting.ce",
|
|
792
734
|
props: {
|
|
793
735
|
width: { default: 800, type: Number },
|
|
@@ -795,152 +737,152 @@ const gt = ["width", "height"], mt = /* @__PURE__ */ be({
|
|
|
795
737
|
},
|
|
796
738
|
emits: ["keys-rgb-change", "preset-change", "param-change", "presets-change", "layout-change", "keyboard-ready", "import-preset"],
|
|
797
739
|
setup(e, { expose: t, emit: a }) {
|
|
798
|
-
const
|
|
799
|
-
let
|
|
800
|
-
const K = Y(() =>
|
|
801
|
-
width: `${
|
|
802
|
-
height: `${
|
|
803
|
-
})), { paramValues:
|
|
740
|
+
const i = e, s = a, d = M(i.width), P = M(i.height), u = M(), y = M(), k = M(null), g = M(null), p = M(), b = M(), x = M(50), w = M(!0), L = M({}), A = M(null), _ = M(null);
|
|
741
|
+
let C = he(we());
|
|
742
|
+
const K = Y(() => C.value.selectedPreset()), q = Y(() => ({
|
|
743
|
+
width: `${d.value}px`,
|
|
744
|
+
height: `${P.value}px`
|
|
745
|
+
})), { paramValues: h, handleParamChange: z } = lt({
|
|
804
746
|
preset: () => K.value,
|
|
805
|
-
params: () =>
|
|
747
|
+
params: () => L.value,
|
|
806
748
|
canvasRef: () => A.value
|
|
807
749
|
});
|
|
808
750
|
function V() {
|
|
809
|
-
var
|
|
810
|
-
if (
|
|
811
|
-
const
|
|
812
|
-
return
|
|
751
|
+
var R, O;
|
|
752
|
+
if (y.value) return y.value();
|
|
753
|
+
const l = (O = (R = _.value) == null ? void 0 : R.getMountEl) == null ? void 0 : O.call(R);
|
|
754
|
+
return l ? Te(l) : [];
|
|
813
755
|
}
|
|
814
|
-
function
|
|
815
|
-
|
|
756
|
+
function F(l) {
|
|
757
|
+
s("layout-change", { layout: l });
|
|
816
758
|
}
|
|
817
|
-
let
|
|
818
|
-
function
|
|
819
|
-
if (
|
|
820
|
-
|
|
821
|
-
keyboardConfig:
|
|
759
|
+
let m = null;
|
|
760
|
+
function W() {
|
|
761
|
+
if (m == null || m(), m = null, !k.value || !A.value || !g.value) return;
|
|
762
|
+
m = ct({
|
|
763
|
+
keyboardConfig: k.value,
|
|
822
764
|
getCanvas: () => A.value,
|
|
823
765
|
getKeyElements: V,
|
|
824
|
-
device:
|
|
825
|
-
isUSBDevice:
|
|
826
|
-
lightingVersion:
|
|
766
|
+
device: g.value,
|
|
767
|
+
isUSBDevice: p.value,
|
|
768
|
+
lightingVersion: b.value,
|
|
827
769
|
syncIntervalMs: x.value,
|
|
828
|
-
enabled:
|
|
829
|
-
onKeysRgbChange: (
|
|
830
|
-
|
|
770
|
+
enabled: w,
|
|
771
|
+
onKeysRgbChange: (R) => {
|
|
772
|
+
s("keys-rgb-change", { keysRgb: R });
|
|
831
773
|
}
|
|
832
774
|
}).stopKeySync;
|
|
833
775
|
}
|
|
834
|
-
function
|
|
835
|
-
|
|
836
|
-
presetId:
|
|
837
|
-
preset:
|
|
776
|
+
function G(l) {
|
|
777
|
+
s("preset-change", {
|
|
778
|
+
presetId: l,
|
|
779
|
+
preset: C.value.selectedPreset()
|
|
838
780
|
});
|
|
839
781
|
}
|
|
840
|
-
async function le(
|
|
841
|
-
var
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
initialPresets:
|
|
845
|
-
initialImported:
|
|
846
|
-
onPresetsChange: (
|
|
847
|
-
onImportPreset: (
|
|
848
|
-
}),
|
|
782
|
+
async function le(l) {
|
|
783
|
+
var O, n, r, o;
|
|
784
|
+
const R = await De(l.device);
|
|
785
|
+
d.value = l.canvasWidth ?? i.width, P.value = l.canvasHeight ?? i.height, u.value = l.initialLayout, y.value = l.getKeyElements, k.value = l.keyboardConfig, g.value = R, p.value = l.isUSBDevice, b.value = l.lightingVersion, x.value = l.syncIntervalMs ?? 50, L.value = l.defaultParams ?? {}, C.value = we({
|
|
786
|
+
initialPresets: l.presets ?? [],
|
|
787
|
+
initialImported: l.importedPresets ?? [],
|
|
788
|
+
onPresetsChange: (c) => s("presets-change", { importedSerialized: c }),
|
|
789
|
+
onImportPreset: (c) => s("import-preset", c)
|
|
790
|
+
}), l.selectedPresetId ? C.value.selectPreset(l.selectedPresetId) : (O = l.presets) != null && O[0] ? C.value.selectPreset(l.presets[0].id) : (n = l.importedPresets) != null && n[0] && C.value.selectPreset(l.importedPresets[0].id), await Me(), (o = (r = _.value) == null ? void 0 : r.applyFitScale) == null || o.call(r), W(), G(C.value.selectedPresetId.value), s("keyboard-ready");
|
|
849
791
|
}
|
|
850
|
-
function ne(
|
|
851
|
-
|
|
792
|
+
function ne(l) {
|
|
793
|
+
C.value.selectPreset(l), G(l);
|
|
852
794
|
}
|
|
853
|
-
async function
|
|
854
|
-
await
|
|
795
|
+
async function ue(l) {
|
|
796
|
+
await C.value.deleteImportedPreset(l), G(C.value.selectedPresetId.value);
|
|
855
797
|
}
|
|
856
|
-
async function
|
|
857
|
-
const
|
|
858
|
-
return
|
|
798
|
+
async function ce(l) {
|
|
799
|
+
const R = await C.value.importPreset(l);
|
|
800
|
+
return R && G(R.id), R;
|
|
859
801
|
}
|
|
860
|
-
function
|
|
861
|
-
|
|
862
|
-
const
|
|
863
|
-
key:
|
|
864
|
-
value:
|
|
865
|
-
params: ie(
|
|
802
|
+
function X(l, R) {
|
|
803
|
+
z(l, R);
|
|
804
|
+
const O = K.value, n = {
|
|
805
|
+
key: l,
|
|
806
|
+
value: R,
|
|
807
|
+
params: ie(O, h.value)
|
|
866
808
|
};
|
|
867
|
-
|
|
809
|
+
s("param-change", n);
|
|
868
810
|
}
|
|
869
811
|
function re() {
|
|
870
|
-
const
|
|
812
|
+
const l = C.value;
|
|
871
813
|
return {
|
|
872
|
-
presetList:
|
|
873
|
-
selectedPresetId:
|
|
874
|
-
selectedPreset:
|
|
875
|
-
isInitialPreset:
|
|
814
|
+
presetList: l.presetList,
|
|
815
|
+
selectedPresetId: l.selectedPresetId,
|
|
816
|
+
selectedPreset: l.selectedPreset,
|
|
817
|
+
isInitialPreset: l.isInitialPreset
|
|
876
818
|
};
|
|
877
819
|
}
|
|
878
820
|
function Q() {
|
|
879
|
-
return ie(K.value,
|
|
821
|
+
return ie(K.value, h.value);
|
|
880
822
|
}
|
|
881
823
|
function de() {
|
|
882
|
-
var
|
|
883
|
-
(
|
|
824
|
+
var l, R;
|
|
825
|
+
(R = (l = _.value) == null ? void 0 : l.resetLayout) == null || R.call(l);
|
|
884
826
|
}
|
|
885
827
|
return ae(
|
|
886
|
-
() => [
|
|
887
|
-
() =>
|
|
828
|
+
() => [k.value, g.value, p.value, b.value],
|
|
829
|
+
() => W()
|
|
888
830
|
), t({
|
|
889
831
|
init: le,
|
|
890
832
|
getPresetState: re,
|
|
891
833
|
selectPreset: ne,
|
|
892
|
-
deletePreset:
|
|
893
|
-
importPreset:
|
|
894
|
-
setParam:
|
|
834
|
+
deletePreset: ue,
|
|
835
|
+
importPreset: ce,
|
|
836
|
+
setParam: X,
|
|
895
837
|
getParamValues: Q,
|
|
896
838
|
resetKeyboardLayout: de,
|
|
897
839
|
getKeyElements: V
|
|
898
|
-
}), (
|
|
840
|
+
}), (l, R) => (ee(), te("div", {
|
|
899
841
|
class: "preview-wrap",
|
|
900
|
-
style: oe(
|
|
842
|
+
style: oe(q.value)
|
|
901
843
|
}, [
|
|
902
|
-
|
|
844
|
+
j("canvas", {
|
|
903
845
|
ref_key: "canvasEl",
|
|
904
846
|
ref: A,
|
|
905
847
|
class: "preview-canvas",
|
|
906
|
-
width:
|
|
907
|
-
height:
|
|
908
|
-
}, null, 8,
|
|
909
|
-
Ve(
|
|
848
|
+
width: d.value,
|
|
849
|
+
height: P.value
|
|
850
|
+
}, null, 8, ft),
|
|
851
|
+
Ve(Se, {
|
|
910
852
|
ref_key: "overlayRef",
|
|
911
|
-
ref:
|
|
912
|
-
"canvas-width":
|
|
913
|
-
"canvas-height":
|
|
914
|
-
"initial-layout":
|
|
915
|
-
"on-layout-change":
|
|
853
|
+
ref: _,
|
|
854
|
+
"canvas-width": d.value,
|
|
855
|
+
"canvas-height": P.value,
|
|
856
|
+
"initial-layout": u.value,
|
|
857
|
+
"on-layout-change": F,
|
|
916
858
|
"get-key-elements": V
|
|
917
859
|
}, {
|
|
918
860
|
keyboard: Ne(() => [
|
|
919
|
-
|
|
861
|
+
Ce(l.$slots, "keyboard", {}, void 0, !0)
|
|
920
862
|
]),
|
|
921
863
|
_: 3
|
|
922
864
|
}, 8, ["canvas-width", "canvas-height", "initial-layout"])
|
|
923
865
|
], 4));
|
|
924
866
|
}
|
|
925
|
-
}),
|
|
926
|
-
|
|
927
|
-
),
|
|
928
|
-
|
|
867
|
+
}), gt = ".preview-wrap[data-v-ba92361e]{position:relative;flex-shrink:0;overflow:hidden;border-radius:8px;background:#000}.preview-canvas[data-v-ba92361e]{display:block;width:100%;height:100%}", mt = /* @__PURE__ */ ze(ht, [["styles", [gt]], ["__scopeId", "data-v-ba92361e"]]), yt = Pe(
|
|
868
|
+
mt
|
|
869
|
+
), pt = Pe(
|
|
870
|
+
Se
|
|
929
871
|
);
|
|
930
|
-
function
|
|
872
|
+
function wt() {
|
|
931
873
|
const e = [
|
|
932
|
-
["hfd-ai-lighting",
|
|
933
|
-
["hfd-ai-lighting-keyboard-overlay",
|
|
874
|
+
["hfd-ai-lighting", yt],
|
|
875
|
+
["hfd-ai-lighting-keyboard-overlay", pt]
|
|
934
876
|
];
|
|
935
877
|
for (const [t, a] of e)
|
|
936
878
|
customElements.get(t) || customElements.define(t, a);
|
|
937
879
|
}
|
|
938
|
-
|
|
880
|
+
wt();
|
|
939
881
|
export {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
882
|
+
yt as HfdAiLightingElement,
|
|
883
|
+
pt as HfdAiLightingKeyboardOverlayElement,
|
|
884
|
+
Mt as deserializePreset,
|
|
885
|
+
wt as registerAiLightingElements,
|
|
944
886
|
Ke as serializePreset,
|
|
945
|
-
|
|
887
|
+
dt as validatePreset
|
|
946
888
|
};
|