@kidlib/web-audio 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@kidlib/web-audio",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "High-level Web Audio primitives for musical instruments and tools.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/KristinnRoach/web-audio.git"
9
9
  },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "packageManager": "pnpm@11.5.2",
10
+ "files": [
11
+ "dist"
12
+ ],
14
13
  "type": "module",
15
14
  "types": "./dist/index.d.ts",
16
15
  "exports": {
@@ -27,37 +26,41 @@
27
26
  "import": "./dist/components.js"
28
27
  }
29
28
  },
30
- "files": [
31
- "dist"
32
- ],
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
33
32
  "scripts": {
34
- "build:worklets": "node build-processors.js",
35
- "build": "pnpm clean && node build-processors.js && vite build",
36
- "prepack": "pnpm build",
37
- "watch:processors": "node watch-processors.js",
38
- "watch": "pnpm build:worklets && concurrently \"vitest\" \"vite build --watch\" \"pnpm watch:processors\"",
33
+ "build:worklets": "vp node build-processors.js",
34
+ "build": "vp run clean && vp build",
35
+ "prepack": "vp run build",
36
+ "watch:processors": "vp node watch-processors.js",
37
+ "watch": "concurrently \"vp test watch\" \"vp build --watch\" \"vp run watch:processors\"",
39
38
  "clean": "rimraf dist",
40
- "test": "vitest run",
41
- "test:browser": "vitest run --config vitest.browser.config.ts",
42
- "test:coverage": "vitest run --coverage",
43
- "test:watch": "vitest",
44
- "test:all": "pnpm test && pnpm test:browser"
39
+ "test": "vp test run",
40
+ "test:browser": "vp test run --config vitest.browser.config.ts",
41
+ "test:coverage": "vp test run --coverage",
42
+ "test:watch": "vp test",
43
+ "test:all": "vp run test && vp run test:browser",
44
+ "prepare": "vp config"
45
45
  },
46
46
  "dependencies": {
47
47
  "webmidi": "^3.1.13"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/audioworklet": "^0.0.72",
51
+ "@types/node": "^24.13.3",
51
52
  "@types/webmidi": "^2.1.0",
52
- "@vitest/browser": "^3.2.4",
53
- "@vitest/coverage-v8": "3.2.4",
53
+ "@vitest/browser-playwright": "catalog:",
54
+ "@vitest/coverage-v8": "catalog:",
54
55
  "concurrently": "^9.1.2",
55
56
  "jsdom": "^26.0.0",
56
57
  "playwright": "^1.53.2",
57
58
  "rimraf": "^5.0.1",
58
59
  "typescript": "5.8.3",
59
- "vite": "^6.0.0",
60
+ "vite": "catalog:",
60
61
  "vite-plugin-dts": "^4.5.3",
61
- "vitest": "^3.2.4"
62
- }
62
+ "vite-plus": "catalog:",
63
+ "vitest": "catalog:"
64
+ },
65
+ "packageManager": "pnpm@11.5.2"
63
66
  }
