qrush-compressor 0.0.1-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Qrush Compressor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # đŸ¦€ Qrush Compressor
2
+
3
+ Fast file and image compression library powered by WebAssembly (Rust).
4
+ Qrush Compressor is an advanced library for file and image compression, developed in Rust and compiled to WebAssembly. Rust enables superior performance and resource optimization, achieving fast and efficient compression directly in the browser or any modern JavaScript environment. Thanks to Rust’s memory safety and concurrency, data processing is robust and scalable—ideal for web applications that require maximum speed and low resource usage.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install qrush-compressor
10
+ ```
11
+
12
+ ## Quick Start
13
+
14
+ ### Initialize WASM
15
+
16
+ ```typescript
17
+ import init from 'qrush-compressor';
18
+ await init(); // Required before using any function
19
+ ```
20
+
21
+ ### Compress Data
22
+
23
+ ```typescript
24
+ import { compress, WasmCompressionMethod, WasmCompressionLevel } from 'qrush-compressor';
25
+
26
+ const data = new Uint8Array([...]);
27
+ const result = compress(data, WasmCompressionMethod.Gzip, WasmCompressionLevel.Best);
28
+
29
+ console.log(`Original: ${result.original_size()} bytes`);
30
+ console.log(`Compressed: ${result.compressed_size()} bytes`);
31
+ console.log(`Ratio: ${(result.compression_ratio() * 100).toFixed(2)}%`);
32
+ ```
33
+
34
+ ### Compress Image
35
+
36
+ ```typescript
37
+ import { compress_image_jpeg } from 'qrush-compressor';
38
+
39
+ const imageData = new Uint8Array([...]); // Your image file
40
+ const result = compress_image_jpeg(imageData, 85); // Quality 1-100
41
+ const jpegBytes = result.data();
42
+ ```
43
+
44
+ ### Resize & Compress Image
45
+
46
+ ```typescript
47
+ import { compress_and_resize_image } from 'qrush-compressor';
48
+
49
+ const result = compress_and_resize_image(
50
+ imageData,
51
+ 1920, // max width (null for auto)
52
+ null, // max height (null for auto)
53
+ 85 // quality
54
+ );
55
+ ```
56
+
57
+ ## Framework Examples
58
+
59
+ ### React
60
+
61
+ ```tsx
62
+ import { useEffect, useState } from 'react';
63
+ import init, { compress_image_jpeg } from 'qrush-compressor';
64
+
65
+ function App() {
66
+ const [ready, setReady] = useState(false);
67
+
68
+ useEffect(() => {
69
+ init().then(() => setReady(true));
70
+ }, []);
71
+
72
+ const handleFile = async (e: React.ChangeEvent<HTMLInputElement>) => {
73
+ if (!ready || !e.target.files) return;
74
+ const file = e.target.files[0];
75
+ const data = new Uint8Array(await file.arrayBuffer());
76
+ const result = compress_image_jpeg(data, 85);
77
+ console.log(`Saved ${((1 - result.compression_ratio()) * 100).toFixed(2)}%`);
78
+ };
79
+
80
+ return <input type="file" onChange={handleFile} accept="image/*" />;
81
+ }
82
+ ```
83
+
84
+ ### Angular
85
+
86
+ ```typescript
87
+ import { Component, OnInit } from '@angular/core';
88
+ import init, { compress, WasmCompressionMethod } from 'qrush-compressor';
89
+
90
+ @Component({
91
+ selector: 'app-root',
92
+ template: '<input type="file" (change)="onFile($event)">'
93
+ })
94
+ export class AppComponent implements OnInit {
95
+ async ngOnInit() {
96
+ await init();
97
+ }
98
+
99
+ async onFile(event: any) {
100
+ const file = event.target.files[0];
101
+ const data = new Uint8Array(await file.arrayBuffer());
102
+ const result = compress(data, WasmCompressionMethod.Brotli);
103
+ console.log(`Compressed to ${result.compressed_size()} bytes`);
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Vue 3
109
+
110
+ ```vue
111
+ <script setup lang="ts">
112
+ import { ref, onMounted } from 'vue';
113
+ import init, { compress_image_jpeg } from 'qrush-compressor';
114
+
115
+ onMounted(async () => {
116
+ await init();
117
+ });
118
+
119
+ async function handleFile(e: Event) {
120
+ const file = (e.target as HTMLInputElement).files?.[0];
121
+ if (!file) return;
122
+ const data = new Uint8Array(await file.arrayBuffer());
123
+ const result = compress_image_jpeg(data, 80);
124
+ console.log(`Compressed: ${result.compressed_size()} bytes`);
125
+ }
126
+ </script>
127
+
128
+ <template>
129
+ <input type="file" @change="handleFile" accept="image/*">
130
+ </template>
131
+ ```
132
+
133
+ ## API Reference
134
+
135
+ ### Compression Methods
136
+
137
+ - `WasmCompressionMethod.Gzip` - Standard GZIP
138
+ - `WasmCompressionMethod.Zlib` - ZLIB format
139
+ - `WasmCompressionMethod.Brotli` - Best compression
140
+
141
+ ### Compression Levels
142
+
143
+ - `WasmCompressionLevel.Fast` - Fastest
144
+ - `WasmCompressionLevel.Default` - Balanced
145
+ - `WasmCompressionLevel.Best` - Maximum compression
146
+
147
+ ### Functions
148
+
149
+ #### `compress(data, method, level)`
150
+ Compress binary data.
151
+
152
+ #### `decompress(data, method)`
153
+ Decompress previously compressed data.
154
+
155
+ #### `compress_image_jpeg(data, quality)`
156
+ Compress image to JPEG format.
157
+
158
+ #### `compress_and_resize_image(data, maxWidth, maxHeight, quality)`
159
+ Resize and compress image in one step.
160
+
161
+ ## Performance
162
+
163
+ | Method | Compression | Speed |
164
+ |--------|-------------|-------|
165
+ | Brotli | Best (~20%) | Slow |
166
+ | ZLIB | Good (~25%) | Fast |
167
+ | GZIP | Good (~26%) | Fast |
168
+
169
+ ## Browser Support
170
+
171
+ All modern browsers (Chrome, Firefox, Safari, Edge).
172
+
173
+ ## License
174
+
175
+ MIT
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "qrush-compressor",
3
+ "version": "0.0.1-alpha.1",
4
+ "description": "Fast file and image compression library using WebAssembly. Perfect for Angular, React, Vue, and other web frameworks.",
5
+ "main": "qrush_compressor.js",
6
+ "types": "qrush_compressor.d.ts",
7
+ "files": [
8
+ "qrush_compressor.js",
9
+ "qrush_compressor.d.ts",
10
+ "qrush_compressor_bg.wasm",
11
+ "qrush_compressor_bg.wasm.d.ts",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "keywords": [
16
+ "compression",
17
+ "image",
18
+ "wasm",
19
+ "webassembly",
20
+ "rust",
21
+ "gzip",
22
+ "brotli",
23
+ "jpeg",
24
+ "optimizer",
25
+ "angular",
26
+ "react",
27
+ "vue"
28
+ ],
29
+ "author": "Enrique Ruiz <enrique.ruiz@nunsys.com>",
30
+ "license": "MIT"
31
+ }
@@ -0,0 +1,46 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export enum WasmCompressionLevel {
5
+ Fast = 0,
6
+ Default = 1,
7
+ Best = 2,
8
+ }
9
+
10
+ export enum WasmCompressionMethod {
11
+ Gzip = 0,
12
+ Zlib = 1,
13
+ Brotli = 2,
14
+ }
15
+
16
+ export class WasmCompressionResult {
17
+ private constructor();
18
+ free(): void;
19
+ [Symbol.dispose](): void;
20
+ readonly compressed_size: number;
21
+ readonly compression_ratio: number;
22
+ readonly data: Uint8Array;
23
+ readonly original_size: number;
24
+ }
25
+
26
+ /**
27
+ * Compress data using the specified method
28
+ */
29
+ export function compress(data: Uint8Array, method: WasmCompressionMethod, level: WasmCompressionLevel): WasmCompressionResult;
30
+
31
+ /**
32
+ * Compress and resize an image
33
+ */
34
+ export function compress_and_resize_image(data: Uint8Array, width: number | null | undefined, height: number | null | undefined, quality: number): WasmCompressionResult;
35
+
36
+ /**
37
+ * Compress an image with quality setting (JPEG)
38
+ */
39
+ export function compress_image_jpeg(data: Uint8Array, quality: number): WasmCompressionResult;
40
+
41
+ /**
42
+ * Decompress data using the specified method
43
+ */
44
+ export function decompress(data: Uint8Array, method: WasmCompressionMethod): Uint8Array;
45
+
46
+ export function init(): void;
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./qrush_compressor.d.ts" */
2
+
3
+ import * as wasm from "./qrush_compressor_bg.wasm";
4
+ import { __wbg_set_wasm } from "./qrush_compressor_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ WasmCompressionLevel, WasmCompressionMethod, WasmCompressionResult, compress, compress_and_resize_image, compress_image_jpeg, decompress, init
9
+ } from "./qrush_compressor_bg.js";
Binary file
@@ -0,0 +1,74 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_wasmcompressionresult_free: (a: number, b: number) => void;
5
+ export const compress: (a: number, b: number, c: number, d: number) => [number, number, number];
6
+ export const compress_and_resize_image: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
7
+ export const compress_image_jpeg: (a: number, b: number, c: number) => [number, number, number];
8
+ export const decompress: (a: number, b: number, c: number) => [number, number, number, number];
9
+ export const init: () => void;
10
+ export const wasmcompressionresult_compressed_size: (a: number) => number;
11
+ export const wasmcompressionresult_compression_ratio: (a: number) => number;
12
+ export const wasmcompressionresult_data: (a: number) => [number, number];
13
+ export const wasmcompressionresult_original_size: (a: number) => number;
14
+ export const BroccoliConcatFinish: (a: number, b: number, c: number) => number;
15
+ export const BroccoliConcatFinished: (a: number, b: number, c: number) => number;
16
+ export const BroccoliConcatStream: (a: number, b: number, c: number, d: number, e: number) => number;
17
+ export const BroccoliConcatStreaming: (a: number, b: number, c: number, d: number, e: number) => number;
18
+ export const BroccoliCreateInstance: (a: number) => void;
19
+ export const BroccoliCreateInstanceWithWindowSize: (a: number, b: number) => void;
20
+ export const BroccoliDestroyInstance: (a: number) => void;
21
+ export const BroccoliNewBrotliFile: (a: number) => void;
22
+ export const BrotliEncoderCompress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
23
+ export const BrotliEncoderCompressMulti: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
24
+ export const BrotliEncoderCompressStream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
25
+ export const BrotliEncoderCompressStreaming: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
26
+ export const BrotliEncoderCompressWorkPool: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => number;
27
+ export const BrotliEncoderCreateInstance: (a: number, b: number, c: number) => number;
28
+ export const BrotliEncoderCreateWorkPool: (a: number, b: number, c: number, d: number) => number;
29
+ export const BrotliEncoderDestroyInstance: (a: number) => void;
30
+ export const BrotliEncoderDestroyWorkPool: (a: number) => void;
31
+ export const BrotliEncoderFreeU8: (a: number, b: number, c: number) => void;
32
+ export const BrotliEncoderFreeUsize: (a: number, b: number, c: number) => void;
33
+ export const BrotliEncoderHasMoreOutput: (a: number) => number;
34
+ export const BrotliEncoderIsFinished: (a: number) => number;
35
+ export const BrotliEncoderMallocU8: (a: number, b: number) => number;
36
+ export const BrotliEncoderMallocUsize: (a: number, b: number) => number;
37
+ export const BrotliEncoderMaxCompressedSize: (a: number) => number;
38
+ export const BrotliEncoderMaxCompressedSizeMulti: (a: number, b: number) => number;
39
+ export const BrotliEncoderSetCustomDictionary: (a: number, b: number, c: number) => void;
40
+ export const BrotliEncoderSetParameter: (a: number, b: number, c: number) => number;
41
+ export const BrotliEncoderTakeOutput: (a: number, b: number) => number;
42
+ export const BrotliEncoderVersion: () => number;
43
+ export const CBrotliDecoderErrorString: (a: number) => number;
44
+ export const BrotliDecoderErrorString: (a: number) => number;
45
+ export const CBrotliDecoderGetErrorCode: (a: number) => number;
46
+ export const BrotliDecoderGetErrorCode: (a: number) => number;
47
+ export const CBrotliDecoderGetErrorString: (a: number) => number;
48
+ export const BrotliDecoderGetErrorString: (a: number) => number;
49
+ export const CBrotliDecoderHasMoreOutput: (a: number) => number;
50
+ export const BrotliDecoderHasMoreOutput: (a: number) => number;
51
+ export const CBrotliDecoderIsFinished: (a: number) => number;
52
+ export const BrotliDecoderIsFinished: (a: number) => number;
53
+ export const CBrotliDecoderIsUsed: (a: number) => number;
54
+ export const BrotliDecoderIsUsed: (a: number) => number;
55
+ export const CBrotliDecoderTakeOutput: (a: number, b: number) => number;
56
+ export const BrotliDecoderTakeOutput: (a: number, b: number) => number;
57
+ export const BrotliDecoderFreeU8: (a: number, b: number, c: number) => void;
58
+ export const BrotliDecoderVersion: () => number;
59
+ export const BrotliDecoderMallocU8: (a: number, b: number) => number;
60
+ export const BrotliDecoderFreeUsize: (a: number, b: number, c: number) => void;
61
+ export const BrotliDecoderDecompress: (a: number, b: number, c: number, d: number) => number;
62
+ export const BrotliDecoderMallocUsize: (a: number, b: number) => number;
63
+ export const BrotliDecoderSetParameter: (a: number, b: number, c: number) => void;
64
+ export const BrotliDecoderCreateInstance: (a: number, b: number, c: number) => number;
65
+ export const BrotliDecoderDestroyInstance: (a: number) => void;
66
+ export const BrotliDecoderDecompressStream: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
67
+ 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
+ export const BrotliDecoderDecompressStreaming: (a: number, b: number, c: number, d: number, e: number) => number;
69
+ export const BrotliDecoderDecompressWithReturnInfo: (a: number, b: number, c: number, d: number, e: number) => void;
70
+ export const __wbindgen_externrefs: WebAssembly.Table;
71
+ export const __wbindgen_malloc: (a: number, b: number) => number;
72
+ export const __externref_table_dealloc: (a: number) => void;
73
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
74
+ export const __wbindgen_start: () => void;