qpdf-compress 0.6.3 → 0.6.4
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/package.json +2 -2
- package/scripts/download-qpdf.mjs +29 -6
- package/src/qpdf_addon.cc +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qpdf-compress",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Native PDF compression for Node.js, powered by QPDF",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"eslint-plugin-prettier": "^5.5.5",
|
|
97
97
|
"husky": "^9.1.7",
|
|
98
98
|
"lint-staged": "^16.4.0",
|
|
99
|
-
"node-gyp": "^
|
|
99
|
+
"node-gyp": "^13.0.0",
|
|
100
100
|
"prettier": "^3.8.1",
|
|
101
101
|
"typescript": "^5.9.3",
|
|
102
102
|
"typescript-eslint": "^8.57.2",
|
|
@@ -132,6 +132,19 @@ if (process.platform === 'win32') {
|
|
|
132
132
|
`-DVCPKG_TARGET_TRIPLET=${triplet}`,
|
|
133
133
|
);
|
|
134
134
|
|
|
135
|
+
// qpdf locates zlib via pkg-config first, then falls back to find_path/
|
|
136
|
+
// find_library. The GitHub Windows image no longer ships pkg-config and the
|
|
137
|
+
// fallback misses the vcpkg tree, so point qpdf's ZLIB_*_PATH cache vars
|
|
138
|
+
// straight at the vcpkg-installed static zlib (mirrors LIBJPEG_*_PATH).
|
|
139
|
+
const vcpkgInstalled = join(vcpkgRoot, 'installed', triplet);
|
|
140
|
+
const zlibLib = ['zlib.lib', 'zs.lib', 'zlibstatic.lib']
|
|
141
|
+
.map((n) => join(vcpkgInstalled, 'lib', n))
|
|
142
|
+
.find((p) => existsSync(p));
|
|
143
|
+
cmakeArgs.push(`-DZLIB_H_PATH:PATH=${join(vcpkgInstalled, 'include')}`);
|
|
144
|
+
if (zlibLib) {
|
|
145
|
+
cmakeArgs.push(`-DZLIB_LIB_PATH:FILEPATH=${zlibLib}`);
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
// cross-compile for ARM64 when triplet indicates it
|
|
136
149
|
if (triplet.startsWith('arm64')) {
|
|
137
150
|
cmakeArgs.push('-A', 'arm64');
|
|
@@ -200,13 +213,23 @@ if (process.platform === 'win32') {
|
|
|
200
213
|
];
|
|
201
214
|
|
|
202
215
|
const vcpkgLibDir = candidateLibDirs.find((d) => existsSync(d));
|
|
203
|
-
if (vcpkgLibDir) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
if (!vcpkgLibDir) {
|
|
217
|
+
console.error('vcpkg lib dir not found; checked:', candidateLibDirs);
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
// vcpkg's static zlib lib name varies across versions (zlib.lib / zs.lib /
|
|
221
|
+
// zlibstatic.lib); copy whichever exists to the zlib.lib name binding.gyp links.
|
|
222
|
+
const zlibNames = ['zlib.lib', 'zs.lib', 'zlibstatic.lib'];
|
|
223
|
+
const zlibSrc = zlibNames.map((n) => join(vcpkgLibDir, n)).find((p) => existsSync(p));
|
|
224
|
+
if (!zlibSrc) {
|
|
225
|
+
console.error(
|
|
226
|
+
`zlib static lib not found in ${vcpkgLibDir}. Contents:`,
|
|
227
|
+
readdirSync(vcpkgLibDir),
|
|
228
|
+
);
|
|
229
|
+
process.exit(1);
|
|
209
230
|
}
|
|
231
|
+
cpSync(zlibSrc, join(depsDir, 'lib', 'zlib.lib'));
|
|
232
|
+
console.log(`Copied ${zlibSrc} -> deps/qpdf/lib/zlib.lib`);
|
|
210
233
|
}
|
|
211
234
|
|
|
212
235
|
// step 5: clean up source and build dirs
|
package/src/qpdf_addon.cc
CHANGED
|
@@ -306,12 +306,11 @@ static Napi::Value Compress(const Napi::CallbackInfo &info) {
|
|
|
306
306
|
|
|
307
307
|
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
308
308
|
auto *addonData = new AddonData();
|
|
309
|
+
// SetInstanceData installs a finalizer that deletes addonData on env teardown,
|
|
310
|
+
// so the cleanup hook must NOT delete it again (double free); it only flips the
|
|
311
|
+
// alive flag so in-flight workers bail out.
|
|
309
312
|
env.SetInstanceData(addonData);
|
|
310
|
-
|
|
311
|
-
env.AddCleanupHook([addonData]() {
|
|
312
|
-
addonData->envAlive->store(false);
|
|
313
|
-
delete addonData;
|
|
314
|
-
});
|
|
313
|
+
env.AddCleanupHook([addonData]() { addonData->envAlive->store(false); });
|
|
315
314
|
|
|
316
315
|
exports.Set("compress", Napi::Function::New(env, Compress));
|
|
317
316
|
return exports;
|