@napi-rs/image 1.9.0 → 1.9.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.
Files changed (4) hide show
  1. package/README.md +5 -5
  2. package/index.d.ts +9 -9
  3. package/index.js +32 -17
  4. package/package.json +18 -18
package/README.md CHANGED
@@ -62,7 +62,7 @@ export interface Metadata {
62
62
  colorType: JsColorType
63
63
  }
64
64
 
65
- export const enum JsColorType {
65
+ export enum JsColorType {
66
66
  /** Pixel is 8-bit luminance */
67
67
  L8 = 0,
68
68
  /** Pixel is 8-bit luminance with an alpha channel */
@@ -172,7 +172,7 @@ export interface AvifConfig {
172
172
  * https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
173
173
  * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
174
174
  */
175
- export const enum ChromaSubsampling {
175
+ export enum ChromaSubsampling {
176
176
  /**
177
177
  * Each of the three Y'CbCr components has the same sample rate, thus there is no chroma subsampling. This scheme is sometimes used in high-end film scanners and cinematic post-production.
178
178
  * Note that "4:4:4" may instead be wrongly referring to R'G'B' color space, which implicitly also does not have any chroma subsampling (except in JPEG R'G'B' can be subsampled).
@@ -228,7 +228,7 @@ export interface PngEncodeOptions {
228
228
  /** Default is `FilterType::NoFilter` */
229
229
  filterType?: FilterType | undefined | null
230
230
  }
231
- export const enum CompressionType {
231
+ export enum CompressionType {
232
232
  /** Default compression level */
233
233
  Default = 0,
234
234
  /** Fast, minimal compression */
@@ -240,7 +240,7 @@ export const enum CompressionType {
240
240
  /** Run-length encoding compression */
241
241
  Rle = 4,
242
242
  }
243
- export const enum FilterType {
243
+ export enum FilterType {
244
244
  /**
245
245
  * No processing done, best used for low bit depth greyscale or data with a
246
246
  * low color count
@@ -405,7 +405,7 @@ invert(): this
405
405
  */
406
406
  resize(width: number, height?: number | undefined | null, filterType?: ResizeFilterType | undefined | null): this
407
407
 
408
- export const enum ResizeFilterType {
408
+ export enum ResizeFilterType {
409
409
  /** Nearest Neighbor */
410
410
  Nearest = 0,
411
411
  /** Linear Filter */
package/index.d.ts CHANGED
@@ -131,7 +131,7 @@ export interface AvifConfig {
131
131
  * https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
132
132
  * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
133
133
  */
134
- export const enum ChromaSubsampling {
134
+ export enum ChromaSubsampling {
135
135
  /**
136
136
  * Each of the three Y'CbCr components has the same sample rate, thus there is no chroma subsampling. This scheme is sometimes used in high-end film scanners and cinematic post-production.
137
137
  * Note that "4:4:4" may instead be wrongly referring to R'G'B' color space, which implicitly also does not have any chroma subsampling (except in JPEG R'G'B' can be subsampled).
@@ -170,7 +170,7 @@ export const enum ChromaSubsampling {
170
170
  Yuv400 = 3
171
171
  }
172
172
 
173
- export const enum CompressionType {
173
+ export enum CompressionType {
174
174
  /** Default compression level */
175
175
  Default = 0,
176
176
  /** Fast, minimal compression */
@@ -183,7 +183,7 @@ export function compressJpeg(input: Buffer, options?: JpegCompressOptions | unde
183
183
 
184
184
  export function compressJpegSync(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer
185
185
 
186
- export const enum FastResizeFilter {
186
+ export enum FastResizeFilter {
187
187
  /**
188
188
  * Each pixel of source image contributes to one pixel of the
189
189
  * destination image with identical weights. For upscaling is equivalent
@@ -230,7 +230,7 @@ export interface FastResizeOptions {
230
230
  fit?: ResizeFit
231
231
  }
232
232
 
233
- export const enum FilterType {
233
+ export enum FilterType {
234
234
  /**
235
235
  * No processing done, best used for low bit depth greyscale or data with a
236
236
  * low color count
@@ -261,7 +261,7 @@ export interface JpegCompressOptions {
261
261
  optimizeScans?: boolean
262
262
  }
263
263
 
264
- export const enum JsColorType {
264
+ export enum JsColorType {
265
265
  /** Pixel is 8-bit luminance */
266
266
  L8 = 0,
267
267
  /** Pixel is 8-bit luminance with an alpha channel */
@@ -297,7 +297,7 @@ export interface Metadata {
297
297
  colorType: JsColorType
298
298
  }
299
299
 
300
- export const enum Orientation {
300
+ export enum Orientation {
301
301
  /** Normal */
302
302
  Horizontal = 1,
303
303
  MirrorHorizontal = 2,
@@ -381,7 +381,7 @@ export interface PngQuantOptions {
381
381
  posterization?: number
382
382
  }
383
383
 
384
- export const enum PngRowFilter {
384
+ export enum PngRowFilter {
385
385
  None = 0,
386
386
  Sub = 1,
387
387
  Up = 2,
@@ -462,7 +462,7 @@ export const enum PngRowFilter {
462
462
  * </tr>
463
463
  * </table>
464
464
  */
465
- export const enum ResizeFilterType {
465
+ export enum ResizeFilterType {
466
466
  /** Nearest Neighbor */
467
467
  Nearest = 0,
468
468
  /** Linear Filter */
@@ -475,7 +475,7 @@ export const enum ResizeFilterType {
475
475
  Lanczos3 = 4
476
476
  }
477
477
 
478
- export const enum ResizeFit {
478
+ export enum ResizeFit {
479
479
  /**
480
480
  * (default) Preserving aspect ratio
481
481
  * ensure the image covers both provided dimensions by cropping/clipping to fit.
package/index.js CHANGED
@@ -88,7 +88,7 @@ switch (platform) {
88
88
  }
89
89
  break
90
90
  default:
91
- throw new Error(`Unsupported architecture on Android ${arch}`)
91
+ loadError = new Error(`Unsupported architecture on Android ${arch}`)
92
92
  }
93
93
  break
94
94
  case 'win32':
@@ -136,7 +136,7 @@ switch (platform) {
136
136
  }
137
137
  break
138
138
  default:
139
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
139
+ loadError = new Error(`Unsupported architecture on Windows: ${arch}`)
140
140
  }
141
141
  break
142
142
  case 'darwin':
@@ -177,22 +177,37 @@ switch (platform) {
177
177
  }
178
178
  break
179
179
  default:
180
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
180
+ loadError = new Error(`Unsupported architecture on macOS: ${arch}`)
181
181
  }
182
182
  break
183
183
  case 'freebsd':
184
- if (arch !== 'x64') {
185
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
186
- }
187
- localFileExisted = existsSync(join(__dirname, 'image.freebsd-x64.node'))
188
- try {
189
- if (localFileExisted) {
190
- nativeBinding = require('./image.freebsd-x64.node')
191
- } else {
192
- nativeBinding = require('@napi-rs/image-freebsd-x64')
193
- }
194
- } catch (e) {
195
- loadError = e
184
+ switch (arch) {
185
+ case 'x64':
186
+ localFileExisted = existsSync(join(__dirname, 'image.freebsd-x64.node'))
187
+ try {
188
+ if (localFileExisted) {
189
+ nativeBinding = require('./image.freebsd-x64.node')
190
+ } else {
191
+ nativeBinding = require('@napi-rs/image-freebsd-x64')
192
+ }
193
+ } catch (e) {
194
+ loadError = e
195
+ }
196
+ break
197
+ case 'arm64':
198
+ localFileExisted = existsSync(join(__dirname, 'image.freebsd-arm64.node'))
199
+ try {
200
+ if (localFileExisted) {
201
+ nativeBinding = require('./image.freebsd-arm64.node')
202
+ } else {
203
+ nativeBinding = require('@napi-rs/image-freebsd-arm64')
204
+ }
205
+ } catch (e) {
206
+ loadError = e
207
+ }
208
+ break
209
+ default:
210
+ loadError = new Error(`Unsupported architecture on FreeBSD: ${arch}`)
196
211
  }
197
212
  break
198
213
  case 'linux':
@@ -313,11 +328,11 @@ switch (platform) {
313
328
  }
314
329
  break
315
330
  default:
316
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
331
+ loadError = new Error(`Unsupported architecture on Linux: ${arch}`)
317
332
  }
318
333
  break
319
334
  default:
320
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
335
+ loadError = new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
321
336
  }
322
337
 
323
338
  if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/image",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "main": "index.js",
5
5
  "browser": "browser.js",
6
6
  "types": "index.d.ts",
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "scripts": {
56
56
  "artifacts": "napi artifacts -d ../../artifacts",
57
- "build": "napi build --platform --release",
58
- "build:debug": "napi build --platform",
57
+ "build": "napi build --platform --no-const-enum --release",
58
+ "build:debug": "napi build --platform --no-const-enum",
59
59
  "format": "run-p format:prettier format:rs",
60
60
  "format:prettier": "prettier --config ./package.json -w .",
61
61
  "format:rs": "cargo fmt --all",
@@ -64,22 +64,22 @@
64
64
  },
65
65
  "repository": "git@github.com:Brooooooklyn/Image.git",
66
66
  "devDependencies": {
67
- "@napi-rs/cli": "^3.0.0-alpha.40",
68
- "@napi-rs/wasm-runtime": "^0.1.1"
67
+ "@napi-rs/cli": "^3.0.0-alpha.41",
68
+ "@napi-rs/wasm-runtime": "^0.2.0"
69
69
  },
70
- "gitHead": "caeb47b4e0b58de9280f5bdd2dab4d16c643d6b7",
70
+ "gitHead": "c505d043caea0850f90362bba9d96d72ebe1ca1b",
71
71
  "optionalDependencies": {
72
- "@napi-rs/image-darwin-x64": "1.9.0",
73
- "@napi-rs/image-win32-x64-msvc": "1.9.0",
74
- "@napi-rs/image-linux-x64-gnu": "1.9.0",
75
- "@napi-rs/image-darwin-arm64": "1.9.0",
76
- "@napi-rs/image-android-arm64": "1.9.0",
77
- "@napi-rs/image-linux-arm64-gnu": "1.9.0",
78
- "@napi-rs/image-linux-arm64-musl": "1.9.0",
79
- "@napi-rs/image-linux-arm-gnueabihf": "1.9.0",
80
- "@napi-rs/image-linux-x64-musl": "1.9.0",
81
- "@napi-rs/image-freebsd-x64": "1.9.0",
82
- "@napi-rs/image-win32-ia32-msvc": "1.9.0",
83
- "@napi-rs/image-wasm32-wasi": "1.9.0"
72
+ "@napi-rs/image-darwin-x64": "1.9.2",
73
+ "@napi-rs/image-win32-x64-msvc": "1.9.2",
74
+ "@napi-rs/image-linux-x64-gnu": "1.9.2",
75
+ "@napi-rs/image-darwin-arm64": "1.9.2",
76
+ "@napi-rs/image-android-arm64": "1.9.2",
77
+ "@napi-rs/image-linux-arm64-gnu": "1.9.2",
78
+ "@napi-rs/image-linux-arm64-musl": "1.9.2",
79
+ "@napi-rs/image-linux-arm-gnueabihf": "1.9.2",
80
+ "@napi-rs/image-linux-x64-musl": "1.9.2",
81
+ "@napi-rs/image-freebsd-x64": "1.9.2",
82
+ "@napi-rs/image-win32-ia32-msvc": "1.9.2",
83
+ "@napi-rs/image-wasm32-wasi": "1.9.2"
84
84
  }
85
85
  }