CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-native-community--cli-types

TypeScript type definitions for React Native Community CLI configuration and command structures

Pending
Overview
Eval results
Files

third-party-types.mddocs/

Third-Party Type Definitions

@react-native-community/cli-types includes type definitions for third-party modules used within the React Native CLI ecosystem. These are not directly exported from the package but are available when the package is installed.

Capabilities

Node Stream Zip Types

Type definitions for the 'node-stream-zip' module, providing TypeScript support for zip file operations within React Native CLI tools.

Note: These types are provided as module augmentation (declare module 'node-stream-zip') and become available automatically when @react-native-community/cli-types is installed.

/**
 * Configuration options for StreamZip instances
 */
interface StreamZipOptions {
  /** File path to read */
  file: string;
  /** Whether to store entries for random access (default: true) */
  storeEntries?: boolean;
  /** Skip entry name validation for malicious paths (default: false) */
  skipEntryNameValidation?: boolean;
  /** Chunk size for reading (default: automatic) */
  chunkSize?: number;
}

/**
 * Represents an entry within a zip archive
 */
class ZipEntry {
  /** Entry name/path within the archive */
  name: string;
  /** Whether this entry is a directory */
  isDirectory: boolean;
  /** Whether this entry is a file */
  isFile: boolean;
  /** Comment associated with this entry */
  comment: string;
  /** Uncompressed size of the entry */
  size: number;
}

/**
 * Main class for reading zip archives
 */
class StreamZip {
  /** Create new StreamZip instance */
  constructor(config: StreamZipOptions);
  
  /** Register event handler for when zip is ready to use */
  on(event: 'ready', handler: () => void): void;
  
  /** Get specific entry by name */
  entry(entry: string): ZipEntry;
  
  /** Get all entries in the archive */
  entries(): ZipEntry[];
  
  /** Total number of entries in the archive */
  entriesCount: number;
  
  /** Get readable stream for entry content */
  stream(
    entry: string,
    callback: (err: any | null, stream?: Stream) => void,
  ): void;
  
  /** Synchronously read entry data as buffer */
  entryDataSync(entry: string): Buffer;
  
  /** Open entry for reading */
  openEntry(
    entry: string,
    callback: (err: any | null, entry?: ZipEntry) => void,
    sync: boolean,
  ): void;
  
  /** Extract entry or entire archive to filesystem */
  extract(
    entry: string | null,
    outPath: string,
    callback: (err?: any) => void,
  ): void;
  
  /** Close the zip archive */
  close(callback?: (err?: any) => void): void;
}

Usage Examples:

// These types are available after installing @react-native-community/cli-types
import StreamZip from 'node-stream-zip';
import { Stream } from 'stream';

// Create zip reader
const zip = new StreamZip({
  file: './archive.zip',
  storeEntries: true
});

// Wait for zip to be ready
zip.on('ready', () => {
  console.log(`Entries: ${zip.entriesCount}`);
  
  // List all entries
  const entries = zip.entries();
  for (const entry of entries) {
    console.log(`${entry.name}: ${entry.size} bytes`);
  }
  
  // Extract specific file
  zip.extract('path/to/file.txt', './extracted/', (err) => {
    if (err) throw err;
    console.log('File extracted');
    zip.close();
  });
});

// Extract entire archive
zip.extract(null, './extracted/', (err) => {
  if (err) throw err;
  console.log('Archive extracted');
  zip.close();
});

// Read file data synchronously (after 'ready' event)
zip.on('ready', () => {
  const data = zip.entryDataSync('config.json');
  const config = JSON.parse(data.toString());
  console.log('Config:', config);
  zip.close();
});

Integration with React Native CLI

These zip utilities are used internally by React Native CLI for:

  • Extracting project templates
  • Processing bundled assets
  • Handling compressed dependencies
  • Archive-based project scaffolding

While not directly exported from @react-native-community/cli-types, these types ensure type safety when CLI tools work with zip archives.

Install with Tessl CLI

npx tessl i tessl/npm-react-native-community--cli-types

docs

android-platform.md

command-system.md

configuration-types.md

index.md

ios-platform.md

third-party-types.md

tile.json