@ohos-ports/sharp 0.34.5-beta.11 → 0.34.5-beta.12

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 (2) hide show
  1. package/lib/sharp.js +30 -5
  2. package/package.json +7 -3
package/lib/sharp.js CHANGED
@@ -21,14 +21,22 @@ try {
21
21
  // Create soname symlinks: libXXX.so.Y.Z.W → libXXX.so.Y
22
22
  // The .node binary NEEDED entries request sonames (e.g. libvips-cpp.so.42)
23
23
  // but the libvips package only ships full-version files (e.g. libvips-cpp.so.42.20.3)
24
+ // HarmonyOS fix: some libs carry 2-component sonames (e.g. libbz2.so.1.0,
25
+ // per embedded SONAME) — create a symlink for every soname prefix variant
26
+ // so both 1- and 2-component NEEDED requests resolve.
24
27
  try {
25
28
  for (const file of fs.readdirSync(libvipsLibPath)) {
26
- const m = file.match(/^(.+\.so\.\d+)\.\d+\.\d+$/);
29
+ const m = file.match(/^(.+\.so)\.(\d[\w.]*)$/);
27
30
  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 (_) {}
31
+ const base = m[1];
32
+ const parts = m[2].split('.');
33
+ for (let i = 1; i < parts.length; i++) {
34
+ const soname = `${base}.${parts.slice(0, i).join('.')}`;
35
+ const sonamePath = path.join(libvipsLibPath, soname);
36
+ if (!fs.existsSync(sonamePath)) {
37
+ try { fs.symlinkSync(file, sonamePath); } catch (_) {
38
+ try { fs.copyFileSync(path.join(libvipsLibPath, file), sonamePath); } catch (_) {}
39
+ }
32
40
  }
33
41
  }
34
42
  }
@@ -38,6 +46,23 @@ try {
38
46
  if (!currentLdPath.includes(libvipsLibPath)) {
39
47
  process.env.LD_LIBRARY_PATH = `${libvipsLibPath}:${currentLdPath}`;
40
48
  }
49
+ // HarmonyOS RPATH fix: the prebuilt .node carries RPATH
50
+ // $ORIGIN/../../sharp-libvips-openharmony-arm64/lib (the @img/ namespace
51
+ // layout), but the libvips package is installed as
52
+ // @ohos-ports/img-sharp-libvips-<platform>. JS-side LD_LIBRARY_PATH is
53
+ // invisible to the dynamic loader, so create a compatibility symlink at
54
+ // node_modules/@ohos-ports/sharp-libvips-<platform> -> img-sharp-libvips-<platform>
55
+ // so dlopen resolves libvips-cpp.so.42 via the original RPATH.
56
+ try {
57
+ const scopedDir = path.resolve(libvipsLibPath, '..', '..');
58
+ const linkPath = path.join(scopedDir, `sharp-libvips-${runtimePlatform}`);
59
+ const linkTarget = `img-sharp-libvips-${runtimePlatform}`;
60
+ if (!fs.existsSync(linkPath)) {
61
+ try { fs.symlinkSync(linkTarget, linkPath, 'dir'); } catch (_) {
62
+ try { fs.mkdirSync(linkPath, { recursive: true }); } catch (_) {}
63
+ }
64
+ }
65
+ } catch (_) {}
41
66
  }
42
67
  } catch (_e) { /* libvips not available as separate package, skip */ }
43
68
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ohos-ports/sharp",
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.11",
3
+ "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images [ohos-ports: openharmony-arm64 native (libvips 8.18.3) + soname-variant/RPATH symlink self-healing]",
4
+ "version": "0.34.5-beta.12",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -118,7 +118,8 @@
118
118
  ],
119
119
  "repository": {
120
120
  "type": "git",
121
- "url": "git://github.com/lovell/sharp.git"
121
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
122
+ "directory": "ports/sharp/0.34.5"
122
123
  },
123
124
  "keywords": [
124
125
  "jpeg",
@@ -199,5 +200,8 @@
199
200
  },
200
201
  "funding": {
201
202
  "url": "https://opencollective.com/libvips"
203
+ },
204
+ "bugs": {
205
+ "url": "https://github.com/ohos-ports/ohos-ports/issues"
202
206
  }
203
207
  }