@@ -1,167 +0,0 @@
1
- async function u() {
2
- try {
3
- return await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 }), (await navigator.mediaDevices.enumerateDevices()).map((a) => ({
4
- deviceId: a.deviceId,
5
- label: a.label,
6
- kind: a.kind
7
- }));
8
- } catch (e) {
9
- return console.error("Failed to enumerate devices:", e), [];
10
- }
11
- }
12
- async function f() {
13
- if (!navigator.requestMIDIAccess)
14
- throw new Error("MIDI access not supported in this browser");
15
- return navigator.requestMIDIAccess();
16
- }
17
- async function N(e = {
18
- echoCancellation: !1,
19
- noiseSuppression: !0,
20
- // ?
21
- autoGainControl: !0
22
- // ?
23
- }, a = "") {
24
- try {
25
- return await navigator.mediaDevices.getUserMedia({
26
- audio: a ? {
27
- ...e,
28
- deviceId: { exact: a }
29
- } : e
30
- });
31
- } catch (t) {
32
- if (a && t.name === "OverconstrainedError")
33
- return console.warn(
34
- "Requested audio input device unavailable, falling back to default"
35
- ), navigator.mediaDevices.getUserMedia({ audio: e });
36
- throw t;
37
- }
38
- }
39
- async function w(e = {
40
- width: 1280,
41
- height: 720,
42
- facingMode: "user"
43
- }) {
44
- return navigator.mediaDevices.getUserMedia({
45
- video: e
46
- });
47
- }
48
- async function M() {
49
- return (await u()).filter((a) => a.kind === "audioinput");
50
- }
51
- async function E() {
52
- return (await u()).filter((a) => a.kind === "audiooutput");
53
- }
54
- async function I() {
55
- return (await u()).filter((a) => a.kind === "videoinput");
56
- }
57
- function k(e) {
58
- return navigator.mediaDevices.addEventListener("devicechange", e), () => navigator.mediaDevices.removeEventListener("devicechange", e);
59
- }
60
- const g = {
61
- KeyZ: 48,
62
- KeyS: 49,
63
- KeyX: 50,
64
- KeyD: 51,
65
- KeyC: 52,
66
- KeyV: 53,
67
- KeyG: 54,
68
- KeyB: 55,
69
- KeyH: 56,
70
- KeyN: 57,
71
- KeyJ: 58,
72
- KeyM: 59,
73
- Comma: 60,
74
- KeyL: 61,
75
- Period: 62,
76
- Semicolon: 63,
77
- Slash: 64,
78
- KeyQ: 60,
79
- Digit2: 61,
80
- KeyW: 62,
81
- Digit3: 63,
82
- KeyE: 64,
83
- KeyR: 65,
84
- Digit5: 66,
85
- KeyT: 67,
86
- Digit6: 68,
87
- KeyY: 69,
88
- Digit7: 70,
89
- KeyU: 71,
90
- KeyI: 72,
91
- Digit9: 73,
92
- KeyO: 74,
93
- Digit0: 75,
94
- KeyP: 76,
95
- BracketLeft: 77,
96
- Equal: 78,
97
- BracketRight: 79,
98
- // Numpad
99
- Numpad1: 60,
100
- Numpad2: 62,
101
- Numpad3: 64,
102
- Numpad4: 65,
103
- Numpad5: 67,
104
- Numpad6: 69,
105
- Numpad7: 71,
106
- Numpad8: 72,
107
- Numpad9: 74
108
- };
109
- function n(e) {
110
- const { baseNote: a, scale: t } = e;
111
- if (t.length === 0)
112
- throw new RangeError("scale must contain at least one interval");
113
- const y = [
114
- ["KeyZ", "KeyX", "KeyC", "KeyV", "KeyB", "KeyN", "KeyM", "Comma", "Period", "Slash"],
115
- ["KeyA", "KeyS", "KeyD", "KeyF", "KeyG", "KeyH", "KeyJ", "KeyK", "KeyL", "Semicolon", "Quote", "Backslash"],
116
- ["KeyQ", "KeyW", "KeyE", "KeyR", "KeyT", "KeyY", "KeyU", "KeyI", "KeyO", "KeyP", "BracketLeft", "BracketRight"],
117
- ["Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "Digit0", "Minus", "Equal"]
118
- ], o = {};
119
- return y.forEach((s, i) => {
120
- const c = a + i * 12;
121
- s.forEach((r, d) => {
122
- const K = d % t.length, m = Math.floor(d / t.length);
123
- o[r] = c + m * 12 + t[K];
124
- });
125
- }), ["Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9"].forEach((s, i) => {
126
- const c = i % t.length, r = Math.floor(i / t.length);
127
- o[s] = a + 36 + r * 12 + t[c];
128
- }), o;
129
- }
130
- const p = n({
131
- baseNote: 36,
132
- scale: [0, 2, 4, 5, 7, 9, 11]
133
- }), v = n({
134
- baseNote: 36,
135
- scale: [0, 2, 3, 5, 7, 8, 10]
136
- }), l = n({
137
- baseNote: 36,
138
- scale: [0, 2, 4, 7, 9]
139
- // Major pentatonic
140
- }), D = n({
141
- baseNote: 48,
142
- scale: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
143
- }), b = "major", A = {
144
- piano: g,
145
- major: p,
146
- minor: v,
147
- pentatonic: l,
148
- chromatic: D
149
- };
150
- export {
151
- b as D,
152
- n as a,
153
- M as b,
154
- D as c,
155
- g as d,
156
- E as e,
157
- w as f,
158
- N as g,
159
- u as h,
160
- f as i,
161
- I as j,
162
- A as k,
163
- v as l,
164
- p as m,
165
- k as o,
166
- l as p
167
- };