sharp 0.33.0-alpha.4 → 0.33.0-alpha.6

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/install/check.js CHANGED
@@ -3,18 +3,27 @@
3
3
 
4
4
  'use strict';
5
5
 
6
- const { useGlobalLibvips, globalLibvipsVersion, log, gypRebuild } = require('../lib/libvips');
6
+ const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
7
7
 
8
8
  const buildFromSource = (msg) => {
9
9
  log(msg);
10
10
  log('Attempting to build from source via node-gyp');
11
11
  try {
12
- require('node-gyp');
12
+ require('node-addon-api');
13
+ log('Found node-addon-api');
13
14
  } catch (err) {
14
- log('You might need to install node-gyp');
15
+ log('Please add node-addon-api to your dependencies');
16
+ return;
17
+ }
18
+ try {
19
+ const gyp = require('node-gyp');
20
+ log(`Found node-gyp version ${gyp().version}`);
21
+ } catch (err) {
22
+ log('Please add node-gyp to your dependencies');
23
+ return;
15
24
  }
16
25
  log('See https://sharp.pixelplumbing.com/install#building-from-source');
17
- const status = gypRebuild();
26
+ const status = spawnRebuild();
18
27
  if (status !== 0) {
19
28
  process.exit(status);
20
29
  }
package/lib/libvips.js CHANGED
@@ -80,8 +80,8 @@ const isRosetta = () => {
80
80
  };
81
81
 
82
82
  /* istanbul ignore next */
83
- const gypRebuild = () =>
84
- spawnSync('node-gyp rebuild', {
83
+ const spawnRebuild = () =>
84
+ spawnSync('node-gyp rebuild --directory=src', {
85
85
  ...spawnSyncOptions,
86
86
  stdio: 'inherit'
87
87
  }).status;
@@ -146,7 +146,7 @@ module.exports = {
146
146
  buildSharpLibvipsLibDir,
147
147
  runtimePlatformArch,
148
148
  log,
149
- gypRebuild,
149
+ spawnRebuild,
150
150
  globalLibvipsVersion,
151
151
  pkgConfigPath,
152
152
  useGlobalLibvips
package/lib/sharp.js CHANGED
@@ -9,11 +9,12 @@ 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));
12
13
 
13
14
  /* istanbul ignore next */
14
15
  try {
15
16
  // Check for local build
16
- module.exports = require(`../build/Release/sharp-${runtimePlatform}.node`);
17
+ module.exports = require(`../src/build/Release/sharp-${runtimePlatform}.node`);
17
18
  } catch (errLocal) {
18
19
  try {
19
20
  // Check for runtime package
@@ -29,11 +30,15 @@ try {
29
30
  help.push('Possible solutions:');
30
31
  // Common error messages
31
32
  if (prebuiltPlatforms.includes(runtimePlatform)) {
32
- help.push(`- Add an explicit dependency for the runtime platform: "npm install --force @sharpen/sharp-${runtimePlatform}"`);
33
+ help.push('- Add explicit dependencies for the runtime platform:');
34
+ help.push(` npm install --force @sharpen/sharp-${runtimePlatform}`);
35
+ if (!isWindows) {
36
+ help.push(` npm install --force @sharpen/sharp-libvips-${runtimePlatform}`);
37
+ }
33
38
  } else {
34
39
  help.push(`- The ${runtimePlatform} platform requires manual installation of libvips >= ${minimumLibvipsVersion}`);
35
40
  }
36
- if (runtimePlatform.startsWith('linux') && /symbol not found/i.test(errPackage)) {
41
+ if (isLinux && /symbol not found/i.test(errPackage)) {
37
42
  try {
38
43
  const { engines } = require(`@sharpen/sharp-libvips-${runtimePlatform}/package`);
39
44
  const libcFound = `${familySync()} ${versionSync()}`;
@@ -41,16 +46,17 @@ try {
41
46
  help.push(`- Update your OS: found ${libcFound}, requires ${libcRequires}`);
42
47
  } catch (errEngines) {}
43
48
  }
44
- if (runtimePlatform.startsWith('darwin') && /Incompatible library version/.test(errLocal.message)) {
45
- help.push('- Update Homebrew: "brew update && brew upgrade vips"');
49
+ if (isMacOs && /Incompatible library version/.test(errLocal.message)) {
50
+ help.push('- Update Homebrew:');
51
+ help.push(' brew update && brew upgrade vips');
46
52
  }
47
53
  if (errPackage.code === 'ERR_DLOPEN_DISABLED') {
48
54
  help.push('- Run Node.js without using the --no-addons flag');
49
55
  }
50
56
  // Link to installation docs
51
- if (runtimePlatform.startsWith('linux') && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
57
+ if (isLinux && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
52
58
  help.push('- Using worker threads on Linux? See https://sharp.pixelplumbing.com/install#worker-threads');
53
- } else if (runtimePlatform.startsWith('win32') && /The specified procedure could not be found/.test(errPackage.message)) {
59
+ } else if (isWindows && /The specified procedure could not be found/.test(errPackage.message)) {
54
60
  help.push('- Using the canvas package on Windows? See https://sharp.pixelplumbing.com/install#canvas-and-windows');
55
61
  } else {
56
62
  help.push('- Consult the installation documentation: https://sharp.pixelplumbing.com/install');
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",
4
+ "version": "0.33.0-alpha.6",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -90,7 +90,7 @@
90
90
  ],
91
91
  "scripts": {
92
92
  "install": "node install/check",
93
- "clean": "rm -rf build/ .nyc_output/ coverage/ test/fixtures/output.*",
93
+ "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
94
94
  "test": "npm run test-lint && npm run test-unit && npm run test-licensing && npm run test-types",
95
95
  "test-lint": "semistandard && cpplint",
96
96
  "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha",
@@ -107,10 +107,9 @@
107
107
  "main": "lib/index.js",
108
108
  "types": "lib/index.d.ts",
109
109
  "files": [
110
- "binding.gyp",
111
110
  "install",
112
111
  "lib",
113
- "src"
112
+ "src/*.{cc,h,gyp}"
114
113
  ],
115
114
  "repository": {
116
115
  "type": "git",
@@ -137,12 +136,11 @@
137
136
  "dependencies": {
138
137
  "color": "^4.2.3",
139
138
  "detect-libc": "^2.0.2",
140
- "node-addon-api": "^7.0.0",
141
139
  "semver": "^7.5.4"
142
140
  },
143
141
  "optionalDependencies": {
144
- "@sharpen/sharp-darwin-arm64": "0.0.1-alpha.4",
145
- "@sharpen/sharp-darwin-x64": "0.0.1-alpha.4",
142
+ "@sharpen/sharp-darwin-arm64": "0.0.1-alpha.6",
143
+ "@sharpen/sharp-darwin-x64": "0.0.1-alpha.6",
146
144
  "@sharpen/sharp-libvips-darwin-arm64": "0.0.1-alpha.2",
147
145
  "@sharpen/sharp-libvips-darwin-x64": "0.0.1-alpha.2",
148
146
  "@sharpen/sharp-libvips-linux-arm": "0.0.1-alpha.2",
@@ -150,13 +148,13 @@
150
148
  "@sharpen/sharp-libvips-linux-x64": "0.0.1-alpha.2",
151
149
  "@sharpen/sharp-libvips-linuxmusl-arm64": "0.0.1-alpha.2",
152
150
  "@sharpen/sharp-libvips-linuxmusl-x64": "0.0.1-alpha.2",
153
- "@sharpen/sharp-linux-arm": "0.0.1-alpha.4",
154
- "@sharpen/sharp-linux-arm64": "0.0.1-alpha.4",
155
- "@sharpen/sharp-linux-x64": "0.0.1-alpha.4",
156
- "@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.4",
157
- "@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.4",
158
- "@sharpen/sharp-win32-ia32": "0.0.1-alpha.4",
159
- "@sharpen/sharp-win32-x64": "0.0.1-alpha.4"
151
+ "@sharpen/sharp-linux-arm": "0.0.1-alpha.6",
152
+ "@sharpen/sharp-linux-arm64": "0.0.1-alpha.6",
153
+ "@sharpen/sharp-linux-x64": "0.0.1-alpha.6",
154
+ "@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.6",
155
+ "@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.6",
156
+ "@sharpen/sharp-win32-ia32": "0.0.1-alpha.6",
157
+ "@sharpen/sharp-win32-x64": "0.0.1-alpha.6"
160
158
  },
161
159
  "devDependencies": {
162
160
  "@sharpen/sharp-libvips-dev": "0.0.1-alpha.2",
@@ -171,6 +169,7 @@
171
169
  "jsdoc-to-markdown": "^8.0.0",
172
170
  "license-checker": "^25.0.1",
173
171
  "mocha": "^10.2.0",
172
+ "node-addon-api": "^7.0.0",
174
173
  "nyc": "^15.1.0",
175
174
  "prebuild": "^12.1.0",
176
175
  "semistandard": "^17.0.0",
@@ -3,11 +3,11 @@
3
3
 
4
4
  {
5
5
  'variables': {
6
- 'vips_version': '<!(node -p "require(\'./lib/libvips\').minimumLibvipsVersion")',
7
- 'platform_and_arch': '<!(node -p "require(\'./lib/libvips\').buildPlatformArch()")',
8
- 'sharp_libvips_include_dir': '<!(node -p "require(\'./lib/libvips\').buildSharpLibvipsIncludeDir()")',
9
- 'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'./lib/libvips\').buildSharpLibvipsCPlusPlusDir()")',
10
- 'sharp_libvips_lib_dir': '<!(node -p "require(\'./lib/libvips\').buildSharpLibvipsLibDir()")'
6
+ 'vips_version': '<!(node -p "require(\'../lib/libvips\').minimumLibvipsVersion")',
7
+ 'platform_and_arch': '<!(node -p "require(\'../lib/libvips\').buildPlatformArch()")',
8
+ 'sharp_libvips_include_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsIncludeDir()")',
9
+ 'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsCPlusPlusDir()")',
10
+ 'sharp_libvips_lib_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsLibDir()")'
11
11
  },
12
12
  'targets': [{
13
13
  'target_name': 'libvips-cpp',
@@ -86,8 +86,8 @@
86
86
  'variables': {
87
87
  'conditions': [
88
88
  ['OS != "win"', {
89
- 'pkg_config_path': '<!(node -p "require(\'./lib/libvips\').pkgConfigPath()")',
90
- 'use_global_libvips': '<!(node -p "Boolean(require(\'./lib/libvips\').useGlobalLibvips()).toString()")'
89
+ 'pkg_config_path': '<!(node -p "require(\'../lib/libvips\').pkgConfigPath()")',
90
+ 'use_global_libvips': '<!(node -p "Boolean(require(\'../lib/libvips\').useGlobalLibvips()).toString()")'
91
91
  }, {
92
92
  'pkg_config_path': '',
93
93
  'use_global_libvips': ''
@@ -95,13 +95,13 @@
95
95
  ]
96
96
  },
97
97
  'sources': [
98
- 'src/common.cc',
99
- 'src/metadata.cc',
100
- 'src/stats.cc',
101
- 'src/operations.cc',
102
- 'src/pipeline.cc',
103
- 'src/utilities.cc',
104
- 'src/sharp.cc'
98
+ 'common.cc',
99
+ 'metadata.cc',
100
+ 'stats.cc',
101
+ 'operations.cc',
102
+ 'pipeline.cc',
103
+ 'utilities.cc',
104
+ 'sharp.cc'
105
105
  ],
106
106
  'include_dirs': [
107
107
  '<!(node -p "require(\'node-addon-api\').include_dir")',
@@ -154,7 +154,6 @@
154
154
  'OTHER_LDFLAGS': [
155
155
  # Ensure runtime linking is relative to sharp.node
156
156
  '-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
157
- '-Wl,-rpath,\'@loader_path/../../node_modules/@sharpen/sharp-libvips-<(platform_and_arch)/lib\'',
158
157
  '-Wl,-rpath,\'@loader_path/../../../node_modules/@sharpen/sharp-libvips-<(platform_and_arch)/lib\''
159
158
  ]
160
159
  }
@@ -175,7 +174,6 @@
175
174
  '-Wl,-s',
176
175
  '-Wl,--disable-new-dtags',
177
176
  '-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
178
- '-Wl,-rpath=\'$$ORIGIN/../../node_modules/@sharpen/sharp-libvips-<(platform_and_arch)/lib\'',
179
177
  '-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@sharpen/sharp-libvips-<(platform_and_arch)/lib\''
180
178
  ]
181
179
  }