@oxvo/ai-live-assist 7.4.50 → 7.5.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/cjs/AiLiveAssist.d.ts +76 -11
- package/cjs/AiLiveAssist.js +1771 -298
- package/cjs/client.d.ts +19 -0
- package/cjs/client.js +51 -0
- package/cjs/context.d.ts +23 -1
- package/cjs/context.js +713 -126
- package/cjs/control.d.ts +2 -0
- package/cjs/control.js +42 -3
- package/cjs/ctaOffer.d.ts +11 -0
- package/cjs/ctaOffer.js +185 -0
- package/cjs/dialogFocusScope.js +1 -1
- package/cjs/guideAdmission.d.ts +46 -0
- package/cjs/guideAdmission.js +397 -0
- package/cjs/guideHost.d.ts +47 -0
- package/cjs/guideHost.js +48 -0
- package/cjs/guideInstallation.d.ts +12 -0
- package/cjs/guideInstallation.js +60 -0
- package/cjs/guideInstaller.d.ts +4 -0
- package/cjs/guideInstaller.js +116 -0
- package/cjs/guideMount.d.ts +22 -0
- package/cjs/guideMount.js +84 -0
- package/cjs/guideRecording.d.ts +64 -0
- package/cjs/guideRecording.js +176 -0
- package/cjs/guideRecordingSession.d.ts +35 -0
- package/cjs/guideRecordingSession.js +167 -0
- package/cjs/guideSubjectStore.d.ts +32 -0
- package/cjs/guideSubjectStore.js +105 -0
- package/cjs/guideTypes.d.ts +117 -0
- package/cjs/guideTypes.js +15 -0
- package/cjs/index.d.ts +6 -0
- package/cjs/index.js +25 -11
- package/cjs/liveAudioProcessor.d.ts +92 -0
- package/cjs/liveAudioProcessor.js +269 -0
- package/cjs/liveAudioQueue.d.ts +40 -0
- package/cjs/liveAudioQueue.js +130 -0
- package/cjs/liveAudioWorklet.d.ts +1 -0
- package/cjs/liveAudioWorklet.js +63 -0
- package/cjs/liveBrowserDetector.d.ts +16 -0
- package/cjs/liveBrowserDetector.js +75 -0
- package/cjs/liveBrowserDetectorWorker.d.ts +1 -0
- package/cjs/liveBrowserDetectorWorker.js +72 -0
- package/cjs/liveControlChannel.d.ts +176 -0
- package/cjs/liveControlChannel.js +829 -0
- package/cjs/liveDuplexMedia.d.ts +204 -0
- package/cjs/liveDuplexMedia.js +740 -0
- package/cjs/liveGuideAdmission.d.ts +21 -0
- package/cjs/liveGuideAdmission.js +94 -0
- package/cjs/liveGuideWidget.d.ts +68 -0
- package/cjs/liveGuideWidget.js +451 -0
- package/cjs/liveSpeechAssets.d.ts +36 -0
- package/cjs/liveSpeechAssets.js +39 -0
- package/cjs/liveSpeechCaptureBridge.d.ts +32 -0
- package/cjs/liveSpeechCaptureBridge.js +140 -0
- package/cjs/liveSpeechDetector.d.ts +62 -0
- package/cjs/liveSpeechDetector.js +206 -0
- package/cjs/liveSpeechModel.d.ts +46 -0
- package/cjs/liveSpeechModel.js +105 -0
- package/cjs/liveSpeechResampler.d.ts +22 -0
- package/cjs/liveSpeechResampler.js +93 -0
- package/cjs/liveSpeechWorker.d.ts +56 -0
- package/cjs/liveSpeechWorker.js +143 -0
- package/cjs/locales/resources.js +568 -8
- package/cjs/media.d.ts +11 -0
- package/cjs/media.js +78 -9
- package/cjs/messages.js +22 -8
- package/cjs/pageAssistancePreference.d.ts +15 -3
- package/cjs/pageAssistancePreference.js +46 -7
- package/cjs/preview.d.ts +4 -1
- package/cjs/preview.js +42 -1
- package/cjs/recording.d.ts +12 -0
- package/cjs/recording.js +150 -0
- package/cjs/standalone.d.ts +6 -0
- package/cjs/standalone.js +12 -0
- package/cjs/types.d.ts +31 -5
- package/cjs/types.js +14 -0
- package/cjs/ui.d.ts +128 -4
- package/cjs/ui.js +1918 -276
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/cjs/voicePresenceUi.d.ts +52 -4
- package/cjs/voicePresenceUi.js +659 -57
- package/lib/AiLiveAssist.d.ts +76 -11
- package/lib/AiLiveAssist.js +1772 -299
- package/lib/client.d.ts +19 -0
- package/lib/client.js +51 -0
- package/lib/context.d.ts +23 -1
- package/lib/context.js +713 -126
- package/lib/control.d.ts +2 -0
- package/lib/control.js +42 -3
- package/lib/ctaOffer.d.ts +11 -0
- package/lib/ctaOffer.js +179 -0
- package/lib/dialogFocusScope.js +1 -1
- package/lib/guideAdmission.d.ts +46 -0
- package/lib/guideAdmission.js +392 -0
- package/lib/guideHost.d.ts +47 -0
- package/lib/guideHost.js +42 -0
- package/lib/guideInstallation.d.ts +12 -0
- package/lib/guideInstallation.js +56 -0
- package/lib/guideInstaller.d.ts +4 -0
- package/lib/guideInstaller.js +113 -0
- package/lib/guideMount.d.ts +22 -0
- package/lib/guideMount.js +77 -0
- package/lib/guideRecording.d.ts +64 -0
- package/lib/guideRecording.js +172 -0
- package/lib/guideRecordingSession.d.ts +35 -0
- package/lib/guideRecordingSession.js +163 -0
- package/lib/guideSubjectStore.d.ts +32 -0
- package/lib/guideSubjectStore.js +101 -0
- package/lib/guideTypes.d.ts +117 -0
- package/lib/guideTypes.js +11 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +21 -10
- package/lib/liveAudioProcessor.d.ts +92 -0
- package/lib/liveAudioProcessor.js +265 -0
- package/lib/liveAudioQueue.d.ts +40 -0
- package/lib/liveAudioQueue.js +126 -0
- package/lib/liveAudioWorklet.d.ts +1 -0
- package/lib/liveAudioWorklet.js +61 -0
- package/lib/liveBrowserDetector.d.ts +16 -0
- package/lib/liveBrowserDetector.js +71 -0
- package/lib/liveBrowserDetectorWorker.d.ts +1 -0
- package/lib/liveBrowserDetectorWorker.js +70 -0
- package/lib/liveControlChannel.d.ts +176 -0
- package/lib/liveControlChannel.js +825 -0
- package/lib/liveDuplexMedia.d.ts +204 -0
- package/lib/liveDuplexMedia.js +736 -0
- package/lib/liveGuideAdmission.d.ts +21 -0
- package/lib/liveGuideAdmission.js +90 -0
- package/lib/liveGuideWidget.d.ts +68 -0
- package/lib/liveGuideWidget.js +447 -0
- package/lib/liveSpeechAssets.d.ts +36 -0
- package/lib/liveSpeechAssets.js +35 -0
- package/lib/liveSpeechCaptureBridge.d.ts +32 -0
- package/lib/liveSpeechCaptureBridge.js +136 -0
- package/lib/liveSpeechDetector.d.ts +62 -0
- package/lib/liveSpeechDetector.js +202 -0
- package/lib/liveSpeechModel.d.ts +46 -0
- package/lib/liveSpeechModel.js +101 -0
- package/lib/liveSpeechResampler.d.ts +22 -0
- package/lib/liveSpeechResampler.js +89 -0
- package/lib/liveSpeechWorker.d.ts +56 -0
- package/lib/liveSpeechWorker.js +137 -0
- package/lib/locales/resources.js +568 -8
- package/lib/media.d.ts +11 -0
- package/lib/media.js +77 -8
- package/lib/messages.js +22 -8
- package/lib/pageAssistancePreference.d.ts +15 -3
- package/lib/pageAssistancePreference.js +46 -7
- package/lib/preview.d.ts +4 -1
- package/lib/preview.js +42 -1
- package/lib/recording.d.ts +12 -0
- package/lib/recording.js +146 -0
- package/lib/standalone.d.ts +6 -0
- package/lib/standalone.js +6 -0
- package/lib/types.d.ts +31 -5
- package/lib/types.js +14 -0
- package/lib/ui.d.ts +128 -4
- package/lib/ui.js +1919 -277
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/voicePresenceUi.d.ts +52 -4
- package/lib/voicePresenceUi.js +659 -57
- package/package.json +16 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const OUTPUT_RATE = 16000;
|
|
2
|
+
const FRAME_SIZE = 512;
|
|
3
|
+
const TAPS = 64;
|
|
4
|
+
const PHASES = 256;
|
|
5
|
+
/** Detector-only causal windowed-sinc resampler. Never modifies the source PCM. */
|
|
6
|
+
export class LiveSpeechResampler {
|
|
7
|
+
constructor(sampleRate) {
|
|
8
|
+
this.sampleRate = sampleRate;
|
|
9
|
+
this.coefficients = new Float32Array(TAPS * PHASES);
|
|
10
|
+
this.history = new Float32Array(TAPS);
|
|
11
|
+
this.frame = new Float32Array(FRAME_SIZE);
|
|
12
|
+
this.frameSize = 0;
|
|
13
|
+
this.inputCount = 0;
|
|
14
|
+
this.sourceBase = null;
|
|
15
|
+
this.outputCount = 0;
|
|
16
|
+
this.closed = false;
|
|
17
|
+
if (!Number.isSafeInteger(sampleRate) || sampleRate < 8000 || sampleRate > 96000) {
|
|
18
|
+
throw new Error('Invalid detector sample rate.');
|
|
19
|
+
}
|
|
20
|
+
// Leave a transition band below the smaller Nyquist frequency. This FIR's
|
|
21
|
+
// group delay is 31.5 source samples; it affects detection, never sent audio.
|
|
22
|
+
const cutoff = 0.45 * Math.min(1, OUTPUT_RATE / sampleRate);
|
|
23
|
+
for (let phase = 0; phase < PHASES; phase++) {
|
|
24
|
+
let sum = 0;
|
|
25
|
+
for (let tap = 0; tap < TAPS; tap++) {
|
|
26
|
+
const distance = tap + phase / PHASES - (TAPS - 1) / 2;
|
|
27
|
+
const sinc = distance === 0 ? 2 * cutoff : Math.sin(2 * Math.PI * cutoff * distance) / (Math.PI * distance);
|
|
28
|
+
const window = 0.42 - 0.5 * Math.cos(2 * Math.PI * tap / (TAPS - 1)) +
|
|
29
|
+
0.08 * Math.cos(4 * Math.PI * tap / (TAPS - 1));
|
|
30
|
+
const value = sinc * window;
|
|
31
|
+
this.coefficients[phase * TAPS + tap] = value;
|
|
32
|
+
sum += value;
|
|
33
|
+
}
|
|
34
|
+
for (let tap = 0; tap < TAPS; tap++)
|
|
35
|
+
this.coefficients[phase * TAPS + tap] /= sum;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
get pcmBytes() { return this.closed ? 0 : this.history.byteLength + this.frame.byteLength; }
|
|
39
|
+
push(input, sourceStart, emit) {
|
|
40
|
+
if (this.closed)
|
|
41
|
+
return false;
|
|
42
|
+
if (!(input instanceof Float32Array) || input.length < 1 || input.length > 4096 ||
|
|
43
|
+
!Number.isSafeInteger(sourceStart) || sourceStart < 0 || sourceStart !== (this.sourceBase ?? sourceStart) + this.inputCount ||
|
|
44
|
+
!Number.isSafeInteger(sourceStart + input.length))
|
|
45
|
+
return this.fail();
|
|
46
|
+
// Validate the entire quantum before producing any partial output.
|
|
47
|
+
for (const sample of input)
|
|
48
|
+
if (!Number.isFinite(sample) || Math.abs(sample) > 1)
|
|
49
|
+
return this.fail();
|
|
50
|
+
this.sourceBase ?? (this.sourceBase = sourceStart);
|
|
51
|
+
for (const sample of input) {
|
|
52
|
+
const index = this.inputCount++;
|
|
53
|
+
this.history[index % TAPS] = sample;
|
|
54
|
+
while (Math.floor(this.outputCount * this.sampleRate / OUTPUT_RATE) <= index) {
|
|
55
|
+
const position = this.outputCount * this.sampleRate / OUTPUT_RATE;
|
|
56
|
+
const whole = Math.floor(position);
|
|
57
|
+
const phase = Math.min(PHASES - 1, Math.floor((position - whole) * PHASES));
|
|
58
|
+
let filtered = 0;
|
|
59
|
+
for (let tap = 0; tap < TAPS; tap++) {
|
|
60
|
+
const source = whole - tap;
|
|
61
|
+
if (source >= 0)
|
|
62
|
+
filtered += this.history[source % TAPS] * this.coefficients[phase * TAPS + tap];
|
|
63
|
+
}
|
|
64
|
+
this.outputCount++;
|
|
65
|
+
// A windowed reconstruction can overshoot slightly; normalize only this
|
|
66
|
+
// detector copy, never the native-rate buffer used for transmission.
|
|
67
|
+
this.frame[this.frameSize++] = Math.max(-1, Math.min(1, filtered));
|
|
68
|
+
if (this.frameSize === FRAME_SIZE) {
|
|
69
|
+
const completed = this.frame;
|
|
70
|
+
this.frame = new Float32Array(FRAME_SIZE);
|
|
71
|
+
this.frameSize = 0;
|
|
72
|
+
if (!emit({ samples: completed, sourceEnd: this.sourceBase + index + 1 })) {
|
|
73
|
+
completed.fill(0);
|
|
74
|
+
return this.fail();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
close() {
|
|
82
|
+
this.closed = true;
|
|
83
|
+
this.history.fill(0);
|
|
84
|
+
this.frame.fill(0);
|
|
85
|
+
this.frame = new Float32Array(0);
|
|
86
|
+
this.frameSize = 0;
|
|
87
|
+
}
|
|
88
|
+
fail() { this.close(); return false; }
|
|
89
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { LocalSpeechModel } from './liveSpeechModel.js';
|
|
2
|
+
export type LiveSpeechRequest = {
|
|
3
|
+
type: 'init';
|
|
4
|
+
epoch: number;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'frame';
|
|
7
|
+
epoch: number;
|
|
8
|
+
sequence: number;
|
|
9
|
+
sourceEnd: number;
|
|
10
|
+
samples: ArrayBuffer;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'reset';
|
|
13
|
+
epoch: number;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'close';
|
|
16
|
+
};
|
|
17
|
+
export type LiveSpeechReply = {
|
|
18
|
+
type: 'ready';
|
|
19
|
+
epoch: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'result';
|
|
22
|
+
epoch: number;
|
|
23
|
+
sequence: number;
|
|
24
|
+
sourceEnd: number;
|
|
25
|
+
probability: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'unhealthy';
|
|
28
|
+
reason: 'protocol' | 'model';
|
|
29
|
+
} | {
|
|
30
|
+
type: 'closed';
|
|
31
|
+
};
|
|
32
|
+
export declare function isLiveSpeechEpoch(value: unknown): value is number;
|
|
33
|
+
/** Bootstrap from an explicitly created dedicated worker; never installed at import time. */
|
|
34
|
+
export declare function installLiveSpeechWorker(scope: {
|
|
35
|
+
postMessage(reply: LiveSpeechReply): void;
|
|
36
|
+
addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
37
|
+
removeEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
38
|
+
}, createModel: () => Promise<LocalSpeechModel>): () => void;
|
|
39
|
+
/** Explicit worker-side engine: no implicit worker registration, capture, or timers. */
|
|
40
|
+
export declare class LiveSpeechWorkerEngine {
|
|
41
|
+
private readonly createModel;
|
|
42
|
+
private readonly emit;
|
|
43
|
+
private epoch;
|
|
44
|
+
private expectedSequence;
|
|
45
|
+
private sourceEnd;
|
|
46
|
+
private model;
|
|
47
|
+
private initialized;
|
|
48
|
+
private busy;
|
|
49
|
+
private resetPending;
|
|
50
|
+
private closed;
|
|
51
|
+
private disposed;
|
|
52
|
+
constructor(createModel: () => Promise<LocalSpeechModel>, emit: (reply: LiveSpeechReply) => void);
|
|
53
|
+
receive(raw: unknown): void;
|
|
54
|
+
private settle;
|
|
55
|
+
private fail;
|
|
56
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export function isLiveSpeechEpoch(value) {
|
|
2
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
3
|
+
}
|
|
4
|
+
/** Bootstrap from an explicitly created dedicated worker; never installed at import time. */
|
|
5
|
+
export function installLiveSpeechWorker(scope, createModel) {
|
|
6
|
+
const engine = new LiveSpeechWorkerEngine(createModel, reply => scope.postMessage(reply));
|
|
7
|
+
const listener = (event) => engine.receive(event.data);
|
|
8
|
+
scope.addEventListener('message', listener);
|
|
9
|
+
return () => {
|
|
10
|
+
scope.removeEventListener('message', listener);
|
|
11
|
+
engine.receive({ type: 'close' });
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Explicit worker-side engine: no implicit worker registration, capture, or timers. */
|
|
15
|
+
export class LiveSpeechWorkerEngine {
|
|
16
|
+
constructor(createModel, emit) {
|
|
17
|
+
this.createModel = createModel;
|
|
18
|
+
this.emit = emit;
|
|
19
|
+
this.epoch = -1;
|
|
20
|
+
this.expectedSequence = 0;
|
|
21
|
+
this.sourceEnd = 0;
|
|
22
|
+
this.model = null;
|
|
23
|
+
this.initialized = false;
|
|
24
|
+
this.busy = false;
|
|
25
|
+
this.resetPending = false;
|
|
26
|
+
this.closed = false;
|
|
27
|
+
this.disposed = false;
|
|
28
|
+
}
|
|
29
|
+
receive(raw) {
|
|
30
|
+
if (this.closed)
|
|
31
|
+
return;
|
|
32
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
33
|
+
return this.fail('protocol');
|
|
34
|
+
const message = raw;
|
|
35
|
+
if (message.type === 'close') {
|
|
36
|
+
this.closed = true;
|
|
37
|
+
void this.settle();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!isLiveSpeechEpoch(message.epoch))
|
|
41
|
+
return this.fail('protocol');
|
|
42
|
+
if (message.type === 'init') {
|
|
43
|
+
if (this.initialized)
|
|
44
|
+
return this.fail('protocol');
|
|
45
|
+
this.initialized = true;
|
|
46
|
+
this.epoch = message.epoch;
|
|
47
|
+
this.busy = true;
|
|
48
|
+
void Promise.resolve().then(() => this.createModel()).then(model => { this.model = model; })
|
|
49
|
+
.catch(() => this.fail('model')).finally(() => {
|
|
50
|
+
this.busy = false;
|
|
51
|
+
if (!this.closed && !this.resetPending)
|
|
52
|
+
this.emit({ type: 'ready', epoch: this.epoch });
|
|
53
|
+
void this.settle();
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!this.initialized)
|
|
58
|
+
return this.fail('protocol');
|
|
59
|
+
if (message.type === 'reset') {
|
|
60
|
+
if (message.epoch <= this.epoch)
|
|
61
|
+
return;
|
|
62
|
+
this.epoch = message.epoch;
|
|
63
|
+
this.expectedSequence = 0;
|
|
64
|
+
this.sourceEnd = 0;
|
|
65
|
+
this.resetPending = true;
|
|
66
|
+
void this.settle();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (message.epoch < this.epoch)
|
|
70
|
+
return; // Old transferred frames cannot affect a new capture epoch.
|
|
71
|
+
if (message.type !== 'frame' || message.epoch !== this.epoch || this.busy || this.resetPending || !this.model ||
|
|
72
|
+
message.sequence !== this.expectedSequence || !isLiveSpeechEpoch(message.sourceEnd) || message.sourceEnd <= this.sourceEnd ||
|
|
73
|
+
!(message.samples instanceof ArrayBuffer) || message.samples.byteLength !== 512 * 4)
|
|
74
|
+
return this.fail('protocol');
|
|
75
|
+
const frame = new Float32Array(message.samples);
|
|
76
|
+
if (frame.some(value => !Number.isFinite(value) || Math.abs(value) > 1)) {
|
|
77
|
+
frame.fill(0);
|
|
78
|
+
return this.fail('protocol');
|
|
79
|
+
}
|
|
80
|
+
const epoch = this.epoch;
|
|
81
|
+
const sequence = this.expectedSequence++;
|
|
82
|
+
const sourceEnd = message.sourceEnd;
|
|
83
|
+
this.sourceEnd = sourceEnd;
|
|
84
|
+
this.busy = true;
|
|
85
|
+
const model = this.model;
|
|
86
|
+
let result = null;
|
|
87
|
+
void Promise.resolve().then(() => model.process(frame)).then(probability => {
|
|
88
|
+
if (!Number.isFinite(probability) || probability < 0 || probability > 1)
|
|
89
|
+
return this.fail('model');
|
|
90
|
+
result = probability;
|
|
91
|
+
}).catch(() => this.fail('model')).finally(() => {
|
|
92
|
+
frame.fill(0);
|
|
93
|
+
this.busy = false;
|
|
94
|
+
if (!this.closed && epoch === this.epoch && result !== null) {
|
|
95
|
+
this.emit({ type: 'result', epoch, sequence, sourceEnd, probability: result });
|
|
96
|
+
}
|
|
97
|
+
void this.settle();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async settle() {
|
|
101
|
+
if (this.busy)
|
|
102
|
+
return;
|
|
103
|
+
if (this.closed) {
|
|
104
|
+
if (this.disposed)
|
|
105
|
+
return;
|
|
106
|
+
this.disposed = true;
|
|
107
|
+
await this.model?.close().catch(() => undefined);
|
|
108
|
+
this.model = null;
|
|
109
|
+
this.emit({ type: 'closed' });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!this.resetPending || !this.model)
|
|
113
|
+
return;
|
|
114
|
+
this.busy = true;
|
|
115
|
+
this.resetPending = false;
|
|
116
|
+
const epoch = this.epoch;
|
|
117
|
+
try {
|
|
118
|
+
await this.model.reset();
|
|
119
|
+
if (!this.closed && epoch === this.epoch)
|
|
120
|
+
this.emit({ type: 'ready', epoch });
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
this.fail('model');
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
this.busy = false;
|
|
127
|
+
void this.settle();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
fail(reason) {
|
|
131
|
+
if (this.closed)
|
|
132
|
+
return;
|
|
133
|
+
this.closed = true;
|
|
134
|
+
this.emit({ type: 'unhealthy', reason });
|
|
135
|
+
void this.settle();
|
|
136
|
+
}
|
|
137
|
+
}
|