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.js
CHANGED
|
@@ -2875,83 +2875,6 @@ function createMicController(constraints = { audio: true }) {
|
|
|
2875
2875
|
};
|
|
2876
2876
|
}
|
|
2877
2877
|
|
|
2878
|
-
// call-control-sdk/lib/utils/audioLoader.ts
|
|
2879
|
-
var import_incoming = __toESM(require("./incoming-4WP3FJI4.mp3"));
|
|
2880
|
-
var audioBlobUrl = null;
|
|
2881
|
-
var audioBuffer = null;
|
|
2882
|
-
async function loadAudioAsBlob() {
|
|
2883
|
-
if (audioBlobUrl) {
|
|
2884
|
-
return audioBlobUrl;
|
|
2885
|
-
}
|
|
2886
|
-
if (import_incoming.default.startsWith("data:") || import_incoming.default.startsWith("http://") || import_incoming.default.startsWith("https://") || import_incoming.default.startsWith("blob:")) {
|
|
2887
|
-
return import_incoming.default;
|
|
2888
|
-
}
|
|
2889
|
-
try {
|
|
2890
|
-
const response = await fetch(import_incoming.default);
|
|
2891
|
-
if (!response.ok) {
|
|
2892
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
2893
|
-
}
|
|
2894
|
-
const blob = await response.blob();
|
|
2895
|
-
if (blob.size === 0) {
|
|
2896
|
-
throw new Error("Empty blob");
|
|
2897
|
-
}
|
|
2898
|
-
audioBlobUrl = URL.createObjectURL(blob);
|
|
2899
|
-
return audioBlobUrl;
|
|
2900
|
-
} catch (error) {
|
|
2901
|
-
console.error("Could not create blob URL, using direct URL:", error);
|
|
2902
|
-
return import_incoming.default;
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
2905
|
-
async function createAudioElement() {
|
|
2906
|
-
const audio = new Audio();
|
|
2907
|
-
audio.loop = true;
|
|
2908
|
-
audio.volume = 0.7;
|
|
2909
|
-
audio.preload = "auto";
|
|
2910
|
-
let audioUrl = "";
|
|
2911
|
-
try {
|
|
2912
|
-
audioUrl = await loadAudioAsBlob();
|
|
2913
|
-
} catch (error) {
|
|
2914
|
-
console.warn("Failed to load audio as blob, trying direct URL:", error);
|
|
2915
|
-
audioUrl = import_incoming.default;
|
|
2916
|
-
}
|
|
2917
|
-
const tryLoadAudio = async (url) => {
|
|
2918
|
-
return new Promise((resolve) => {
|
|
2919
|
-
const checkCanPlay = () => {
|
|
2920
|
-
const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
|
|
2921
|
-
if (canPlay) {
|
|
2922
|
-
resolve(true);
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
if (audio.error) {
|
|
2926
|
-
resolve(false);
|
|
2927
|
-
return;
|
|
2928
|
-
}
|
|
2929
|
-
setTimeout(checkCanPlay, 100);
|
|
2930
|
-
};
|
|
2931
|
-
audio.addEventListener("canplay", () => resolve(true), { once: true });
|
|
2932
|
-
audio.addEventListener("error", () => resolve(false), { once: true });
|
|
2933
|
-
audio.src = url;
|
|
2934
|
-
audio.load();
|
|
2935
|
-
setTimeout(() => resolve(false), 2e3);
|
|
2936
|
-
});
|
|
2937
|
-
};
|
|
2938
|
-
let loaded = await tryLoadAudio(audioUrl);
|
|
2939
|
-
if (!loaded && audioUrl !== import_incoming.default) {
|
|
2940
|
-
loaded = await tryLoadAudio(import_incoming.default);
|
|
2941
|
-
if (loaded) {
|
|
2942
|
-
audioUrl = import_incoming.default;
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
return audio;
|
|
2946
|
-
}
|
|
2947
|
-
function cleanupAudioResources() {
|
|
2948
|
-
if (audioBlobUrl) {
|
|
2949
|
-
URL.revokeObjectURL(audioBlobUrl);
|
|
2950
|
-
audioBlobUrl = null;
|
|
2951
|
-
}
|
|
2952
|
-
audioBuffer = null;
|
|
2953
|
-
}
|
|
2954
|
-
|
|
2955
2878
|
// call-control-sdk/lib/components/callControls.tsx
|
|
2956
2879
|
var import_vault5 = require("@react-solutions/vault");
|
|
2957
2880
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -2995,7 +2918,6 @@ function CallControls({ onDataChange }) {
|
|
|
2995
2918
|
});
|
|
2996
2919
|
const micRef = (0, import_react11.useRef)(null);
|
|
2997
2920
|
const webSocketRef = (0, import_react11.useRef)(null);
|
|
2998
|
-
const audioRef = (0, import_react11.useRef)(null);
|
|
2999
2921
|
const reconnectTimeoutRef = (0, import_react11.useRef)(null);
|
|
3000
2922
|
const pingIntervalRef = (0, import_react11.useRef)(null);
|
|
3001
2923
|
const reconnectAttemptsRef = (0, import_react11.useRef)(0);
|
|
@@ -3256,22 +3178,6 @@ function CallControls({ onDataChange }) {
|
|
|
3256
3178
|
if (wrapUpinterval) clearInterval(wrapUpinterval);
|
|
3257
3179
|
};
|
|
3258
3180
|
}, [state.callData.status]);
|
|
3259
|
-
(0, import_react11.useEffect)(() => {
|
|
3260
|
-
createAudioElement().then((audio) => {
|
|
3261
|
-
audioRef.current = audio;
|
|
3262
|
-
}).catch((error) => {
|
|
3263
|
-
console.error("Failed to load audio element:", error);
|
|
3264
|
-
});
|
|
3265
|
-
return () => {
|
|
3266
|
-
if (audioRef.current) {
|
|
3267
|
-
audioRef.current.pause();
|
|
3268
|
-
audioRef.current.currentTime = 0;
|
|
3269
|
-
audioRef.current.src = "";
|
|
3270
|
-
audioRef.current = null;
|
|
3271
|
-
}
|
|
3272
|
-
cleanupAudioResources();
|
|
3273
|
-
};
|
|
3274
|
-
}, []);
|
|
3275
3181
|
(0, import_react11.useEffect)(() => {
|
|
3276
3182
|
if (onDataChange && state.callData) {
|
|
3277
3183
|
const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
|
|
@@ -3420,16 +3326,6 @@ function CallControls({ onDataChange }) {
|
|
|
3420
3326
|
isMergeCall: false
|
|
3421
3327
|
}
|
|
3422
3328
|
]);
|
|
3423
|
-
if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current) {
|
|
3424
|
-
audioRef.current.play().catch((error) => {
|
|
3425
|
-
console.error("Failed to play ringtone:", error);
|
|
3426
|
-
});
|
|
3427
|
-
}
|
|
3428
|
-
} else {
|
|
3429
|
-
if (audioRef.current) {
|
|
3430
|
-
audioRef.current.pause();
|
|
3431
|
-
audioRef.current.currentTime = 0;
|
|
3432
|
-
}
|
|
3433
3329
|
}
|
|
3434
3330
|
if (data.status === "ONCALL" /* ONCALL */) {
|
|
3435
3331
|
sdkStateManager.startCall();
|