agglomerative-clustering 4.0.0-beta.2 → 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 +26 -56
- package/dist/index.d.cts +15 -76
- package/dist/index.d.ts +15 -76
- package/dist/index.mjs +25 -50
- package/dist/shared.cjs +30 -78
- package/dist/shared.mjs +28 -73
- package/dist/worker-thread.mjs +15 -18
- package/dist/worker.cjs +108 -60
- package/dist/worker.d.cts +0 -32
- package/dist/worker.d.ts +0 -32
- package/dist/worker.mjs +107 -54
- 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 () {
|
|
@@ -581,24 +581,54 @@ const sendable = value => {
|
|
|
581
581
|
|
|
582
582
|
// Where the options sit among a function's arguments after the image (see takeControls).
|
|
583
583
|
const optionsPosition = {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
584
|
+
buildClustering: 0,
|
|
585
|
+
buildPalette: 1,
|
|
586
|
+
buildSwatches: 1,
|
|
587
587
|
quantize: 1,
|
|
588
|
-
quantizeFromClustering: 2,
|
|
589
588
|
quantizeWithPalette: 1,
|
|
590
589
|
quantizeToIndices: 1,
|
|
591
|
-
quantizeToIndicesFromClustering: 2,
|
|
592
590
|
quantizeToIndicesWithPalette: 1
|
|
593
591
|
};
|
|
594
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
|
+
|
|
595
626
|
// Like fetch: an aborted call rejects with the signal's reason, an AbortError unless the caller gave another.
|
|
596
627
|
const abortReason = signal => signal.reason !== undefined ? signal.reason : new DOMException('This operation was aborted', 'AbortError');
|
|
597
|
-
const imageFunctions = ['
|
|
598
|
-
const mappedImageFunctions = ['quantize', '
|
|
628
|
+
const imageFunctions = ['buildClustering', 'buildPalette', 'buildSwatches', 'quantize', 'quantizeWithPalette', 'quantizeToIndices', 'quantizeToIndicesWithPalette'];
|
|
629
|
+
const mappedImageFunctions = ['quantize', 'quantizeWithPalette'];
|
|
599
630
|
// The functions that only cluster, and so take no dither option.
|
|
600
|
-
const clusteringOnlyFunctions = ['
|
|
601
|
-
const otherFunctions = ['getPaletteFromClustering', 'getSwatchesFromClustering', 'getClusteringInfo'];
|
|
631
|
+
const clusteringOnlyFunctions = ['buildClustering', 'buildPalette', 'buildSwatches'];
|
|
602
632
|
|
|
603
633
|
// Calls each worker's `abandon` once the worker made by createWorker() has been garbage-collected (see `abandoned`).
|
|
604
634
|
const abandonment = typeof FinalizationRegistry === 'function' ? new FinalizationRegistry(abandon => abandon()) : null;
|
|
@@ -629,6 +659,9 @@ const makeWorker = (options, allowScript) => {
|
|
|
629
659
|
wasm: initialWasm
|
|
630
660
|
};
|
|
631
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;
|
|
632
665
|
let connection = null;
|
|
633
666
|
let starting = null;
|
|
634
667
|
// Counts the workers this instance has started, so a late message or error from one it already dropped is ignored.
|
|
@@ -646,7 +679,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
646
679
|
let nextHandle = 1;
|
|
647
680
|
const pending = new Map();
|
|
648
681
|
// Whether a call made now is posted before it returns (see `own`).
|
|
649
|
-
const ready = () => connection !== null && !initial;
|
|
682
|
+
const ready = () => connection !== null && shaken && !initial;
|
|
650
683
|
// The image of a call made before the worker is ready: with `transfer: true` its buffer is moved out of the caller's
|
|
651
684
|
// hands at once (a structured clone that transfers it, so the caller's array empties now, as it would on posting),
|
|
652
685
|
// otherwise copied.
|
|
@@ -685,6 +718,8 @@ const makeWorker = (options, allowScript) => {
|
|
|
685
718
|
connection = null;
|
|
686
719
|
starting = null;
|
|
687
720
|
initialising = null;
|
|
721
|
+
shaken = false;
|
|
722
|
+
shaking = null;
|
|
688
723
|
if (initialWasm !== undefined) {
|
|
689
724
|
initial = {
|
|
690
725
|
wasm: initialWasm
|
|
@@ -785,6 +820,41 @@ const makeWorker = (options, allowScript) => {
|
|
|
785
820
|
}
|
|
786
821
|
connection = connection || started;
|
|
787
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
|
+
}
|
|
788
858
|
if (initial && !(method === 'init' && args.length > 0 && args[0].wasm !== undefined)) {
|
|
789
859
|
initialising = initialising || post('init', [initial], [], origin).then(() => {
|
|
790
860
|
initial = null;
|
|
@@ -887,10 +957,8 @@ const makeWorker = (options, allowScript) => {
|
|
|
887
957
|
connection.unref();
|
|
888
958
|
}
|
|
889
959
|
// A value that can't be structured-cloned (a function, symbol or promise) is an invalid argument, as it
|
|
890
|
-
// would be if the main entry were called with it.
|
|
891
|
-
reject(error && error.name === 'DataCloneError' ?
|
|
892
|
-
cause: error
|
|
893
|
-
}) : 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);
|
|
894
962
|
}
|
|
895
963
|
});
|
|
896
964
|
};
|
|
@@ -900,6 +968,14 @@ const makeWorker = (options, allowScript) => {
|
|
|
900
968
|
instance[name] = (image, ...rest) => {
|
|
901
969
|
const origin = new Error();
|
|
902
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);
|
|
903
979
|
const position = optionsPosition[name];
|
|
904
980
|
const {
|
|
905
981
|
options,
|
|
@@ -914,7 +990,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
914
990
|
// The main entry reports a wrong argument before an abort, so the worker checks the arguments (a
|
|
915
991
|
// copy, never transferred: an aborted call leaves the image with the caller) without doing the work.
|
|
916
992
|
try {
|
|
917
|
-
await invoke(name, [own(
|
|
993
|
+
await invoke(name, [own(checked), ...args.map(own)], [], origin, {
|
|
918
994
|
check: true
|
|
919
995
|
});
|
|
920
996
|
} catch (error) {
|
|
@@ -924,12 +1000,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
924
1000
|
}
|
|
925
1001
|
throw abortReason(signal);
|
|
926
1002
|
}
|
|
927
|
-
|
|
928
|
-
// array, and given once the call succeeds: the thread checks the other arguments, and its own copy is
|
|
929
|
-
// silenced (PRINCIPLES "Warnings").
|
|
930
|
-
const warning = (0, _shared.bareImageWarning)(image);
|
|
931
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
932
|
-
let sent = send(image);
|
|
1003
|
+
let sent = checked;
|
|
933
1004
|
if (!ready()) {
|
|
934
1005
|
sent = take(sent);
|
|
935
1006
|
args = args.map(own);
|
|
@@ -938,21 +1009,10 @@ const makeWorker = (options, allowScript) => {
|
|
|
938
1009
|
signal,
|
|
939
1010
|
onProgress
|
|
940
1011
|
});
|
|
941
|
-
if (warning) {
|
|
942
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
943
|
-
}
|
|
944
1012
|
return mapped ? rebuild(image)(result) : result;
|
|
945
1013
|
})();
|
|
946
1014
|
};
|
|
947
1015
|
}
|
|
948
|
-
for (const name of otherFunctions) {
|
|
949
|
-
instance[name] = (...args) => invoke(name, ready() ? args : args.map(own), [], new Error());
|
|
950
|
-
}
|
|
951
|
-
// 3.4.0's names for the functions that cluster an image. The old names are the same functions, and they still name the
|
|
952
|
-
// call on the wire, so a worker script copied from an older version still understands it.
|
|
953
|
-
instance.buildClustering = instance.getClustering;
|
|
954
|
-
instance.buildPalette = instance.getPalette;
|
|
955
|
-
instance.buildSwatches = instance.getSwatches;
|
|
956
1016
|
instance.init = initArgs => {
|
|
957
1017
|
const origin = new Error();
|
|
958
1018
|
let checked;
|
|
@@ -1073,6 +1133,11 @@ const makeWorker = (options, allowScript) => {
|
|
|
1073
1133
|
if (released || !handle) {
|
|
1074
1134
|
throw (0, _shared.fail)('invalid-handle', "Invalid handle: it was released.");
|
|
1075
1135
|
}
|
|
1136
|
+
const bare = (0, _shared.bareImageError)(image);
|
|
1137
|
+
if (bare) {
|
|
1138
|
+
throw bare;
|
|
1139
|
+
}
|
|
1140
|
+
const checked = send(image);
|
|
1076
1141
|
const {
|
|
1077
1142
|
options,
|
|
1078
1143
|
signal,
|
|
@@ -1081,7 +1146,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1081
1146
|
if (signal && signal.aborted) {
|
|
1082
1147
|
// As the functions on the worker do: a wrong argument is reported before the abort.
|
|
1083
1148
|
try {
|
|
1084
|
-
await invoke(method, [id, own(
|
|
1149
|
+
await invoke(method, [id, own(checked), k, options], [], origin, {
|
|
1085
1150
|
check: true
|
|
1086
1151
|
});
|
|
1087
1152
|
} catch (error) {
|
|
@@ -1091,9 +1156,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1091
1156
|
}
|
|
1092
1157
|
throw abortReason(signal);
|
|
1093
1158
|
}
|
|
1094
|
-
|
|
1095
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
1096
|
-
let sent = send(image);
|
|
1159
|
+
let sent = checked;
|
|
1097
1160
|
const ahead = !ready();
|
|
1098
1161
|
if (ahead) {
|
|
1099
1162
|
sent = take(sent);
|
|
@@ -1102,9 +1165,6 @@ const makeWorker = (options, allowScript) => {
|
|
|
1102
1165
|
signal,
|
|
1103
1166
|
onProgress
|
|
1104
1167
|
});
|
|
1105
|
-
if (warning) {
|
|
1106
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
1107
|
-
}
|
|
1108
1168
|
return mapped ? rebuild(image)(result) : result;
|
|
1109
1169
|
})();
|
|
1110
1170
|
};
|
|
@@ -1127,6 +1187,12 @@ const makeWorker = (options, allowScript) => {
|
|
|
1127
1187
|
instance.cluster = (image, clusterOptions) => {
|
|
1128
1188
|
const origin = new Error();
|
|
1129
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);
|
|
1130
1196
|
const {
|
|
1131
1197
|
options,
|
|
1132
1198
|
signal,
|
|
@@ -1136,9 +1202,7 @@ const makeWorker = (options, allowScript) => {
|
|
|
1136
1202
|
throw abortReason(signal);
|
|
1137
1203
|
}
|
|
1138
1204
|
const id = nextHandle++;
|
|
1139
|
-
const
|
|
1140
|
-
const byteLength = warning ? image.byteLength : 0;
|
|
1141
|
-
const sent = ready() ? send(image) : take(send(image));
|
|
1205
|
+
const sent = ready() ? checked : take(checked);
|
|
1142
1206
|
// Counted from before the call, so an abandoned worker isn't stopped between the call settling and the handle
|
|
1143
1207
|
// existing (see `abandoned`).
|
|
1144
1208
|
liveHandles++;
|
|
@@ -1157,9 +1221,6 @@ const makeWorker = (options, allowScript) => {
|
|
|
1157
1221
|
}
|
|
1158
1222
|
throw error;
|
|
1159
1223
|
}
|
|
1160
|
-
if (warning) {
|
|
1161
|
-
(0, _shared.warnOnce)(warning, byteLength);
|
|
1162
|
-
}
|
|
1163
1224
|
return makeHandle(id, 'image', rebuild(image));
|
|
1164
1225
|
})();
|
|
1165
1226
|
};
|
|
@@ -1246,29 +1307,16 @@ const init = (...args) => sharedWorker().init(...args);
|
|
|
1246
1307
|
exports.init = init;
|
|
1247
1308
|
const buildClustering = (...args) => sharedWorker().buildClustering(...args);
|
|
1248
1309
|
exports.buildClustering = buildClustering;
|
|
1249
|
-
const getClustering = exports.getClustering = buildClustering;
|
|
1250
1310
|
const buildPalette = (...args) => sharedWorker().buildPalette(...args);
|
|
1251
1311
|
exports.buildPalette = buildPalette;
|
|
1252
|
-
const getPalette = exports.getPalette = buildPalette;
|
|
1253
|
-
const getPaletteFromClustering = (...args) => sharedWorker().getPaletteFromClustering(...args);
|
|
1254
|
-
exports.getPaletteFromClustering = getPaletteFromClustering;
|
|
1255
1312
|
const buildSwatches = (...args) => sharedWorker().buildSwatches(...args);
|
|
1256
1313
|
exports.buildSwatches = buildSwatches;
|
|
1257
|
-
const getSwatches = exports.getSwatches = buildSwatches;
|
|
1258
|
-
const getSwatchesFromClustering = (...args) => sharedWorker().getSwatchesFromClustering(...args);
|
|
1259
|
-
exports.getSwatchesFromClustering = getSwatchesFromClustering;
|
|
1260
|
-
const getClusteringInfo = (...args) => sharedWorker().getClusteringInfo(...args);
|
|
1261
|
-
exports.getClusteringInfo = getClusteringInfo;
|
|
1262
1314
|
const quantize = (...args) => sharedWorker().quantize(...args);
|
|
1263
1315
|
exports.quantize = quantize;
|
|
1264
|
-
const quantizeFromClustering = (...args) => sharedWorker().quantizeFromClustering(...args);
|
|
1265
|
-
exports.quantizeFromClustering = quantizeFromClustering;
|
|
1266
1316
|
const quantizeWithPalette = (...args) => sharedWorker().quantizeWithPalette(...args);
|
|
1267
1317
|
exports.quantizeWithPalette = quantizeWithPalette;
|
|
1268
1318
|
const quantizeToIndices = (...args) => sharedWorker().quantizeToIndices(...args);
|
|
1269
1319
|
exports.quantizeToIndices = quantizeToIndices;
|
|
1270
|
-
const quantizeToIndicesFromClustering = (...args) => sharedWorker().quantizeToIndicesFromClustering(...args);
|
|
1271
|
-
exports.quantizeToIndicesFromClustering = quantizeToIndicesFromClustering;
|
|
1272
1320
|
const quantizeToIndicesWithPalette = (...args) => sharedWorker().quantizeToIndicesWithPalette(...args);
|
|
1273
1321
|
exports.quantizeToIndicesWithPalette = quantizeToIndicesWithPalette;
|
|
1274
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'];
|