@revizly/sharp 0.35.0-revizly35 → 0.35.0-revizly37

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);
@@ -1207,8 +1207,6 @@ function tiff (options) {
1207
1207
  *
1208
1208
  * AVIF image sequences are not supported.
1209
1209
  *
1210
- * When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
1211
- *
1212
1210
  * @example
1213
1211
  * const data = await sharp(input)
1214
1212
  * .avif({ effort: 2 })
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);
@@ -1207,8 +1207,6 @@ function tiff (options) {
1207
1207
  *
1208
1208
  * AVIF image sequences are not supported.
1209
1209
  *
1210
- * When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
1211
- *
1212
1210
  * @example
1213
1211
  * const data = await sharp(input)
1214
1212
  * .avif({ effort: 2 })
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
@@ -27,8 +27,8 @@
27
27
 
28
28
  /// <reference types="node" />
29
29
 
30
- import type { Duplex } from 'node:stream';
31
- import { ColorLike } from '@img/colour';
30
+ declare type Duplex = import('node:stream').Duplex;
31
+ declare type ColorLike = import('@img/colour').ColorLike;
32
32
 
33
33
  //#region Constructor functions
34
34
 
@@ -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 {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@revizly/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.0-revizly35",
4
+ "version": "0.35.0-revizly37",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -98,10 +98,11 @@
98
98
  "build:dist": "node scripts/build.mjs",
99
99
  "clean": "rm -rf src/build/ test/fixtures/output.*",
100
100
  "test": "npm run lint && npm run test-unit",
101
- "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
101
+ "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-publish",
102
102
  "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
103
103
  "lint-js": "biome lint",
104
- "lint-types": "tsd --files ./test/types/sharp.test-d.ts",
104
+ "lint-publish": "publint --strict",
105
+ "lint-types": "tsd --files ./test/types/sharp.test-d.{cts,mts}",
105
106
  "test-leak": "./test/leak/leak.sh",
106
107
  "test-unit": "node --experimental-test-coverage test/unit.mjs",
107
108
  "package-from-local-build": "node npm/from-local-build.js",
@@ -120,13 +121,20 @@
120
121
  ],
121
122
  "main": "./dist/index.cjs",
122
123
  "module": "./dist/index.mjs",
123
- "types": "./lib/index.d.ts",
124
+ "types": "./dist/index.d.mts",
124
125
  "exports": {
125
126
  ".": {
126
- "import": "./dist/index.mjs",
127
- "require": "./dist/index.cjs"
127
+ "import": {
128
+ "types": "./dist/index.d.mts",
129
+ "default": "./dist/index.mjs"
130
+ },
131
+ "require": {
132
+ "types": "./dist/index.d.cts",
133
+ "default": "./dist/index.cjs"
134
+ }
128
135
  }
129
136
  },
137
+ "sideEffects": true,
130
138
  "repository": {
131
139
  "type": "git",
132
140
  "url": "git://github.com/janaz/sharp.git"
@@ -152,19 +160,19 @@
152
160
  "dependencies": {
153
161
  "@img/colour": "^1.1.0",
154
162
  "detect-libc": "^2.1.2",
155
- "semver": "^7.8.3"
163
+ "semver": "^7.8.4"
156
164
  },
157
165
  "optionalDependencies": {
158
- "@revizly/sharp-libvips-linux-arm64": "1.0.38",
159
- "@revizly/sharp-libvips-linux-x64": "1.0.38",
160
- "@revizly/sharp-linux-arm64": "0.35.0-revizly35",
161
- "@revizly/sharp-linux-x64": "0.35.0-revizly35"
166
+ "@revizly/sharp-libvips-linux-arm64": "1.0.40",
167
+ "@revizly/sharp-libvips-linux-x64": "1.0.40",
168
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly37",
169
+ "@revizly/sharp-linux-x64": "0.35.0-revizly37"
162
170
  },
163
171
  "devDependencies": {
164
- "@biomejs/biome": "^2.4.16",
172
+ "@biomejs/biome": "^2.5.0",
165
173
  "@cpplint/cli": "^0.1.0",
166
174
  "@emnapi/runtime": "^1.11.0",
167
- "@revizly/sharp-libvips-dev": "1.0.38",
175
+ "@revizly/sharp-libvips-dev": "1.0.40",
168
176
  "@types/node": "*",
169
177
  "emnapi": "^1.11.0",
170
178
  "exif-reader": "^2.0.3",
@@ -172,6 +180,7 @@
172
180
  "icc": "^4.0.0",
173
181
  "node-addon-api": "^8.8.0",
174
182
  "node-gyp": "^12.4.0",
183
+ "publint": "^0.3.21",
175
184
  "tar-fs": "^3.1.2",
176
185
  "tsd": "^0.33.0"
177
186
  },