@alexkroman1/aai-ui 1.16.0 → 3.0.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/_module-url-C_4gRVL0.js +15 -0
- package/dist/audio.d.ts +85 -11
- package/dist/audio.js +112 -83
- package/dist/chat-view-C1oJxsWz.js +129 -0
- package/dist/client-config.d.ts +6 -6
- package/dist/components/chat-view.d.ts +1 -8
- package/dist/components/chat-view.js +2 -2
- package/dist/components/console-shell.d.ts +37 -0
- package/dist/components/controls.js +1 -1
- package/dist/components/url-chips.d.ts +1 -4
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -4
- package/dist/{controls-BbZcmnJf.js → controls-DV368uhb.js} +2 -5
- package/dist/default-client/assets/_module-url-BX0RuRU2.js +1 -0
- package/dist/default-client/assets/audio-BGHiiDY_.js +1 -0
- package/dist/default-client/assets/capture-processor-BLPsqnGl.js +90 -0
- package/dist/default-client/assets/{index-BunwIXSP.js → index-DXf7-M0Q.js} +156 -36
- package/dist/default-client/assets/index-Dv-Q5VRL.css +2 -0
- package/dist/default-client/assets/playback-processor-B_T_1KQP.js +278 -0
- package/dist/default-client/index.html +2 -2
- package/dist/define-client-Cyf1jqAl.js +150 -0
- package/dist/define-client.d.ts +0 -9
- package/dist/define-client.js +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.js +7 -5
- package/dist/{session-core-B64kau_v.js → session-core-BM3WHeoY.js} +36 -128
- package/dist/session-core-messages.d.ts +0 -4
- package/dist/session-core-types.d.ts +1 -27
- package/dist/session-core.js +1 -1
- package/dist/types.d.ts +24 -1
- package/dist/types.js +32 -2
- package/dist/worklets/_module-url.d.ts +10 -0
- package/dist/worklets/capture-processor.d.ts +3 -3
- package/dist/worklets/capture-processor.js +35 -52
- package/dist/worklets/playback-processor.d.ts +3 -3
- package/dist/worklets/playback-processor.js +149 -26
- package/package.json +2 -2
- package/dist/chat-view-gi6FccZq.js +0 -193
- package/dist/components/sync-chat-view.d.ts +0 -18
- package/dist/components/text-controls.d.ts +0 -14
- package/dist/default-client/assets/audio-DNDZgEZp.js +0 -1
- package/dist/default-client/assets/capture-processor-UlKEKyIW.js +0 -108
- package/dist/default-client/assets/index-BogmeUln.css +0 -2
- package/dist/default-client/assets/playback-processor-C5HVRVbu.js +0 -156
- package/dist/define-client-DdpijqAu.js +0 -906
- package/dist/session-core-upload.d.ts +0 -16
- package/dist/sync-mic.d.ts +0 -93
- package/dist/sync-session.d.ts +0 -49
- package/dist/sync-vad.d.ts +0 -54
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
var e=new Blob([`
|
|
2
|
-
class PlaybackProcessor extends AudioWorkletProcessor {
|
|
3
|
-
constructor(options) {
|
|
4
|
-
super();
|
|
5
|
-
const rate = options.processorOptions?.sampleRate ?? 24000;
|
|
6
|
-
// Wait for ~400ms of audio before starting.
|
|
7
|
-
// If 'done' arrives first (short utterance), start immediately.
|
|
8
|
-
this.jitterSamples = Math.floor(rate * 0.4);
|
|
9
|
-
// Float32 ring buffer — 60s at the context sample rate. Allocated once for
|
|
10
|
-
// the node's lifetime; per-turn state resets via resetTurn(). writePos and
|
|
11
|
-
// readPos are absolute (monotonic) sample counts; the buffer is indexed
|
|
12
|
-
// modulo capacity so a reply longer than 60s keeps playing instead of
|
|
13
|
-
// writing past the end and going silent.
|
|
14
|
-
this.capacity = rate * 60;
|
|
15
|
-
this.samples = new Float32Array(this.capacity);
|
|
16
|
-
// Platform endianness probe: the wire format is PCM16 little-endian, so
|
|
17
|
-
// the Int16Array fast path in ingestBytes is only valid on LE hosts
|
|
18
|
-
// (every shipping browser target; the DataView path is the fallback).
|
|
19
|
-
this.littleEndian = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
20
|
-
this.resetTurn();
|
|
21
|
-
|
|
22
|
-
this.port.onmessage = (e) => {
|
|
23
|
-
const d = e.data;
|
|
24
|
-
if (d.event === 'write') {
|
|
25
|
-
this.ingestBytes(d.buffer);
|
|
26
|
-
} else if (d.event === 'interrupt') {
|
|
27
|
-
this.interrupted = true;
|
|
28
|
-
} else if (d.event === 'done') {
|
|
29
|
-
this.isDone = true;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Reset per-turn state so the node is reusable across replies without
|
|
35
|
-
// reallocating the sample buffer or re-instantiating the worklet.
|
|
36
|
-
resetTurn() {
|
|
37
|
-
this.interrupted = false;
|
|
38
|
-
this.isDone = false;
|
|
39
|
-
this.playing = false;
|
|
40
|
-
// Carry-over byte for split samples across chunks
|
|
41
|
-
this.carry = null;
|
|
42
|
-
this.writePos = 0;
|
|
43
|
-
this.readPos = 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// End the current turn: notify the host and rearm for the next reply.
|
|
47
|
-
// Must NOT return false from process() — a processor that stops is dead
|
|
48
|
-
// for good, forcing a new node (and buffer) per reply.
|
|
49
|
-
// \`reason\` ('interrupt' | 'done') tells the host which turn boundary this
|
|
50
|
-
// stop belongs to: interrupt-stops are dropped host-side (flush() already
|
|
51
|
-
// settled that turn), so they can never resolve a later turn's done() early.
|
|
52
|
-
stopTurn(reason) {
|
|
53
|
-
this.port.postMessage({ event: 'stop', reason });
|
|
54
|
-
this.resetTurn();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
ingestBytes(uint8) {
|
|
58
|
-
let bytes = uint8;
|
|
59
|
-
|
|
60
|
-
if (this.carry !== null) {
|
|
61
|
-
const merged = new Uint8Array(1 + bytes.length);
|
|
62
|
-
merged[0] = this.carry;
|
|
63
|
-
merged.set(bytes, 1);
|
|
64
|
-
bytes = merged;
|
|
65
|
-
this.carry = null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (bytes.length % 2 !== 0) {
|
|
69
|
-
this.carry = bytes[bytes.length - 1];
|
|
70
|
-
bytes = bytes.subarray(0, bytes.length - 1);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (bytes.length === 0) return;
|
|
74
|
-
const numSamples = bytes.length / 2;
|
|
75
|
-
const cap = this.capacity;
|
|
76
|
-
const samples = this.samples;
|
|
77
|
-
if (this.littleEndian && (bytes.byteOffset & 1) === 0) {
|
|
78
|
-
// Fast path: 2-byte-aligned LE bytes wrap directly as an Int16Array;
|
|
79
|
-
// copy wrap-aware in at most two runs with no per-sample DataView call
|
|
80
|
-
// or modulo. This runs on the realtime audio thread.
|
|
81
|
-
const int16 = new Int16Array(bytes.buffer, bytes.byteOffset, numSamples);
|
|
82
|
-
let src = 0;
|
|
83
|
-
let dst = this.writePos % cap;
|
|
84
|
-
while (src < numSamples) {
|
|
85
|
-
const run = Math.min(numSamples - src, cap - dst);
|
|
86
|
-
for (let j = 0; j < run; j++) {
|
|
87
|
-
samples[dst + j] = int16[src + j] / 0x8000;
|
|
88
|
-
}
|
|
89
|
-
src += run;
|
|
90
|
-
dst = 0;
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
// Odd byte offset (or big-endian host): fall back to per-sample reads.
|
|
94
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
95
|
-
let dst = this.writePos % cap;
|
|
96
|
-
for (let i = 0; i < numSamples; i++) {
|
|
97
|
-
samples[dst] = view.getInt16(i * 2, true) / 0x8000;
|
|
98
|
-
dst++;
|
|
99
|
-
if (dst === cap) dst = 0;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
this.writePos += numSamples;
|
|
103
|
-
// If the producer outran the consumer by more than the buffer holds, drop
|
|
104
|
-
// the oldest unplayed audio rather than reading samples we've overwritten.
|
|
105
|
-
if (this.writePos - this.readPos > this.capacity) {
|
|
106
|
-
this.readPos = this.writePos - this.capacity;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
process(inputs, outputs) {
|
|
111
|
-
// No output wired up yet — nothing to render this quantum. Throwing here
|
|
112
|
-
// would permanently kill the processor (the node is persistent per
|
|
113
|
-
// session), so guard like the capture processor does.
|
|
114
|
-
if (!outputs[0] || !outputs[0][0]) return true;
|
|
115
|
-
const out = outputs[0][0];
|
|
116
|
-
if (this.interrupted) {
|
|
117
|
-
out.fill(0);
|
|
118
|
-
this.stopTurn('interrupt');
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const avail = this.writePos - this.readPos;
|
|
123
|
-
|
|
124
|
-
// Wait for jitter buffer to fill, unless done (short utterance)
|
|
125
|
-
if (!this.playing) {
|
|
126
|
-
if (avail >= this.jitterSamples || this.isDone) {
|
|
127
|
-
this.playing = true;
|
|
128
|
-
} else {
|
|
129
|
-
out.fill(0);
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (avail > 0) {
|
|
135
|
-
const n = Math.min(avail, out.length);
|
|
136
|
-
// Copy from the ring buffer, splitting across the wrap boundary.
|
|
137
|
-
const start = this.readPos % this.capacity;
|
|
138
|
-
const first = Math.min(n, this.capacity - start);
|
|
139
|
-
out.set(this.samples.subarray(start, start + first), 0);
|
|
140
|
-
if (n > first) out.set(this.samples.subarray(0, n - first), first);
|
|
141
|
-
this.readPos += n;
|
|
142
|
-
out.fill(0, n);
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// No data: output silence, end the turn only when done
|
|
147
|
-
out.fill(0);
|
|
148
|
-
if (this.isDone) {
|
|
149
|
-
this.stopTurn('done');
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
registerProcessor('playback-processor', PlaybackProcessor);
|
|
156
|
-
`],{type:`application/javascript`}),t=URL.createObjectURL(e);export{t as default};
|