@eka-care/ekascribe-ts-sdk 1.5.85 → 1.5.86
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,6 +134,9 @@ class AudioFileManager {
|
|
|
134
134
|
createSharedWorkerInstance() {
|
|
135
135
|
try {
|
|
136
136
|
// new URL(relativeOrAbsolutePath, baseUrl)
|
|
137
|
+
// const worker = new SharedWorker(
|
|
138
|
+
// 'https://unpkg.com/@eka-care/ekascribe-ts-sdk@1.5.80/dist/shared-worker/s3-file-upload.js'
|
|
139
|
+
// );
|
|
137
140
|
const worker = new SharedWorker(new URL('../shared-worker/s3-file-upload.js', import.meta.url));
|
|
138
141
|
this.sharedWorkerInstance = worker;
|
|
139
142
|
const onEventCallback = EkaScribeStore.eventCallback;
|
|
@@ -246,7 +249,16 @@ class AudioFileManager {
|
|
|
246
249
|
return true;
|
|
247
250
|
}
|
|
248
251
|
catch (error) {
|
|
249
|
-
|
|
252
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
253
|
+
if (errorMessage.includes('SecurityError') || errorMessage.includes('Failed to construct')) {
|
|
254
|
+
console.error('Error creating shared worker instance: CORS/Same-origin policy violation. ' +
|
|
255
|
+
'The SharedWorker script must be served from the same origin as your application, ' +
|
|
256
|
+
'or the server must allow cross-origin access with proper CORS headers. ' +
|
|
257
|
+
'Falling back to non-worker upload method.', error);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
console.error('Error creating shared worker instance:', error);
|
|
261
|
+
}
|
|
250
262
|
return false;
|
|
251
263
|
}
|
|
252
264
|
}
|
|
@@ -428,7 +440,14 @@ class AudioFileManager {
|
|
|
428
440
|
// Shared Workers are supported
|
|
429
441
|
console.log('Shared Workers are supported in this browser.');
|
|
430
442
|
if (!this.sharedWorkerInstance) {
|
|
431
|
-
this.createSharedWorkerInstance();
|
|
443
|
+
const workerCreated = this.createSharedWorkerInstance();
|
|
444
|
+
if (!workerCreated) {
|
|
445
|
+
// SharedWorker creation failed (likely due to CORS/same-origin policy)
|
|
446
|
+
// Fall back to non-worker upload
|
|
447
|
+
console.warn('Failed to create SharedWorker instance. Falling back to non-worker upload method.');
|
|
448
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
432
451
|
}
|
|
433
452
|
await this.uploadAudioToS3WithWorker({ audioFrames, fileName, chunkIndex });
|
|
434
453
|
}
|
|
@@ -447,6 +466,8 @@ class AudioFileManager {
|
|
|
447
466
|
}
|
|
448
467
|
catch (error) {
|
|
449
468
|
console.error('Error uploading audio to S3: uploadAudioToS3WithWorker: ', error);
|
|
469
|
+
// Fall back to non-worker upload if worker fails
|
|
470
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
450
471
|
}
|
|
451
472
|
}
|
|
452
473
|
async uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex, }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eka-care/ekascribe-ts-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.86",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": "git@github.com:eka-care/eka-js-sdk.git",
|
|
6
6
|
"author": "Sanikagoyal28 <sanikagoyal9@gmail.com>",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=12.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.14.1",
|