call-control-sdk 6.5.5-uat.4 → 6.5.5-uat.5
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/index.js +0 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/incoming-4WP3FJI4.mp3 +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2900,83 +2900,6 @@ function createMicController(constraints = { audio: true }) {
|
|
|
2900
2900
|
};
|
|
2901
2901
|
}
|
|
2902
2902
|
|
|
2903
|
-
// call-control-sdk/lib/utils/audioLoader.ts
|
|
2904
|
-
import incomingRingtoneUrl from "./incoming-4WP3FJI4.mp3";
|
|
2905
|
-
var audioBlobUrl = null;
|
|
2906
|
-
var audioBuffer = null;
|
|
2907
|
-
async function loadAudioAsBlob() {
|
|
2908
|
-
if (audioBlobUrl) {
|
|
2909
|
-
return audioBlobUrl;
|
|
2910
|
-
}
|
|
2911
|
-
if (incomingRingtoneUrl.startsWith("data:") || incomingRingtoneUrl.startsWith("http://") || incomingRingtoneUrl.startsWith("https://") || incomingRingtoneUrl.startsWith("blob:")) {
|
|
2912
|
-
return incomingRingtoneUrl;
|
|
2913
|
-
}
|
|
2914
|
-
try {
|
|
2915
|
-
const response = await fetch(incomingRingtoneUrl);
|
|
2916
|
-
if (!response.ok) {
|
|
2917
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
2918
|
-
}
|
|
2919
|
-
const blob = await response.blob();
|
|
2920
|
-
if (blob.size === 0) {
|
|
2921
|
-
throw new Error("Empty blob");
|
|
2922
|
-
}
|
|
2923
|
-
audioBlobUrl = URL.createObjectURL(blob);
|
|
2924
|
-
return audioBlobUrl;
|
|
2925
|
-
} catch (error) {
|
|
2926
|
-
console.error("Could not create blob URL, using direct URL:", error);
|
|
2927
|
-
return incomingRingtoneUrl;
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
async function createAudioElement() {
|
|
2931
|
-
const audio = new Audio();
|
|
2932
|
-
audio.loop = true;
|
|
2933
|
-
audio.volume = 0.7;
|
|
2934
|
-
audio.preload = "auto";
|
|
2935
|
-
let audioUrl = "";
|
|
2936
|
-
try {
|
|
2937
|
-
audioUrl = await loadAudioAsBlob();
|
|
2938
|
-
} catch (error) {
|
|
2939
|
-
console.warn("Failed to load audio as blob, trying direct URL:", error);
|
|
2940
|
-
audioUrl = incomingRingtoneUrl;
|
|
2941
|
-
}
|
|
2942
|
-
const tryLoadAudio = async (url) => {
|
|
2943
|
-
return new Promise((resolve) => {
|
|
2944
|
-
const checkCanPlay = () => {
|
|
2945
|
-
const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
|
|
2946
|
-
if (canPlay) {
|
|
2947
|
-
resolve(true);
|
|
2948
|
-
return;
|
|
2949
|
-
}
|
|
2950
|
-
if (audio.error) {
|
|
2951
|
-
resolve(false);
|
|
2952
|
-
return;
|
|
2953
|
-
}
|
|
2954
|
-
setTimeout(checkCanPlay, 100);
|
|
2955
|
-
};
|
|
2956
|
-
audio.addEventListener("canplay", () => resolve(true), { once: true });
|
|
2957
|
-
audio.addEventListener("error", () => resolve(false), { once: true });
|
|
2958
|
-
audio.src = url;
|
|
2959
|
-
audio.load();
|
|
2960
|
-
setTimeout(() => resolve(false), 2e3);
|
|
2961
|
-
});
|
|
2962
|
-
};
|
|
2963
|
-
let loaded = await tryLoadAudio(audioUrl);
|
|
2964
|
-
if (!loaded && audioUrl !== incomingRingtoneUrl) {
|
|
2965
|
-
loaded = await tryLoadAudio(incomingRingtoneUrl);
|
|
2966
|
-
if (loaded) {
|
|
2967
|
-
audioUrl = incomingRingtoneUrl;
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
return audio;
|
|
2971
|
-
}
|
|
2972
|
-
function cleanupAudioResources() {
|
|
2973
|
-
if (audioBlobUrl) {
|
|
2974
|
-
URL.revokeObjectURL(audioBlobUrl);
|
|
2975
|
-
audioBlobUrl = null;
|
|
2976
|
-
}
|
|
2977
|
-
audioBuffer = null;
|
|
2978
|
-
}
|
|
2979
|
-
|
|
2980
2903
|
// call-control-sdk/lib/components/callControls.tsx
|
|
2981
2904
|
import { getItem as getItem5 } from "@react-solutions/vault";
|
|
2982
2905
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
@@ -3020,7 +2943,6 @@ function CallControls({ onDataChange }) {
|
|
|
3020
2943
|
});
|
|
3021
2944
|
const micRef = useRef2(null);
|
|
3022
2945
|
const webSocketRef = useRef2(null);
|
|
3023
|
-
const audioRef = useRef2(null);
|
|
3024
2946
|
const reconnectTimeoutRef = useRef2(null);
|
|
3025
2947
|
const pingIntervalRef = useRef2(null);
|
|
3026
2948
|
const reconnectAttemptsRef = useRef2(0);
|
|
@@ -3281,22 +3203,6 @@ function CallControls({ onDataChange }) {
|
|
|
3281
3203
|
if (wrapUpinterval) clearInterval(wrapUpinterval);
|
|
3282
3204
|
};
|
|
3283
3205
|
}, [state.callData.status]);
|
|
3284
|
-
useEffect5(() => {
|
|
3285
|
-
createAudioElement().then((audio) => {
|
|
3286
|
-
audioRef.current = audio;
|
|
3287
|
-
}).catch((error) => {
|
|
3288
|
-
console.error("Failed to load audio element:", error);
|
|
3289
|
-
});
|
|
3290
|
-
return () => {
|
|
3291
|
-
if (audioRef.current) {
|
|
3292
|
-
audioRef.current.pause();
|
|
3293
|
-
audioRef.current.currentTime = 0;
|
|
3294
|
-
audioRef.current.src = "";
|
|
3295
|
-
audioRef.current = null;
|
|
3296
|
-
}
|
|
3297
|
-
cleanupAudioResources();
|
|
3298
|
-
};
|
|
3299
|
-
}, []);
|
|
3300
3206
|
useEffect5(() => {
|
|
3301
3207
|
if (onDataChange && state.callData) {
|
|
3302
3208
|
const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
|
|
@@ -3445,16 +3351,6 @@ function CallControls({ onDataChange }) {
|
|
|
3445
3351
|
isMergeCall: false
|
|
3446
3352
|
}
|
|
3447
3353
|
]);
|
|
3448
|
-
if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current) {
|
|
3449
|
-
audioRef.current.play().catch((error) => {
|
|
3450
|
-
console.error("Failed to play ringtone:", error);
|
|
3451
|
-
});
|
|
3452
|
-
}
|
|
3453
|
-
} else {
|
|
3454
|
-
if (audioRef.current) {
|
|
3455
|
-
audioRef.current.pause();
|
|
3456
|
-
audioRef.current.currentTime = 0;
|
|
3457
|
-
}
|
|
3458
3354
|
}
|
|
3459
3355
|
if (data.status === "ONCALL" /* ONCALL */) {
|
|
3460
3356
|
sdkStateManager.startCall();
|