agglomerative-clustering 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +5 -5
- package/dist/clustering.wasm +0 -0
- package/dist/index.cjs +37 -63
- package/dist/index.d.cts +15 -76
- package/dist/index.d.ts +15 -76
- package/dist/index.mjs +36 -57
- package/dist/shared.cjs +73 -79
- package/dist/shared.mjs +68 -73
- package/dist/worker-thread.mjs +15 -18
- package/dist/worker.cjs +139 -84
- package/dist/worker.d.cts +0 -32
- package/dist/worker.d.ts +0 -32
- package/dist/worker.mjs +138 -78
- package/package.json +2 -2
package/dist/worker.cjs
CHANGED
|
@@ -49,7 +49,7 @@ Object.defineProperty(exports, "errorCodes", {
|
|
|
49
49
|
return _shared.errorCodes;
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
|
-
exports.
|
|
52
|
+
exports.formatVersion = void 0;
|
|
53
53
|
Object.defineProperty(exports, "imageFormats", {
|
|
54
54
|
enumerable: true,
|
|
55
55
|
get: function () {
|
|
@@ -63,7 +63,7 @@ Object.defineProperty(exports, "isCodedError", {
|
|
|
63
63
|
return _shared.isCodedError;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
exports.terminate = exports.quantizeWithPalette = exports.quantizeToIndicesWithPalette = exports.
|
|
66
|
+
exports.terminate = exports.quantizeWithPalette = exports.quantizeToIndicesWithPalette = exports.quantizeToIndices = exports.quantize = void 0;
|
|
67
67
|
Object.defineProperty(exports, "version", {
|
|
68
68
|
enumerable: true,
|
|
69
69
|
get: function () {
|
|
@@ -324,8 +324,38 @@ const send = image => {
|
|
|
324
324
|
if (notPixels(image)) {
|
|
325
325
|
throw (0, _shared.fail)('invalid-argument', `Invalid image: expected object with \`data\` and \`format\`.${(0, _shared.imageHint)(image)}`, 'image');
|
|
326
326
|
}
|
|
327
|
+
// An image object goes through the main entry's own checks here (its fields read once, then shape, data, detached buffer, format,
|
|
328
|
+
// sizes, unknown keys, premultiplied), so what can't be sent is reported as the main entry reports it, before anything is posted.
|
|
329
|
+
// A function, a Symbol or a thenable gets the shape error rather than the structured clone's.
|
|
330
|
+
if (!ArrayBuffer.isView(image) && !(0, _shared.isImageData)(image)) {
|
|
331
|
+
const copy = (0, _shared.imageCopy)(image);
|
|
332
|
+
if (copy === image) {
|
|
333
|
+
if (typeof image !== 'object' || image === null) {
|
|
334
|
+
throw (0, _shared.fail)('invalid-argument', `Invalid image: expected object with \`data\` and \`format\`.${(0, _shared.imageHint)(image)}`, 'image');
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
const premultiplied = (0, _shared.checkImageBody)(copy);
|
|
338
|
+
if (copy.data.byteLength >= _shared.maxBytes) {
|
|
339
|
+
throw (0, _shared.tooLarge)(copy.data.byteLength);
|
|
340
|
+
}
|
|
341
|
+
const sent = {
|
|
342
|
+
data: copy.data,
|
|
343
|
+
format: copy.format
|
|
344
|
+
};
|
|
345
|
+
if (copy.premultiplied !== undefined) {
|
|
346
|
+
sent.premultiplied = premultiplied;
|
|
347
|
+
}
|
|
348
|
+
if (copy.width !== undefined) {
|
|
349
|
+
sent.width = copy.width;
|
|
350
|
+
}
|
|
351
|
+
if (copy.height !== undefined) {
|
|
352
|
+
sent.height = copy.height;
|
|
353
|
+
}
|
|
354
|
+
return sent;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
327
357
|
// A detached buffer (transferred to a worker created with transfer: true, say) is reported as the main entry reports it.
|
|
328
|
-
const pixels = ArrayBuffer.isView(image) ? image :
|
|
358
|
+
const pixels = ArrayBuffer.isView(image) ? image : (0, _shared.isImageData)(image) && ArrayBuffer.isView(image.data) ? image.data : null;
|
|
329
359
|
if (pixels && (0, _shared.isDetached)(pixels)) {
|
|
330
360
|
throw (0, _shared.detachedError)(ArrayBuffer.isView(image) ? 'bare' : (0, _shared.isImageData)(image) ? 'imagedata' : 'data');
|
|
331
361
|
}
|
|
@@ -343,29 +373,6 @@ const send = image => {
|
|
|
343
373
|
height: image.height
|
|
344
374
|
};
|
|
345
375
|
}
|
|
346
|
-
if (image && typeof image === 'object' && !ArrayBuffer.isView(image) && ArrayBuffer.isView(image.data)) {
|
|
347
|
-
// The main entry's checks (shape, unknown keys, premultiplied) run here, in its order, before anything is posted. Data of another
|
|
348
|
-
// type, or no format, goes on as it is for the worker's own error.
|
|
349
|
-
const sent = {
|
|
350
|
-
data: image.data,
|
|
351
|
-
format: image.format
|
|
352
|
-
};
|
|
353
|
-
if (image.format && ((0, _shared.isUint8Array)(image.data) || (0, _shared.isUint8ClampedArray)(image.data))) {
|
|
354
|
-
const premultiplied = (0, _shared.checkImageObject)(image);
|
|
355
|
-
if (image.premultiplied !== undefined) {
|
|
356
|
-
sent.premultiplied = premultiplied;
|
|
357
|
-
}
|
|
358
|
-
} else if (image.premultiplied !== undefined) {
|
|
359
|
-
sent.premultiplied = image.premultiplied;
|
|
360
|
-
}
|
|
361
|
-
if (image.width !== undefined) {
|
|
362
|
-
sent.width = image.width;
|
|
363
|
-
}
|
|
364
|
-
if (image.height !== undefined) {
|
|
365
|
-
sent.height = image.height;
|
|
366
|
-
}
|
|
367
|
-
return sent;
|
|
368
|
-
}
|
|
369
376
|
return image;
|
|
370
377
|
};
|
|
371
378
|
|
|
@@ -574,24 +581,54 @@ const sendable = value => {
|
|
|
574
581
|
|
|
575
582
|
// Where the options sit among a function's arguments after the image (see takeControls).
|
|
576
583
|
const optionsPosition = {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
584
|
+
buildClustering: 0,
|
|
585
|
+
buildPalette: 1,
|
|
586
|
+
buildSwatches: 1,
|
|
580
587
|
quantize: 1,
|
|
581
|
-
quantizeFromClustering: 2,
|
|
582
588
|
quantizeWithPalette: 1,
|
|
583
589
|
quantizeToIndices: 1,
|
|
584
|
-
quantizeToIndicesFromClustering: 2,
|
|
585
590
|
quantizeToIndicesWithPalette: 1
|
|
586
591
|
};
|
|
587
592
|
|
|
593
|
+
// The names of the arguments each call posts, for saying which one can't be sent.
|
|
594
|
+
const argumentNames = {
|
|
595
|
+
buildClustering: ['image', 'options'],
|
|
596
|
+
buildPalette: ['image', 'k', 'options'],
|
|
597
|
+
buildSwatches: ['image', 'k', 'options'],
|
|
598
|
+
quantize: ['image', 'k', 'options'],
|
|
599
|
+
quantizeToIndices: ['image', 'k', 'options'],
|
|
600
|
+
quantizeWithPalette: ['image', 'palette', 'options'],
|
|
601
|
+
quantizeToIndicesWithPalette: ['image', 'palette', 'options'],
|
|
602
|
+
init: ['options'],
|
|
603
|
+
cluster: [null, 'image', 'options'],
|
|
604
|
+
load: [null, 'clustering'],
|
|
605
|
+
handleGetPalette: [null, 'k'],
|
|
606
|
+
handleGetSwatches: [null, 'k'],
|
|
607
|
+
handleChooseFrom: [null, 'palette', 'k', 'options'],
|
|
608
|
+
handleQuantize: [null, 'k', 'options'],
|
|
609
|
+
handleQuantizeToIndices: [null, 'k', 'options'],
|
|
610
|
+
handleQuantizeWithPalette: [null, 'palette', 'options'],
|
|
611
|
+
handleQuantizeToIndicesWithPalette: [null, 'palette', 'options'],
|
|
612
|
+
handleQuantizeImage: [null, 'image', 'k', 'options'],
|
|
613
|
+
handleQuantizeToIndicesImage: [null, 'image', 'k', 'options']
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// The error for a call whose message can't be cloned: the first argument that fails alone names itself.
|
|
617
|
+
const unsendable = (method, args, error) => {
|
|
618
|
+
const names = argumentNames[method] || [];
|
|
619
|
+
const index = args.findIndex((value, at) => names[at] && !sendable(value));
|
|
620
|
+
const cause = {
|
|
621
|
+
cause: error
|
|
622
|
+
};
|
|
623
|
+
return index < 0 ? Object.assign((0, _shared.fail)('invalid-argument', `Invalid argument: it cannot be sent to the worker (${error.message})`), cause) : Object.assign((0, _shared.fail)('invalid-argument', `Invalid ${names[index]}: it cannot be sent to the worker (${error.message})`, names[index]), cause);
|
|
624
|
+
};
|
|
625
|
+
|
|
588
626
|
// Like fetch: an aborted call rejects with the signal's reason, an AbortError unless the caller gave another.
|
|
589
627
|
const abortReason = signal => signal.reason !== undefined ? signal.reason : new DOMException('This operation was aborted', 'AbortError');
|
|
590
|
-
const imageFunctions = ['
|
|
591
|
-
const mappedImageFunctions = ['quantize', '
|
|
628
|
+
const imageFunctions = ['buildClustering', 'buildPalette', 'buildSwatches', 'quantize', 'quantizeWithPalette', 'quantizeToIndices', 'quantizeToIndicesWithPalette'];
|
|
629
|
+
const mappedImageFunctions = ['quantize', 'quantizeWithPalette'];
|
|
592
630
|
// The functions that only cluster, and so take no dither option.
|
|
593
|
-
const clusteringOnlyFunctions = ['
|
|
594
|
-
const otherFunctions = ['getPaletteFromClustering', 'getSwatchesFromClustering', 'getClusteringInfo'];
|
|
631
|
+
const clusteringOnlyFunctions = ['buildClustering', 'buildPalette', 'buildSwatches'];
|
|
595
632
|
|
|
596
633
|
// Calls each worker's `abandon` once the worker made by createWorker() has been garbage-collected (see `abandoned`).
|
|
597
634
|
const abandonment = typeof FinalizationRegistry === 'function' ? new FinalizationRegistry(abandon => abandon()) : null;
|
|
@@ -622,6 +659,9 @@ const makeWorker = (options, allowScript) => {
|
|
|
622
659
|
wasm: initialWasm
|
|
623
660
|
};
|
|
624
661
|
let initialising = null;
|
|
662
|
+
// Whether the worker script has said it is this version (the first message to every worker), and that exchange.
|
|
663
|
+
let shaken = false;
|
|
664
|
+
let shaking = null;
|
|
625
665
|
let connection = null;
|
|
626
666
|
let starting = null;
|
|
627
667
|
// Counts the workers this instance has started, so a late message or error from one it already dropped is ignored.
|
|
@@ -639,7 +679,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
639
679
|
let nextHandle = 1;
|
|
640
680
|
const pending = new Map();
|
|
641
681
|
// Whether a call made now is posted before it returns (see `own`).
|
|
642
|
-
const ready = () => connection !== null && !initial;
|
|
682
|
+
const ready = () => connection !== null && shaken && !initial;
|
|
643
683
|
// The image of a call made before the worker is ready: with `transfer: true` its buffer is moved out of the caller's
|
|
644
684
|
// hands at once (a structured clone that transfers it, so the caller's array empties now, as it would on posting),
|
|
645
685
|
// otherwise copied.
|
|
@@ -678,6 +718,8 @@ const makeWorker = (options, allowScript) => {
|
|
|
678
718
|
connection = null;
|
|
679
719
|
starting = null;
|
|
680
720
|
initialising = null;
|
|
721
|
+
shaken = false;
|
|
722
|
+
shaking = null;
|
|
681
723
|
if (initialWasm !== undefined) {
|
|
682
724
|
initial = {
|
|
683
725
|
wasm: initialWasm
|
|
@@ -778,6 +820,41 @@ const makeWorker = (options, allowScript) => {
|
|
|
778
820
|
}
|
|
779
821
|
connection = connection || started;
|
|
780
822
|
}
|
|
823
|
+
if (!shaken) {
|
|
824
|
+
// The first message to a worker: its script must be this version's (an older thread answers `handshake` as an
|
|
825
|
+
// unknown method; a 3.4-3.8 one would otherwise run calls but never see their signals or progress callbacks).
|
|
826
|
+
// Nothing else is posted before it answers, so a mismatch is reported to every call waiting on the worker.
|
|
827
|
+
if (!shaking) {
|
|
828
|
+
const mine = generation;
|
|
829
|
+
shaking = post('handshake', [], [], origin).then(theirs => {
|
|
830
|
+
if (theirs === _shared.version) {
|
|
831
|
+
shaken = true;
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
throw theirs;
|
|
835
|
+
}, error => {
|
|
836
|
+
// A coded error from the call itself (terminated, failed) is passed on; only a reply that is an error
|
|
837
|
+
// from the thread (an unknown method) means an older script.
|
|
838
|
+
if (error && error.code !== undefined && error.code !== 'invalid-argument') {
|
|
839
|
+
throw error;
|
|
840
|
+
}
|
|
841
|
+
throw undefined;
|
|
842
|
+
}).catch(theirs => {
|
|
843
|
+
if (theirs instanceof Error) {
|
|
844
|
+
throw theirs;
|
|
845
|
+
}
|
|
846
|
+
if (terminated) {
|
|
847
|
+
throw (0, _shared.fail)('worker-terminated', "Worker terminated.");
|
|
848
|
+
}
|
|
849
|
+
const reason = `The worker script is from another version of agglomerative-clustering (${typeof theirs === 'string' ? theirs : 'an older one'}; this is ${_shared.version}). Use the worker-thread.mjs from this version.`;
|
|
850
|
+
if (mine === generation) {
|
|
851
|
+
lose(reason);
|
|
852
|
+
}
|
|
853
|
+
throw (0, _shared.fail)('worker-failed', reason);
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
await shaking;
|
|
857
|
+
}
|
|
781
858
|
if (initial && !(method === 'init' && args.length > 0 && args[0].wasm !== undefined)) {
|
|
782
859
|
initialising = initialising || post('init', [initial], [], origin).then(() => {
|
|
783
860
|
initial = null;
|
|
@@ -880,10 +957,8 @@ const makeWorker = (options, allowScript) => {
|
|
|
880
957
|
connection.unref();
|
|
881
958
|
}
|
|
882
959
|
// A value that can't be structured-cloned (a function, symbol or promise) is an invalid argument, as it
|
|
883
|
-
// would be if the main entry were called with it.
|
|
884
|
-
reject(error && error.name === 'DataCloneError' ?
|
|
885
|
-
cause: error
|
|
886
|
-
}) : error);
|
|
960
|
+
// would be if the main entry were called with it; the first argument that fails alone is named.
|
|
961
|
+
reject(error && error.name === 'DataCloneError' ? unsendable(method, args.map(_shared.mark), error) : error);
|
|
887
962
|
}
|
|
888
963
|
});
|
|
889
964
|
};
|
|
@@ -893,6 +968,14 @@ const makeWorker = (options, allowScript) => {
|
|
|
893
968
|
instance[name] = (image, ...rest) => {
|
|
894
969
|
const origin = new Error();
|
|
895
970
|
return (async () => {
|
|
971
|
+
// A bare RGB or grey array is refused first, as in the main entry (before the options are read, an abort is
|
|
972
|
+
// honoured, or anything is posted or a transfer can empty the array).
|
|
973
|
+
const bare = (0, _shared.bareImageError)(image);
|
|
974
|
+
if (bare) {
|
|
975
|
+
throw bare;
|
|
976
|
+
}
|
|
977
|
+
// then the rest of the image's checks (its fields are read once here), before the options, as in the main entry
|
|
978
|
+
const checked = send(image);
|
|
896
979
|
const position = optionsPosition[name];
|
|
897
980
|
const {
|
|
898
981
|
options,
|
|
@@ -907,7 +990,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
907
990
|
// The main entry reports a wrong argument before an abort, so the worker checks the arguments (a
|
|
908
991
|
// copy, never transferred: an aborted call leaves the image with the caller) without doing the work.
|
|
909
992
|
try {
|
|
910
|
-
await invoke(name, [own(
|
|
993
|
+
await invoke(name, [own(checked), ...args.map(own)], [], origin, {
|
|
911
994
|
check: true
|
|
912
995
|
});
|
|
913
996
|
} catch (error) {
|
|
@@ -917,12 +1000,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
917
1000
|
}
|
|
918
1001
|
throw abortReason(signal);
|
|
919
1002
|
}
|
|
920
|
-
|
|
921
|
-
// array, and given once the call succeeds: the thread checks the other arguments, and its own copy is
|
|
922
|
-
// silenced (PRINCIPLES "Warnings").
|
|
923
|
-
const warning = (0, _shared.bareImageWarning)(image);
|
|
924
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
925
|
-
let sent = send(image);
|
|
1003
|
+
let sent = checked;
|
|
926
1004
|
if (!ready()) {
|
|
927
1005
|
sent = take(sent);
|
|
928
1006
|
args = args.map(own);
|
|
@@ -931,21 +1009,10 @@ const makeWorker = (options, allowScript) => {
|
|
|
931
1009
|
signal,
|
|
932
1010
|
onProgress
|
|
933
1011
|
});
|
|
934
|
-
if (warning) {
|
|
935
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
936
|
-
}
|
|
937
1012
|
return mapped ? rebuild(image)(result) : result;
|
|
938
1013
|
})();
|
|
939
1014
|
};
|
|
940
1015
|
}
|
|
941
|
-
for (const name of otherFunctions) {
|
|
942
|
-
instance[name] = (...args) => invoke(name, ready() ? args : args.map(own), [], new Error());
|
|
943
|
-
}
|
|
944
|
-
// 3.4.0's names for the functions that cluster an image. The old names are the same functions, and they still name the
|
|
945
|
-
// call on the wire, so a worker script copied from an older version still understands it.
|
|
946
|
-
instance.buildClustering = instance.getClustering;
|
|
947
|
-
instance.buildPalette = instance.getPalette;
|
|
948
|
-
instance.buildSwatches = instance.getSwatches;
|
|
949
1016
|
instance.init = initArgs => {
|
|
950
1017
|
const origin = new Error();
|
|
951
1018
|
let checked;
|
|
@@ -1066,6 +1133,11 @@ const makeWorker = (options, allowScript) => {
|
|
|
1066
1133
|
if (released || !handle) {
|
|
1067
1134
|
throw (0, _shared.fail)('invalid-handle', "Invalid handle: it was released.");
|
|
1068
1135
|
}
|
|
1136
|
+
const bare = (0, _shared.bareImageError)(image);
|
|
1137
|
+
if (bare) {
|
|
1138
|
+
throw bare;
|
|
1139
|
+
}
|
|
1140
|
+
const checked = send(image);
|
|
1069
1141
|
const {
|
|
1070
1142
|
options,
|
|
1071
1143
|
signal,
|
|
@@ -1074,7 +1146,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1074
1146
|
if (signal && signal.aborted) {
|
|
1075
1147
|
// As the functions on the worker do: a wrong argument is reported before the abort.
|
|
1076
1148
|
try {
|
|
1077
|
-
await invoke(method, [id, own(
|
|
1149
|
+
await invoke(method, [id, own(checked), k, options], [], origin, {
|
|
1078
1150
|
check: true
|
|
1079
1151
|
});
|
|
1080
1152
|
} catch (error) {
|
|
@@ -1084,9 +1156,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1084
1156
|
}
|
|
1085
1157
|
throw abortReason(signal);
|
|
1086
1158
|
}
|
|
1087
|
-
|
|
1088
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
1089
|
-
let sent = send(image);
|
|
1159
|
+
let sent = checked;
|
|
1090
1160
|
const ahead = !ready();
|
|
1091
1161
|
if (ahead) {
|
|
1092
1162
|
sent = take(sent);
|
|
@@ -1095,9 +1165,6 @@ const makeWorker = (options, allowScript) => {
|
|
|
1095
1165
|
signal,
|
|
1096
1166
|
onProgress
|
|
1097
1167
|
});
|
|
1098
|
-
if (warning) {
|
|
1099
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
1100
|
-
}
|
|
1101
1168
|
return mapped ? rebuild(image)(result) : result;
|
|
1102
1169
|
})();
|
|
1103
1170
|
};
|
|
@@ -1120,6 +1187,12 @@ const makeWorker = (options, allowScript) => {
|
|
|
1120
1187
|
instance.cluster = (image, clusterOptions) => {
|
|
1121
1188
|
const origin = new Error();
|
|
1122
1189
|
return (async () => {
|
|
1190
|
+
// The image is checked before the options and the abort, as the main entry does.
|
|
1191
|
+
const bare = (0, _shared.bareImageError)(image);
|
|
1192
|
+
if (bare) {
|
|
1193
|
+
throw bare;
|
|
1194
|
+
}
|
|
1195
|
+
const checked = send(image);
|
|
1123
1196
|
const {
|
|
1124
1197
|
options,
|
|
1125
1198
|
signal,
|
|
@@ -1129,9 +1202,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1129
1202
|
throw abortReason(signal);
|
|
1130
1203
|
}
|
|
1131
1204
|
const id = nextHandle++;
|
|
1132
|
-
const
|
|
1133
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
1134
|
-
const sent = ready() ? send(image) : take(send(image));
|
|
1205
|
+
const sent = ready() ? checked : take(checked);
|
|
1135
1206
|
// Counted from before the call, so an abandoned worker isn't stopped between the call settling and the handle
|
|
1136
1207
|
// existing (see `abandoned`).
|
|
1137
1208
|
liveHandles++;
|
|
@@ -1150,9 +1221,6 @@ const makeWorker = (options, allowScript) => {
|
|
|
1150
1221
|
}
|
|
1151
1222
|
throw error;
|
|
1152
1223
|
}
|
|
1153
|
-
if (warning) {
|
|
1154
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
1155
|
-
}
|
|
1156
1224
|
return makeHandle(id, 'image', rebuild(image));
|
|
1157
1225
|
})();
|
|
1158
1226
|
};
|
|
@@ -1239,29 +1307,16 @@ const init = (...args) => sharedWorker().init(...args);
|
|
|
1239
1307
|
exports.init = init;
|
|
1240
1308
|
const buildClustering = (...args) => sharedWorker().buildClustering(...args);
|
|
1241
1309
|
exports.buildClustering = buildClustering;
|
|
1242
|
-
const getClustering = exports.getClustering = buildClustering;
|
|
1243
1310
|
const buildPalette = (...args) => sharedWorker().buildPalette(...args);
|
|
1244
1311
|
exports.buildPalette = buildPalette;
|
|
1245
|
-
const getPalette = exports.getPalette = buildPalette;
|
|
1246
|
-
const getPaletteFromClustering = (...args) => sharedWorker().getPaletteFromClustering(...args);
|
|
1247
|
-
exports.getPaletteFromClustering = getPaletteFromClustering;
|
|
1248
1312
|
const buildSwatches = (...args) => sharedWorker().buildSwatches(...args);
|
|
1249
1313
|
exports.buildSwatches = buildSwatches;
|
|
1250
|
-
const getSwatches = exports.getSwatches = buildSwatches;
|
|
1251
|
-
const getSwatchesFromClustering = (...args) => sharedWorker().getSwatchesFromClustering(...args);
|
|
1252
|
-
exports.getSwatchesFromClustering = getSwatchesFromClustering;
|
|
1253
|
-
const getClusteringInfo = (...args) => sharedWorker().getClusteringInfo(...args);
|
|
1254
|
-
exports.getClusteringInfo = getClusteringInfo;
|
|
1255
1314
|
const quantize = (...args) => sharedWorker().quantize(...args);
|
|
1256
1315
|
exports.quantize = quantize;
|
|
1257
|
-
const quantizeFromClustering = (...args) => sharedWorker().quantizeFromClustering(...args);
|
|
1258
|
-
exports.quantizeFromClustering = quantizeFromClustering;
|
|
1259
1316
|
const quantizeWithPalette = (...args) => sharedWorker().quantizeWithPalette(...args);
|
|
1260
1317
|
exports.quantizeWithPalette = quantizeWithPalette;
|
|
1261
1318
|
const quantizeToIndices = (...args) => sharedWorker().quantizeToIndices(...args);
|
|
1262
1319
|
exports.quantizeToIndices = quantizeToIndices;
|
|
1263
|
-
const quantizeToIndicesFromClustering = (...args) => sharedWorker().quantizeToIndicesFromClustering(...args);
|
|
1264
|
-
exports.quantizeToIndicesFromClustering = quantizeToIndicesFromClustering;
|
|
1265
1320
|
const quantizeToIndicesWithPalette = (...args) => sharedWorker().quantizeToIndicesWithPalette(...args);
|
|
1266
1321
|
exports.quantizeToIndicesWithPalette = quantizeToIndicesWithPalette;
|
|
1267
1322
|
// For file tracers (see scripts/patch-cjs.mjs); never called.
|
package/dist/worker.d.cts
CHANGED
|
@@ -127,29 +127,13 @@ export interface AgglomerativeWorker {
|
|
|
127
127
|
init(options?: InitOptions): Promise<void>;
|
|
128
128
|
/** The main entry's `buildClustering`, run in this worker. */
|
|
129
129
|
buildClustering(image: ImageLike, options?: ClusteringOptions): Promise<Clustering>;
|
|
130
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildClustering} in 3.4.0 (the same function). Removed in 4.0. */
|
|
131
|
-
getClustering(image: ImageLike, options?: ClusteringOptions): Promise<Clustering>;
|
|
132
130
|
/** The main entry's `buildPalette`, run in this worker. */
|
|
133
131
|
buildPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
134
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
135
|
-
getPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
136
|
-
/** @deprecated Use `clustering.getPalette(k)`; off the main thread, `(await worker.load(clustering)).getPalette(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
137
|
-
getPaletteFromClustering(clustering: Clustering, k: number): Promise<Palette>;
|
|
138
132
|
/** The main entry's `buildSwatches`, run in this worker. */
|
|
139
133
|
buildSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
140
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
141
|
-
getSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
142
|
-
/** @deprecated Use `clustering.getSwatches(k)`; off the main thread, `(await worker.load(clustering)).getSwatches(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
143
|
-
getSwatchesFromClustering(clustering: Clustering, k: number): Promise<Swatches>;
|
|
144
|
-
/** @deprecated Use `clustering.getClusteringInfo()`; off the main thread, `(await worker.load(clustering)).getClusteringInfo()` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
145
|
-
getClusteringInfo(clustering: Clustering): Promise<ClusteringInfo>;
|
|
146
134
|
quantize<Image extends ImageLike>(image: Image, k: number, options?: QuantizeOptions): Promise<ImageResult<Image>>;
|
|
147
|
-
/** @deprecated Use `clustering.quantize(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantize(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
148
|
-
quantizeFromClustering<Image extends ImageLike>(image: Image, clustering: Clustering, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
149
135
|
quantizeWithPalette<Image extends ImageLike>(image: Image, palette: PaletteLike, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
150
136
|
quantizeToIndices(image: ImageLike, k: number, options?: QuantizeIndexOptions): Promise<IndexedImage>;
|
|
151
|
-
/** @deprecated Use `clustering.quantizeToIndices(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantizeToIndices(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
152
|
-
quantizeToIndicesFromClustering(image: ImageLike, clustering: Clustering, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
153
137
|
quantizeToIndicesWithPalette(image: ImageLike, palette: PaletteLike, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
154
138
|
/** Clusters `image` and keeps it, with its clustering, in the worker. */
|
|
155
139
|
cluster<Image extends ImageLike>(image: Image, options?: ClusteringOptions): Promise<ClusteringHandle<ImageResult<Image>>>;
|
|
@@ -183,31 +167,15 @@ export function terminate(): Promise<void>;
|
|
|
183
167
|
export function init(options?: SharedInitOptions): Promise<void>;
|
|
184
168
|
/** The main entry's `buildClustering`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
185
169
|
export const buildClustering: AgglomerativeWorker['buildClustering'];
|
|
186
|
-
/** @deprecated Renamed {@link buildClustering} in 3.4.0 (the same function). Removed in 4.0. */
|
|
187
|
-
export const getClustering: AgglomerativeWorker['getClustering'];
|
|
188
170
|
/** The main entry's `buildPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
189
171
|
export const buildPalette: AgglomerativeWorker['buildPalette'];
|
|
190
|
-
/** @deprecated Renamed {@link buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
191
|
-
export const getPalette: AgglomerativeWorker['getPalette'];
|
|
192
|
-
/** @deprecated Use `clustering.getPalette(k)`; off the main thread, `(await worker.load(clustering)).getPalette(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
193
|
-
export const getPaletteFromClustering: AgglomerativeWorker['getPaletteFromClustering'];
|
|
194
172
|
/** The main entry's `buildSwatches`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
195
173
|
export const buildSwatches: AgglomerativeWorker['buildSwatches'];
|
|
196
|
-
/** @deprecated Renamed {@link buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
197
|
-
export const getSwatches: AgglomerativeWorker['getSwatches'];
|
|
198
|
-
/** @deprecated Use `clustering.getSwatches(k)`; off the main thread, `(await worker.load(clustering)).getSwatches(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
199
|
-
export const getSwatchesFromClustering: AgglomerativeWorker['getSwatchesFromClustering'];
|
|
200
|
-
/** @deprecated Use `clustering.getClusteringInfo()`; off the main thread, `(await worker.load(clustering)).getClusteringInfo()` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
201
|
-
export const getClusteringInfo: AgglomerativeWorker['getClusteringInfo'];
|
|
202
174
|
/** The main entry's `quantize`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
203
175
|
export const quantize: AgglomerativeWorker['quantize'];
|
|
204
|
-
/** @deprecated Use `clustering.quantize(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantize(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
205
|
-
export const quantizeFromClustering: AgglomerativeWorker['quantizeFromClustering'];
|
|
206
176
|
/** The main entry's `quantizeWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
207
177
|
export const quantizeWithPalette: AgglomerativeWorker['quantizeWithPalette'];
|
|
208
178
|
/** The main entry's `quantizeToIndices`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
209
179
|
export const quantizeToIndices: AgglomerativeWorker['quantizeToIndices'];
|
|
210
|
-
/** @deprecated Use `clustering.quantizeToIndices(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantizeToIndices(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
211
|
-
export const quantizeToIndicesFromClustering: AgglomerativeWorker['quantizeToIndicesFromClustering'];
|
|
212
180
|
/** The main entry's `quantizeToIndicesWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
213
181
|
export const quantizeToIndicesWithPalette: AgglomerativeWorker['quantizeToIndicesWithPalette'];
|
package/dist/worker.d.ts
CHANGED
|
@@ -127,29 +127,13 @@ export interface AgglomerativeWorker {
|
|
|
127
127
|
init(options?: InitOptions): Promise<void>;
|
|
128
128
|
/** The main entry's `buildClustering`, run in this worker. */
|
|
129
129
|
buildClustering(image: ImageLike, options?: ClusteringOptions): Promise<Clustering>;
|
|
130
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildClustering} in 3.4.0 (the same function). Removed in 4.0. */
|
|
131
|
-
getClustering(image: ImageLike, options?: ClusteringOptions): Promise<Clustering>;
|
|
132
130
|
/** The main entry's `buildPalette`, run in this worker. */
|
|
133
131
|
buildPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
134
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
135
|
-
getPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
136
|
-
/** @deprecated Use `clustering.getPalette(k)`; off the main thread, `(await worker.load(clustering)).getPalette(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
137
|
-
getPaletteFromClustering(clustering: Clustering, k: number): Promise<Palette>;
|
|
138
132
|
/** The main entry's `buildSwatches`, run in this worker. */
|
|
139
133
|
buildSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
140
|
-
/** @deprecated Renamed {@link AgglomerativeWorker.buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
141
|
-
getSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
142
|
-
/** @deprecated Use `clustering.getSwatches(k)`; off the main thread, `(await worker.load(clustering)).getSwatches(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
143
|
-
getSwatchesFromClustering(clustering: Clustering, k: number): Promise<Swatches>;
|
|
144
|
-
/** @deprecated Use `clustering.getClusteringInfo()`; off the main thread, `(await worker.load(clustering)).getClusteringInfo()` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
145
|
-
getClusteringInfo(clustering: Clustering): Promise<ClusteringInfo>;
|
|
146
134
|
quantize<Image extends ImageLike>(image: Image, k: number, options?: QuantizeOptions): Promise<ImageResult<Image>>;
|
|
147
|
-
/** @deprecated Use `clustering.quantize(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantize(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
148
|
-
quantizeFromClustering<Image extends ImageLike>(image: Image, clustering: Clustering, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
149
135
|
quantizeWithPalette<Image extends ImageLike>(image: Image, palette: PaletteLike, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
150
136
|
quantizeToIndices(image: ImageLike, k: number, options?: QuantizeIndexOptions): Promise<IndexedImage>;
|
|
151
|
-
/** @deprecated Use `clustering.quantizeToIndices(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantizeToIndices(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
152
|
-
quantizeToIndicesFromClustering(image: ImageLike, clustering: Clustering, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
153
137
|
quantizeToIndicesWithPalette(image: ImageLike, palette: PaletteLike, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
154
138
|
/** Clusters `image` and keeps it, with its clustering, in the worker. */
|
|
155
139
|
cluster<Image extends ImageLike>(image: Image, options?: ClusteringOptions): Promise<ClusteringHandle<ImageResult<Image>>>;
|
|
@@ -183,31 +167,15 @@ export function terminate(): Promise<void>;
|
|
|
183
167
|
export function init(options?: SharedInitOptions): Promise<void>;
|
|
184
168
|
/** The main entry's `buildClustering`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
185
169
|
export const buildClustering: AgglomerativeWorker['buildClustering'];
|
|
186
|
-
/** @deprecated Renamed {@link buildClustering} in 3.4.0 (the same function). Removed in 4.0. */
|
|
187
|
-
export const getClustering: AgglomerativeWorker['getClustering'];
|
|
188
170
|
/** The main entry's `buildPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
189
171
|
export const buildPalette: AgglomerativeWorker['buildPalette'];
|
|
190
|
-
/** @deprecated Renamed {@link buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
191
|
-
export const getPalette: AgglomerativeWorker['getPalette'];
|
|
192
|
-
/** @deprecated Use `clustering.getPalette(k)`; off the main thread, `(await worker.load(clustering)).getPalette(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
193
|
-
export const getPaletteFromClustering: AgglomerativeWorker['getPaletteFromClustering'];
|
|
194
172
|
/** The main entry's `buildSwatches`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
195
173
|
export const buildSwatches: AgglomerativeWorker['buildSwatches'];
|
|
196
|
-
/** @deprecated Renamed {@link buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
197
|
-
export const getSwatches: AgglomerativeWorker['getSwatches'];
|
|
198
|
-
/** @deprecated Use `clustering.getSwatches(k)`; off the main thread, `(await worker.load(clustering)).getSwatches(k)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
199
|
-
export const getSwatchesFromClustering: AgglomerativeWorker['getSwatchesFromClustering'];
|
|
200
|
-
/** @deprecated Use `clustering.getClusteringInfo()`; off the main thread, `(await worker.load(clustering)).getClusteringInfo()` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
201
|
-
export const getClusteringInfo: AgglomerativeWorker['getClusteringInfo'];
|
|
202
174
|
/** The main entry's `quantize`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
203
175
|
export const quantize: AgglomerativeWorker['quantize'];
|
|
204
|
-
/** @deprecated Use `clustering.quantize(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantize(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
205
|
-
export const quantizeFromClustering: AgglomerativeWorker['quantizeFromClustering'];
|
|
206
176
|
/** The main entry's `quantizeWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
207
177
|
export const quantizeWithPalette: AgglomerativeWorker['quantizeWithPalette'];
|
|
208
178
|
/** The main entry's `quantizeToIndices`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
209
179
|
export const quantizeToIndices: AgglomerativeWorker['quantizeToIndices'];
|
|
210
|
-
/** @deprecated Use `clustering.quantizeToIndices(image, k, options)`; off the main thread, `(await worker.load(clustering)).quantizeToIndices(image, k, options)` (`worker.load` is in the worker entry). Deprecated in 3.8, removed in 4.0; no warning at run time. */
|
|
211
|
-
export const quantizeToIndicesFromClustering: AgglomerativeWorker['quantizeToIndicesFromClustering'];
|
|
212
180
|
/** The main entry's `quantizeToIndicesWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
213
181
|
export const quantizeToIndicesWithPalette: AgglomerativeWorker['quantizeToIndicesWithPalette'];
|