@napi-rs/image 1.9.2 → 1.10.0
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/index.d.ts +19 -21
- package/index.js +287 -272
- package/package.json +21 -18
package/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(input: Buffer)
|
|
3
|
+
export declare class Transformer {
|
|
4
|
+
constructor(input: Uint8Array)
|
|
6
5
|
/** Support CSS3 color, e.g. rgba(255, 255, 255, .8) */
|
|
7
|
-
static fromSvg(input: string |
|
|
6
|
+
static fromSvg(input: string | Uint8Array, background?: string | undefined | null): Transformer
|
|
8
7
|
static fromRgbaPixels(input: Uint8Array | Uint8ClampedArray, width: number, height: number): Transformer
|
|
9
8
|
metadata(withExif?: boolean | undefined | null, signal?: AbortSignal | undefined | null): Promise<Metadata>
|
|
10
9
|
/**
|
|
@@ -73,7 +72,7 @@ export class Transformer {
|
|
|
73
72
|
/** Crop a cut-out of this image delimited by the bounding rectangle. */
|
|
74
73
|
crop(x: number, y: number, width: number, height: number): this
|
|
75
74
|
/** Overlay an image at a given coordinate (x, y) */
|
|
76
|
-
overlay(onTop:
|
|
75
|
+
overlay(onTop: Uint8Array, x: number, y: number): this
|
|
77
76
|
/** Return this image's pixels as a native endian byte slice. */
|
|
78
77
|
rawPixels(signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
79
78
|
/** Return this image's pixels as a native endian byte slice. */
|
|
@@ -131,7 +130,7 @@ export interface AvifConfig {
|
|
|
131
130
|
* https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
|
|
132
131
|
* https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
|
|
133
132
|
*/
|
|
134
|
-
export enum ChromaSubsampling {
|
|
133
|
+
export declare enum ChromaSubsampling {
|
|
135
134
|
/**
|
|
136
135
|
* 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
136
|
* 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 +169,7 @@ export enum ChromaSubsampling {
|
|
|
170
169
|
Yuv400 = 3
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
export enum CompressionType {
|
|
172
|
+
export declare enum CompressionType {
|
|
174
173
|
/** Default compression level */
|
|
175
174
|
Default = 0,
|
|
176
175
|
/** Fast, minimal compression */
|
|
@@ -179,11 +178,11 @@ export enum CompressionType {
|
|
|
179
178
|
Best = 2
|
|
180
179
|
}
|
|
181
180
|
|
|
182
|
-
export function compressJpeg(input:
|
|
181
|
+
export declare function compressJpeg(input: Uint8Array, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
183
182
|
|
|
184
|
-
export function compressJpegSync(input:
|
|
183
|
+
export declare function compressJpegSync(input: Uint8Array, options?: JpegCompressOptions | undefined | null): Buffer
|
|
185
184
|
|
|
186
|
-
export enum FastResizeFilter {
|
|
185
|
+
export declare enum FastResizeFilter {
|
|
187
186
|
/**
|
|
188
187
|
* Each pixel of source image contributes to one pixel of the
|
|
189
188
|
* destination image with identical weights. For upscaling is equivalent
|
|
@@ -230,7 +229,7 @@ export interface FastResizeOptions {
|
|
|
230
229
|
fit?: ResizeFit
|
|
231
230
|
}
|
|
232
231
|
|
|
233
|
-
export enum FilterType {
|
|
232
|
+
export declare enum FilterType {
|
|
234
233
|
/**
|
|
235
234
|
* No processing done, best used for low bit depth greyscale or data with a
|
|
236
235
|
* low color count
|
|
@@ -261,7 +260,7 @@ export interface JpegCompressOptions {
|
|
|
261
260
|
optimizeScans?: boolean
|
|
262
261
|
}
|
|
263
262
|
|
|
264
|
-
export enum JsColorType {
|
|
263
|
+
export declare enum JsColorType {
|
|
265
264
|
/** Pixel is 8-bit luminance */
|
|
266
265
|
L8 = 0,
|
|
267
266
|
/** Pixel is 8-bit luminance with an alpha channel */
|
|
@@ -284,9 +283,9 @@ export enum JsColorType {
|
|
|
284
283
|
Rgba32F = 9
|
|
285
284
|
}
|
|
286
285
|
|
|
287
|
-
export function losslessCompressPng(input:
|
|
286
|
+
export declare function losslessCompressPng(input: Uint8Array, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
288
287
|
|
|
289
|
-
export function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
|
|
288
|
+
export declare function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
|
|
290
289
|
|
|
291
290
|
export interface Metadata {
|
|
292
291
|
width: number
|
|
@@ -297,7 +296,7 @@ export interface Metadata {
|
|
|
297
296
|
colorType: JsColorType
|
|
298
297
|
}
|
|
299
298
|
|
|
300
|
-
export enum Orientation {
|
|
299
|
+
export declare enum Orientation {
|
|
301
300
|
/** Normal */
|
|
302
301
|
Horizontal = 1,
|
|
303
302
|
MirrorHorizontal = 2,
|
|
@@ -359,9 +358,9 @@ export interface PNGLosslessOptions {
|
|
|
359
358
|
strip?: boolean
|
|
360
359
|
}
|
|
361
360
|
|
|
362
|
-
export function pngQuantize(input:
|
|
361
|
+
export declare function pngQuantize(input: Uint8Array, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
|
|
363
362
|
|
|
364
|
-
export function pngQuantizeSync(input:
|
|
363
|
+
export declare function pngQuantizeSync(input: Uint8Array, options?: PngQuantOptions | undefined | null): Buffer
|
|
365
364
|
|
|
366
365
|
export interface PngQuantOptions {
|
|
367
366
|
/** default is 70 */
|
|
@@ -381,7 +380,7 @@ export interface PngQuantOptions {
|
|
|
381
380
|
posterization?: number
|
|
382
381
|
}
|
|
383
382
|
|
|
384
|
-
export enum PngRowFilter {
|
|
383
|
+
export declare enum PngRowFilter {
|
|
385
384
|
None = 0,
|
|
386
385
|
Sub = 1,
|
|
387
386
|
Up = 2,
|
|
@@ -462,7 +461,7 @@ export enum PngRowFilter {
|
|
|
462
461
|
* </tr>
|
|
463
462
|
* </table>
|
|
464
463
|
*/
|
|
465
|
-
export enum ResizeFilterType {
|
|
464
|
+
export declare enum ResizeFilterType {
|
|
466
465
|
/** Nearest Neighbor */
|
|
467
466
|
Nearest = 0,
|
|
468
467
|
/** Linear Filter */
|
|
@@ -475,7 +474,7 @@ export enum ResizeFilterType {
|
|
|
475
474
|
Lanczos3 = 4
|
|
476
475
|
}
|
|
477
476
|
|
|
478
|
-
export enum ResizeFit {
|
|
477
|
+
export declare enum ResizeFit {
|
|
479
478
|
/**
|
|
480
479
|
* (default) Preserving aspect ratio
|
|
481
480
|
* ensure the image covers both provided dimensions by cropping/clipping to fit.
|
|
@@ -496,4 +495,3 @@ export interface ResizeOptions {
|
|
|
496
495
|
filter?: ResizeFilterType
|
|
497
496
|
fit?: ResizeFit
|
|
498
497
|
}
|
|
499
|
-
|
package/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// prettier-ignore
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
3
4
|
/* auto-generated by NAPI-RS */
|
|
4
5
|
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { platform, arch } = process
|
|
6
|
+
const { createRequire } = require('node:module')
|
|
7
|
+
require = createRequire(__filename)
|
|
9
8
|
|
|
9
|
+
const { readFileSync } = require('node:fs')
|
|
10
10
|
let nativeBinding = null
|
|
11
|
-
|
|
12
|
-
let loadError = null
|
|
11
|
+
const loadErrors = []
|
|
13
12
|
|
|
14
13
|
const isMusl = () => {
|
|
15
14
|
let musl = false
|
|
@@ -36,7 +35,11 @@ const isMuslFromFilesystem = () => {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
const isMuslFromReport = () => {
|
|
39
|
-
|
|
38
|
+
let report = null
|
|
39
|
+
if (typeof process.report?.getReport === 'function') {
|
|
40
|
+
process.report.excludeNetwork = true
|
|
41
|
+
report = process.report.getReport()
|
|
42
|
+
}
|
|
40
43
|
if (!report) {
|
|
41
44
|
return null
|
|
42
45
|
}
|
|
@@ -60,287 +63,293 @@ const isMuslFromChildProcess = () => {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (localFileExisted) {
|
|
70
|
-
nativeBinding = require('./image.android-arm64.node')
|
|
71
|
-
} else {
|
|
72
|
-
nativeBinding = require('@napi-rs/image-android-arm64')
|
|
73
|
-
}
|
|
74
|
-
} catch (e) {
|
|
75
|
-
loadError = e
|
|
76
|
-
}
|
|
77
|
-
break
|
|
78
|
-
case 'arm':
|
|
79
|
-
localFileExisted = existsSync(join(__dirname, 'image.android-arm-eabi.node'))
|
|
80
|
-
try {
|
|
81
|
-
if (localFileExisted) {
|
|
82
|
-
nativeBinding = require('./image.android-arm-eabi.node')
|
|
83
|
-
} else {
|
|
84
|
-
nativeBinding = require('@napi-rs/image-android-arm-eabi')
|
|
85
|
-
}
|
|
86
|
-
} catch (e) {
|
|
87
|
-
loadError = e
|
|
88
|
-
}
|
|
89
|
-
break
|
|
90
|
-
default:
|
|
91
|
-
loadError = new Error(`Unsupported architecture on Android ${arch}`)
|
|
66
|
+
function requireNative() {
|
|
67
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
|
+
try {
|
|
69
|
+
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
loadErrors.push(err)
|
|
92
72
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
73
|
+
} else if (process.platform === 'android') {
|
|
74
|
+
if (process.arch === 'arm64') {
|
|
75
|
+
try {
|
|
76
|
+
return require('./image.android-arm64.node')
|
|
77
|
+
} catch (e) {
|
|
78
|
+
loadErrors.push(e)
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return require('@napi-rs/image-android-arm64')
|
|
82
|
+
} catch (e) {
|
|
83
|
+
loadErrors.push(e)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} else if (process.arch === 'arm') {
|
|
87
|
+
try {
|
|
88
|
+
return require('./image.android-arm-eabi.node')
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadErrors.push(e)
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
return require('@napi-rs/image-android-arm-eabi')
|
|
94
|
+
} catch (e) {
|
|
95
|
+
loadErrors.push(e)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
100
|
+
}
|
|
101
|
+
} else if (process.platform === 'win32') {
|
|
102
|
+
if (process.arch === 'x64') {
|
|
103
|
+
try {
|
|
104
|
+
return require('./image.win32-x64-msvc.node')
|
|
105
|
+
} catch (e) {
|
|
106
|
+
loadErrors.push(e)
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
return require('@napi-rs/image-win32-x64-msvc')
|
|
110
|
+
} catch (e) {
|
|
111
|
+
loadErrors.push(e)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
} else if (process.arch === 'ia32') {
|
|
115
|
+
try {
|
|
116
|
+
return require('./image.win32-ia32-msvc.node')
|
|
117
|
+
} catch (e) {
|
|
118
|
+
loadErrors.push(e)
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
return require('@napi-rs/image-win32-ia32-msvc')
|
|
122
|
+
} catch (e) {
|
|
123
|
+
loadErrors.push(e)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
} else if (process.arch === 'arm64') {
|
|
127
|
+
try {
|
|
128
|
+
return require('./image.win32-arm64-msvc.node')
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadErrors.push(e)
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
return require('@napi-rs/image-win32-arm64-msvc')
|
|
134
|
+
} catch (e) {
|
|
135
|
+
loadErrors.push(e)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
} else {
|
|
139
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
case 'darwin':
|
|
143
|
-
localFileExisted = existsSync(join(__dirname, 'image.darwin-universal.node'))
|
|
141
|
+
} else if (process.platform === 'darwin') {
|
|
144
142
|
try {
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
return require('./image.darwin-universal.node')
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadErrors.push(e)
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
return require('@napi-rs/image-darwin-universal')
|
|
149
|
+
} catch (e) {
|
|
150
|
+
loadErrors.push(e)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (process.arch === 'x64') {
|
|
154
|
+
try {
|
|
155
|
+
return require('./image.darwin-x64.node')
|
|
156
|
+
} catch (e) {
|
|
157
|
+
loadErrors.push(e)
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
return require('@napi-rs/image-darwin-x64')
|
|
161
|
+
} catch (e) {
|
|
162
|
+
loadErrors.push(e)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
} else if (process.arch === 'arm64') {
|
|
166
|
+
try {
|
|
167
|
+
return require('./image.darwin-arm64.node')
|
|
168
|
+
} catch (e) {
|
|
169
|
+
loadErrors.push(e)
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return require('@napi-rs/image-darwin-arm64')
|
|
173
|
+
} catch (e) {
|
|
174
|
+
loadErrors.push(e)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
179
|
+
}
|
|
180
|
+
} else if (process.platform === 'freebsd') {
|
|
181
|
+
if (process.arch === 'x64') {
|
|
182
|
+
try {
|
|
183
|
+
return require('./image.freebsd-x64.node')
|
|
184
|
+
} catch (e) {
|
|
185
|
+
loadErrors.push(e)
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return require('@napi-rs/image-freebsd-x64')
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadErrors.push(e)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
} else if (process.arch === 'arm64') {
|
|
194
|
+
try {
|
|
195
|
+
return require('./image.freebsd-arm64.node')
|
|
196
|
+
} catch (e) {
|
|
197
|
+
loadErrors.push(e)
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
return require('@napi-rs/image-freebsd-arm64')
|
|
201
|
+
} catch (e) {
|
|
202
|
+
loadErrors.push(e)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
} else {
|
|
206
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
207
|
+
}
|
|
208
|
+
} else if (process.platform === 'linux') {
|
|
209
|
+
if (process.arch === 'x64') {
|
|
210
|
+
if (isMusl()) {
|
|
211
|
+
try {
|
|
212
|
+
return require('./image.linux-x64-musl.node')
|
|
213
|
+
} catch (e) {
|
|
214
|
+
loadErrors.push(e)
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
return require('@napi-rs/image-linux-x64-musl')
|
|
218
|
+
} catch (e) {
|
|
219
|
+
loadErrors.push(e)
|
|
220
|
+
}
|
|
221
|
+
|
|
147
222
|
} else {
|
|
148
|
-
|
|
223
|
+
try {
|
|
224
|
+
return require('./image.linux-x64-gnu.node')
|
|
225
|
+
} catch (e) {
|
|
226
|
+
loadErrors.push(e)
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
return require('@napi-rs/image-linux-x64-gnu')
|
|
230
|
+
} catch (e) {
|
|
231
|
+
loadErrors.push(e)
|
|
149
232
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
localFileExisted = existsSync(join(__dirname, 'image.darwin-x64.node'))
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
} else if (process.arch === 'arm64') {
|
|
236
|
+
if (isMusl()) {
|
|
155
237
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
join(__dirname, 'image.darwin-arm64.node')
|
|
168
|
-
)
|
|
238
|
+
return require('./image.linux-arm64-musl.node')
|
|
239
|
+
} catch (e) {
|
|
240
|
+
loadErrors.push(e)
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
return require('@napi-rs/image-linux-arm64-musl')
|
|
244
|
+
} catch (e) {
|
|
245
|
+
loadErrors.push(e)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
} else {
|
|
169
249
|
try {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
case 'freebsd':
|
|
184
|
-
switch (arch) {
|
|
185
|
-
case 'x64':
|
|
186
|
-
localFileExisted = existsSync(join(__dirname, 'image.freebsd-x64.node'))
|
|
250
|
+
return require('./image.linux-arm64-gnu.node')
|
|
251
|
+
} catch (e) {
|
|
252
|
+
loadErrors.push(e)
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
return require('@napi-rs/image-linux-arm64-gnu')
|
|
256
|
+
} catch (e) {
|
|
257
|
+
loadErrors.push(e)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
} else if (process.arch === 'arm') {
|
|
262
|
+
if (isMusl()) {
|
|
187
263
|
try {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
264
|
+
return require('./image.linux-arm-musleabihf.node')
|
|
265
|
+
} catch (e) {
|
|
266
|
+
loadErrors.push(e)
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
return require('@napi-rs/image-linux-arm-musleabihf')
|
|
270
|
+
} catch (e) {
|
|
271
|
+
loadErrors.push(e)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
} else {
|
|
199
275
|
try {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
case 'linux':
|
|
214
|
-
switch (arch) {
|
|
215
|
-
case 'x64':
|
|
216
|
-
if (isMusl()) {
|
|
217
|
-
localFileExisted = existsSync(
|
|
218
|
-
join(__dirname, 'image.linux-x64-musl.node')
|
|
219
|
-
)
|
|
220
|
-
try {
|
|
221
|
-
if (localFileExisted) {
|
|
222
|
-
nativeBinding = require('./image.linux-x64-musl.node')
|
|
223
|
-
} else {
|
|
224
|
-
nativeBinding = require('@napi-rs/image-linux-x64-musl')
|
|
225
|
-
}
|
|
226
|
-
} catch (e) {
|
|
227
|
-
loadError = e
|
|
228
|
-
}
|
|
229
|
-
} else {
|
|
230
|
-
localFileExisted = existsSync(
|
|
231
|
-
join(__dirname, 'image.linux-x64-gnu.node')
|
|
232
|
-
)
|
|
233
|
-
try {
|
|
234
|
-
if (localFileExisted) {
|
|
235
|
-
nativeBinding = require('./image.linux-x64-gnu.node')
|
|
236
|
-
} else {
|
|
237
|
-
nativeBinding = require('@napi-rs/image-linux-x64-gnu')
|
|
238
|
-
}
|
|
239
|
-
} catch (e) {
|
|
240
|
-
loadError = e
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
break
|
|
244
|
-
case 'arm64':
|
|
245
|
-
if (isMusl()) {
|
|
246
|
-
localFileExisted = existsSync(
|
|
247
|
-
join(__dirname, 'image.linux-arm64-musl.node')
|
|
248
|
-
)
|
|
249
|
-
try {
|
|
250
|
-
if (localFileExisted) {
|
|
251
|
-
nativeBinding = require('./image.linux-arm64-musl.node')
|
|
252
|
-
} else {
|
|
253
|
-
nativeBinding = require('@napi-rs/image-linux-arm64-musl')
|
|
254
|
-
}
|
|
255
|
-
} catch (e) {
|
|
256
|
-
loadError = e
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
localFileExisted = existsSync(
|
|
260
|
-
join(__dirname, 'image.linux-arm64-gnu.node')
|
|
261
|
-
)
|
|
262
|
-
try {
|
|
263
|
-
if (localFileExisted) {
|
|
264
|
-
nativeBinding = require('./image.linux-arm64-gnu.node')
|
|
265
|
-
} else {
|
|
266
|
-
nativeBinding = require('@napi-rs/image-linux-arm64-gnu')
|
|
267
|
-
}
|
|
268
|
-
} catch (e) {
|
|
269
|
-
loadError = e
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
break
|
|
273
|
-
case 'arm':
|
|
274
|
-
localFileExisted = existsSync(
|
|
275
|
-
join(__dirname, 'image.linux-arm-gnueabihf.node')
|
|
276
|
-
)
|
|
276
|
+
return require('./image.linux-arm-gnueabihf.node')
|
|
277
|
+
} catch (e) {
|
|
278
|
+
loadErrors.push(e)
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
return require('@napi-rs/image-linux-arm-gnueabihf')
|
|
282
|
+
} catch (e) {
|
|
283
|
+
loadErrors.push(e)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
} else if (process.arch === 'riscv64') {
|
|
288
|
+
if (isMusl()) {
|
|
277
289
|
try {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
localFileExisted = existsSync(
|
|
290
|
-
join(__dirname, 'image.linux-riscv64-musl.node')
|
|
291
|
-
)
|
|
292
|
-
try {
|
|
293
|
-
if (localFileExisted) {
|
|
294
|
-
nativeBinding = require('./image.linux-riscv64-musl.node')
|
|
295
|
-
} else {
|
|
296
|
-
nativeBinding = require('@napi-rs/image-linux-riscv64-musl')
|
|
297
|
-
}
|
|
298
|
-
} catch (e) {
|
|
299
|
-
loadError = e
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
localFileExisted = existsSync(
|
|
303
|
-
join(__dirname, 'image.linux-riscv64-gnu.node')
|
|
304
|
-
)
|
|
305
|
-
try {
|
|
306
|
-
if (localFileExisted) {
|
|
307
|
-
nativeBinding = require('./image.linux-riscv64-gnu.node')
|
|
308
|
-
} else {
|
|
309
|
-
nativeBinding = require('@napi-rs/image-linux-riscv64-gnu')
|
|
310
|
-
}
|
|
311
|
-
} catch (e) {
|
|
312
|
-
loadError = e
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
break
|
|
316
|
-
case 's390x':
|
|
317
|
-
localFileExisted = existsSync(
|
|
318
|
-
join(__dirname, 'image.linux-s390x-gnu.node')
|
|
319
|
-
)
|
|
290
|
+
return require('./image.linux-riscv64-musl.node')
|
|
291
|
+
} catch (e) {
|
|
292
|
+
loadErrors.push(e)
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
return require('@napi-rs/image-linux-riscv64-musl')
|
|
296
|
+
} catch (e) {
|
|
297
|
+
loadErrors.push(e)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
} else {
|
|
320
301
|
try {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
302
|
+
return require('./image.linux-riscv64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return require('@napi-rs/image-linux-riscv64-gnu')
|
|
308
|
+
} catch (e) {
|
|
309
|
+
loadErrors.push(e)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
} else if (process.arch === 'ppc64') {
|
|
314
|
+
try {
|
|
315
|
+
return require('./image.linux-ppc64-gnu.node')
|
|
316
|
+
} catch (e) {
|
|
317
|
+
loadErrors.push(e)
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
return require('@napi-rs/image-linux-ppc64-gnu')
|
|
321
|
+
} catch (e) {
|
|
322
|
+
loadErrors.push(e)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
} else if (process.arch === 's390x') {
|
|
326
|
+
try {
|
|
327
|
+
return require('./image.linux-s390x-gnu.node')
|
|
328
|
+
} catch (e) {
|
|
329
|
+
loadErrors.push(e)
|
|
330
|
+
}
|
|
331
|
+
try {
|
|
332
|
+
return require('@napi-rs/image-linux-s390x-gnu')
|
|
333
|
+
} catch (e) {
|
|
334
|
+
loadErrors.push(e)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
} else {
|
|
338
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
332
339
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
340
|
+
} else {
|
|
341
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
342
|
+
}
|
|
336
343
|
}
|
|
337
344
|
|
|
345
|
+
nativeBinding = requireNative()
|
|
346
|
+
|
|
338
347
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
339
348
|
try {
|
|
340
349
|
nativeBinding = require('./image.wasi.cjs')
|
|
341
350
|
} catch (err) {
|
|
342
351
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
343
|
-
|
|
352
|
+
loadErrors.push(err)
|
|
344
353
|
}
|
|
345
354
|
}
|
|
346
355
|
if (!nativeBinding) {
|
|
@@ -348,19 +357,25 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
348
357
|
nativeBinding = require('@napi-rs/image-wasm32-wasi')
|
|
349
358
|
} catch (err) {
|
|
350
359
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
351
|
-
|
|
360
|
+
loadErrors.push(err)
|
|
352
361
|
}
|
|
353
362
|
}
|
|
354
363
|
}
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
if (!nativeBinding) {
|
|
358
|
-
if (
|
|
359
|
-
throw
|
|
367
|
+
if (loadErrors.length > 0) {
|
|
368
|
+
throw new Error(
|
|
369
|
+
`Cannot find native binding. ` +
|
|
370
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
371
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
372
|
+
{ cause: loadErrors }
|
|
373
|
+
)
|
|
360
374
|
}
|
|
361
375
|
throw new Error(`Failed to load native binding`)
|
|
362
376
|
}
|
|
363
377
|
|
|
378
|
+
module.exports = nativeBinding
|
|
364
379
|
module.exports.Transformer = nativeBinding.Transformer
|
|
365
380
|
module.exports.ChromaSubsampling = nativeBinding.ChromaSubsampling
|
|
366
381
|
module.exports.CompressionType = nativeBinding.CompressionType
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/image",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
24
|
-
"index.d.ts"
|
|
24
|
+
"index.d.ts",
|
|
25
|
+
"browser.js"
|
|
25
26
|
],
|
|
26
27
|
"publishConfig": {
|
|
27
28
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"targets": [
|
|
33
34
|
"x86_64-apple-darwin",
|
|
34
35
|
"x86_64-pc-windows-msvc",
|
|
36
|
+
"aarch64-pc-windows-msvc",
|
|
35
37
|
"x86_64-unknown-linux-gnu",
|
|
36
38
|
"aarch64-apple-darwin",
|
|
37
39
|
"aarch64-linux-android",
|
|
@@ -60,26 +62,27 @@
|
|
|
60
62
|
"format:prettier": "prettier --config ./package.json -w .",
|
|
61
63
|
"format:rs": "cargo fmt --all",
|
|
62
64
|
"prepublishOnly": "napi prepublish",
|
|
63
|
-
"version": "napi version
|
|
65
|
+
"version": "napi version"
|
|
64
66
|
},
|
|
65
67
|
"repository": "git@github.com:Brooooooklyn/Image.git",
|
|
66
68
|
"devDependencies": {
|
|
67
|
-
"@napi-rs/cli": "^3.0.0-alpha.
|
|
68
|
-
"@napi-rs/wasm-runtime": "^0.2.
|
|
69
|
+
"@napi-rs/cli": "^3.0.0-alpha.91",
|
|
70
|
+
"@napi-rs/wasm-runtime": "^0.2.11"
|
|
69
71
|
},
|
|
70
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "2e8fcc3e92c1c18361b9fa1a63a0e83f7d3e307d",
|
|
71
73
|
"optionalDependencies": {
|
|
72
|
-
"@napi-rs/image-darwin-x64": "1.
|
|
73
|
-
"@napi-rs/image-win32-x64-msvc": "1.
|
|
74
|
-
"@napi-rs/image-
|
|
75
|
-
"@napi-rs/image-
|
|
76
|
-
"@napi-rs/image-
|
|
77
|
-
"@napi-rs/image-
|
|
78
|
-
"@napi-rs/image-linux-arm64-
|
|
79
|
-
"@napi-rs/image-linux-
|
|
80
|
-
"@napi-rs/image-linux-
|
|
81
|
-
"@napi-rs/image-
|
|
82
|
-
"@napi-rs/image-
|
|
83
|
-
"@napi-rs/image-
|
|
74
|
+
"@napi-rs/image-darwin-x64": "1.10.0",
|
|
75
|
+
"@napi-rs/image-win32-x64-msvc": "1.10.0",
|
|
76
|
+
"@napi-rs/image-win32-arm64-msvc": "1.10.0",
|
|
77
|
+
"@napi-rs/image-linux-x64-gnu": "1.10.0",
|
|
78
|
+
"@napi-rs/image-darwin-arm64": "1.10.0",
|
|
79
|
+
"@napi-rs/image-android-arm64": "1.10.0",
|
|
80
|
+
"@napi-rs/image-linux-arm64-gnu": "1.10.0",
|
|
81
|
+
"@napi-rs/image-linux-arm64-musl": "1.10.0",
|
|
82
|
+
"@napi-rs/image-linux-arm-gnueabihf": "1.10.0",
|
|
83
|
+
"@napi-rs/image-linux-x64-musl": "1.10.0",
|
|
84
|
+
"@napi-rs/image-freebsd-x64": "1.10.0",
|
|
85
|
+
"@napi-rs/image-win32-ia32-msvc": "1.10.0",
|
|
86
|
+
"@napi-rs/image-wasm32-wasi": "1.10.0"
|
|
84
87
|
}
|
|
85
88
|
}
|