NativeScript for Capacitor

The platform at your fingertips.

Isolated NativeScript environment

Use NativeScript within your existing Capacitor app.

./src/nativescript/zip.ts
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);
  });
};
./src/app/explore-container.component.ts
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'
    });
  }
}

Use anywhere in your Ionic codebase

Completely inactive with zero impact on your web environment. It is only active when Capacitor is running.