@ohos-ports/sharp 0.34.5-beta.1 → 0.34.5-beta.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/install/check.js +59 -0
- package/lib/colour.js +1 -1
- package/lib/sharp.js +33 -0
- package/lib/utility.js +17 -5
- package/package.json +3 -3
package/install/check.js
CHANGED
|
@@ -12,3 +12,62 @@ try {
|
|
|
12
12
|
const summary = err.message.split(/\n/).slice(0, 1);
|
|
13
13
|
console.log(`sharp: skipping install check: ${summary}`);
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
// Create libvips shared library symlinks on OpenHarmony
|
|
17
|
+
// The native binary's RPATH references "sharp-libvips-openharmony-arm64" but
|
|
18
|
+
// the actual package name is "img-sharp-libvips-openharmony-arm64" — we need
|
|
19
|
+
// both package-level symlinks and .so version symlinks for RPATH to resolve.
|
|
20
|
+
try {
|
|
21
|
+
const { runtimePlatformArch } = require('../lib/libvips');
|
|
22
|
+
const platform = runtimePlatformArch();
|
|
23
|
+
if (platform.startsWith('openharmony')) {
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
let libDir;
|
|
27
|
+
try {
|
|
28
|
+
libDir = require('@ohos-ports/img-sharp-libvips-openharmony-arm64/lib');
|
|
29
|
+
} catch {
|
|
30
|
+
try {
|
|
31
|
+
libDir = require('@img/sharp-libvips-openharmony-arm64/lib');
|
|
32
|
+
} catch {}
|
|
33
|
+
}
|
|
34
|
+
if (libDir && fs.existsSync(libDir)) {
|
|
35
|
+
// 1. Create .so version symlinks (libvips-cpp.so.42 → libvips-cpp.so.42.20.3)
|
|
36
|
+
const soSymlinks = [
|
|
37
|
+
['libvips-cpp.so.42', 'libvips-cpp.so.42.20.3'],
|
|
38
|
+
['libvips.so.42', 'libvips.so.42.20.3'],
|
|
39
|
+
['libpcre2-8.so', 'libpcre2-8.so.0']
|
|
40
|
+
];
|
|
41
|
+
for (const [link, target] of soSymlinks) {
|
|
42
|
+
const linkPath = path.join(libDir, link);
|
|
43
|
+
const targetPath = path.join(libDir, target);
|
|
44
|
+
if (fs.existsSync(linkPath)) continue;
|
|
45
|
+
if (!fs.existsSync(targetPath)) continue;
|
|
46
|
+
try {
|
|
47
|
+
fs.symlinkSync(target, linkPath);
|
|
48
|
+
console.log(`sharp: created symlink ${link} -> ${target}`);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// symlink creation may fail due to permissions; non-fatal
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 2. Create package-level symlinks so RPATH can resolve
|
|
55
|
+
// RPATH: $ORIGIN/../../sharp-libvips-openharmony-arm64/lib
|
|
56
|
+
// Actual package: img-sharp-libvips-openharmony-arm64
|
|
57
|
+
// Need: @ohos-ports/sharp-libvips-openharmony-arm64 → img-sharp-libvips-openharmony-arm64
|
|
58
|
+
const pkgDir = path.dirname(libDir);
|
|
59
|
+
const scopeDir = path.dirname(pkgDir);
|
|
60
|
+
const pkgBaseName = path.basename(pkgDir);
|
|
61
|
+
const rpathLinkName = pkgBaseName.replace(/^img-/, '');
|
|
62
|
+
const rpathLinkPath = path.join(scopeDir, rpathLinkName);
|
|
63
|
+
if (!fs.existsSync(rpathLinkPath)) {
|
|
64
|
+
try {
|
|
65
|
+
fs.symlinkSync(pkgBaseName, rpathLinkPath);
|
|
66
|
+
console.log(`sharp: created package symlink ${rpathLinkName} -> ${pkgBaseName}`);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
// non-fatal
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch {}
|
package/lib/colour.js
CHANGED
package/lib/sharp.js
CHANGED
|
@@ -10,10 +10,43 @@ const { familySync, versionSync } = require('detect-libc');
|
|
|
10
10
|
const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
|
11
11
|
const runtimePlatform = runtimePlatformArch();
|
|
12
12
|
|
|
13
|
+
// OpenHarmony: set LD_LIBRARY_PATH for libvips before loading native binary
|
|
14
|
+
// The .node binary's RPATH references @img/ namespace but the actual .so
|
|
15
|
+
// files are installed under @ohos-ports/img-sharp-libvips-{platform}/lib
|
|
16
|
+
try {
|
|
17
|
+
const libvipsLibPath = require(`@ohos-ports/img-sharp-libvips-${runtimePlatform}/lib`);
|
|
18
|
+
if (libvipsLibPath) {
|
|
19
|
+
const path = require('node:path');
|
|
20
|
+
const fs = require('node:fs');
|
|
21
|
+
// Create soname symlinks: libXXX.so.Y.Z.W → libXXX.so.Y
|
|
22
|
+
// The .node binary NEEDED entries request sonames (e.g. libvips-cpp.so.42)
|
|
23
|
+
// but the libvips package only ships full-version files (e.g. libvips-cpp.so.42.20.3)
|
|
24
|
+
try {
|
|
25
|
+
for (const file of fs.readdirSync(libvipsLibPath)) {
|
|
26
|
+
const m = file.match(/^(.+\.so\.\d+)\.\d+\.\d+$/);
|
|
27
|
+
if (m) {
|
|
28
|
+
const soname = path.join(libvipsLibPath, m[1]);
|
|
29
|
+
if (!fs.existsSync(soname)) {
|
|
30
|
+
try { fs.symlinkSync(file, soname); } catch (_) {
|
|
31
|
+
try { fs.copyFileSync(path.join(libvipsLibPath, file), soname); } catch (_) {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (_) {}
|
|
37
|
+
const currentLdPath = process.env.LD_LIBRARY_PATH || '';
|
|
38
|
+
if (!currentLdPath.includes(libvipsLibPath)) {
|
|
39
|
+
process.env.LD_LIBRARY_PATH = `${libvipsLibPath}:${currentLdPath}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (_e) { /* libvips not available as separate package, skip */ }
|
|
43
|
+
|
|
13
44
|
const paths = [
|
|
14
45
|
`../src/build/Release/sharp-${runtimePlatform}.node`,
|
|
15
46
|
'../src/build/Release/sharp-wasm32.node',
|
|
47
|
+
`@ohos-ports/img-sharp-${runtimePlatform}/sharp.node`,
|
|
16
48
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
49
|
+
'@ohos-ports/img-sharp-wasm32/sharp.node',
|
|
17
50
|
'@img/sharp-wasm32/sharp.node'
|
|
18
51
|
];
|
|
19
52
|
|
package/lib/utility.js
CHANGED
|
@@ -61,16 +61,28 @@ let versions = {
|
|
|
61
61
|
if (!libvipsVersion.isGlobal) {
|
|
62
62
|
if (!libvipsVersion.isWasm) {
|
|
63
63
|
try {
|
|
64
|
-
versions = require(`@img
|
|
64
|
+
versions = require(`@ohos-ports/img-sharp-${runtimePlatform}/versions`);
|
|
65
65
|
} catch (_) {
|
|
66
66
|
try {
|
|
67
|
-
versions = require(`@img/sharp
|
|
68
|
-
} catch (_) {
|
|
67
|
+
versions = require(`@img/sharp-${runtimePlatform}/versions`);
|
|
68
|
+
} catch (_) {
|
|
69
|
+
try {
|
|
70
|
+
versions = require(`@ohos-ports/img-sharp-libvips-${runtimePlatform}/versions`);
|
|
71
|
+
} catch (_) {
|
|
72
|
+
try {
|
|
73
|
+
versions = require(`@img/sharp-libvips-${runtimePlatform}/versions`);
|
|
74
|
+
} catch (_) {}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
} else {
|
|
71
79
|
try {
|
|
72
|
-
versions = require('@img
|
|
73
|
-
} catch (_) {
|
|
80
|
+
versions = require('@ohos-ports/img-sharp-wasm32/versions');
|
|
81
|
+
} catch (_) {
|
|
82
|
+
try {
|
|
83
|
+
versions = require('@img/sharp-wasm32/versions');
|
|
84
|
+
} catch (_) {}
|
|
85
|
+
}
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
88
|
versions.sharp = require('../package.json').version;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/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.34.5-beta.
|
|
4
|
+
"version": "0.34.5-beta.11",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"vips"
|
|
140
140
|
],
|
|
141
141
|
"dependencies": {
|
|
142
|
-
"@img
|
|
142
|
+
"@ohos-ports/img-colour": "^1.1.0-beta.0",
|
|
143
143
|
"detect-libc": "^2.1.2",
|
|
144
144
|
"semver": "^7.7.3"
|
|
145
145
|
},
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
"@img/sharp-win32-arm64": "0.34.5",
|
|
169
169
|
"@img/sharp-win32-ia32": "0.34.5",
|
|
170
170
|
"@img/sharp-win32-x64": "0.34.5",
|
|
171
|
-
"@ohos-ports/img-sharp-openharmony-arm64": "0.34.5-beta.
|
|
171
|
+
"@ohos-ports/img-sharp-openharmony-arm64": "0.34.5-beta.4"
|
|
172
172
|
},
|
|
173
173
|
"devDependencies": {
|
|
174
174
|
"@ohos-ports/biomejs-biome": "^2.3.4-beta.0",
|