@eka-care/ekascribe-ts-sdk 1.5.79 → 1.5.81
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.
|
@@ -134,7 +134,7 @@ class AudioFileManager {
|
|
|
134
134
|
createSharedWorkerInstance() {
|
|
135
135
|
try {
|
|
136
136
|
// new URL(relativeOrAbsolutePath, baseUrl)
|
|
137
|
-
const worker = new SharedWorker(
|
|
137
|
+
const worker = new SharedWorker('https://unpkg.com/@eka-care/ekascribe-ts-sdk@1.5.80/dist/shared-worker/s3-file-upload.js');
|
|
138
138
|
this.sharedWorkerInstance = worker;
|
|
139
139
|
const onEventCallback = EkaScribeStore.eventCallback;
|
|
140
140
|
this.sharedWorkerInstance.port.onmessage = async (event) => {
|
|
@@ -246,7 +246,16 @@ class AudioFileManager {
|
|
|
246
246
|
return true;
|
|
247
247
|
}
|
|
248
248
|
catch (error) {
|
|
249
|
-
|
|
249
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
250
|
+
if (errorMessage.includes('SecurityError') || errorMessage.includes('Failed to construct')) {
|
|
251
|
+
console.error('Error creating shared worker instance: CORS/Same-origin policy violation. ' +
|
|
252
|
+
'The SharedWorker script must be served from the same origin as your application, ' +
|
|
253
|
+
'or the server must allow cross-origin access with proper CORS headers. ' +
|
|
254
|
+
'Falling back to non-worker upload method.', error);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.error('Error creating shared worker instance:', error);
|
|
258
|
+
}
|
|
250
259
|
return false;
|
|
251
260
|
}
|
|
252
261
|
}
|
|
@@ -428,7 +437,14 @@ class AudioFileManager {
|
|
|
428
437
|
// Shared Workers are supported
|
|
429
438
|
console.log('Shared Workers are supported in this browser.');
|
|
430
439
|
if (!this.sharedWorkerInstance) {
|
|
431
|
-
this.createSharedWorkerInstance();
|
|
440
|
+
const workerCreated = this.createSharedWorkerInstance();
|
|
441
|
+
if (!workerCreated) {
|
|
442
|
+
// SharedWorker creation failed (likely due to CORS/same-origin policy)
|
|
443
|
+
// Fall back to non-worker upload
|
|
444
|
+
console.warn('Failed to create SharedWorker instance. Falling back to non-worker upload method.');
|
|
445
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
432
448
|
}
|
|
433
449
|
await this.uploadAudioToS3WithWorker({ audioFrames, fileName, chunkIndex });
|
|
434
450
|
}
|
|
@@ -447,6 +463,8 @@ class AudioFileManager {
|
|
|
447
463
|
}
|
|
448
464
|
catch (error) {
|
|
449
465
|
console.error('Error uploading audio to S3: uploadAudioToS3WithWorker: ', error);
|
|
466
|
+
// Fall back to non-worker upload if worker fails
|
|
467
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
450
468
|
}
|
|
451
469
|
}
|
|
452
470
|
async uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex, }) {
|