sharp 0.35.1 → 0.35.2-rc.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.
@@ -424,10 +424,10 @@ function blur (options) {
424
424
  function dilate (width) {
425
425
  if (!is.defined(width)) {
426
426
  this.options.dilateWidth = 1;
427
- } else if (is.integer(width) && width > 0) {
427
+ } else if (is.integer(width) && is.inRange(width, 1, 65536)) {
428
428
  this.options.dilateWidth = width;
429
429
  } else {
430
- throw is.invalidParameterError('dilate', 'positive integer', dilate);
430
+ throw is.invalidParameterError('width', 'integer between 1 and 65536', width);
431
431
  }
432
432
  return this;
433
433
  }
@@ -447,10 +447,10 @@ function dilate (width) {
447
447
  function erode (width) {
448
448
  if (!is.defined(width)) {
449
449
  this.options.erodeWidth = 1;
450
- } else if (is.integer(width) && width > 0) {
450
+ } else if (is.integer(width) && is.inRange(width, 1, 65536)) {
451
451
  this.options.erodeWidth = width;
452
452
  } else {
453
- throw is.invalidParameterError('erode', 'positive integer', erode);
453
+ throw is.invalidParameterError('width', 'integer between 1 and 65536', width);
454
454
  }
455
455
  return this;
456
456
  }
@@ -862,10 +862,13 @@ function recomb (inputMatrix) {
862
862
  if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {
863
863
  throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length);
864
864
  }
865
- const recombMatrix = inputMatrix.flat().map(Number);
865
+ const recombMatrix = inputMatrix.flat();
866
866
  if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {
867
867
  throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length);
868
868
  }
869
+ if (!recombMatrix.every(is.number)) {
870
+ throw is.invalidParameterError('inputMatrix', 'array of numbers', recombMatrix);
871
+ }
869
872
  this.options.recombMatrix = recombMatrix;
870
873
  return this;
871
874
  }
@@ -424,10 +424,10 @@ function blur (options) {
424
424
  function dilate (width) {
425
425
  if (!is.defined(width)) {
426
426
  this.options.dilateWidth = 1;
427
- } else if (is.integer(width) && width > 0) {
427
+ } else if (is.integer(width) && is.inRange(width, 1, 65536)) {
428
428
  this.options.dilateWidth = width;
429
429
  } else {
430
- throw is.invalidParameterError('dilate', 'positive integer', dilate);
430
+ throw is.invalidParameterError('width', 'integer between 1 and 65536', width);
431
431
  }
432
432
  return this;
433
433
  }
@@ -447,10 +447,10 @@ function dilate (width) {
447
447
  function erode (width) {
448
448
  if (!is.defined(width)) {
449
449
  this.options.erodeWidth = 1;
450
- } else if (is.integer(width) && width > 0) {
450
+ } else if (is.integer(width) && is.inRange(width, 1, 65536)) {
451
451
  this.options.erodeWidth = width;
452
452
  } else {
453
- throw is.invalidParameterError('erode', 'positive integer', erode);
453
+ throw is.invalidParameterError('width', 'integer between 1 and 65536', width);
454
454
  }
455
455
  return this;
456
456
  }
@@ -862,10 +862,13 @@ function recomb (inputMatrix) {
862
862
  if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {
863
863
  throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length);
864
864
  }
865
- const recombMatrix = inputMatrix.flat().map(Number);
865
+ const recombMatrix = inputMatrix.flat();
866
866
  if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {
867
867
  throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length);
868
868
  }
869
+ if (!recombMatrix.every(is.number)) {
870
+ throw is.invalidParameterError('inputMatrix', 'array of numbers', recombMatrix);
871
+ }
869
872
  this.options.recombMatrix = recombMatrix;
870
873
  return this;
871
874
  }
package/dist/output.cjs CHANGED
@@ -929,7 +929,7 @@ function gif (options) {
929
929
  }
930
930
  }
