Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ragaeeb/kokokor/llms.txt

Use this file to discover all available pages before exploring further.

Package Manager Installation

Kokokor is available on npm and can be installed using your preferred package manager:
npm install kokokor

Requirements

Kokokor requires one of the following runtime environments:

Node.js

Version: 24.0.0 or higherKokokor uses modern JavaScript features and ESM modules

Bun

Version: 1.3.9 or higherNative Bun runtime support for optimal performance
Kokokor is built as an ESM (ECMAScript Module) package. Ensure your project is configured to use ESM or has proper module resolution for ESM packages.

Verify Installation

After installing, verify that Kokokor is properly set up by importing it in your project:
import { reconstructParagraphs } from 'kokokor';

console.log(typeof reconstructParagraphs); // Should output: "function"
If the import works without errors, you’re ready to start using Kokokor!

TypeScript Setup

Kokokor is written in TypeScript and includes full type definitions out of the box. No additional @types packages are needed.

TypeScript Configuration

Ensure your tsconfig.json is configured for ESM modules:
tsconfig.json
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "bundler",
    "target": "ES2022",
    "lib": ["ES2022"],
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

Import with Full Type Safety

All exports include comprehensive TypeScript types:
import {
  reconstructParagraphs,
  mapObservationsToTextLines,
  mapTextLinesToParagraphs,
  formatTextBlocks,
  type Observation,
  type TextBlock,
  type BoundingBox,
  type ReconstructInput,
  type ReconstructOptions
} from 'kokokor';

// Full type inference and autocomplete available
const input: ReconstructInput = {
  observations: [],
  page: { dpiX: 300, dpiY: 300, width: 2480, height: 3508 }
};

const result = reconstructParagraphs(input);
// result.text: string
// result.textBlocks: TextBlock[]

Package Information

License

MIT License - Free for commercial and personal use

Bundle Size

Lightweight with minimal dependencies

Module Format

ESM (ECMAScript Modules)

TypeScript

Full type definitions included

Next Steps

Now that you have Kokokor installed, you’re ready to start reconstructing paragraphs from OCR output:

Quick Start Guide

Learn how to use Kokokor with a simple example

Troubleshooting

Module Resolution Errors

If you encounter module resolution errors, ensure your project is configured for ESM: For Node.js projects, add to your package.json:
package.json
{
  "type": "module"
}
For TypeScript projects, update your tsconfig.json as shown in the TypeScript Setup section above.

CommonJS Compatibility

Kokokor is an ESM-only package. If you need to use it in a CommonJS project, consider using dynamic imports:
const { reconstructParagraphs } = await import('kokokor');
Or migrate your project to ESM for the best experience.