dicom-curate 0.2.0 → 0.3.0
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/esm/index.js +50 -33
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +9 -2
- package/dist/umd/dicom-curate.umd.js +50 -33
- package/dist/umd/dicom-curate.umd.js.map +1 -1
- package/dist/umd/dicom-curate.umd.min.js +1 -1
- package/dist/umd/dicom-curate.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -96,14 +96,12 @@ function initializeMappingWorkers() {
|
|
|
96
96
|
mapResultsList.push(event.data.mapResults);
|
|
97
97
|
workersActive -= 1;
|
|
98
98
|
// Report progress
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
}
|
|
99
|
+
progressCallback({
|
|
100
|
+
response: 'progress',
|
|
101
|
+
mapResults: event.data.mapResults,
|
|
102
|
+
processedFiles: mapResultsList.length,
|
|
103
|
+
totalFiles: filesToProcess.length + mapResultsList.length + workersActive,
|
|
104
|
+
});
|
|
107
105
|
dispatchMappingJobs();
|
|
108
106
|
if (mapResultsList.length % 100 === 0) {
|
|
109
107
|
console.log(`Finished mapping ${mapResultsList.length} files`);
|
|
@@ -142,6 +140,12 @@ function dispatchMappingJobs() {
|
|
|
142
140
|
clearCaches();
|
|
143
141
|
console.log(`Finished mapping ${mapResultsList.length} files`);
|
|
144
142
|
console.log('job is finished');
|
|
143
|
+
progressCallback({
|
|
144
|
+
response: 'done',
|
|
145
|
+
mapResultsList: mapResultsList,
|
|
146
|
+
processedFiles: mapResultsList.length,
|
|
147
|
+
totalFiles: mapResultsList.length,
|
|
148
|
+
});
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
function collectMappingOptions(organizeOptions) {
|
|
@@ -197,31 +201,44 @@ function queueFilesForMapping(organizeOptions) {
|
|
|
197
201
|
let progressCallback;
|
|
198
202
|
function curateMany(organizeOptions, onProgress) {
|
|
199
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
request
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
// Resolve promise if progressCallback gets called with 'done'
|
|
206
|
+
progressCallback = (msg) => {
|
|
207
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(msg);
|
|
208
|
+
if (msg.response === 'done') {
|
|
209
|
+
resolve(msg);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
try {
|
|
213
|
+
// create the mapping workers
|
|
214
|
+
initializeMappingWorkers();
|
|
215
|
+
// Set global mappingWorkerOptions
|
|
216
|
+
mappingWorkerOptions = (yield collectMappingOptions(organizeOptions));
|
|
217
|
+
//
|
|
218
|
+
// If the request provides a directory, then use the worker
|
|
219
|
+
// to recursively convert to fileSystemHandles.
|
|
220
|
+
// If the request provides a list of File objects,
|
|
221
|
+
// send them to the mapping workers directly.
|
|
222
|
+
//
|
|
223
|
+
if (organizeOptions.inputType === 'directory') {
|
|
224
|
+
const fileListWorker = initializeFileListWorker();
|
|
225
|
+
fileListWorker.postMessage({
|
|
226
|
+
request: 'scan',
|
|
227
|
+
directoryHandle: organizeOptions.inputDirectory,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
else if (organizeOptions.inputType === 'files') {
|
|
231
|
+
queueFilesForMapping(organizeOptions);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
console.error('`inputType` should be "directory" or "files"');
|
|
235
|
+
}
|
|
236
|
+
dispatchMappingJobs();
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
reject(error);
|
|
240
|
+
}
|
|
241
|
+
}));
|
|
225
242
|
});
|
|
226
243
|
}
|
|
227
244
|
export { curateMany, curateOne, extractColumnMappings, clearCaches };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { extractColumnMappings } from './csvMapping';
|
|
2
2
|
import { clearCaches } from './clearCaches';
|
|
3
3
|
import { curateOne } from './curateOne';
|
|
4
|
-
import type { OrganizeOptions, TProgressMessage } from './types';
|
|
4
|
+
import type { OrganizeOptions, TProgressMessage, TProgressMessageDone } from './types';
|
|
5
5
|
export type ProgressCallback = (message: TProgressMessage) => void;
|
|
6
6
|
export type { TPs315Options, TMapResults, TProgressMessage, OrganizeOptions, TCurationSpecification, } from './types';
|
|
7
7
|
export { specVersion } from './config/specVersion';
|
|
8
8
|
export { sample2PassCurationSpecification as sampleSpecification } from './config/sample2PassCurationSpecification';
|
|
9
9
|
export { csvTextToRows } from './csvMapping';
|
|
10
10
|
export type { Row } from './csvMapping';
|
|
11
|
-
declare function curateMany(organizeOptions: OrganizeOptions, onProgress?: ProgressCallback): Promise<
|
|
11
|
+
declare function curateMany(organizeOptions: OrganizeOptions, onProgress?: ProgressCallback): Promise<TProgressMessageDone>;
|
|
12
12
|
export { curateMany, curateOne, extractColumnMappings, clearCaches };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -134,11 +134,18 @@ export type TCurationSpecification = {
|
|
|
134
134
|
mapping: TMappedValues;
|
|
135
135
|
} & (TMappingInputDirect | TMappingInputTwoPass);
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
response: 'start' | 'progress' | 'finished' | 'error';
|
|
137
|
+
type TProgressMessageBase = {
|
|
139
138
|
totalFiles?: number;
|
|
140
139
|
processedFiles?: number;
|
|
140
|
+
};
|
|
141
|
+
type TProgressMessageProgress = TProgressMessageBase & {
|
|
142
|
+
response: 'progress';
|
|
141
143
|
mapResults?: TMapResults;
|
|
142
144
|
error?: Error;
|
|
143
145
|
};
|
|
146
|
+
export type TProgressMessageDone = TProgressMessageBase & {
|
|
147
|
+
response: 'done';
|
|
148
|
+
mapResultsList: TMapResults[];
|
|
149
|
+
};
|
|
150
|
+
export type TProgressMessage = TProgressMessageProgress | TProgressMessageDone;
|
|
144
151
|
export {};
|
|
@@ -62928,14 +62928,12 @@
|
|
|
62928
62928
|
mapResultsList.push(event.data.mapResults);
|
|
62929
62929
|
workersActive -= 1;
|
|
62930
62930
|
// Report progress
|
|
62931
|
-
|
|
62932
|
-
|
|
62933
|
-
|
|
62934
|
-
|
|
62935
|
-
|
|
62936
|
-
|
|
62937
|
-
});
|
|
62938
|
-
}
|
|
62931
|
+
progressCallback({
|
|
62932
|
+
response: 'progress',
|
|
62933
|
+
mapResults: event.data.mapResults,
|
|
62934
|
+
processedFiles: mapResultsList.length,
|
|
62935
|
+
totalFiles: filesToProcess.length + mapResultsList.length + workersActive,
|
|
62936
|
+
});
|
|
62939
62937
|
dispatchMappingJobs();
|
|
62940
62938
|
if (mapResultsList.length % 100 === 0) {
|
|
62941
62939
|
console.log(`Finished mapping ${mapResultsList.length} files`);
|
|
@@ -62974,6 +62972,12 @@
|
|
|
62974
62972
|
clearCaches();
|
|
62975
62973
|
console.log(`Finished mapping ${mapResultsList.length} files`);
|
|
62976
62974
|
console.log('job is finished');
|
|
62975
|
+
progressCallback({
|
|
62976
|
+
response: 'done',
|
|
62977
|
+
mapResultsList: mapResultsList,
|
|
62978
|
+
processedFiles: mapResultsList.length,
|
|
62979
|
+
totalFiles: mapResultsList.length,
|
|
62980
|
+
});
|
|
62977
62981
|
}
|
|
62978
62982
|
}
|
|
62979
62983
|
function collectMappingOptions(organizeOptions) {
|
|
@@ -63029,31 +63033,44 @@
|
|
|
63029
63033
|
let progressCallback;
|
|
63030
63034
|
function curateMany(organizeOptions, onProgress) {
|
|
63031
63035
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63032
|
-
|
|
63033
|
-
|
|
63034
|
-
|
|
63035
|
-
|
|
63036
|
-
|
|
63037
|
-
|
|
63038
|
-
|
|
63039
|
-
|
|
63040
|
-
|
|
63041
|
-
|
|
63042
|
-
|
|
63043
|
-
|
|
63044
|
-
|
|
63045
|
-
|
|
63046
|
-
request
|
|
63047
|
-
|
|
63048
|
-
|
|
63049
|
-
|
|
63050
|
-
|
|
63051
|
-
|
|
63052
|
-
|
|
63053
|
-
|
|
63054
|
-
|
|
63055
|
-
|
|
63056
|
-
|
|
63036
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
63037
|
+
// Resolve promise if progressCallback gets called with 'done'
|
|
63038
|
+
progressCallback = (msg) => {
|
|
63039
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(msg);
|
|
63040
|
+
if (msg.response === 'done') {
|
|
63041
|
+
resolve(msg);
|
|
63042
|
+
}
|
|
63043
|
+
};
|
|
63044
|
+
try {
|
|
63045
|
+
// create the mapping workers
|
|
63046
|
+
initializeMappingWorkers();
|
|
63047
|
+
// Set global mappingWorkerOptions
|
|
63048
|
+
mappingWorkerOptions = (yield collectMappingOptions(organizeOptions));
|
|
63049
|
+
//
|
|
63050
|
+
// If the request provides a directory, then use the worker
|
|
63051
|
+
// to recursively convert to fileSystemHandles.
|
|
63052
|
+
// If the request provides a list of File objects,
|
|
63053
|
+
// send them to the mapping workers directly.
|
|
63054
|
+
//
|
|
63055
|
+
if (organizeOptions.inputType === 'directory') {
|
|
63056
|
+
const fileListWorker = initializeFileListWorker();
|
|
63057
|
+
fileListWorker.postMessage({
|
|
63058
|
+
request: 'scan',
|
|
63059
|
+
directoryHandle: organizeOptions.inputDirectory,
|
|
63060
|
+
});
|
|
63061
|
+
}
|
|
63062
|
+
else if (organizeOptions.inputType === 'files') {
|
|
63063
|
+
queueFilesForMapping(organizeOptions);
|
|
63064
|
+
}
|
|
63065
|
+
else {
|
|
63066
|
+
console.error('`inputType` should be "directory" or "files"');
|
|
63067
|
+
}
|
|
63068
|
+
dispatchMappingJobs();
|
|
63069
|
+
}
|
|
63070
|
+
catch (error) {
|
|
63071
|
+
reject(error);
|
|
63072
|
+
}
|
|
63073
|
+
}));
|
|
63057
63074
|
});
|
|
63058
63075
|
}
|
|
63059
63076
|
|