@ubercode/dcmtk 0.9.2 → 0.9.4
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-DW1uwonV.d.ts → index-x98H349Q.d.ts} +2 -2
- package/dist/{index-BJOfTTB-.d.cts → index-zdzuZTms.d.cts} +2 -2
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +16 -12
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +1 -1
- package/dist/servers.d.ts +1 -1
- package/dist/servers.js +16 -12
- package/dist/servers.js.map +1 -1
- package/package.json +1 -1
package/dist/servers.cjs
CHANGED
|
@@ -3224,19 +3224,27 @@ var DicomReceiver = class _DicomReceiver extends events.EventEmitter {
|
|
|
3224
3224
|
this.wireRefusingAssociation(worker);
|
|
3225
3225
|
this.wireOutputCapture(worker);
|
|
3226
3226
|
}
|
|
3227
|
-
/** Wires FILE_RECEIVED from dcmrecv worker
|
|
3227
|
+
/** Wires FILE_RECEIVED from dcmrecv worker — files are processed serially per worker. */
|
|
3228
3228
|
wireFileReceived(worker) {
|
|
3229
3229
|
worker.dcmrecv.onFileReceived((data) => {
|
|
3230
|
-
const
|
|
3230
|
+
const assocId = worker.associationId;
|
|
3231
|
+
const assocDir = worker.associationDir;
|
|
3232
|
+
if (assocDir === void 0 || assocId === void 0) {
|
|
3233
|
+
this.emit("error", {
|
|
3234
|
+
error: new Error(`DicomReceiver: FILE_RECEIVED with no active association (worker state: ${worker.state})`),
|
|
3235
|
+
filePath: data.filePath,
|
|
3236
|
+
callingAE: data.callingAE,
|
|
3237
|
+
calledAE: data.calledAE,
|
|
3238
|
+
source: data.source
|
|
3239
|
+
});
|
|
3240
|
+
return;
|
|
3241
|
+
}
|
|
3242
|
+
const promise = this.handleFileReceived(worker, data, assocId, assocDir);
|
|
3231
3243
|
worker.pendingFiles.push(promise);
|
|
3232
|
-
void promise.finally(() => removePending(worker.pendingFiles, promise));
|
|
3233
3244
|
});
|
|
3234
3245
|
}
|
|
3235
3246
|
/** Moves a received file, opens it as DicomInstance, and emits FILE_RECEIVED. */
|
|
3236
|
-
async handleFileReceived(worker, data) {
|
|
3237
|
-
if (worker.associationDir === void 0 || worker.associationId === void 0) return;
|
|
3238
|
-
const assocId = worker.associationId;
|
|
3239
|
-
const assocDir = worker.associationDir;
|
|
3247
|
+
async handleFileReceived(worker, data, assocId, assocDir) {
|
|
3240
3248
|
try {
|
|
3241
3249
|
await this.moveAndEmitFile(worker, data, assocId, assocDir);
|
|
3242
3250
|
} catch (thrown) {
|
|
@@ -3291,7 +3299,7 @@ var DicomReceiver = class _DicomReceiver extends events.EventEmitter {
|
|
|
3291
3299
|
void this.finalizeAssociation(worker, data);
|
|
3292
3300
|
});
|
|
3293
3301
|
}
|
|
3294
|
-
/** Awaits pending file operations, emits ASSOCIATION_COMPLETE, resets worker state. */
|
|
3302
|
+
/** Awaits ALL pending file operations, emits ASSOCIATION_COMPLETE, resets worker state. */
|
|
3295
3303
|
async finalizeAssociation(worker, data) {
|
|
3296
3304
|
if (worker.pendingFiles.length > 0) {
|
|
3297
3305
|
await Promise.all(worker.pendingFiles);
|
|
@@ -3444,10 +3452,6 @@ async function removeDirSafe(dirPath) {
|
|
|
3444
3452
|
} catch {
|
|
3445
3453
|
}
|
|
3446
3454
|
}
|
|
3447
|
-
function removePending(arr, promise) {
|
|
3448
|
-
const idx = arr.indexOf(promise);
|
|
3449
|
-
if (idx !== -1) void arr.splice(idx, 1);
|
|
3450
|
-
}
|
|
3451
3455
|
function delay(ms) {
|
|
3452
3456
|
return new Promise((resolve) => {
|
|
3453
3457
|
setTimeout(resolve, ms);
|