@seydx/node-av-linux-x64 3.1.1 → 3.1.3

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.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script for platform-specific packages.
5
+ * Extracts the compressed .node binary from the ZIP file.
6
+ */
7
+
8
+ import { createWriteStream, existsSync, unlinkSync } from 'node:fs';
9
+ import { dirname, join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+ import { Open } from 'unzipper';
12
+
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+ const zipPath = join(__dirname, 'node-av.node.zip');
15
+ const targetPath = join(__dirname, 'node-av.node');
16
+
17
+ async function extractBinary() {
18
+ // Skip if already extracted
19
+ if (existsSync(targetPath)) {
20
+ console.log('Binary already extracted, skipping...');
21
+ return;
22
+ }
23
+
24
+ // Skip if ZIP doesn't exist (dev mode or manual installation)
25
+ if (!existsSync(zipPath)) {
26
+ console.warn('Warning: node-av.node.zip not found, skipping extraction');
27
+ return;
28
+ }
29
+
30
+ try {
31
+ console.log('Extracting node-av binary from ZIP...');
32
+
33
+ const directory = await Open.file(zipPath);
34
+
35
+ // Find the .node file in the ZIP
36
+ const nodeFile = directory.files.find((file) => file.path.endsWith('.node'));
37
+
38
+ if (!nodeFile) {
39
+ throw new Error('No .node file found in ZIP archive');
40
+ }
41
+
42
+ // Extract to target path
43
+ await new Promise((resolve, reject) => {
44
+ nodeFile.stream().pipe(createWriteStream(targetPath)).on('finish', resolve).on('error', reject);
45
+ });
46
+
47
+ console.log('Binary extracted successfully');
48
+
49
+ // Clean up ZIP file after extraction to save space
50
+ unlinkSync(zipPath);
51
+ console.log('Cleaned up ZIP file');
52
+ } catch (error) {
53
+ console.error('Failed to extract binary:', error.message);
54
+ // Don't throw - allow installation to continue even if extraction fails
55
+ // This prevents blocking npm install in edge cases
56
+ process.exit(0);
57
+ }
58
+ }
59
+
60
+ extractBinary().catch((error) => {
61
+ console.error('Unexpected error during binary extraction:', error);
62
+ process.exit(0);
63
+ });
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seydx/node-av-linux-x64",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "node-av (linux-x64 binary)",
5
5
  "author": "seydx (https://github.com/seydx/av)",
6
6
  "license": "MIT",
@@ -8,10 +8,19 @@
8
8
  "type": "git",
9
9
  "url": "git://github.com/seydx/av.git"
10
10
  },
11
+ "type": "module",
11
12
  "files": [
12
- "node-av.node"
13
+ "node-av.node.zip",
14
+ "node-av.node",
15
+ "install.js"
13
16
  ],
14
17
  "main": "node-av.node",
18
+ "scripts": {
19
+ "postinstall": "node install.js"
20
+ },
21
+ "dependencies": {
22
+ "unzipper": "^0.12.3"
23
+ },
15
24
  "engines": {
16
25
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
17
26
  },
package/node-av.node DELETED
Binary file