agglomerative-clustering 2.0.0 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agglomerative-clustering",
3
- "version": "2.0.0",
4
- "description": "Fast hierarchical agglomerative clustering powered by WebAssembly.",
3
+ "version": "3.0.0-beta.2",
4
+ "description": "Colour palette extraction and image quantization with exact Ward clustering, in WebAssembly. Cluster an image once, then cut it to a palette of any size.",
5
5
  "license": "MIT",
6
6
  "author": "Rohan Fredriksson",
7
7
  "type": "module",
@@ -12,62 +12,100 @@
12
12
  "url": "git+https://github.com/RohanFredriksson/agglomerative-clustering.git"
13
13
  },
14
14
  "keywords": [
15
- "nodejs",
16
- "browser",
17
- "cpp",
18
- "clustering",
19
- "kd-tree",
20
- "webassembly",
21
- "wasm",
22
- "image-processing",
23
- "nearest-neighbour",
24
- "image-compression",
25
- "image-analysis",
15
+ "color-quantization",
16
+ "image-quantization",
17
+ "palette",
18
+ "color-palette",
19
+ "palette-extraction",
26
20
  "palette-generation",
21
+ "color-reduction",
22
+ "dithering",
23
+ "ward",
24
+ "oklab",
25
+ "indexed-color",
26
+ "gif",
27
+ "png8",
28
+ "clustering",
27
29
  "hierarchical-clustering",
28
- "color-clustering",
29
30
  "agglomerative-clustering",
30
- "image-quantization",
31
- "color-reduction",
32
- "spatial-hashing"
31
+ "image-processing",
32
+ "webassembly",
33
+ "wasm",
34
+ "web-worker",
35
+ "nodejs",
36
+ "browser"
33
37
  ],
34
38
  "exports": {
35
39
  ".": {
36
- "types": "./dist/index.d.ts",
37
- "require": "./dist/index.cjs",
38
- "import": "./dist/index.mjs"
40
+ "import": {
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.mjs"
43
+ },
44
+ "require": {
45
+ "types": "./dist/index.d.cts",
46
+ "default": "./dist/index.cjs"
47
+ }
48
+ },
49
+ "./worker": {
50
+ "types": "./dist/worker.d.ts",
51
+ "import": "./dist/worker.mjs",
52
+ "default": "./dist/worker.mjs"
53
+ },
54
+ "./clustering.wasm": "./dist/clustering.wasm",
55
+ "./package.json": "./package.json"
56
+ },
57
+ "typesVersions": {
58
+ "*": {
59
+ "worker": [
60
+ "dist/worker.d.ts"
61
+ ]
39
62
  }
40
63
  },
64
+ "engines": {
65
+ "node": "^20.19.0 || >=22.12.0"
66
+ },
41
67
  "files": [
42
68
  "dist/",
43
69
  "README.md"
44
70
  ],
45
71
  "scripts": {
46
- "build:wasm": "mkdirp dist && em++ src/clustering.cpp -O3 -msimd128 -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME='createWasmModule' -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=32MB -s MAXIMUM_MEMORY=2147483648 -s EXPORTED_FUNCTIONS=\"['_get_clustering','_get_palette','_get_palette_from_clustering','_quantize','_quantize_with_clustering','_quantize_with_palette','_malloc','_free']\" -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8']\" -o dist/clustering.js",
47
- "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir dist --extensions \".js\" --out-file-extension .cjs",
72
+ "build:wasm": "mkdirp dist && em++ src/clustering.cpp -O3 -msimd128 -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME='createWasmModule' -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=32MB -s MAXIMUM_MEMORY=2147483648 -s EXPORTED_FUNCTIONS=\"['_library_version','_get_clustering','_clustering_job_start','_clustering_job_step','_clustering_job_result','_clustering_job_free','_get_palette','_get_palette_from_clustering','_get_palette_weights','_quantize','_quantize_with_clustering','_quantize_with_palette','_quantize_indices','_quantize_indices_with_clustering','_quantize_indices_with_palette','_malloc','_free']\" -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8']\" -o dist/clustering.js && node scripts/patch-glue.mjs",
73
+ "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir dist --extensions \".js\" --ignore \"src/worker.js\",\"src/worker-thread.js\" --out-file-extension .cjs",
48
74
  "build:esm": "cross-env BABEL_ENV=esm babel src --out-dir dist --extensions \".js\" --out-file-extension .mjs",
49
- "build:types": "mkdirp dist && node -e \"require('fs').copyFileSync('src/index.d.ts', 'dist/index.d.ts')\"",
75
+ "build:types": "mkdirp dist && node -e \"const fs = require('fs'); for (const f of ['index.d.ts', 'worker.d.ts']) {fs.copyFileSync('src/' + f, 'dist/' + f);} fs.copyFileSync('src/index.d.ts', 'dist/index.d.cts');\"",
50
76
  "build:js": "npm run build:types && npm run build:cjs && npm run build:esm",
51
- "build": "npm run build:wasm && npm run build:js",
77
+ "build": "node scripts/sync-version.mjs --check && npm run build:wasm && npm run build:js",
78
+ "version": "node scripts/sync-version.mjs && git add src/shared.js src/version.hpp",
52
79
  "prepublishOnly": "npm run build",
53
80
  "test": "vitest run",
81
+ "test:browser": "node test/browser/run.mjs",
54
82
  "bench": "vitest bench",
55
83
  "bench:full": "node bench/run.js",
56
84
  "bench:compare": "node bench/compare.js",
57
85
  "quality": "node bench/run.js --no-pipeline --label quality",
58
- "demo": "node demo/serve.mjs"
86
+ "demo": "node demo/serve.mjs",
87
+ "test:types": "tsc -p test/types/tsconfig.nodenext.json && tsc -p test/types/tsconfig.bundler.json && tsc -p test/types/tsconfig.node.json"
59
88
  },
60
89
  "devDependencies": {
61
90
  "@babel/cli": "^7.27.2",
62
91
  "@babel/core": "^7.27.4",
63
92
  "@babel/plugin-transform-modules-commonjs": "^7.27.1",
64
93
  "@babel/preset-env": "^7.27.2",
94
+ "@types/node": "^22.20.5",
65
95
  "canvas": "^3.2.3",
66
96
  "cross-env": "^7.0.3",
97
+ "esbuild": "^0.28.2",
98
+ "fast-png": "^8.0.0",
99
+ "gifenc": "^1.0.3",
67
100
  "image-q": "^4.0.0",
68
101
  "libimagequant-wasm": "^0.3.0",
69
102
  "mkdirp": "^3.0.1",
103
+ "omggif": "^1.0.10",
104
+ "playwright-core": "^1.56.1",
70
105
  "quantize": "^1.0.2",
71
- "vitest": "^4.1.5"
106
+ "typescript": "^5.9.3",
107
+ "vite": "^8.0.10",
108
+ "vitest": "^4.1.5",
109
+ "webpack": "^5.112.2"
72
110
  }
73
111
  }