@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.
@@ -0,0 +1,65 @@
1
+ function h(e, n, t) {
2
+ var f, k;
3
+ const { keyList: i, musicConfig: r } = e, o = i[n], u = o == null ? void 0 : o[t];
4
+ if (!u) return t;
5
+ let s = 0;
6
+ for (let l = 0; l < t; l++) {
7
+ const y = (f = r == null ? void 0 : r.keyOffset) == null ? void 0 : f.find((d) => {
8
+ var D;
9
+ return d.value === ((D = o[l]) == null ? void 0 : D.value);
10
+ });
11
+ y && (s += y.offsetX);
12
+ }
13
+ let c = t + s;
14
+ const a = (k = r == null ? void 0 : r.keyOffset) == null ? void 0 : k.find((l) => l.value === u.value);
15
+ return a && (c += a.offsetX), c;
16
+ }
17
+ function w(e) {
18
+ const { keyList: n, musicConfig: t } = e, i = n.reduce((u, s) => Math.max(u, s.length), 0), r = (t == null ? void 0 : t.maxColOffset) || 0, o = i + r + 1;
19
+ return Array.from({ length: n.length }, () => Array.from({ length: o }, () => ({ r: 0, g: 0, b: 0 })));
20
+ }
21
+ function m(e, n) {
22
+ var u;
23
+ const { keyList: t, musicConfig: i } = n, r = t.flatMap((s, c) => {
24
+ let a = 0;
25
+ return s.map((f, k) => {
26
+ let l = k + a;
27
+ if (i != null && i.keyOffset) {
28
+ const y = i.keyOffset.find((d) => d.value === f.value);
29
+ y && (l += y.offsetX, a += y.offsetX);
30
+ }
31
+ return {
32
+ row: c,
33
+ col: l,
34
+ value: f.value
35
+ };
36
+ });
37
+ }), o = new Array(r.length * 4).fill(0);
38
+ for (let s = 0; s < r.length; s++) {
39
+ const c = r[s], a = ((u = e[c.row]) == null ? void 0 : u[c.col]) ?? { r: 0, g: 0, b: 0 }, f = s * 4;
40
+ o[f] = c.value, o[f + 1] = a.r, o[f + 2] = a.g, o[f + 3] = a.b;
41
+ }
42
+ return o;
43
+ }
44
+ const v = ["setMusicData", "getDeviceId", "isConnected", "getDevice"];
45
+ function b(e) {
46
+ if (!e || typeof e != "object") return !1;
47
+ const n = e;
48
+ return v.every((t) => typeof n[t] == "function");
49
+ }
50
+ async function g(e) {
51
+ if (!e)
52
+ throw new Error("[keyboard-kit] init.device is required");
53
+ if (!b(e))
54
+ throw new Error("[keyboard-kit] init.device must be an @hfd-sdk/keyboard-sdk HFDDevice instance");
55
+ const { HFDDevice: n } = await import("@hfd-sdk/keyboard-sdk");
56
+ if (!(e instanceof n))
57
+ throw new Error("[keyboard-kit] init.device must be created via new HFDDevice() from @hfd-sdk/keyboard-sdk");
58
+ return e;
59
+ }
60
+ export {
61
+ g as a,
62
+ m as b,
63
+ w as c,
64
+ h as g
65
+ };
@@ -0,0 +1,8 @@
1
+ import { MusicV2Engine, MusicV2EngineOptions } from './types';
2
+ /**
3
+ * 创建音乐律动 V2 引擎(框架无关)。
4
+ *
5
+ * 工作流程:定时(默认 50ms,worker-timers 不受页面隐藏节流)采样振幅 →
6
+ * 按当前模式绘制按键 RGB 网格 → 串行下发到键盘硬件。
7
+ */
8
+ export declare function createMusicV2Engine(options: MusicV2EngineOptions): Promise<MusicV2Engine>;
@@ -0,0 +1,12 @@
1
+ export { createMusicV2Engine } from './engine';
2
+ export { MusicV2Renderer } from './visualizers';
3
+ export type { MusicV2RenderParams } from './visualizers';
4
+ export { createSystemAudioSource } from './system-audio';
5
+ export type { SystemAudioSource, SystemAudioFrequencyBands } from './system-audio';
6
+ export { createMusicV2PluginClient } from './plugin-client';
7
+ export type { MusicV2PluginClient, MusicV2PluginClientOptions } from './plugin-client';
8
+ export { RING_68_KEY_POSITIONS, RING_87_KEY_POSITIONS, RING_108_KEY_POSITIONS, VOLCANO_64_KEY_POSITIONS, VOLCANO_84_ISO_KEY_POSITIONS, VOLCANO_87_KEY_POSITIONS, VOLCANO_98_KEY_POSITIONS, getMusicRingKeyPositions, getMusicVolcanoKeyPositions, } from './key-positions';
9
+ export { HSVtoRGB, hexToRgb } from '../shared/color';
10
+ export { buildMusicData, createKeysRgbGrid, getMusicGridCol } from '../shared/hardware/build-music-data';
11
+ export type { MusicV2Mode, MusicV2BackgroundMode, MusicV2AmplitudeSource, MusicV2ScreenLightClient, MusicV2LedConfig, MusicV2EngineOptions, MusicV2State, MusicV2Engine, } from './types';
12
+ export type { keyPosition, volcanoMountainPositions, KeyboardConfig, } from '../shared/types';