ezshare-cli 1.0.1 → 1.0.2
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/dist/utils/compression.js +11 -2
- package/package.json +1 -1
|
@@ -16,7 +16,14 @@
|
|
|
16
16
|
import { Transform } from 'node:stream';
|
|
17
17
|
import { extname } from 'node:path';
|
|
18
18
|
import { execSync } from 'node:child_process';
|
|
19
|
-
import
|
|
19
|
+
// Dynamic import to handle CommonJS module from ES module context
|
|
20
|
+
let zstdModule = null;
|
|
21
|
+
async function getZstdModule() {
|
|
22
|
+
if (!zstdModule) {
|
|
23
|
+
zstdModule = await import('simple-zstd');
|
|
24
|
+
}
|
|
25
|
+
return zstdModule;
|
|
26
|
+
}
|
|
20
27
|
// Protocol flags
|
|
21
28
|
const FLAG_RAW = 0x00;
|
|
22
29
|
const FLAG_COMPRESSED = 0x01;
|
|
@@ -150,6 +157,7 @@ export async function createCompressStream(shouldCompress = true) {
|
|
|
150
157
|
' Windows: choco install zstd');
|
|
151
158
|
}
|
|
152
159
|
// Get zstd compression stream
|
|
160
|
+
const { compress } = await getZstdModule();
|
|
153
161
|
const zstdStream = await compress(COMPRESSION_LEVEL);
|
|
154
162
|
// Track state
|
|
155
163
|
let flagSent = false;
|
|
@@ -257,7 +265,8 @@ export async function createDecompressStream() {
|
|
|
257
265
|
return callback(new Error('zstd is not installed but data is compressed'));
|
|
258
266
|
}
|
|
259
267
|
// Synchronously set up - decompress() returns Promise but we handle async carefully
|
|
260
|
-
|
|
268
|
+
getZstdModule()
|
|
269
|
+
.then(({ decompress }) => decompress())
|
|
261
270
|
.then((stream) => {
|
|
262
271
|
if (destroyed) {
|
|
263
272
|
stream.destroy();
|