open-index/open-npm huggingface dataset:
npm package: @neo-office/web-sdk
Description: High-level browser SDK for viewing and editing Office documents (DOCX, PPTX, XLSX). Built on top of the Neo Office WASM engine — no server, no external services.
Latest version: 0.1.1

# @neo-office/web-sdk

High-level browser SDK for viewing and editing Office documents (DOCX, PPTX, XLSX). Built on top of the Neo Office WASM engine — no server, no external services.

## Installation

```bash
npm install @neo-office/web-sdk
```

## Quick Start

```ts
import { NeoPreviewEngine } from '@neo-office/web-sdk';

const engine = new NeoPreviewEngine();
await engine.init();

// Open a file (File object from <input> or drag-and-drop)
const handle = await engine.openFile(file);

// Render a page to an HTML element
await engine.renderPage(handle, 0, document.getElementById('viewer'));

// Clean up
engine.dispose();
```

## PPTX — HTML Renderer

Render a PowerPoint slide as a pixel-perfect HTML/CSS/SVG layout:

```ts
import { renderSlideToHtml } from '@neo-office/web-sdk';
import type { PptxHtmlRenderOptions } from '@neo-office/web-sdk';

const options: PptxHtmlRenderOptions = {
  slideIndex: 0,
  containerWidth: 960,
};

const html = renderSlideToHtml(presentation, options);
document.getElementById('slide').innerHTML = html;
```

## PPTX — Animations

Play entrance animations and slide transitions:

```ts
import { PptxAnimationPlayer, playSlideTransition } from '@neo-office/web-sdk';

// Entrance animations (click-to-advance)
const player = new PptxAnimationPlayer(slideEl, slide.animations);
player.start();
player.advance(); // trigger next click group

// Slide transitions
await playSlideTransition(fromEl, toEl, transition);
```

## Edit Session

Track mutations before committing them back to the document:

```ts
import { EditSession } from '@neo-office/web-sdk';

const session = new EditSession(handle);

session.apply({ type: 'SET_TEXT', shapeId: 'sp1', text: 'Hello' });
session.apply({ type: 'MOVE_SHAPE', shapeId: 'sp1', x: 100, y: 200 });

const mutations = session.mutations; // inspect pending changes
session.commit();                    // finalise
```

## API Reference

### `NeoPreviewEngine`

| Method | Returns | Description |
|---|---|---|
| `init()` | `Promise<void>` | Initialise the WASM engine |
| `openFile(file)` | `Promise<DocumentHandle>` | Load a `File` object |
| `openBytes(bytes, name)` | `Promise<DocumentHandle>` | Load raw `Uint8Array` |
| `renderPage(handle, page, el)` | `Promise<void>` | Render a page into a DOM element |
| `getMetadata(handle)` | `Promise<object>` | Title, author, word count, … |
| `search(handle, query)` | `Promise<SearchResult[]>` | Full-text search |
| `dispose()` | `void` | Release all resources |

### `renderSlideToHtml(presentation, options)`

Converts a parsed `PptxPresentation` slide into an HTML string. Options:

```ts
interface PptxHtmlRenderOptions {
  slideIndex: number;        // 0-based
  containerWidth?: number;   // px, default 960
  containerHeight?: number;  // px, auto-calculated if omitted
}
```

## Peer Dependencies

None — the WASM engine is bundled.

## License

MIT