Skip to content

Commit

Permalink
feature: updated version and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
efraespada committed Nov 8, 2024
1 parent 9878363 commit 658ccb3
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.3.24
## 1.4.0

* Fixed decompression size.
* Added `compressionLevel` parameter.
Expand Down
130 changes: 108 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,140 @@
[![pub package](https://img.shields.io/pub/v/zstandard.svg)](https://pub.dev/packages/zstandard)
[![pub package](https://img.shields.io/pub/v/zstandard.svg)](https://pub.dev/packages/zstandard)
[![pub package](https://img.shields.io/pub/v/zstandard_cli.svg)](https://pub.dev/packages/zstandard_cli)

# Zstandard

Zstandard (zstd) is a fast, high-compression algorithm developed by Meta (formerly Facebook) designed for real-time compression scenarios. It provides a flexible range of compression levels, allowing both high-speed and high-ratio compression, making it ideal for applications with diverse performance needs. Zstandard is commonly used in data storage, transmission, and backup solutions.
Zstandard (zstd) is a fast, high-compression algorithm developed by Meta (formerly Facebook) designed for real-time compression scenarios. It offers a flexible range of compression levels, allowing both high-speed and high-ratio compression, making it ideal for applications with diverse performance needs. Zstandard is widely used in data storage, transmission, and backup solutions.

This is a Flutter plugin that provides a pure implementation of the zstd compression algorithm, developed by Meta. It integrates the zstd library in C through FFI for native platforms, ensuring efficient compression and decompression. For web platforms, it leverages WebAssembly to deliver the same robust compression capabilities. This plugin enables seamless, cross-platform data compression, making it ideal for applications requiring high-speed and efficient data processing.
This repository contains a federated Flutter plugin and a CLI package for `zstandard` compression, enabling both in-app and command-line usage. The two main components are:

| | Android | iOS | [Web](https://flutter.dev/web) | [macOS](https://flutter.dev/desktop) | [Windows](https://flutter.dev/desktop) | [Linux](https://flutter.dev/desktop) | [Fuchsia](https://fuchsia.dev/) |
|:-----------:|:------------------:|:------------------:|:------------------------------:|:------------------------------------:|:--------------------------------------:|:------------------------------------:|:-------------------------------:|
| Status | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: ||
| Native | FFI | FFI | WebAssembly | FFI | FFI | FFI ||
| Precompiled | No | No | Yes (wasm) | No | No | No ||
- **[zstandard](https://pub.dev/packages/zstandard):** A Flutter plugin for cross-platform compression, supporting mobile, desktop, and web platforms. This package integrates the zstd library through FFI for native platforms and WebAssembly for the web, allowing efficient data compression in any Flutter environment.

- **[zstandard_cli](https://pub.dev/packages/zstandard_cli):** A pure Dart package providing CLI capabilities for macOS, Windows, and Linux. It enables command-line compression and decompression for data files and streams.

> The C files to build the compression library come from the original [facebook/zstd](https://github.com/facebook/zstd/tree/dev/lib) repository.
> **Note:** The `zstandard` plugin is designed for use in Flutter applications. For pure Dart applications or CLI usage, refer to the `zstandard_cli` package.
## Usage
---

## Compatibility

| | [Android](https://flutter.dev) | [iOS](https://developer.apple.com/ios/) | [Web](https://flutter.dev/web) | [macOS](https://flutter.dev/desktop) | [Windows](https://flutter.dev/desktop) | [Linux](https://flutter.dev/desktop) | [Fuchsia](https://fuchsia.dev/) |
|:-----------:|:------------------------------:|:--------------------------------------:|:-------------------------------------:|:------------------------------------:|:--------------------------------------:|:------------------------------------:|:-------------------------------:|
| Flutter | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: (wasm) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: ||
| Native | FFI | FFI | WebAssembly | FFI | FFI | FFI ||
| Precompiled | No | No | Yes | No | No | No ||

| | [macOS](https://flutter.dev/desktop) | [Windows](https://flutter.dev/desktop) | [Linux](https://flutter.dev/desktop) |
|:-----------:|:------------------------------------:|:--------------------------------------:|:------------------------------------:|
| CLI | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| arm64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Precompiled | Yes | Yes | Yes |

---

## Basic Usage

### In-App (Flutter)

```dart
void act() async {
import 'package:zstandard/zstandard.dart';
void main() async {
final zstandard = Zstandard();
Uint8List original = Uint8List.fromList([...]);
Uint8List originalData = Uint8List.fromList([...]);
Uint8List? compressed = await zstandard.compress(original);
Uint8List? compressed = await zstandard.compress(originalData);
Uint8List? decompressed = await zstandard.decompress(compressed ?? Uint8List(0));
}
```

With extension functions:
Using extensions:

```dart
void act() async {
Uint8List original = Uint8List.fromList([...]);
import 'package:zstandard/zstandard.dart';
void main() async {
Uint8List originalData = Uint8List.fromList([...]);
Uint8List? compressed = await original.compress();
Uint8List? compressed = await originalData.compress();
Uint8List? decompressed = await compressed.decompress();
}
```

<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_android/images/sample.png"></p>
### Command Line (zstandard_cli)

<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_ios/images/sample.png"></p>
```bash
# Compress a file with a specified compression level
dart run zstandard_cli:compress myfile.txt 3

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_macos/images/sample.png"></p>
# Decompress a file
dart run zstandard_cli:decompress myfile.txt.zstd
```

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_web/images/sample.png"></p>
#### Dart Code Example (CLI)

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_windows/images/sample.png"></p>
```dart
import 'package:zstandard_cli/zstandard_cli.dart';
void main() async {
var cli = ZstandardCLI();
final originalData = Uint8List.fromList([...]);
final compressed = await cli.compress(originalData, compressionLevel: 3);
final decompressed = await cli.decompress(compressed ?? Uint8List(0));
}
```

Using extensions in Dart:

```dart
import 'package:zstandard_cli/zstandard_cli.dart';
void main() async {
final originalData = Uint8List.fromList([...]);
final compressed = await originalData.compress(compressionLevel: 3);
final decompressed = await compressed.decompress();
}
```

---

## Screenshots

### Compression and Decompression Samples

#### macOS

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/macos_compression_sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/macos_decompression_sample.png"></p>

#### Windows

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/windows_compression_sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/windows_decompression_sample.png"></p>

#### Linux

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/linux_compression_sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/linux_decompression_sample.png"></p>

#### Flutter Plugin (Android, iOS, macOS, Web, Windows, Linux)

<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_android/images/sample.png"></p>
<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_ios/images/sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_macos/images/sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_web/images/sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_windows/images/sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_linux/images/sample.png"></p>

---

## License

This project uses code from the original [facebook/zstd](https://github.com/facebook/zstd/tree/dev/lib) repository. Please see the LICENSE file for more information.
11 changes: 7 additions & 4 deletions zstandard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

# Zstandard

Zstandard (zstd) is a fast, high-compression algorithm developed by Meta (formerly Facebook) designed for real-time compression scenarios. It provides a flexible range of compression levels, allowing both high-speed and high-ratio compression, making it ideal for applications with diverse performance needs. Zstandard is commonly used in data storage, transmission, and backup solutions.
Zstandard (zstd) is a fast, high-compression algorithm developed by Meta (formerly Facebook) for real-time applications. It offers a broad range of compression levels, supporting both high-speed and high-compression-ratio requirements, making it ideal for data storage, transmission, and backup solutions.

This is a Flutter plugin that provides a pure implementation of the zstd compression algorithm, developed by Meta. It integrates the zstd library in C through FFI for native platforms, ensuring efficient compression and decompression. For web platforms, it leverages WebAssembly to deliver the same robust compression capabilities. This plugin enables seamless, cross-platform data compression, making it ideal for applications requiring high-speed and efficient data processing.
This Flutter plugin provides a native implementation of the zstd compression algorithm. It integrates the zstd library in C through FFI for native platforms (Android, iOS, Windows, macOS, and Linux), ensuring efficient compression and decompression. On the web, it leverages WebAssembly to deliver the same high-performance compression. This plugin enables seamless, cross-platform data compression, suitable for applications needing fast, efficient data processing.

| | Android | iOS | [Web](https://flutter.dev/web) | [macOS](https://flutter.dev/desktop) | [Windows](https://flutter.dev/desktop) | [Linux](https://flutter.dev/desktop) | [Fuchsia](https://fuchsia.dev/) |
|:-----------:|:------------------:|:------------------:|:------------------------------:|:------------------------------------:|:--------------------------------------:|:------------------------------------:|:-------------------------------:|
| Status | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: ||
| Native | FFI | FFI | WebAssembly | FFI | FFI | FFI ||
| Precompiled | No | No | Yes (wasm) | No | No | No ||

> **Note:** The C files for the compression library are sourced from the official [facebook/zstd](https://github.com/facebook/zstd/tree/dev/lib) repository.
> The C files to build the compression library come from the original [facebook/zstd](https://github.com/facebook/zstd/tree/dev/lib) repository.
> For command-line usage on desktops, refer to the [zstandard_cli](https://pub.dev/packages/zstandard_cli) package.
## Usage
## Basic Usage

```dart
void act() async {
Expand All @@ -41,6 +42,8 @@ void act() async {
}
```

Below are examples of the plugin in action across different platforms.

<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_android/images/sample.png"></p>

<p align="center"><img width="50%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_ios/images/sample.png"></p>
Expand Down
16 changes: 9 additions & 7 deletions zstandard_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

# zstandard_cli

The CLI implementation of [`zstandard`](https://pub.dev/packages/zstandard).
The command-line implementation of [`zstandard`](https://pub.dev/packages/zstandard).

Zstandard (zstd) is a fast, high-compression algorithm developed by Meta (formerly Facebook) designed for real-time compression scenarios. It provides a flexible range of compression levels, allowing both high-speed and high-ratio compression, making it ideal for applications with diverse performance needs. Zstandard is commonly used in data storage, transmission, and backup solutions.
Zstandard (zstd) is a fast compression algorithm developed by Meta (formerly Facebook) for real-time scenarios. It provides a flexible range of compression levels, enabling both high-speed and high-compression-ratio options. This makes it ideal for applications needing efficient data storage, transmission, and backup solutions.

`zstandard_cli` is a Dart package which provides bindings to the high-performance Zstandard compression library, enabling both in-code and command-line compression and decompression. It leverages FFI for direct access to native Zstandard functionality, allowing efficient data processing in Dart applications, from compressing data in memory to handling files through the CLI.

**Only available on macOS, Windows, and Linux desktops**.
`zstandard_cli` is a Dart package that binds to the high-performance Zstandard compression library, enabling both in-code and command-line compression and decompression. It leverages FFI to directly access native Zstandard functionality, allowing efficient data processing in Dart applications, from in-memory data compression to file handling via the CLI.

**Available on macOS, Windows, and Linux desktops only**.

| | [macOS](https://flutter.dev/desktop) | [Windows](https://flutter.dev/desktop) | [Linux](https://flutter.dev/desktop) |
|:-----------:|:------------------------------------:|:--------------------------------------:|:------------------------------------:|
| x64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| arm64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| arm64 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Precompiled | Yes | Yes | Yes |

> This is a pure Dart package for desktops. For Flutter usage check the [zstandard](https://pub.dev/packages/zstandard) plugin
> **Note:** This is a pure Dart package for desktop usage. For Flutter, please see the [zstandard](https://pub.dev/packages/zstandard) plugin.
## Basic Usage

Expand Down Expand Up @@ -53,6 +52,9 @@ dart run zstandard_cli:compress any_file 3
dart run zstandard_cli:decompress any_file.zstd
```

---

The images provided below illustrate how to use `zstandard_cli` for compression and decompression on different platforms.

<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/macos_compression_sample.png"></p>
<p align="center"><img width="90%" vspace="10" src="https://github.com/landamessenger/zstandard/raw/master/zstandard_cli/images/macos_decompression_sample.png"></p>
Expand Down
2 changes: 1 addition & 1 deletion zstandard_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.3.24
## 1.4.0

* Fixed decompression size.
* Added `compressionLevel` parameter.
Expand Down
2 changes: 1 addition & 1 deletion zstandard_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: zstandard_platform_interface
description: A common platform interface for the zstandard plugin.
version: 1.3.24
version: 1.4.0
homepage: https://landamessenger.com
repository: https://github.com/landamessenger/zstandard/tree/master/zstandard_platform_interface

Expand Down

0 comments on commit 658ccb3

Please sign in to comment.