{"id":12788,"library":"aab-parser","title":"AAB Parser","description":"aab-parser is a lightweight, asynchronous Android App Bundle (AAB) parser written entirely in TypeScript. It provides functionality to extract key manifest attributes from an AAB file, either as a strongly typed `Manifest` object (a subset of common attributes) or a raw JSON object with more comprehensive data. A key differentiator is its pure Node.js implementation, which means it does not require a Java Development Kit (JDK) installation, unlike many other AAB inspection tools. The current stable version is 1.0.1, released recently after its initial 1.0.0 debut, suggesting an early but active development phase with releases focused on stability and minor enhancements rather than a fixed cadence. It is primarily used for programmatic inspection of AAB metadata in build pipelines or analysis tools.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/qucumbah/aab-parser","tags":["javascript","android","aab","parser","typescript"],"install":[{"cmd":"npm install aab-parser","lang":"bash","label":"npm"},{"cmd":"yarn add aab-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add aab-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Preferred ESM named import for functions. CommonJS `require` can lead to incorrect type inference or module resolution issues in modern TypeScript/Node.js environments.","wrong":"const aabParser = require('aab-parser'); aabParser.parseAabManifest(...);","symbol":"parseAabManifest","correct":"import { parseAabManifest } from 'aab-parser';"},{"note":"ESM named import for accessing the function that returns the full manifest as a plain JSON object.","wrong":"const { parseAabManifestJSON } = require('aab-parser');","symbol":"parseAabManifestJSON","correct":"import { parseAabManifestJSON } from 'aab-parser';"},{"note":"Use `import type` for type declarations to ensure they are stripped during compilation, preventing potential runtime errors or bundle size increases.","wrong":"import { Manifest } from 'aab-parser';","symbol":"Manifest","correct":"import type { Manifest } from 'aab-parser';"}],"quickstart":{"code":"import { parseAabManifest, Manifest } from 'aab-parser';\nimport * as path from 'path';\nimport { promises as fs } from 'fs';\n\n// Ensure you have an 'example.aab' file in your project root or specify a path.\n// For testing, you might use a dummy AAB or a real one from a build process.\nconst AAB_FILE_PATH = process.env.AAB_PATH ?? path.join(__dirname, 'example.aab');\n\nasync function main() {\n  try {\n    // Create a dummy AAB file for demonstration if it doesn't exist\n    // In a real scenario, this file would be provided.\n    try {\n        await fs.access(AAB_FILE_PATH);\n    } catch (error) {\n        console.warn(`AAB file not found at ${AAB_FILE_PATH}. This example requires an AAB file to run fully.`);\n        console.warn(\"Creating a placeholder. Please replace with a real AAB for actual parsing.\");\n        await fs.writeFile(AAB_FILE_PATH, Buffer.from('PK\\x03\\x04... (truncated for brevity, a real AAB is much larger)', 'binary'));\n    }\n\n    console.log(`Parsing AAB manifest from: ${AAB_FILE_PATH}`);\n    const manifest: Manifest = await parseAabManifest(AAB_FILE_PATH);\n\n    console.log('Parsed AAB Manifest:');\n    console.log(manifest);\n\n    // Example of accessing specific fields\n    console.log(`Package Name: ${manifest.packageName}`);\n    console.log(`Version Code: ${manifest.versionCode}`);\n    console.log(`Version Name: ${manifest.versionName}`);\n\n  } catch (error) {\n    console.error('Error parsing AAB manifest:', error);\n  }\n}\n\nmain();\n","lang":"typescript","description":"Demonstrates how to asynchronously parse an Android App Bundle (AAB) file to extract its manifest information using `parseAabManifest`, showing the typed output and handling potential file errors."},"warnings":[{"fix":"For comprehensive manifest data, invoke `parseAabManifestJSON` which returns a plain object containing all parsed fields from the manifest XML.","message":"The `Manifest` type and the `parseAabManifest` function return a strict subset of AAB manifest attributes. If you require full, untyped manifest data, use `parseAabManifestJSON` instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use `await` with `parseAabManifest` and `parseAabManifestJSON` within an `async` function, or ensure your environment supports top-level `await`.","message":"All parsing functions in `aab-parser` are asynchronous and return Promises. Synchronous usage will result in an unhandled promise rejection or a `TypeError` if `await` is not used correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Adopt ESM `import { parseAabManifest, Manifest } from 'aab-parser';` for clarity and compatibility in TypeScript projects. Ensure your `tsconfig.json` and `package.json` are configured for ESM (e.g., `\"type\": \"module\"`).","message":"The README example uses CommonJS `require()`. While this might work, in modern TypeScript and Node.js projects, ESM `import` statements are preferred for better type inference, tree-shaking, and consistency. Mixing module systems can lead to build or runtime issues.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Wrap your code calling `parseAabManifest` or `parseAabManifestJSON` in an `async` function, or ensure your project is configured as an ESM module with Node.js version supporting top-level await (Node.js 14.8+).","cause":"Attempting to use `await` outside an `async` function or in a CommonJS module that doesn't support top-level await.","error":"SyntaxError: await is only valid in async functions and the top level bodies of modules"},{"fix":"Verify the file path is correct and accessible. Use an absolute path or ensure the relative path is correct from where your script is executed.","cause":"The provided path to the AAB file is incorrect, or the file does not exist at that location.","error":"Error: ENOENT: no such file or directory, open 'path/to/your/bundle.aab'"},{"fix":"Always include error handling (`try...catch`) around AAB parsing calls. Log the error to understand the underlying cause. Ensure the AAB file is valid and not corrupt.","cause":"Attempting to access properties on the result of `parseAabManifest` or `parseAabManifestJSON` when the parsing failed or returned an unexpected value (e.g., due to a corrupt AAB).","error":"TypeError: Cannot read properties of undefined (reading 'packageName')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null}