931
931
  if (is.defined(options.effort)) {
932
- if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {
932
+ if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {
933
933
  this.options.gifEffort = options.effort;
934
934
  } else {
935
935
  throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);
package/dist/output.mjs CHANGED
@@ -929,7 +929,7 @@ function gif (options) {
929
929
  }
930
930
  }
931
931
  if (is.defined(options.effort)) {
932
- if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {
932
+ if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {
933
933
  this.options.gifEffort = options.effort;
934
934
  } else {
935
935
  throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);
package/dist/sharp.cjs CHANGED
@@ -82,11 +82,8 @@ if (!sharp) {
82
82
  case "linux-wasm32":
83
83
  sharp = require("@img/sharp-webcontainers-wasm32/sharp.node");
84
84
  break;
85
- default:
86
- sharp = require("@img/sharp-wasm32/sharp.node");
87
- break;
88
85
  }
89
- if (["linux-x64", "linuxmusl-x64"].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
86
+ if (sharp && ["linux-x64", "linuxmusl-x64"].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
90
87
  const err = new Error("Prebuilt binaries for Linux x64 require v2 microarchitecture");
91
88
  err.code = "Unsupported CPU";
92
89
  errors.push(err);
@@ -96,6 +93,13 @@ if (!sharp) {
96
93
  errors.push(err);
97
94
  }
98
95
  }
96
+ if (!sharp) {
97
+ try {
98
+ sharp = require("@img/sharp-wasm32/sharp.node");
99
+ } catch (err) {
100
+ errors.push(err);
101
+ }
102
+ }
99
103
 
100
104
  if (!sharp) {
101
105
  const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os) => runtimePlatform.startsWith(os));
package/dist/sharp.mjs CHANGED
@@ -82,11 +82,8 @@ if (!sharp) {
82
82
  case "linux-wasm32":
83
83
  sharp = require("@img/sharp-webcontainers-wasm32/sharp.node");
84
84
  break;
85
- default:
86
- sharp = require("@img/sharp-wasm32/sharp.node");
87
- break;
88
85
  }
89
- if (["linux-x64", "linuxmusl-x64"].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
86
+ if (sharp && ["linux-x64", "linuxmusl-x64"].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
90
87
  const err = new Error("Prebuilt binaries for Linux x64 require v2 microarchitecture");
91
88
  err.code = "Unsupported CPU";
92
89
  errors.push(err);
@@ -96,6 +93,13 @@ if (!sharp) {
96
93
  errors.push(err);
97
94
  }
98
95
  }
96
+ if (!sharp) {
97
+ try {
98
+ sharp = require("@img/sharp-wasm32/sharp.node");
99
+ } catch (err) {
100
+ errors.push(err);
101
+ }
102
+ }
99
103
 
100
104
  if (!sharp) {
101
105
  const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os) => runtimePlatform.startsWith(os));
package/lib/index.d.ts CHANGED
@@ -1187,6 +1187,23 @@ declare namespace sharp {
1187
1187
 
1188
1188
  type Unit = 'inch' | 'cm';
1189
1189
 
1190
+ type MediaType =
1191
+ 'application/pdf' |
1192
+ 'image/avif' |
1193
+ 'image/fits' |
1194
+ 'image/gif' |
1195
+ 'image/heic' |
1196
+ 'image/jp2' |
1197
+ 'image/jpeg' |
1198
+ 'image/jxl' |
1199
+ 'image/png' |
1200
+ 'image/svg+xml' |
1201
+ 'image/tiff' |
1202
+ 'image/vnd.radiance' |
1203
+ 'image/webp' |
1204
+ 'image/x-exr' |
1205
+ 'image/x-portable-pixmap';
1206
+
1190
1207
  interface WriteableMetadata {
1191
1208
  /** Number of pixels per inch (DPI) */
1192
1209
  density?: number | undefined;
@@ -1280,6 +1297,8 @@ declare namespace sharp {
1280
1297
  comments?: CommentsMetadata[] | undefined;
1281
1298
  /** HDR gain map, if present */
1282
1299
  gainMap?: GainMapMetadata | undefined;
1300
+ /** Media Type (MIME Type) */
1301
+ mediaType?: MediaType | undefined;
1283
1302
  }
1284
1303
 
1285
1304
  interface LevelMetadata {
@@ -1973,4 +1992,4 @@ declare namespace sharp {
1973
1992
  type Matrix4x4 = [[number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number]];
1974
1993
  }
1975
1994
 
1976
- export default sharp;
1995
+ export = sharp;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sharp",
3
3
  "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
4
- "version": "0.35.1",
4
+ "version": "0.35.2-rc.1",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -102,7 +102,7 @@
102
102
  "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
103
103
  "lint-js": "biome lint",
104
104
  "lint-publish": "publint --strict",
105
- "lint-types": "tsd --files ./test/types/sharp.test-d.ts",
105
+ "lint-types": "tsd --files ./test/types/sharp.test-d.{cts,mts}",
106
106
  "test-leak": "./test/leak/leak.sh",
107
107
  "test-unit": "node --experimental-test-coverage test/unit.mjs",
108
108
  "package-from-local-build": "node npm/from-local-build.js",
@@ -163,9 +163,9 @@
163
163
  "semver": "^7.8.4"
164
164
  },
165
165
  "optionalDependencies": {
166
- "@img/sharp-darwin-arm64": "0.35.1",
167
- "@img/sharp-darwin-x64": "0.35.1",
168
- "@img/sharp-freebsd-wasm32": "0.35.1",
166
+ "@img/sharp-darwin-arm64": "0.35.2-rc.1",
167
+ "@img/sharp-darwin-x64": "0.35.2-rc.1",
168
+ "@img/sharp-freebsd-wasm32": "0.35.2-rc.1",
169
169
  "@img/sharp-libvips-darwin-arm64": "1.3.0",
170
170
  "@img/sharp-libvips-darwin-x64": "1.3.0",
171
171
  "@img/sharp-libvips-linux-arm": "1.3.0",
@@ -176,21 +176,21 @@
176
176
  "@img/sharp-libvips-linux-x64": "1.3.0",
177
177
  "@img/sharp-libvips-linuxmusl-arm64": "1.3.0",
178
178
  "@img/sharp-libvips-linuxmusl-x64": "1.3.0",
179
- "@img/sharp-linux-arm": "0.35.1",
180
- "@img/sharp-linux-arm64": "0.35.1",
181
- "@img/sharp-linux-ppc64": "0.35.1",
182
- "@img/sharp-linux-riscv64": "0.35.1",
183
- "@img/sharp-linux-s390x": "0.35.1",
184
- "@img/sharp-linux-x64": "0.35.1",
185
- "@img/sharp-linuxmusl-arm64": "0.35.1",
186
- "@img/sharp-linuxmusl-x64": "0.35.1",
187
- "@img/sharp-webcontainers-wasm32": "0.35.1",
188
- "@img/sharp-win32-arm64": "0.35.1",
189
- "@img/sharp-win32-ia32": "0.35.1",
190
- "@img/sharp-win32-x64": "0.35.1"
179
+ "@img/sharp-linux-arm": "0.35.2-rc.1",
180
+ "@img/sharp-linux-arm64": "0.35.2-rc.1",
181
+ "@img/sharp-linux-ppc64": "0.35.2-rc.1",
182
+ "@img/sharp-linux-riscv64": "0.35.2-rc.1",
183
+ "@img/sharp-linux-s390x": "0.35.2-rc.1",
184
+ "@img/sharp-linux-x64": "0.35.2-rc.1",
185
+ "@img/sharp-linuxmusl-arm64": "0.35.2-rc.1",
186
+ "@img/sharp-linuxmusl-x64": "0.35.2-rc.1",
187
+ "@img/sharp-webcontainers-wasm32": "0.35.2-rc.1",
188
+ "@img/sharp-win32-arm64": "0.35.2-rc.1",
189
+ "@img/sharp-win32-ia32": "0.35.2-rc.1",
190
+ "@img/sharp-win32-x64": "0.35.2-rc.1"
191
191
  },
192
192
  "devDependencies": {
193
- "@biomejs/biome": "^2.4.16",
193
+ "@biomejs/biome": "^2.5.0",
194
194
  "@cpplint/cli": "^0.1.0",
195
195
  "@emnapi/runtime": "^1.11.0",
196
196
  "@img/sharp-libvips-dev": "1.3.0",