sharp 0.33.0-alpha.10 → 0.33.0-alpha.11
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/lib/libvips.js +25 -7
- package/lib/sharp.js +67 -53
- package/lib/utility.js +10 -4
- package/package.json +23 -13
- package/src/binding.gyp +23 -3
- package/src/utilities.cc +5 -0
package/lib/libvips.js
CHANGED
|
@@ -16,7 +16,7 @@ const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).versio
|
|
|
16
16
|
|
|
17
17
|
const prebuiltPlatforms = [
|
|
18
18
|
'darwin-arm64', 'darwin-x64',
|
|
19
|
-
'linux-arm', 'linux-arm64', 'linux-x64',
|
|
19
|
+
'linux-arm', 'linux-arm64', 'linux-s390x', 'linux-x64',
|
|
20
20
|
'linuxmusl-arm64', 'linuxmusl-x64',
|
|
21
21
|
'win32-ia32', 'win32-x64'
|
|
22
22
|
];
|
|
@@ -41,15 +41,23 @@ const runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process
|
|
|
41
41
|
|
|
42
42
|
/* istanbul ignore next */
|
|
43
43
|
const buildPlatformArch = () => {
|
|
44
|
+
if (isEmscripten()) {
|
|
45
|
+
return 'wasm32';
|
|
46
|
+
}
|
|
44
47
|
/* eslint camelcase: ["error", { allow: ["^npm_config_"] }] */
|
|
45
48
|
const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;
|
|
46
|
-
|
|
49
|
+
const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc();
|
|
50
|
+
return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
const buildSharpLibvipsIncludeDir = () => {
|
|
50
54
|
try {
|
|
51
|
-
return require(
|
|
52
|
-
} catch {
|
|
55
|
+
return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`);
|
|
56
|
+
} catch {
|
|
57
|
+
try {
|
|
58
|
+
return require('@img/sharp-libvips-dev/include');
|
|
59
|
+
} catch {}
|
|
60
|
+
}
|
|
53
61
|
/* istanbul ignore next */
|
|
54
62
|
return '';
|
|
55
63
|
};
|
|
@@ -64,12 +72,22 @@ const buildSharpLibvipsCPlusPlusDir = () => {
|
|
|
64
72
|
|
|
65
73
|
const buildSharpLibvipsLibDir = () => {
|
|
66
74
|
try {
|
|
67
|
-
return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);
|
|
68
|
-
} catch {
|
|
75
|
+
return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`);
|
|
76
|
+
} catch {
|
|
77
|
+
try {
|
|
78
|
+
return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);
|
|
79
|
+
} catch {}
|
|
80
|
+
}
|
|
69
81
|
/* istanbul ignore next */
|
|
70
82
|
return '';
|
|
71
83
|
};
|
|
72
84
|
|
|
85
|
+
/* istanbul ignore next */
|
|
86
|
+
const isEmscripten = () => {
|
|
87
|
+
const { CC } = process.env;
|
|
88
|
+
return Boolean(CC && CC.endsWith('/emcc'));
|
|
89
|
+
};
|
|
90
|
+
|
|
73
91
|
const isRosetta = () => {
|
|
74
92
|
/* istanbul ignore next */
|
|
75
93
|
if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
@@ -81,7 +99,7 @@ const isRosetta = () => {
|
|
|
81
99
|
|
|
82
100
|
/* istanbul ignore next */
|
|
83
101
|
const spawnRebuild = () =>
|
|
84
|
-
spawnSync(
|
|
102
|
+
spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {
|
|
85
103
|
...spawnSyncOptions,
|
|
86
104
|
stdio: 'inherit'
|
|
87
105
|
}).status;
|
package/lib/sharp.js
CHANGED
|
@@ -9,61 +9,75 @@ const { familySync, versionSync } = require('detect-libc');
|
|
|
9
9
|
|
|
10
10
|
const { runtimePlatformArch, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
|
11
11
|
const runtimePlatform = runtimePlatformArch();
|
|
12
|
-
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const paths = [
|
|
14
|
+
`../src/build/Release/sharp-${runtimePlatform}.node`,
|
|
15
|
+
'../src/build/Release/sharp-wasm32.node',
|
|
16
|
+
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
17
|
+
'@img/sharp-wasm32/sharp.node'
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const errors = [];
|
|
21
|
+
for (const path of paths) {
|
|
19
22
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
help.push(`- The ${runtimePlatform} platform requires manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
37
|
-
}
|
|
38
|
-
if (isLinux && /symbol not found/i.test(errPackage)) {
|
|
39
|
-
try {
|
|
40
|
-
const { engines } = require(`@img/sharp-libvips-${runtimePlatform}/package`);
|
|
41
|
-
const libcFound = `${familySync()} ${versionSync()}`;
|
|
42
|
-
const libcRequires = `${engines.musl ? 'musl' : 'glibc'} ${engines.musl || engines.glibc}`;
|
|
43
|
-
help.push('- Update your OS:');
|
|
44
|
-
help.push(` Found ${libcFound}`);
|
|
45
|
-
help.push(` Requires ${libcRequires}`);
|
|
46
|
-
} catch (errEngines) {}
|
|
47
|
-
}
|
|
48
|
-
if (isMacOs && /Incompatible library version/.test(errLocal.message)) {
|
|
49
|
-
help.push('- Update Homebrew:');
|
|
50
|
-
help.push(' brew update && brew upgrade vips');
|
|
51
|
-
}
|
|
52
|
-
if (errPackage.code === 'ERR_DLOPEN_DISABLED') {
|
|
53
|
-
help.push('- Run Node.js without using the --no-addons flag');
|
|
54
|
-
}
|
|
55
|
-
if (process.versions.pnp) {
|
|
56
|
-
help.push('- Use a supported yarn linker, either pnpm or node-modules:');
|
|
57
|
-
help.push(' yarn config set nodeLinker node-modules');
|
|
58
|
-
}
|
|
59
|
-
// Link to installation docs
|
|
60
|
-
if (isLinux && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
|
|
61
|
-
help.push('- Using worker threads on Linux? See https://sharp.pixelplumbing.com/install#worker-threads');
|
|
62
|
-
} else if (isWindows && /The specified procedure could not be found/.test(errPackage.message)) {
|
|
63
|
-
help.push('- Using the canvas package on Windows? See https://sharp.pixelplumbing.com/install#canvas-and-windows');
|
|
64
|
-
} else {
|
|
65
|
-
help.push('- Consult the installation documentation: https://sharp.pixelplumbing.com/install');
|
|
23
|
+
module.exports = require(path);
|
|
24
|
+
break;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
errors.push(err);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* istanbul ignore next */
|
|
32
|
+
if (!module.exports) {
|
|
33
|
+
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
|
|
34
|
+
|
|
35
|
+
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
36
|
+
errors.forEach(err => {
|
|
37
|
+
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
38
|
+
help.push(`${err.code}: ${err.message}`);
|
|
66
39
|
}
|
|
67
|
-
|
|
40
|
+
});
|
|
41
|
+
const messages = errors.map(err => err.message).join(' ');
|
|
42
|
+
help.push('Possible solutions:');
|
|
43
|
+
// Common error messages
|
|
44
|
+
if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
45
|
+
const [os, cpu] = runtimePlatform.split('-');
|
|
46
|
+
help.push('- Add platform-specific dependencies:');
|
|
47
|
+
help.push(` npm install --os=${os} --cpu=${cpu} sharp`);
|
|
48
|
+
help.push(' or');
|
|
49
|
+
help.push(` npm install --force @img/sharp-${runtimePlatform}`);
|
|
50
|
+
} else {
|
|
51
|
+
help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`);
|
|
52
|
+
help.push('- Add experimental WebAssembly-based dependencies:');
|
|
53
|
+
help.push(' npm install --cpu=wasm32 sharp');
|
|
54
|
+
}
|
|
55
|
+
if (isLinux && /symbol not found/i.test(messages)) {
|
|
56
|
+
try {
|
|
57
|
+
const { engines } = require(`@img/sharp-libvips-${runtimePlatform}/package`);
|
|
58
|
+
const libcFound = `${familySync()} ${versionSync()}`;
|
|
59
|
+
const libcRequires = `${engines.musl ? 'musl' : 'glibc'} ${engines.musl || engines.glibc}`;
|
|
60
|
+
help.push('- Update your OS:');
|
|
61
|
+
help.push(` Found ${libcFound}`);
|
|
62
|
+
help.push(` Requires ${libcRequires}`);
|
|
63
|
+
} catch (errEngines) {}
|
|
64
|
+
}
|
|
65
|
+
if (isMacOs && /Incompatible library version/.test(messages)) {
|
|
66
|
+
help.push('- Update Homebrew:');
|
|
67
|
+
help.push(' brew update && brew upgrade vips');
|
|
68
|
+
}
|
|
69
|
+
if (errors.some(err => err.code === 'ERR_DLOPEN_DISABLED')) {
|
|
70
|
+
help.push('- Run Node.js without using the --no-addons flag');
|
|
71
|
+
}
|
|
72
|
+
if (process.versions.pnp) {
|
|
73
|
+
help.push('- Use a supported yarn linker, either pnpm or node-modules:');
|
|
74
|
+
help.push(' yarn config set nodeLinker node-modules');
|
|
75
|
+
}
|
|
76
|
+
// Link to installation docs
|
|
77
|
+
if (isWindows && /The specified procedure could not be found/.test(messages)) {
|
|
78
|
+
help.push('- Using the canvas package on Windows? See https://sharp.pixelplumbing.com/install#canvas-and-windows');
|
|
79
|
+
} else {
|
|
80
|
+
help.push('- Consult the installation documentation: https://sharp.pixelplumbing.com/install');
|
|
68
81
|
}
|
|
82
|
+
throw new Error(help.join('\n'));
|
|
69
83
|
}
|
package/lib/utility.js
CHANGED
|
@@ -59,11 +59,17 @@ let versions = {
|
|
|
59
59
|
};
|
|
60
60
|
/* istanbul ignore next */
|
|
61
61
|
if (!libvipsVersion.isGlobal) {
|
|
62
|
-
|
|
63
|
-
versions = require(`@img/sharp-${runtimePlatform}/versions`);
|
|
64
|
-
} catch (_) {
|
|
62
|
+
if (!libvipsVersion.isWasm) {
|
|
65
63
|
try {
|
|
66
|
-
versions = require(`@img/sharp
|
|
64
|
+
versions = require(`@img/sharp-${runtimePlatform}/versions`);
|
|
65
|
+
} catch (_) {
|
|
66
|
+
try {
|
|
67
|
+
versions = require(`@img/sharp-libvips-${runtimePlatform}/versions`);
|
|
68
|
+
} catch (_) {}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
try {
|
|
72
|
+
versions = require('@img/sharp-wasm32/versions');
|
|
67
73
|
} catch (_) {}
|
|
68
74
|
}
|
|
69
75
|
}
|
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.33.0-alpha.
|
|
4
|
+
"version": "0.33.0-alpha.11",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
"Brahim Ait elhaj <brahima@gmail.com>",
|
|
88
88
|
"Mart Jansink <m.jansink@gmail.com>",
|
|
89
89
|
"Lachlan Newman <lachnewman007@gmail.com>",
|
|
90
|
-
"Dennis Beatty <dennis@dcbeatty.com>"
|
|
90
|
+
"Dennis Beatty <dennis@dcbeatty.com>",
|
|
91
|
+
"Ingvar Stepanyan <me@rreverser.com>"
|
|
91
92
|
],
|
|
92
93
|
"scripts": {
|
|
93
94
|
"install": "node install/check",
|
|
@@ -140,8 +141,8 @@
|
|
|
140
141
|
"semver": "^7.5.4"
|
|
141
142
|
},
|
|
142
143
|
"optionalDependencies": {
|
|
143
|
-
"@img/sharp-darwin-arm64": "0.33.0-alpha.
|
|
144
|
-
"@img/sharp-darwin-x64": "0.33.0-alpha.
|
|
144
|
+
"@img/sharp-darwin-arm64": "0.33.0-alpha.11",
|
|
145
|
+
"@img/sharp-darwin-x64": "0.33.0-alpha.11",
|
|
145
146
|
"@img/sharp-libvips-darwin-arm64": "0.0.3",
|
|
146
147
|
"@img/sharp-libvips-darwin-x64": "0.0.3",
|
|
147
148
|
"@img/sharp-libvips-linux-arm": "0.0.3",
|
|
@@ -150,22 +151,26 @@
|
|
|
150
151
|
"@img/sharp-libvips-linux-x64": "0.0.3",
|
|
151
152
|
"@img/sharp-libvips-linuxmusl-arm64": "0.0.3",
|
|
152
153
|
"@img/sharp-libvips-linuxmusl-x64": "0.0.3",
|
|
153
|
-
"@img/sharp-linux-arm": "0.33.0-alpha.
|
|
154
|
-
"@img/sharp-linux-arm64": "0.33.0-alpha.
|
|
155
|
-
"@img/sharp-linux-s390x": "0.33.0-alpha.
|
|
156
|
-
"@img/sharp-linux-x64": "0.33.0-alpha.
|
|
157
|
-
"@img/sharp-linuxmusl-arm64": "0.33.0-alpha.
|
|
158
|
-
"@img/sharp-linuxmusl-x64": "0.33.0-alpha.
|
|
159
|
-
"@img/sharp-
|
|
160
|
-
"@img/sharp-win32-
|
|
154
|
+
"@img/sharp-linux-arm": "0.33.0-alpha.11",
|
|
155
|
+
"@img/sharp-linux-arm64": "0.33.0-alpha.11",
|
|
156
|
+
"@img/sharp-linux-s390x": "0.33.0-alpha.11",
|
|
157
|
+
"@img/sharp-linux-x64": "0.33.0-alpha.11",
|
|
158
|
+
"@img/sharp-linuxmusl-arm64": "0.33.0-alpha.11",
|
|
159
|
+
"@img/sharp-linuxmusl-x64": "0.33.0-alpha.11",
|
|
160
|
+
"@img/sharp-wasm32": "0.33.0-alpha.11",
|
|
161
|
+
"@img/sharp-win32-ia32": "0.33.0-alpha.11",
|
|
162
|
+
"@img/sharp-win32-x64": "0.33.0-alpha.11"
|
|
161
163
|
},
|
|
162
164
|
"devDependencies": {
|
|
165
|
+
"@emnapi/runtime": "^0.43.1",
|
|
163
166
|
"@img/sharp-libvips-dev": "0.0.3",
|
|
167
|
+
"@img/sharp-libvips-dev-wasm32": "0.0.3",
|
|
164
168
|
"@img/sharp-libvips-win32-ia32": "0.0.3",
|
|
165
169
|
"@img/sharp-libvips-win32-x64": "0.0.3",
|
|
166
170
|
"@types/node": "*",
|
|
167
|
-
"async": "^3.2.
|
|
171
|
+
"async": "^3.2.5",
|
|
168
172
|
"cc": "^3.0.1",
|
|
173
|
+
"emnapi": "^0.43.1",
|
|
169
174
|
"exif-reader": "^2.0.0",
|
|
170
175
|
"extract-zip": "^2.0.1",
|
|
171
176
|
"icc": "^3.0.0",
|
|
@@ -203,6 +208,11 @@
|
|
|
203
208
|
"build/include"
|
|
204
209
|
]
|
|
205
210
|
},
|
|
211
|
+
"nyc": {
|
|
212
|
+
"include": [
|
|
213
|
+
"lib"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
206
216
|
"tsd": {
|
|
207
217
|
"directory": "test/types/"
|
|
208
218
|
}
|
package/src/binding.gyp
CHANGED
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
'OTHER_LDFLAGS': [
|
|
156
156
|
# Ensure runtime linking is relative to sharp.node
|
|
157
157
|
'-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
158
|
-
'-Wl,-rpath,\'@loader_path
|
|
158
|
+
'-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
159
159
|
'-Wl,-rpath,\'@loader_path/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
160
160
|
'-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
161
161
|
]
|
|
@@ -170,15 +170,35 @@
|
|
|
170
170
|
'-l:libvips-cpp.so.42'
|
|
171
171
|
],
|
|
172
172
|
'ldflags': [
|
|
173
|
-
# Ensure runtime linking is relative to sharp.node
|
|
174
173
|
'-Wl,-s',
|
|
175
174
|
'-Wl,--disable-new-dtags',
|
|
175
|
+
'-Wl,-z,nodelete',
|
|
176
176
|
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
177
|
-
'-Wl,-rpath=\'$$ORIGIN
|
|
177
|
+
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
178
178
|
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
179
179
|
'-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
180
180
|
]
|
|
181
181
|
}
|
|
182
|
+
}],
|
|
183
|
+
['OS == "emscripten"', {
|
|
184
|
+
'product_extension': 'node.js',
|
|
185
|
+
'link_settings': {
|
|
186
|
+
'ldflags': [
|
|
187
|
+
'-fexceptions',
|
|
188
|
+
'--pre-js=<!(node -p "require.resolve(\'./emscripten/pre.js\')")',
|
|
189
|
+
'-Oz',
|
|
190
|
+
'-sALLOW_MEMORY_GROWTH',
|
|
191
|
+
'-sENVIRONMENT=node',
|
|
192
|
+
'-sEXPORTED_FUNCTIONS=["_vips_shutdown", "_uv_library_shutdown"]',
|
|
193
|
+
'-sNODERAWFS',
|
|
194
|
+
'-sTEXTDECODER=0',
|
|
195
|
+
'-sWASM_ASYNC_COMPILATION=0',
|
|
196
|
+
'-sWASM_BIGINT'
|
|
197
|
+
],
|
|
198
|
+
'libraries': [
|
|
199
|
+
'<!@(PKG_CONFIG_PATH="<!(node -p "require(\'@img/sharp-libvips-dev-wasm32/lib\')")/pkgconfig" pkg-config --static --libs vips-cpp)'
|
|
200
|
+
],
|
|
201
|
+
}
|
|
182
202
|
}]
|
|
183
203
|
]
|
|
184
204
|
}]
|
package/src/utilities.cc
CHANGED
|
@@ -102,6 +102,11 @@ Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
|
|
|
102
102
|
version.Set("isGlobal", Napi::Boolean::New(env, true));
|
|
103
103
|
#else
|
|
104
104
|
version.Set("isGlobal", Napi::Boolean::New(env, false));
|
|
105
|
+
#endif
|
|
106
|
+
#ifdef __EMSCRIPTEN__
|
|
107
|
+
version.Set("isWasm", Napi::Boolean::New(env, true));
|
|
108
|
+
#else
|
|
109
|
+
version.Set("isWasm", Napi::Boolean::New(env, false));
|
|
105
110
|
#endif
|
|
106
111
|
return version;
|
|
107
112
|
}
|