qrush-compressor 0.0.1-alpha.1 → 0.0.1-alpha.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/README.md +36 -2
- package/package.json +1 -1
- package/qrush_compressor.d.ts +22 -0
- package/qrush_compressor.js +1 -1
- package/qrush_compressor_bg.wasm +0 -0
- package/qrush_compressor_bg.wasm.d.ts +6 -1
package/README.md
CHANGED
|
@@ -54,6 +54,34 @@ const result = compress_and_resize_image(
|
|
|
54
54
|
);
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Create ZIP Archive
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { create_zip_archive } from 'qrush-compressor';
|
|
61
|
+
|
|
62
|
+
const files = [
|
|
63
|
+
{ name: 'document.txt', data: new Uint8Array([...]) },
|
|
64
|
+
{ name: 'image.jpg', data: new Uint8Array([...]) },
|
|
65
|
+
{ name: 'folder/file.pdf', data: new Uint8Array([...]) }
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const zipData = create_zip_archive(files);
|
|
69
|
+
// Download or send zipData
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Extract ZIP Archive
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { extract_zip_archive } from 'qrush-compressor';
|
|
76
|
+
|
|
77
|
+
const zipData = new Uint8Array([...]); // Your ZIP file
|
|
78
|
+
const files = extract_zip_archive(zipData);
|
|
79
|
+
|
|
80
|
+
files.forEach(file => {
|
|
81
|
+
console.log(`File: ${file.name}, Size: ${file.data.length} bytes`);
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
57
85
|
## Framework Examples
|
|
58
86
|
|
|
59
87
|
### React
|
|
@@ -158,6 +186,12 @@ Compress image to JPEG format.
|
|
|
158
186
|
#### `compress_and_resize_image(data, maxWidth, maxHeight, quality)`
|
|
159
187
|
Resize and compress image in one step.
|
|
160
188
|
|
|
189
|
+
#### `create_zip_archive(files)`
|
|
190
|
+
Create a ZIP archive from multiple files. Takes an array of objects with `{name: string, data: Uint8Array}`.
|
|
191
|
+
|
|
192
|
+
#### `extract_zip_archive(zipData)`
|
|
193
|
+
Extract files from a ZIP archive. Returns an array of objects with `{name: string, data: Uint8Array}`.
|
|
194
|
+
|
|
161
195
|
## Performance
|
|
162
196
|
|
|
163
197
|
| Method | Compression | Speed |
|
|
@@ -170,6 +204,6 @@ Resize and compress image in one step.
|
|
|
170
204
|
|
|
171
205
|
All modern browsers (Chrome, Firefox, Safari, Edge).
|
|
172
206
|
|
|
173
|
-
##
|
|
207
|
+
## Author
|
|
174
208
|
|
|
175
|
-
|
|
209
|
+
Enrique Ruiz | Technical Lead
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrush-compressor",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.3",
|
|
4
4
|
"description": "Fast file and image compression library using WebAssembly. Perfect for Angular, React, Vue, and other web frameworks.",
|
|
5
5
|
"main": "qrush_compressor.js",
|
|
6
6
|
"types": "qrush_compressor.d.ts",
|
package/qrush_compressor.d.ts
CHANGED
|
@@ -38,9 +38,31 @@ export function compress_and_resize_image(data: Uint8Array, width: number | null
|
|
|
38
38
|
*/
|
|
39
39
|
export function compress_image_jpeg(data: Uint8Array, quality: number): WasmCompressionResult;
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Creates a ZIP file from multiple files
|
|
43
|
+
*
|
|
44
|
+
* # Arguments
|
|
45
|
+
* * `files` - JavaScript array of objects with {name: string, data: Uint8Array}
|
|
46
|
+
*
|
|
47
|
+
* # Returns
|
|
48
|
+
* A Uint8Array containing the ZIP file data
|
|
49
|
+
*/
|
|
50
|
+
export function create_zip_archive(files: Array<any>): Uint8Array;
|
|
51
|
+
|
|
41
52
|
/**
|
|
42
53
|
* Decompress data using the specified method
|
|
43
54
|
*/
|
|
44
55
|
export function decompress(data: Uint8Array, method: WasmCompressionMethod): Uint8Array;
|
|
45
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Extracts files from a ZIP archive
|
|
59
|
+
*
|
|
60
|
+
* # Arguments
|
|
61
|
+
* * `zip_data` - The ZIP file data as Uint8Array
|
|
62
|
+
*
|
|
63
|
+
* # Returns
|
|
64
|
+
* JavaScript array of objects with {name: string, data: Uint8Array}
|
|
65
|
+
*/
|
|
66
|
+
export function extract_zip_archive(zip_data: Uint8Array): Array<any>;
|
|
67
|
+
|
|
46
68
|
export function init(): void;
|
package/qrush_compressor.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./qrush_compressor_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
WasmCompressionLevel, WasmCompressionMethod, WasmCompressionResult, compress, compress_and_resize_image, compress_image_jpeg, decompress, init
|
|
8
|
+
WasmCompressionLevel, WasmCompressionMethod, WasmCompressionResult, compress, compress_and_resize_image, compress_image_jpeg, create_zip_archive, decompress, extract_zip_archive, init
|
|
9
9
|
} from "./qrush_compressor_bg.js";
|
package/qrush_compressor_bg.wasm
CHANGED
|
Binary file
|
|
@@ -5,7 +5,9 @@ export const __wbg_wasmcompressionresult_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const compress: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
6
|
export const compress_and_resize_image: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
7
7
|
export const compress_image_jpeg: (a: number, b: number, c: number) => [number, number, number];
|
|
8
|
+
export const create_zip_archive: (a: any) => [number, number, number, number];
|
|
8
9
|
export const decompress: (a: number, b: number, c: number) => [number, number, number, number];
|
|
10
|
+
export const extract_zip_archive: (a: number, b: number) => [number, number, number];
|
|
9
11
|
export const init: () => void;
|
|
10
12
|
export const wasmcompressionresult_compressed_size: (a: number) => number;
|
|
11
13
|
export const wasmcompressionresult_compression_ratio: (a: number) => number;
|
|
@@ -67,8 +69,11 @@ export const BrotliDecoderDecompressStream: (a: number, b: number, c: number, d:
|
|
|
67
69
|
export const BrotliDecoderDecompressPrealloc: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
68
70
|
export const BrotliDecoderDecompressStreaming: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
69
71
|
export const BrotliDecoderDecompressWithReturnInfo: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
70
|
-
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
71
72
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
73
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
74
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
75
|
+
export const __externref_table_alloc: () => number;
|
|
76
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
72
77
|
export const __externref_table_dealloc: (a: number) => void;
|
|
73
78
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
74
79
|
export const __wbindgen_start: () => void;
|