agglomerative-clustering 3.0.0-beta.1 → 3.0.0-beta.2
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 +93 -34
- package/dist/clustering.wasm +0 -0
- package/dist/index.cjs +574 -258
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +561 -258
- package/dist/shared.cjs +58 -3
- package/dist/shared.mjs +58 -3
- package/dist/worker.d.ts +2 -2
- package/dist/worker.mjs +281 -136
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -38,9 +38,9 @@ export interface RawImage {
|
|
|
38
38
|
data: Uint8Array | Uint8ClampedArray;
|
|
39
39
|
format: ImageFormat;
|
|
40
40
|
/** Width in pixels. Optional; used for dithering, and copied to `quantize*` results. */
|
|
41
|
-
width?: number;
|
|
41
|
+
width?: number | undefined;
|
|
42
42
|
/** Height in pixels. Optional; copied to `quantize*` results. */
|
|
43
|
-
height?: number;
|
|
43
|
+
height?: number | undefined;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -132,7 +132,7 @@ export interface CancelOptions {
|
|
|
132
132
|
* interrupted. The call's result is the same as without a signal. In the worker entry the worker itself stops
|
|
133
133
|
* working on the call, and a call still waiting its turn never starts.
|
|
134
134
|
*/
|
|
135
|
-
signal?: AbortSignal;
|
|
135
|
+
signal?: AbortSignal | undefined;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** Cancelling a long call and watching it, for the functions that cluster. Both are optional and can be used apart. */
|
|
@@ -142,7 +142,7 @@ export interface RunOptions extends CancelOptions {
|
|
|
142
142
|
* backwards, ending with 1. It is approximate and not linear in time. Giving it also makes the call run in
|
|
143
143
|
* slices, so other tasks (such as painting) get a turn while it works.
|
|
144
144
|
*/
|
|
145
|
-
onProgress
|
|
145
|
+
onProgress?: ((progress: number) => void) | undefined;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** Options for building the colour hierarchy: `getClustering`, `getPalette`, and the clustering half of `quantize` and `quantizeToIndices`. */
|
|
@@ -151,18 +151,18 @@ export interface ClusteringOptions extends RunOptions {
|
|
|
151
151
|
* `'rgb'` (default) minimises squared sRGB error, which is what MSE/PSNR measure.
|
|
152
152
|
* `'oklab'` clusters in OKLab. Neither is better everywhere: see "Choosing a colour space" in the README.
|
|
153
153
|
*/
|
|
154
|
-
colorSpace?: ColorSpace;
|
|
154
|
+
colorSpace?: ColorSpace | undefined;
|
|
155
155
|
/**
|
|
156
156
|
* Bits per channel, 1-8 (default 8: every distinct colour is clustered exactly). Lower values group colours
|
|
157
157
|
* that share their top bits before clustering, at their mean colour, which bounds the time spent on images
|
|
158
158
|
* with very many distinct colours. 6 is a good choice for large photos.
|
|
159
159
|
*/
|
|
160
|
-
precision?: number;
|
|
160
|
+
precision?: number | undefined;
|
|
161
161
|
/**
|
|
162
162
|
* How RGBA pixels count. `'weight'` (default): in proportion to their opacity, so fully transparent pixels are
|
|
163
163
|
* ignored and semi-transparent ones count partially. `'ignore'`: every pixel counts fully, as in 1.x.
|
|
164
164
|
*/
|
|
165
|
-
alpha?: AlphaMode;
|
|
165
|
+
alpha?: AlphaMode | undefined;
|
|
166
166
|
/**
|
|
167
167
|
* `false` (default), `true`, or an alpha cutoff from 1 to 255 (`true` means 128), for RGBA images: pixels with alpha
|
|
168
168
|
* below the cutoff don't exist as far as the palette is concerned. They are left out of clustering, and the rest count
|
|
@@ -173,7 +173,7 @@ export interface ClusteringOptions extends RunOptions {
|
|
|
173
173
|
* clustering (see `ClusteringInfo.transparent`), and `quantizeToIndicesFromClustering` uses it unless you name one.
|
|
174
174
|
* It replaces `alpha` (with a cutoff, pixels count whole or not at all), so giving both is an `invalid-argument` error.
|
|
175
175
|
*/
|
|
176
|
-
transparent?: boolean | number;
|
|
176
|
+
transparent?: boolean | number | undefined;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** Options for mapping pixels to a palette: `quantizeFromClustering`, `quantizeWithPalette`, and the mapping half of `quantize` and `quantizeToIndices`. They take `signal` but no `onProgress`: mapping takes milliseconds. */
|
|
@@ -184,17 +184,17 @@ export interface MappingOptions extends CancelOptions {
|
|
|
184
184
|
* `quantizeToIndicesWithPalette`; `'rgb'` for plain bytes, and in `quantize` and `quantizeToIndices`, which match in the
|
|
185
185
|
* space they cluster in.
|
|
186
186
|
*/
|
|
187
|
-
colorSpace?: ColorSpace;
|
|
187
|
+
colorSpace?: ColorSpace | undefined;
|
|
188
188
|
/**
|
|
189
189
|
* Error-diffusion dithering (serpentine Floyd-Steinberg): `false` (default), `true`, or a strength from 0 to 1.
|
|
190
190
|
* Needs the image width: taken from `ImageData` or `RawImage.width`, or given as `width`.
|
|
191
191
|
*/
|
|
192
|
-
dither?: boolean | number;
|
|
192
|
+
dither?: boolean | number | undefined;
|
|
193
193
|
/**
|
|
194
194
|
* Image width in pixels, for dithering a `Uint8Array` or a `RawImage` without `width`. An image that has its own
|
|
195
195
|
* `width` (`ImageData`, or a `RawImage` with one) must agree with it: a different value is an `invalid-argument` error.
|
|
196
196
|
*/
|
|
197
|
-
width?: number;
|
|
197
|
+
width?: number | undefined;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/** Clustering and mapping options together, for `quantize`, which does both. */
|
|
@@ -214,7 +214,7 @@ export interface IndexOptions {
|
|
|
214
214
|
* you supply (`quantizeToIndicesWithPalette`) there is no `k`: the entry is added to your palette as it is. In
|
|
215
215
|
* `quantizeToIndicesFromClustering` the default is the cutoff the clustering was made with.
|
|
216
216
|
*/
|
|
217
|
-
transparent?: boolean | number;
|
|
217
|
+
transparent?: boolean | number | undefined;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/** The options of `quantizeToIndices`: clustering, mapping and indexed-output options. */
|
|
@@ -262,7 +262,7 @@ export interface InitOptions {
|
|
|
262
262
|
* - its bytes, as an `ArrayBuffer` or a typed array;
|
|
263
263
|
* - an already compiled `WebAssembly.Module`.
|
|
264
264
|
*/
|
|
265
|
-
wasm?: string | URL | ArrayBuffer | ArrayBufferView | WasmModule;
|
|
265
|
+
wasm?: string | URL | ArrayBuffer | ArrayBufferView | WasmModule | undefined;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/** The version of this library, as in its `package.json` (for example `'3.0.0'`). The WebAssembly module checks it matches its own when it loads. */
|
package/dist/index.d.ts
CHANGED
|
@@ -38,9 +38,9 @@ export interface RawImage {
|
|
|
38
38
|
data: Uint8Array | Uint8ClampedArray;
|
|
39
39
|
format: ImageFormat;
|
|
40
40
|
/** Width in pixels. Optional; used for dithering, and copied to `quantize*` results. */
|
|
41
|
-
width?: number;
|
|
41
|
+
width?: number | undefined;
|
|
42
42
|
/** Height in pixels. Optional; copied to `quantize*` results. */
|
|
43
|
-
height?: number;
|
|
43
|
+
height?: number | undefined;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -132,7 +132,7 @@ export interface CancelOptions {
|
|
|
132
132
|
* interrupted. The call's result is the same as without a signal. In the worker entry the worker itself stops
|
|
133
133
|
* working on the call, and a call still waiting its turn never starts.
|
|
134
134
|
*/
|
|
135
|
-
signal?: AbortSignal;
|
|
135
|
+
signal?: AbortSignal | undefined;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** Cancelling a long call and watching it, for the functions that cluster. Both are optional and can be used apart. */
|
|
@@ -142,7 +142,7 @@ export interface RunOptions extends CancelOptions {
|
|
|
142
142
|
* backwards, ending with 1. It is approximate and not linear in time. Giving it also makes the call run in
|
|
143
143
|
* slices, so other tasks (such as painting) get a turn while it works.
|
|
144
144
|
*/
|
|
145
|
-
onProgress
|
|
145
|
+
onProgress?: ((progress: number) => void) | undefined;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** Options for building the colour hierarchy: `getClustering`, `getPalette`, and the clustering half of `quantize` and `quantizeToIndices`. */
|
|
@@ -151,18 +151,18 @@ export interface ClusteringOptions extends RunOptions {
|
|
|
151
151
|
* `'rgb'` (default) minimises squared sRGB error, which is what MSE/PSNR measure.
|
|
152
152
|
* `'oklab'` clusters in OKLab. Neither is better everywhere: see "Choosing a colour space" in the README.
|
|
153
153
|
*/
|
|
154
|
-
colorSpace?: ColorSpace;
|
|
154
|
+
colorSpace?: ColorSpace | undefined;
|
|
155
155
|
/**
|
|
156
156
|
* Bits per channel, 1-8 (default 8: every distinct colour is clustered exactly). Lower values group colours
|
|
157
157
|
* that share their top bits before clustering, at their mean colour, which bounds the time spent on images
|
|
158
158
|
* with very many distinct colours. 6 is a good choice for large photos.
|
|
159
159
|
*/
|
|
160
|
-
precision?: number;
|
|
160
|
+
precision?: number | undefined;
|
|
161
161
|
/**
|
|
162
162
|
* How RGBA pixels count. `'weight'` (default): in proportion to their opacity, so fully transparent pixels are
|
|
163
163
|
* ignored and semi-transparent ones count partially. `'ignore'`: every pixel counts fully, as in 1.x.
|
|
164
164
|
*/
|
|
165
|
-
alpha?: AlphaMode;
|
|
165
|
+
alpha?: AlphaMode | undefined;
|
|
166
166
|
/**
|
|
167
167
|
* `false` (default), `true`, or an alpha cutoff from 1 to 255 (`true` means 128), for RGBA images: pixels with alpha
|
|
168
168
|
* below the cutoff don't exist as far as the palette is concerned. They are left out of clustering, and the rest count
|
|
@@ -173,7 +173,7 @@ export interface ClusteringOptions extends RunOptions {
|
|
|
173
173
|
* clustering (see `ClusteringInfo.transparent`), and `quantizeToIndicesFromClustering` uses it unless you name one.
|
|
174
174
|
* It replaces `alpha` (with a cutoff, pixels count whole or not at all), so giving both is an `invalid-argument` error.
|
|
175
175
|
*/
|
|
176
|
-
transparent?: boolean | number;
|
|
176
|
+
transparent?: boolean | number | undefined;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** Options for mapping pixels to a palette: `quantizeFromClustering`, `quantizeWithPalette`, and the mapping half of `quantize` and `quantizeToIndices`. They take `signal` but no `onProgress`: mapping takes milliseconds. */
|
|
@@ -184,17 +184,17 @@ export interface MappingOptions extends CancelOptions {
|
|
|
184
184
|
* `quantizeToIndicesWithPalette`; `'rgb'` for plain bytes, and in `quantize` and `quantizeToIndices`, which match in the
|
|
185
185
|
* space they cluster in.
|
|
186
186
|
*/
|
|
187
|
-
colorSpace?: ColorSpace;
|
|
187
|
+
colorSpace?: ColorSpace | undefined;
|
|
188
188
|
/**
|
|
189
189
|
* Error-diffusion dithering (serpentine Floyd-Steinberg): `false` (default), `true`, or a strength from 0 to 1.
|
|
190
190
|
* Needs the image width: taken from `ImageData` or `RawImage.width`, or given as `width`.
|
|
191
191
|
*/
|
|
192
|
-
dither?: boolean | number;
|
|
192
|
+
dither?: boolean | number | undefined;
|
|
193
193
|
/**
|
|
194
194
|
* Image width in pixels, for dithering a `Uint8Array` or a `RawImage` without `width`. An image that has its own
|
|
195
195
|
* `width` (`ImageData`, or a `RawImage` with one) must agree with it: a different value is an `invalid-argument` error.
|
|
196
196
|
*/
|
|
197
|
-
width?: number;
|
|
197
|
+
width?: number | undefined;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/** Clustering and mapping options together, for `quantize`, which does both. */
|
|
@@ -214,7 +214,7 @@ export interface IndexOptions {
|
|
|
214
214
|
* you supply (`quantizeToIndicesWithPalette`) there is no `k`: the entry is added to your palette as it is. In
|
|
215
215
|
* `quantizeToIndicesFromClustering` the default is the cutoff the clustering was made with.
|
|
216
216
|
*/
|
|
217
|
-
transparent?: boolean | number;
|
|
217
|
+
transparent?: boolean | number | undefined;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/** The options of `quantizeToIndices`: clustering, mapping and indexed-output options. */
|
|
@@ -262,7 +262,7 @@ export interface InitOptions {
|
|
|
262
262
|
* - its bytes, as an `ArrayBuffer` or a typed array;
|
|
263
263
|
* - an already compiled `WebAssembly.Module`.
|
|
264
264
|
*/
|
|
265
|
-
wasm?: string | URL | ArrayBuffer | ArrayBufferView | WasmModule;
|
|
265
|
+
wasm?: string | URL | ArrayBuffer | ArrayBufferView | WasmModule | undefined;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/** The version of this library, as in its `package.json` (for example `'3.0.0'`). The WebAssembly module checks it matches its own when it loads. */
|