Use NativeScript within your existing Capacitor app.
import { Zip } from "@nativescript/zip";
import { notifyEvent } from "@nativescript/capacitor/bridge";
interface ZipOptions {
directory: string,
archive: string
}
native.fileZip = function (options: ZipOptions) {
const { directory, archive } = options;
Zip.zip({
directory,
archive,
onProgress: (progress) => {
notifyEvent('zipProgress', progress);
},
}).then((filePath) => {
notifyEvent('zipComplete', filePath);
});
};
import { native } from '@nativescript/capacitor';
export class ExploreContainerComponent {
fileZip() {
native.onEvent('zipComplete', (filePath: string) => {
console.log('zip created at:', filePath);
});
native.fileZip({
directory: 'assets',
archive: 'assets.zip'
});
}
}
Completely inactive with zero impact on your web environment. It is only active when Capacitor is running.