agglomerative-clustering 3.7.2 → 4.0.0-beta.1
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 +9 -8
- package/dist/choose.cjs +166 -0
- package/dist/choose.mjs +160 -0
- package/dist/clustering.cjs +1 -1
- package/dist/clustering.js +1 -1
- package/dist/clustering.wasm +0 -0
- package/dist/index.cjs +103 -64
- package/dist/index.d.cts +80 -19
- package/dist/index.d.ts +80 -19
- package/dist/index.mjs +102 -63
- package/dist/shared.cjs +129 -5
- package/dist/shared.mjs +123 -3
- package/dist/worker-thread.mjs +13 -2
- package/dist/worker.cjs +183 -64
- package/dist/worker.d.cts +51 -8
- package/dist/worker.d.ts +51 -8
- package/dist/worker.mjs +184 -65
- package/package.json +2 -2
package/dist/worker.cjs
CHANGED
|
@@ -207,7 +207,7 @@ const start = async (receive, chosen) => {
|
|
|
207
207
|
// A page with an opaque origin (a sandboxed iframe without allow-same-origin, as plugin hosts such as Figma use) can't
|
|
208
208
|
// start a worker from any http(s) script, nor, in Chromium, from a blob: URL; a data: URL module can, and imports it.
|
|
209
209
|
const opaque = !crossOrigin && isOpaqueOrigin() && webOrigins.includes(script.protocol);
|
|
210
|
-
const scriptHint = "Check that worker-thread.mjs is served (open its URL), with index.mjs, shared.mjs, clustering.js and clustering.wasm next to it, which it imports, or say where your copy of dist/ is with createWorker({ script }) or, for the shared worker, init({ script }).";
|
|
210
|
+
const scriptHint = "Check that worker-thread.mjs is served (open its URL), with index.mjs, shared.mjs, choose.mjs, clustering.js and clustering.wasm next to it, which it imports, or say where your copy of dist/ is with createWorker({ script }) or, for the shared worker, init({ script }).";
|
|
211
211
|
let worker,
|
|
212
212
|
source = null;
|
|
213
213
|
try {
|
|
@@ -268,7 +268,7 @@ const start = async (receive, chosen) => {
|
|
|
268
268
|
// Yarn Plug'n'Play keeps packages in zip archives, which Node reads ES modules from only through Yarn's loader.
|
|
269
269
|
const inZip = error => /\.zip[\\/]/.test(String(error && error.message));
|
|
270
270
|
worker.on('error', error => receive({
|
|
271
|
-
failure: missing(error) ? inZip(error) ? `${String(error.message).split('\n')[0]}. Under Yarn Plug'n'Play the package sits in a zip archive, which a worker thread can load its ES modules from only through Yarn's loader: run the app with yarn node (or node --require ./.pnp.cjs --loader ./.pnp.loader.mjs), or unplug the package (yarn unplug agglomerative-clustering). Otherwise keep dist/ together and say where it is with createWorker({ script }).` : `${String(error.message).split('\n')[0]}. The worker script (worker-thread.mjs) needs index.mjs, shared.mjs, clustering.js and clustering.wasm next to it: keep dist/ together, and say where it is with createWorker({ script }) or, for the shared worker, init({ script }) (a path, or a file: URL). In a serverless deployment (AWS Lambda, Vercel or Netlify functions), the file tracer may have left them out: include node_modules/agglomerative-clustering/dist in the function's files.` : error.message
|
|
271
|
+
failure: missing(error) ? inZip(error) ? `${String(error.message).split('\n')[0]}. Under Yarn Plug'n'Play the package sits in a zip archive, which a worker thread can load its ES modules from only through Yarn's loader: run the app with yarn node (or node --require ./.pnp.cjs --loader ./.pnp.loader.mjs), or unplug the package (yarn unplug agglomerative-clustering). Otherwise keep dist/ together and say where it is with createWorker({ script }).` : `${String(error.message).split('\n')[0]}. The worker script (worker-thread.mjs) needs index.mjs, shared.mjs, choose.mjs, clustering.js and clustering.wasm next to it: keep dist/ together, and say where it is with createWorker({ script }) or, for the shared worker, init({ script }) (a path, or a file: URL). In a serverless deployment (AWS Lambda, Vercel or Netlify functions), the file tracer may have left them out: include node_modules/agglomerative-clustering/dist in the function's files.` : error.message
|
|
272
272
|
}));
|
|
273
273
|
worker.on('exit', code => receive({
|
|
274
274
|
failure: `The worker exited unexpectedly (code ${code}).`
|
|
@@ -344,10 +344,20 @@ const send = image => {
|
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
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.
|
|
347
349
|
const sent = {
|
|
348
350
|
data: image.data,
|
|
349
351
|
format: image.format
|
|
350
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
|
+
}
|
|
351
361
|
if (image.width !== undefined) {
|
|
352
362
|
sent.width = image.width;
|
|
353
363
|
}
|
|
@@ -960,6 +970,152 @@ const makeWorker = (options, allowScript) => {
|
|
|
960
970
|
return invoke('init', checked === undefined || Object.keys(checked).length === 0 ? [] : [checked], [], origin).then(() => undefined);
|
|
961
971
|
};
|
|
962
972
|
|
|
973
|
+
// Whether a value is an image where a palette size was expected (a pixel array, an ImageData or `{data, ...}`).
|
|
974
|
+
const looksLikeImage = value => value !== null && typeof value === 'object' && ((0, _shared.isUint8Array)(value) || (0, _shared.isUint8ClampedArray)(value) || (0, _shared.isImageData)(value) || 'data' in value);
|
|
975
|
+
// Builds the handle object for what the worker keeps under `id`: `kind` is 'image' (from `cluster`: an image and its
|
|
976
|
+
// clustering) or 'clustering' (from `load`: a clustering alone). `output` turns a mapped result back into the type of the image given.
|
|
977
|
+
const makeHandle = (id, kind, output) => {
|
|
978
|
+
let released = false;
|
|
979
|
+
// Every method goes through `use`, which refers to `handle`, so a method kept after the handle itself is dropped
|
|
980
|
+
// keeps it alive and it is not reclaimed while still in use.
|
|
981
|
+
const use = (method, args, controls) => {
|
|
982
|
+
if (released || !handle) {
|
|
983
|
+
return Promise.reject((0, _shared.fail)('invalid-handle', "Invalid handle: it was released."));
|
|
984
|
+
}
|
|
985
|
+
return invoke(method, [id, ...args], [], new Error(), controls);
|
|
986
|
+
};
|
|
987
|
+
// Calls with mapping options, whose signal and progress callback stay on this side (see takeControls).
|
|
988
|
+
const withControls = (method, leading, mapOptions) => {
|
|
989
|
+
let taken;
|
|
990
|
+
try {
|
|
991
|
+
taken = takeControls(mapOptions);
|
|
992
|
+
} catch (error) {
|
|
993
|
+
return Promise.reject(error);
|
|
994
|
+
}
|
|
995
|
+
return use(method, [...leading, taken.options], {
|
|
996
|
+
signal: taken.signal,
|
|
997
|
+
onProgress: taken.onProgress
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
// The cuts take no options (the handle's clustering already says how it was made): one passed anyway is an error,
|
|
1001
|
+
// as in the main entry, rather than silently ignored.
|
|
1002
|
+
const plain = (method, name, args, extra) => extra.some(value => value !== undefined) ? Promise.reject((0, _shared.fail)('invalid-argument', `Invalid arguments: handle.${name} takes no options. To map pixels with options, use handle.quantize.`, 'options')) : use(method, args);
|
|
1003
|
+
// An image where k belongs is a mix-up between the two kinds of handle: say so, rather than "k must be an integer".
|
|
1004
|
+
const imageAsK = (name, k) => looksLikeImage(k) ? Promise.reject((0, _shared.fail)('invalid-argument', `Invalid k: this handle holds an image (from worker.cluster) and maps it with ${name}(k); pass k, not an image. To map other images with a stored clustering, use worker.load(clustering).`, 'k')) : null;
|
|
1005
|
+
const handle = {
|
|
1006
|
+
getPalette: (k, ...extra) => plain('handleGetPalette', 'getPalette', [k], extra),
|
|
1007
|
+
getSwatches: (k, ...extra) => plain('handleGetSwatches', 'getSwatches', [k], extra),
|
|
1008
|
+
getClusteringInfo: (...extra) => plain('handleGetClusteringInfo', 'getClusteringInfo', [], extra),
|
|
1009
|
+
// Takes the signal only: the main entry's chooseFrom takes no progress callback, so one given crosses as null for
|
|
1010
|
+
// the thread to reject with the main entry's own error.
|
|
1011
|
+
// That relies on the thread injecting a progress poster only for calls that have one (see `optionsIndex` in
|
|
1012
|
+
// worker-thread.js): the null is then the only onProgress it sees, so its own option check rejects it.
|
|
1013
|
+
chooseFrom: (palette, k, chooseOptions) => {
|
|
1014
|
+
let taken;
|
|
1015
|
+
try {
|
|
1016
|
+
taken = takeControls(chooseOptions, false);
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
return Promise.reject(error);
|
|
1019
|
+
}
|
|
1020
|
+
const sent = taken.onProgress !== undefined ? {
|
|
1021
|
+
...taken.options,
|
|
1022
|
+
onProgress: null
|
|
1023
|
+
} : taken.options;
|
|
1024
|
+
return use('handleChooseFrom', [palette, k, sent], {
|
|
1025
|
+
signal: taken.signal
|
|
1026
|
+
});
|
|
1027
|
+
},
|
|
1028
|
+
release: async () => {
|
|
1029
|
+
if (released) {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
released = true;
|
|
1033
|
+
liveHandles--;
|
|
1034
|
+
if (reclaim) {
|
|
1035
|
+
reclaim.unregister(handle);
|
|
1036
|
+
}
|
|
1037
|
+
// If the worker has been terminated there is nothing left to free (so `await using` and
|
|
1038
|
+
// terminate() can come in either order); any other failure is reported.
|
|
1039
|
+
try {
|
|
1040
|
+
await invoke('release', [id], [], new Error());
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
if (error.code !== 'worker-terminated') {
|
|
1043
|
+
throw error;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
stopIfAbandoned();
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
if (kind === 'image') {
|
|
1050
|
+
Object.assign(handle, {
|
|
1051
|
+
getClustering: (...extra) => plain('handleGetClustering', 'getClustering', [], extra),
|
|
1052
|
+
quantize: (k, mapOptions) => imageAsK('quantize', k) || (async () => output(await withControls('handleQuantize', [k], mapOptions)))(),
|
|
1053
|
+
quantizeToIndices: (k, mapOptions) => imageAsK('quantizeToIndices', k) || withControls('handleQuantizeToIndices', [k], mapOptions),
|
|
1054
|
+
quantizeWithPalette: async (palette, mapOptions) => output(await withControls('handleQuantizeWithPalette', [palette], mapOptions)),
|
|
1055
|
+
quantizeToIndicesWithPalette: (palette, mapOptions) => withControls('handleQuantizeToIndicesWithPalette', [palette], mapOptions)
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
if (kind === 'clustering') {
|
|
1059
|
+
// The handle holds no image: each call maps the image it is given, and returns the type of that image.
|
|
1060
|
+
const mapping = (name, method, mapped) => (image, k, mapOptions) => {
|
|
1061
|
+
if (typeof image === 'number') {
|
|
1062
|
+
return Promise.reject((0, _shared.fail)('invalid-argument', "Invalid image: this handle holds a clustering, not an image (from worker.load); pass the image, then k.", 'image'));
|
|
1063
|
+
}
|
|
1064
|
+
const origin = new Error();
|
|
1065
|
+
return (async () => {
|
|
1066
|
+
if (released || !handle) {
|
|
1067
|
+
throw (0, _shared.fail)('invalid-handle', "Invalid handle: it was released.");
|
|
1068
|
+
}
|
|
1069
|
+
const {
|
|
1070
|
+
options,
|
|
1071
|
+
signal,
|
|
1072
|
+
onProgress
|
|
1073
|
+
} = takeControls(mapOptions);
|
|
1074
|
+
if (signal && signal.aborted) {
|
|
1075
|
+
// As the functions on the worker do: a wrong argument is reported before the abort.
|
|
1076
|
+
try {
|
|
1077
|
+
await invoke(method, [id, own(send(image)), k, options], [], origin, {
|
|
1078
|
+
check: true
|
|
1079
|
+
});
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
if ((0, _shared.isCodedError)(error) && error.argument !== undefined) {
|
|
1082
|
+
throw error;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
throw abortReason(signal);
|
|
1086
|
+
}
|
|
1087
|
+
const warning = (0, _shared.bareImageWarning)(image);
|
|
1088
|
+
const byteLength = warning ? image.byteLength : 0;
|
|
1089
|
+
let sent = send(image);
|
|
1090
|
+
const ahead = !ready();
|
|
1091
|
+
if (ahead) {
|
|
1092
|
+
sent = take(sent);
|
|
1093
|
+
}
|
|
1094
|
+
const result = await invoke(method, [id, sent, ahead ? own(k) : k, options], pixelBuffers(sent), origin, {
|
|
1095
|
+
signal,
|
|
1096
|
+
onProgress
|
|
1097
|
+
});
|
|
1098
|
+
if (warning) {
|
|
1099
|
+
(0, _shared.warnOnce)(warning, byteLength);
|
|
1100
|
+
}
|
|
1101
|
+
return mapped ? rebuild(image)(result) : result;
|
|
1102
|
+
})();
|
|
1103
|
+
};
|
|
1104
|
+
Object.assign(handle, {
|
|
1105
|
+
quantize: mapping('quantize', 'handleQuantizeImage', true),
|
|
1106
|
+
quantizeToIndices: mapping('quantizeToIndices', 'handleQuantizeToIndicesImage', false)
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
// `await using handle = await worker.cluster(image)` releases it at the end of the block.
|
|
1110
|
+
if (typeof Symbol.asyncDispose === 'symbol') {
|
|
1111
|
+
handle[Symbol.asyncDispose] = handle.release;
|
|
1112
|
+
}
|
|
1113
|
+
if (reclaim) {
|
|
1114
|
+
reclaim.register(handle, id, handle);
|
|
1115
|
+
}
|
|
1116
|
+
return handle;
|
|
1117
|
+
};
|
|
1118
|
+
|
|
963
1119
|
// Clusters `image` and keeps it, with its clustering, in the worker.
|
|
964
1120
|
instance.cluster = (image, clusterOptions) => {
|
|
965
1121
|
const origin = new Error();
|
|
@@ -997,70 +1153,33 @@ const makeWorker = (options, allowScript) => {
|
|
|
997
1153
|
if (warning) {
|
|
998
1154
|
(0, _shared.warnOnce)(warning, byteLength);
|
|
999
1155
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
let taken;
|
|
1013
|
-
try {
|
|
1014
|
-
taken = takeControls(mapOptions);
|
|
1015
|
-
} catch (error) {
|
|
1016
|
-
return Promise.reject(error);
|
|
1017
|
-
}
|
|
1018
|
-
return use(method, [...leading, taken.options], {
|
|
1019
|
-
signal: taken.signal,
|
|
1020
|
-
onProgress: taken.onProgress
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
// The cuts take no options (the handle's clustering already says how it was made): one passed anyway is an error,
|
|
1024
|
-
// as in the main entry, rather than silently ignored.
|
|
1025
|
-
const plain = (method, name, args, extra) => extra.some(value => value !== undefined) ? Promise.reject((0, _shared.fail)('invalid-argument', `Invalid arguments: handle.${name} takes no options. To map pixels with options, use handle.quantize.`, 'options')) : use(method, args);
|
|
1026
|
-
const handle = {
|
|
1027
|
-
getClustering: (...extra) => plain('handleGetClustering', 'getClustering', [], extra),
|
|
1028
|
-
getPalette: (k, ...extra) => plain('handleGetPalette', 'getPalette', [k], extra),
|
|
1029
|
-
getSwatches: (k, ...extra) => plain('handleGetSwatches', 'getSwatches', [k], extra),
|
|
1030
|
-
getClusteringInfo: (...extra) => plain('handleGetClusteringInfo', 'getClusteringInfo', [], extra),
|
|
1031
|
-
quantize: async (k, mapOptions) => output(await withControls('handleQuantize', [k], mapOptions)),
|
|
1032
|
-
quantizeToIndices: (k, mapOptions) => withControls('handleQuantizeToIndices', [k], mapOptions),
|
|
1033
|
-
quantizeWithPalette: async (palette, mapOptions) => output(await withControls('handleQuantizeWithPalette', [palette], mapOptions)),
|
|
1034
|
-
quantizeToIndicesWithPalette: (palette, mapOptions) => withControls('handleQuantizeToIndicesWithPalette', [palette], mapOptions),
|
|
1035
|
-
release: async () => {
|
|
1036
|
-
if (released) {
|
|
1037
|
-
return;
|
|
1038
|
-
}
|
|
1039
|
-
released = true;
|
|
1040
|
-
liveHandles--;
|
|
1041
|
-
if (reclaim) {
|
|
1042
|
-
reclaim.unregister(handle);
|
|
1043
|
-
}
|
|
1044
|
-
// If the worker has been terminated there is nothing left to free (so `await using` and
|
|
1045
|
-
// terminate() can come in either order); any other failure is reported.
|
|
1046
|
-
try {
|
|
1047
|
-
await invoke('release', [id], [], new Error());
|
|
1048
|
-
} catch (error) {
|
|
1049
|
-
if (error.code !== 'worker-terminated') {
|
|
1050
|
-
throw error;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
stopIfAbandoned();
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
// `await using handle = await worker.cluster(image)` releases it at the end of the block.
|
|
1057
|
-
if (typeof Symbol.asyncDispose === 'symbol') {
|
|
1058
|
-
handle[Symbol.asyncDispose] = handle.release;
|
|
1156
|
+
return makeHandle(id, 'image', rebuild(image));
|
|
1157
|
+
})();
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
// Keeps a stored clustering in the worker, for cutting it and mapping images with it without sending it again.
|
|
1161
|
+
instance.load = (clustering, ...extra) => {
|
|
1162
|
+
const origin = new Error();
|
|
1163
|
+
return (async () => {
|
|
1164
|
+
// Checked, and the bytes taken, before anything is awaited (see `own`): a damaged clustering, a palette or an
|
|
1165
|
+
// image is reported here, and nothing is posted.
|
|
1166
|
+
if (extra.length > 0) {
|
|
1167
|
+
throw (0, _shared.fail)('invalid-argument', "Invalid arguments: load takes the clustering only. Options go to the handle's methods.", 'options');
|
|
1059
1168
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1169
|
+
(0, _shared.readHeader)(clustering);
|
|
1170
|
+
const id = nextHandle++;
|
|
1171
|
+
const sent = ready() ? clustering : take(clustering);
|
|
1172
|
+
liveHandles++;
|
|
1173
|
+
try {
|
|
1174
|
+
await invoke('load', [id, sent], pixelBuffers(sent), origin);
|
|
1175
|
+
} catch (error) {
|
|
1176
|
+
liveHandles--;
|
|
1177
|
+
if (!terminated) {
|
|
1178
|
+
invoke('release', [id], [], new Error()).catch(() => {});
|
|
1179
|
+
}
|
|
1180
|
+
throw error;
|
|
1062
1181
|
}
|
|
1063
|
-
return
|
|
1182
|
+
return makeHandle(id, 'clustering');
|
|
1064
1183
|
})();
|
|
1065
1184
|
};
|
|
1066
1185
|
|
package/dist/worker.d.cts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ImageLike, RawImage, ClusteringOptions, MappingOptions, QuantizeOptions, QuantizeIndexOptions, MappingIndexOptions,
|
|
7
|
-
IndexedImage, ClusteringInfo, InitOptions, ImageResult, PaletteLike, Swatches,
|
|
7
|
+
IndexedImage, ClusteringInfo, InitOptions, ImageResult, PaletteLike, Swatches, ChooseOptions, PaletteChoice,
|
|
8
8
|
} from './index.cjs';
|
|
9
9
|
import type { Palette, Clustering } from './index.cjs';
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ export { Palette } from './index.cjs';
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The same class as the main entry's `Clustering`. Its methods run on the calling thread and need the main entry imported
|
|
16
|
-
* there; off the thread, use
|
|
16
|
+
* there; off the thread, use `worker.load(clustering)` or `cluster()`.
|
|
17
17
|
*/
|
|
18
18
|
export { Clustering } from './index.cjs';
|
|
19
19
|
|
|
@@ -34,7 +34,7 @@ export const formatVersion: number;
|
|
|
34
34
|
|
|
35
35
|
export type {
|
|
36
36
|
ImageFormat, RawImage, ImageLike, PaletteLike, PlatformImageData, ImageResult, WasmModule, ColorSpace, AlphaMode, DitherMethod, DitherOptions, DitherSteps, ClusteringOptions, MappingOptions, QuantizeOptions,
|
|
37
|
-
ErrorCode, ErrorArgument, CodedError, InitOptions, ProgressOptions, CancelOptions, IndexOptions, QuantizeIndexOptions, MappingIndexOptions, IndexedImage, ClusteringInfo, Swatches,
|
|
37
|
+
ErrorCode, ErrorArgument, CodedError, InitOptions, ProgressOptions, CancelOptions, IndexOptions, QuantizeIndexOptions, MappingIndexOptions, IndexedImage, ClusteringInfo, Swatches, ChooseOptions, PaletteChoice,
|
|
38
38
|
} from './index.cjs';
|
|
39
39
|
|
|
40
40
|
/** Options for `createWorker`. */
|
|
@@ -69,9 +69,14 @@ export interface SharedInitOptions extends InitOptions {
|
|
|
69
69
|
/** An image and its clustering, kept in the worker so re-cutting and re-mapping them copies nothing across. */
|
|
70
70
|
export interface ClusteringHandle<Image extends ImageLike = ImageLike> {
|
|
71
71
|
getClustering(): Promise<Clustering>;
|
|
72
|
+
/** The k-colour palette of the clustering. */
|
|
72
73
|
getPalette(k: number): Promise<Palette>;
|
|
74
|
+
/** Palette, weights and shares of the k-colour cut. */
|
|
73
75
|
getSwatches(k: number): Promise<Swatches>;
|
|
76
|
+
/** The error curve and totals of the clustering. */
|
|
74
77
|
getClusteringInfo(): Promise<ClusteringInfo>;
|
|
78
|
+
/** The main entry's `clustering.chooseFrom`, run in the worker on the kept clustering: picks `k` entries of a fixed palette. Takes `colorSpace` and `signal`. */
|
|
79
|
+
chooseFrom(palette: PaletteLike, k: number, options?: ChooseOptions): Promise<PaletteChoice>;
|
|
75
80
|
/** Maps the kept image to the k-colour palette. Returns the same type as the image given to `cluster`. */
|
|
76
81
|
quantize(k: number, options?: MappingOptions): Promise<Image>;
|
|
77
82
|
quantizeToIndices(k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
@@ -88,6 +93,34 @@ export interface ClusteringHandle<Image extends ImageLike = ImageLike> {
|
|
|
88
93
|
[Symbol.asyncDispose](): Promise<void>;
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A stored clustering, kept in the worker (from `worker.load`): cut it and map images with it without sending it again.
|
|
98
|
+
* It holds no image, so the mapping methods take the image, then k (`cluster` keeps the image and maps it with `quantize(k)`).
|
|
99
|
+
* There is no `getClustering()`: you passed the clustering in and still have it.
|
|
100
|
+
*/
|
|
101
|
+
export interface LoadedClusteringHandle {
|
|
102
|
+
/** The k-colour palette of the clustering. */
|
|
103
|
+
getPalette(k: number): Promise<Palette>;
|
|
104
|
+
/** Palette, weights and shares of the k-colour cut. */
|
|
105
|
+
getSwatches(k: number): Promise<Swatches>;
|
|
106
|
+
/** The error curve and totals of the clustering. */
|
|
107
|
+
getClusteringInfo(): Promise<ClusteringInfo>;
|
|
108
|
+
/** The main entry's `clustering.chooseFrom`, run in the worker on the kept clustering: picks `k` entries of a fixed palette. Takes `colorSpace` and `signal`. */
|
|
109
|
+
chooseFrom(palette: PaletteLike, k: number, options?: ChooseOptions): Promise<PaletteChoice>;
|
|
110
|
+
/** Maps `image` to the k-colour palette of the kept clustering. Returns the same type as the image given. */
|
|
111
|
+
quantize<Image extends ImageLike>(image: Image, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
112
|
+
/** Maps `image` to indices into the k-colour palette of the kept clustering. */
|
|
113
|
+
quantizeToIndices(image: ImageLike, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
114
|
+
/**
|
|
115
|
+
* Frees the clustering in the worker. Later calls on the handle fail. Call it when you are done, or declare the
|
|
116
|
+
* handle with `await using`, which does. A handle that is dropped without either is freed once it is garbage-collected,
|
|
117
|
+
* but when that happens is up to the JavaScript engine.
|
|
118
|
+
*/
|
|
119
|
+
release(): Promise<void>;
|
|
120
|
+
/** The same as `release()`, for `await using`. Present where the runtime has `Symbol.asyncDispose`. */
|
|
121
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
|
|
91
124
|
/** The main entry's functions, run in a worker, plus handles and `terminate`. */
|
|
92
125
|
export interface AgglomerativeWorker {
|
|
93
126
|
/** Loads the module in the worker. `wasm` is the only option, and `createWorker({ wasm })` does the same. */
|
|
@@ -100,21 +133,31 @@ export interface AgglomerativeWorker {
|
|
|
100
133
|
buildPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
101
134
|
/** @deprecated Renamed {@link AgglomerativeWorker.buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
102
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. */
|
|
103
137
|
getPaletteFromClustering(clustering: Clustering, k: number): Promise<Palette>;
|
|
104
138
|
/** The main entry's `buildSwatches`, run in this worker. */
|
|
105
139
|
buildSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
106
140
|
/** @deprecated Renamed {@link AgglomerativeWorker.buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
107
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. */
|
|
108
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. */
|
|
109
145
|
getClusteringInfo(clustering: Clustering): Promise<ClusteringInfo>;
|
|
110
146
|
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. */
|
|
111
148
|
quantizeFromClustering<Image extends ImageLike>(image: Image, clustering: Clustering, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
112
149
|
quantizeWithPalette<Image extends ImageLike>(image: Image, palette: PaletteLike, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
113
150
|
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. */
|
|
114
152
|
quantizeToIndicesFromClustering(image: ImageLike, clustering: Clustering, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
115
153
|
quantizeToIndicesWithPalette(image: ImageLike, palette: PaletteLike, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
116
154
|
/** Clusters `image` and keeps it, with its clustering, in the worker. */
|
|
117
155
|
cluster<Image extends ImageLike>(image: Image, options?: ClusteringOptions): Promise<ClusteringHandle<ImageResult<Image>>>;
|
|
156
|
+
/**
|
|
157
|
+
* Keeps a stored clustering in the worker and gives a handle for cutting it and mapping images with it. The bytes are
|
|
158
|
+
* checked and taken at the call (copied, or moved with `transfer: true`), so you may change the array at once.
|
|
159
|
+
*/
|
|
160
|
+
load(clustering: Clustering | Uint8Array): Promise<LoadedClusteringHandle>;
|
|
118
161
|
/** Stops the worker. Calls still waiting are rejected, and later calls fail. */
|
|
119
162
|
terminate(): Promise<void>;
|
|
120
163
|
/** The same as `terminate()`, for `await using worker = createWorker()`. Present where the runtime has `Symbol.asyncDispose`. */
|
|
@@ -146,25 +189,25 @@ export const getClustering: AgglomerativeWorker['getClustering'];
|
|
|
146
189
|
export const buildPalette: AgglomerativeWorker['buildPalette'];
|
|
147
190
|
/** @deprecated Renamed {@link buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
148
191
|
export const getPalette: AgglomerativeWorker['getPalette'];
|
|
149
|
-
/**
|
|
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. */
|
|
150
193
|
export const getPaletteFromClustering: AgglomerativeWorker['getPaletteFromClustering'];
|
|
151
194
|
/** The main entry's `buildSwatches`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
152
195
|
export const buildSwatches: AgglomerativeWorker['buildSwatches'];
|
|
153
196
|
/** @deprecated Renamed {@link buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
154
197
|
export const getSwatches: AgglomerativeWorker['getSwatches'];
|
|
155
|
-
/**
|
|
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. */
|
|
156
199
|
export const getSwatchesFromClustering: AgglomerativeWorker['getSwatchesFromClustering'];
|
|
157
|
-
/**
|
|
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. */
|
|
158
201
|
export const getClusteringInfo: AgglomerativeWorker['getClusteringInfo'];
|
|
159
202
|
/** The main entry's `quantize`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
160
203
|
export const quantize: AgglomerativeWorker['quantize'];
|
|
161
|
-
/**
|
|
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. */
|
|
162
205
|
export const quantizeFromClustering: AgglomerativeWorker['quantizeFromClustering'];
|
|
163
206
|
/** The main entry's `quantizeWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
164
207
|
export const quantizeWithPalette: AgglomerativeWorker['quantizeWithPalette'];
|
|
165
208
|
/** The main entry's `quantizeToIndices`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
166
209
|
export const quantizeToIndices: AgglomerativeWorker['quantizeToIndices'];
|
|
167
|
-
/**
|
|
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. */
|
|
168
211
|
export const quantizeToIndicesFromClustering: AgglomerativeWorker['quantizeToIndicesFromClustering'];
|
|
169
212
|
/** The main entry's `quantizeToIndicesWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
170
213
|
export const quantizeToIndicesWithPalette: AgglomerativeWorker['quantizeToIndicesWithPalette'];
|
package/dist/worker.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ImageLike, RawImage, ClusteringOptions, MappingOptions, QuantizeOptions, QuantizeIndexOptions, MappingIndexOptions,
|
|
7
|
-
IndexedImage, ClusteringInfo, InitOptions, ImageResult, PaletteLike, Swatches,
|
|
7
|
+
IndexedImage, ClusteringInfo, InitOptions, ImageResult, PaletteLike, Swatches, ChooseOptions, PaletteChoice,
|
|
8
8
|
} from './index.js';
|
|
9
9
|
import type { Palette, Clustering } from './index.js';
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ export { Palette } from './index.js';
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The same class as the main entry's `Clustering`. Its methods run on the calling thread and need the main entry imported
|
|
16
|
-
* there; off the thread, use
|
|
16
|
+
* there; off the thread, use `worker.load(clustering)` or `cluster()`.
|
|
17
17
|
*/
|
|
18
18
|
export { Clustering } from './index.js';
|
|
19
19
|
|
|
@@ -34,7 +34,7 @@ export const formatVersion: number;
|
|
|
34
34
|
|
|
35
35
|
export type {
|
|
36
36
|
ImageFormat, RawImage, ImageLike, PaletteLike, PlatformImageData, ImageResult, WasmModule, ColorSpace, AlphaMode, DitherMethod, DitherOptions, DitherSteps, ClusteringOptions, MappingOptions, QuantizeOptions,
|
|
37
|
-
ErrorCode, ErrorArgument, CodedError, InitOptions, ProgressOptions, CancelOptions, IndexOptions, QuantizeIndexOptions, MappingIndexOptions, IndexedImage, ClusteringInfo, Swatches,
|
|
37
|
+
ErrorCode, ErrorArgument, CodedError, InitOptions, ProgressOptions, CancelOptions, IndexOptions, QuantizeIndexOptions, MappingIndexOptions, IndexedImage, ClusteringInfo, Swatches, ChooseOptions, PaletteChoice,
|
|
38
38
|
} from './index.js';
|
|
39
39
|
|
|
40
40
|
/** Options for `createWorker`. */
|
|
@@ -69,9 +69,14 @@ export interface SharedInitOptions extends InitOptions {
|
|
|
69
69
|
/** An image and its clustering, kept in the worker so re-cutting and re-mapping them copies nothing across. */
|
|
70
70
|
export interface ClusteringHandle<Image extends ImageLike = ImageLike> {
|
|
71
71
|
getClustering(): Promise<Clustering>;
|
|
72
|
+
/** The k-colour palette of the clustering. */
|
|
72
73
|
getPalette(k: number): Promise<Palette>;
|
|
74
|
+
/** Palette, weights and shares of the k-colour cut. */
|
|
73
75
|
getSwatches(k: number): Promise<Swatches>;
|
|
76
|
+
/** The error curve and totals of the clustering. */
|
|
74
77
|
getClusteringInfo(): Promise<ClusteringInfo>;
|
|
78
|
+
/** The main entry's `clustering.chooseFrom`, run in the worker on the kept clustering: picks `k` entries of a fixed palette. Takes `colorSpace` and `signal`. */
|
|
79
|
+
chooseFrom(palette: PaletteLike, k: number, options?: ChooseOptions): Promise<PaletteChoice>;
|
|
75
80
|
/** Maps the kept image to the k-colour palette. Returns the same type as the image given to `cluster`. */
|
|
76
81
|
quantize(k: number, options?: MappingOptions): Promise<Image>;
|
|
77
82
|
quantizeToIndices(k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
@@ -88,6 +93,34 @@ export interface ClusteringHandle<Image extends ImageLike = ImageLike> {
|
|
|
88
93
|
[Symbol.asyncDispose](): Promise<void>;
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A stored clustering, kept in the worker (from `worker.load`): cut it and map images with it without sending it again.
|
|
98
|
+
* It holds no image, so the mapping methods take the image, then k (`cluster` keeps the image and maps it with `quantize(k)`).
|
|
99
|
+
* There is no `getClustering()`: you passed the clustering in and still have it.
|
|
100
|
+
*/
|
|
101
|
+
export interface LoadedClusteringHandle {
|
|
102
|
+
/** The k-colour palette of the clustering. */
|
|
103
|
+
getPalette(k: number): Promise<Palette>;
|
|
104
|
+
/** Palette, weights and shares of the k-colour cut. */
|
|
105
|
+
getSwatches(k: number): Promise<Swatches>;
|
|
106
|
+
/** The error curve and totals of the clustering. */
|
|
107
|
+
getClusteringInfo(): Promise<ClusteringInfo>;
|
|
108
|
+
/** The main entry's `clustering.chooseFrom`, run in the worker on the kept clustering: picks `k` entries of a fixed palette. Takes `colorSpace` and `signal`. */
|
|
109
|
+
chooseFrom(palette: PaletteLike, k: number, options?: ChooseOptions): Promise<PaletteChoice>;
|
|
110
|
+
/** Maps `image` to the k-colour palette of the kept clustering. Returns the same type as the image given. */
|
|
111
|
+
quantize<Image extends ImageLike>(image: Image, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
112
|
+
/** Maps `image` to indices into the k-colour palette of the kept clustering. */
|
|
113
|
+
quantizeToIndices(image: ImageLike, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
114
|
+
/**
|
|
115
|
+
* Frees the clustering in the worker. Later calls on the handle fail. Call it when you are done, or declare the
|
|
116
|
+
* handle with `await using`, which does. A handle that is dropped without either is freed once it is garbage-collected,
|
|
117
|
+
* but when that happens is up to the JavaScript engine.
|
|
118
|
+
*/
|
|
119
|
+
release(): Promise<void>;
|
|
120
|
+
/** The same as `release()`, for `await using`. Present where the runtime has `Symbol.asyncDispose`. */
|
|
121
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
|
|
91
124
|
/** The main entry's functions, run in a worker, plus handles and `terminate`. */
|
|
92
125
|
export interface AgglomerativeWorker {
|
|
93
126
|
/** Loads the module in the worker. `wasm` is the only option, and `createWorker({ wasm })` does the same. */
|
|
@@ -100,21 +133,31 @@ export interface AgglomerativeWorker {
|
|
|
100
133
|
buildPalette(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Palette>;
|
|
101
134
|
/** @deprecated Renamed {@link AgglomerativeWorker.buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
102
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. */
|
|
103
137
|
getPaletteFromClustering(clustering: Clustering, k: number): Promise<Palette>;
|
|
104
138
|
/** The main entry's `buildSwatches`, run in this worker. */
|
|
105
139
|
buildSwatches(image: ImageLike, k: number, options?: ClusteringOptions): Promise<Swatches>;
|
|
106
140
|
/** @deprecated Renamed {@link AgglomerativeWorker.buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
107
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. */
|
|
108
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. */
|
|
109
145
|
getClusteringInfo(clustering: Clustering): Promise<ClusteringInfo>;
|
|
110
146
|
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. */
|
|
111
148
|
quantizeFromClustering<Image extends ImageLike>(image: Image, clustering: Clustering, k: number, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
112
149
|
quantizeWithPalette<Image extends ImageLike>(image: Image, palette: PaletteLike, options?: MappingOptions): Promise<ImageResult<Image>>;
|
|
113
150
|
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. */
|
|
114
152
|
quantizeToIndicesFromClustering(image: ImageLike, clustering: Clustering, k: number, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
115
153
|
quantizeToIndicesWithPalette(image: ImageLike, palette: PaletteLike, options?: MappingIndexOptions): Promise<IndexedImage>;
|
|
116
154
|
/** Clusters `image` and keeps it, with its clustering, in the worker. */
|
|
117
155
|
cluster<Image extends ImageLike>(image: Image, options?: ClusteringOptions): Promise<ClusteringHandle<ImageResult<Image>>>;
|
|
156
|
+
/**
|
|
157
|
+
* Keeps a stored clustering in the worker and gives a handle for cutting it and mapping images with it. The bytes are
|
|
158
|
+
* checked and taken at the call (copied, or moved with `transfer: true`), so you may change the array at once.
|
|
159
|
+
*/
|
|
160
|
+
load(clustering: Clustering | Uint8Array): Promise<LoadedClusteringHandle>;
|
|
118
161
|
/** Stops the worker. Calls still waiting are rejected, and later calls fail. */
|
|
119
162
|
terminate(): Promise<void>;
|
|
120
163
|
/** The same as `terminate()`, for `await using worker = createWorker()`. Present where the runtime has `Symbol.asyncDispose`. */
|
|
@@ -146,25 +189,25 @@ export const getClustering: AgglomerativeWorker['getClustering'];
|
|
|
146
189
|
export const buildPalette: AgglomerativeWorker['buildPalette'];
|
|
147
190
|
/** @deprecated Renamed {@link buildPalette} in 3.4.0 (the same function). Removed in 4.0. */
|
|
148
191
|
export const getPalette: AgglomerativeWorker['getPalette'];
|
|
149
|
-
/**
|
|
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. */
|
|
150
193
|
export const getPaletteFromClustering: AgglomerativeWorker['getPaletteFromClustering'];
|
|
151
194
|
/** The main entry's `buildSwatches`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
152
195
|
export const buildSwatches: AgglomerativeWorker['buildSwatches'];
|
|
153
196
|
/** @deprecated Renamed {@link buildSwatches} in 3.4.0 (the same function). Removed in 4.0. */
|
|
154
197
|
export const getSwatches: AgglomerativeWorker['getSwatches'];
|
|
155
|
-
/**
|
|
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. */
|
|
156
199
|
export const getSwatchesFromClustering: AgglomerativeWorker['getSwatchesFromClustering'];
|
|
157
|
-
/**
|
|
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. */
|
|
158
201
|
export const getClusteringInfo: AgglomerativeWorker['getClusteringInfo'];
|
|
159
202
|
/** The main entry's `quantize`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
160
203
|
export const quantize: AgglomerativeWorker['quantize'];
|
|
161
|
-
/**
|
|
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. */
|
|
162
205
|
export const quantizeFromClustering: AgglomerativeWorker['quantizeFromClustering'];
|
|
163
206
|
/** The main entry's `quantizeWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
164
207
|
export const quantizeWithPalette: AgglomerativeWorker['quantizeWithPalette'];
|
|
165
208
|
/** The main entry's `quantizeToIndices`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
166
209
|
export const quantizeToIndices: AgglomerativeWorker['quantizeToIndices'];
|
|
167
|
-
/**
|
|
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. */
|
|
168
211
|
export const quantizeToIndicesFromClustering: AgglomerativeWorker['quantizeToIndicesFromClustering'];
|
|
169
212
|
/** The main entry's `quantizeToIndicesWithPalette`, run in the shared worker (see `createWorker` for a worker of your own). */
|
|
170
213
|
export const quantizeToIndicesWithPalette: AgglomerativeWorker['quantizeToIndicesWithPalette'];
|