ugly-app 0.1.199 → 0.1.200
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/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/dist/client/audio/AudioPlayer.d.ts.map +1 -1
- package/dist/client/audio/AudioPlayer.js +43 -1
- package/dist/client/audio/AudioPlayer.js.map +1 -1
- package/dist/client/audio/AudioRecorder.d.ts.map +1 -1
- package/dist/client/audio/AudioRecorder.js +27 -1
- package/dist/client/audio/AudioRecorder.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/version.ts +1 -1
- package/src/client/audio/AudioPlayer.ts +43 -1
- package/src/client/audio/AudioRecorder.ts +27 -1
package/dist/cli/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.1.
|
|
1
|
+
export declare const CLI_VERSION = "0.1.200";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cli/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../../src/client/audio/AudioPlayer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../../src/client/audio/AudioPlayer.ts"],"names":[],"mappings":"AAsDA,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,QAAQ,CAAS;IAEzB,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQrB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAenD,IAAI,IAAI,IAAI;IAKN,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B"}
|
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
// src/client/audio/AudioPlayer.ts
|
|
2
|
-
const
|
|
2
|
+
const WORKLET_CODE = `
|
|
3
|
+
class PCM16Player extends AudioWorkletProcessor {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.queue = [];
|
|
7
|
+
this.buffer = new Float32Array(0);
|
|
8
|
+
this.offset = 0;
|
|
9
|
+
this.port.onmessage = (event) => this.handleMessage(event);
|
|
10
|
+
}
|
|
11
|
+
process(_inputs, outputs) {
|
|
12
|
+
const output = outputs[0]?.[0];
|
|
13
|
+
if (!output) return true;
|
|
14
|
+
let writePos = 0;
|
|
15
|
+
while (writePos < output.length) {
|
|
16
|
+
if (this.offset >= this.buffer.length) {
|
|
17
|
+
const next = this.queue.shift();
|
|
18
|
+
if (!next) { output.fill(0, writePos); break; }
|
|
19
|
+
this.buffer = next;
|
|
20
|
+
this.offset = 0;
|
|
21
|
+
}
|
|
22
|
+
const available = this.buffer.length - this.offset;
|
|
23
|
+
const needed = output.length - writePos;
|
|
24
|
+
const toCopy = Math.min(available, needed);
|
|
25
|
+
output.set(this.buffer.subarray(this.offset, this.offset + toCopy), writePos);
|
|
26
|
+
this.offset += toCopy;
|
|
27
|
+
writePos += toCopy;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
handleMessage(event) {
|
|
32
|
+
if (event.data?.type === 'chunk') {
|
|
33
|
+
this.queue.push(event.data.samples);
|
|
34
|
+
} else if (event.data?.type === 'stop') {
|
|
35
|
+
this.queue = [];
|
|
36
|
+
this.buffer = new Float32Array(0);
|
|
37
|
+
this.offset = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
registerProcessor('pcm16-player', PCM16Player);
|
|
42
|
+
`;
|
|
43
|
+
const WORKLET_BLOB = new Blob([WORKLET_CODE], { type: 'application/javascript' });
|
|
44
|
+
const WORKLET_URL = URL.createObjectURL(WORKLET_BLOB);
|
|
3
45
|
function pcm16ToFloat32(buffer) {
|
|
4
46
|
const int16 = new Int16Array(buffer);
|
|
5
47
|
const float32 = new Float32Array(int16.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioPlayer.js","sourceRoot":"","sources":["../../../src/client/audio/AudioPlayer.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"AudioPlayer.js","sourceRoot":"","sources":["../../../src/client/audio/AudioPlayer.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCpB,CAAC;AACF,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAClF,MAAM,WAAW,GAAG,GAAG,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAEtD,SAAS,cAAc,CAAC,MAAmB;IACzC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,OAAO,WAAW;IACd,GAAG,GAAwB,IAAI,CAAC;IAChC,WAAW,GAA4B,IAAI,CAAC;IAC5C,QAAQ,GAAG,KAAK,CAAC;IAEzB,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,WAAW;YAAE,OA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QACT,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.d.ts","sourceRoot":"","sources":["../../../src/client/audio/AudioRecorder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AudioRecorder.d.ts","sourceRoot":"","sources":["../../../src/client/audio/AudioRecorder.ts"],"names":[],"mappings":"AA8BA,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAA2C;IAE1D,IAAI,SAAS,IAAI,OAAO,CAEvB;IAEK,KAAK,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAgClE,IAAI,IAAI,IAAI;CAWb"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
// src/client/audio/AudioRecorder.ts
|
|
2
|
-
const
|
|
2
|
+
const WORKLET_CODE = `
|
|
3
|
+
const CHUNK_SAMPLES = 4096;
|
|
4
|
+
class RecorderProcessor extends AudioWorkletProcessor {
|
|
5
|
+
constructor() { super(); this.buffer = new Float32Array(CHUNK_SAMPLES); this.offset = 0; }
|
|
6
|
+
process(inputs) {
|
|
7
|
+
const input = inputs[0]?.[0];
|
|
8
|
+
if (!input) return true;
|
|
9
|
+
let readPos = 0;
|
|
10
|
+
while (readPos < input.length) {
|
|
11
|
+
const remaining = CHUNK_SAMPLES - this.offset;
|
|
12
|
+
const toCopy = Math.min(remaining, input.length - readPos);
|
|
13
|
+
this.buffer.set(input.subarray(readPos, readPos + toCopy), this.offset);
|
|
14
|
+
this.offset += toCopy;
|
|
15
|
+
readPos += toCopy;
|
|
16
|
+
if (this.offset >= CHUNK_SAMPLES) {
|
|
17
|
+
const chunk = this.buffer.slice();
|
|
18
|
+
this.port.postMessage({ type: 'chunk', samples: chunk }, [chunk.buffer]);
|
|
19
|
+
this.offset = 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
registerProcessor('audio-recorder', RecorderProcessor);
|
|
26
|
+
`;
|
|
27
|
+
const WORKLET_BLOB = new Blob([WORKLET_CODE], { type: 'application/javascript' });
|
|
28
|
+
const WORKLET_URL = URL.createObjectURL(WORKLET_BLOB);
|
|
3
29
|
const TARGET_SAMPLE_RATE = 48000;
|
|
4
30
|
export class AudioRecorder {
|
|
5
31
|
ctx = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.js","sourceRoot":"","sources":["../../../src/client/audio/AudioRecorder.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,MAAM,
|
|
1
|
+
{"version":3,"file":"AudioRecorder.js","sourceRoot":"","sources":["../../../src/client/audio/AudioRecorder.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBpB,CAAC;AACF,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAClF,MAAM,WAAW,GAAG,GAAG,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AACtD,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,MAAM,OAAO,aAAa;IAChB,GAAG,GAAwB,IAAI,CAAC;IAChC,MAAM,GAAuB,IAAI,CAAC;IAClC,OAAO,GAA4B,IAAI,CAAC;IACxC,UAAU,GAAG,KAAK,CAAC;IACnB,OA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C;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAmB;IAC9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QACnC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
package/src/cli/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by prebuild — do not edit manually
|
|
2
|
-
export const CLI_VERSION = "0.1.
|
|
2
|
+
export const CLI_VERSION = "0.1.200";
|
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
// src/client/audio/AudioPlayer.ts
|
|
2
|
-
const
|
|
2
|
+
const WORKLET_CODE = `
|
|
3
|
+
class PCM16Player extends AudioWorkletProcessor {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.queue = [];
|
|
7
|
+
this.buffer = new Float32Array(0);
|
|
8
|
+
this.offset = 0;
|
|
9
|
+
this.port.onmessage = (event) => this.handleMessage(event);
|
|
10
|
+
}
|
|
11
|
+
process(_inputs, outputs) {
|
|
12
|
+
const output = outputs[0]?.[0];
|
|
13
|
+
if (!output) return true;
|
|
14
|
+
let writePos = 0;
|
|
15
|
+
while (writePos < output.length) {
|
|
16
|
+
if (this.offset >= this.buffer.length) {
|
|
17
|
+
const next = this.queue.shift();
|
|
18
|
+
if (!next) { output.fill(0, writePos); break; }
|
|
19
|
+
this.buffer = next;
|
|
20
|
+
this.offset = 0;
|
|
21
|
+
}
|
|
22
|
+
const available = this.buffer.length - this.offset;
|
|
23
|
+
const needed = output.length - writePos;
|
|
24
|
+
const toCopy = Math.min(available, needed);
|
|
25
|
+
output.set(this.buffer.subarray(this.offset, this.offset + toCopy), writePos);
|
|
26
|
+
this.offset += toCopy;
|
|
27
|
+
writePos += toCopy;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
handleMessage(event) {
|
|
32
|
+
if (event.data?.type === 'chunk') {
|
|
33
|
+
this.queue.push(event.data.samples);
|
|
34
|
+
} else if (event.data?.type === 'stop') {
|
|
35
|
+
this.queue = [];
|
|
36
|
+
this.buffer = new Float32Array(0);
|
|
37
|
+
this.offset = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
registerProcessor('pcm16-player', PCM16Player);
|
|
42
|
+
`;
|
|
43
|
+
const WORKLET_BLOB = new Blob([WORKLET_CODE], { type: 'application/javascript' });
|
|
44
|
+
const WORKLET_URL = URL.createObjectURL(WORKLET_BLOB);
|
|
3
45
|
|
|
4
46
|
function pcm16ToFloat32(buffer: ArrayBuffer): Float32Array {
|
|
5
47
|
const int16 = new Int16Array(buffer);
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
// src/client/audio/AudioRecorder.ts
|
|
2
|
-
const
|
|
2
|
+
const WORKLET_CODE = `
|
|
3
|
+
const CHUNK_SAMPLES = 4096;
|
|
4
|
+
class RecorderProcessor extends AudioWorkletProcessor {
|
|
5
|
+
constructor() { super(); this.buffer = new Float32Array(CHUNK_SAMPLES); this.offset = 0; }
|
|
6
|
+
process(inputs) {
|
|
7
|
+
const input = inputs[0]?.[0];
|
|
8
|
+
if (!input) return true;
|
|
9
|
+
let readPos = 0;
|
|
10
|
+
while (readPos < input.length) {
|
|
11
|
+
const remaining = CHUNK_SAMPLES - this.offset;
|
|
12
|
+
const toCopy = Math.min(remaining, input.length - readPos);
|
|
13
|
+
this.buffer.set(input.subarray(readPos, readPos + toCopy), this.offset);
|
|
14
|
+
this.offset += toCopy;
|
|
15
|
+
readPos += toCopy;
|
|
16
|
+
if (this.offset >= CHUNK_SAMPLES) {
|
|
17
|
+
const chunk = this.buffer.slice();
|
|
18
|
+
this.port.postMessage({ type: 'chunk', samples: chunk }, [chunk.buffer]);
|
|
19
|
+
this.offset = 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
registerProcessor('audio-recorder', RecorderProcessor);
|
|
26
|
+
`;
|
|
27
|
+
const WORKLET_BLOB = new Blob([WORKLET_CODE], { type: 'application/javascript' });
|
|
28
|
+
const WORKLET_URL = URL.createObjectURL(WORKLET_BLOB);
|
|
3
29
|
const TARGET_SAMPLE_RATE = 48000;
|
|
4
30
|
|
|
5
31
|
export class AudioRecorder {
|