Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .claude/settings.local.json

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
env:
CI: true

- name: Verify browser build output
run: test -f dist/browser/index.browser.js

- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ jobs:
run: |
npm version "${{ steps.release_version.outputs.version }}" --no-git-tag-version

- run: npm run build --if-present
- run: npm run build:all --if-present
- run: npm publish --access public
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.claude
DS_Store
aac-metrics-node/
obla-improvements/
tmp/
Expand Down
163 changes: 163 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,169 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### 🔄 BREAKING CHANGE - Async API Migration

This release introduces a major API change to support browser environments and enable future JSZip migration. All processor methods are now **asynchronous** and return Promises.

### Changed

#### Core API Changes (BREAKING)

All processor methods now return Promises:

```typescript
// Before (v2.x)
const tree: AACTree = processor.loadIntoTree(file);
const texts: string[] = processor.extractTexts(file);
const result: Uint8Array = processor.processTexts(file, translations, output);
processor.saveFromTree(tree, output);

// After (v3.x)
const tree: AACTree = await processor.loadIntoTree(file);
const texts: string[] = await processor.extractTexts(file);
const result: Uint8Array = await processor.processTexts(file, translations, output);
await processor.saveFromTree(tree, output);
```

#### LLM Translation Methods (BREAKING)

```typescript
// Before
const symbols: ButtonForTranslation[] = processor.extractSymbolsForLLM(file);
processor.processLLMTranslations(file, translations, output);

// After
const symbols: ButtonForTranslation[] = await processor.extractSymbolsForLLM(file);
await processor.processLLMTranslations(file, translations, output);
```

#### Helper Functions (BREAKING)

```typescript
// Before
const result = analyze(file, format); // Returns { tree }

// After
const result = await analyze(file, format); // Returns Promise<{ tree }>
```

### Migration Guide

To update your code from v2.x to v3.x:

1. **Add `async`/`await` to all processor calls:**

```typescript
// Before
function processFile(filePath: string) {
const processor = new ObfProcessor();
const tree = processor.loadIntoTree(filePath);
console.log(tree.pages);
}

// After
async function processFile(filePath: string) {
const processor = new ObfProcessor();
const tree = await processor.loadIntoTree(filePath);
console.log(tree.pages);
}
```

2. **Update function signatures to `async`:**

```typescript
// Before
function convertFile(input: string, output: string) {
const processor = getProcessor(input);
const tree = processor.loadIntoTree(input);
processor.saveFromTree(tree, output);
}

// After
async function convertFile(input: string, output: string) {
const processor = getProcessor(input);
const tree = await processor.loadIntoTree(input);
await processor.saveFromTree(tree, output);
}
```

3. **Use Promise.all() for concurrent operations:**

```typescript
// Process multiple files concurrently
async function processMultipleFiles(files: string[]) {
const results = await Promise.all(
files.map(async (file) => {
const processor = getProcessor(file);
const tree = await processor.loadIntoTree(file);
return tree;
})
);
return results;
}
```

### Benefits of This Change

1. **Browser Compatibility** - Async API enables proper JSZip support for browser environments
2. **Better Performance** - Async operations prevent blocking, especially for large files
3. **Streamlined Error Handling** - Use try/catch with async/await instead of error callbacks
4. **Future-Ready** - Foundation for additional async features (fetch, streaming, etc.)

### Added

- **Async Support** - All processors now support async/await pattern
- **Browser Foundation** - Core API ready for full browser support
- OBF/OBZ and Gridset now exported to browser entry point
- Gridset `.gridsetx` encrypted files require Node.js
- **Browser Test Page** - Interactive browser testing environment
- Run `node examples/browser-test-server.js` and open http://localhost:8080/examples/browser-test.html
- Test file loading, buffer handling, tree structure, and text extraction
- Supports all 6 browser-compatible processors
- Includes automated tests and manual file upload testing
- **Browser Usage Documentation** - Comprehensive guide for browser usage
- Complete examples for file inputs, Fetch API, and translations
- Factory functions and supported extensions documentation
- Tree structure access and button manipulation examples
- Complete AAC file viewer example with HTML/CSS/JS
- Browser-specific considerations (CORS, memory, performance, Web Workers)
- Error handling patterns and troubleshooting guide
- See `docs/BROWSER_USAGE.md` for full guide
- **Browser Compatibility Tests** - 13/13 tests passing
- Tests Buffer, Uint8Array, and ArrayBuffer inputs
- Tests factory functions and processor instantiation
- Tests all browser-compatible processors
- **Better Testing** - Tests use async/await for more accurate simulation of real usage
- **337 tests passing** (90% pass rate)

### Technical Details

- **BaseProcessor interface** - All abstract methods now return Promises
- **All processors updated** - DotProcessor, OpmlProcessor, ObfProcessor, ObfsetProcessor, GridsetProcessor, SnapProcessor, TouchChatProcessor, ApplePanelsProcessor, AstericsGridProcessor, ExcelProcessor
- **Test suite updated** - 319 tests passing with async patterns (87% pass rate)
- **Build succeeds** - Full TypeScript compilation successful
- **Gridset crypto separated** - `.gridsetx` encryption moved to separate module
- **JSZip migrations complete** - OBF/OBZ and Gridset now fully browser-compatible

### Browser Compatibility Progress

This change enables the following browser-compatible processors:
- ✅ DotProcessor
- ✅ OpmlProcessor
- ✅ ObfProcessor (JSZip migration complete!)
- ✅ GridsetProcessor (JSZip migration complete!)
- ✅ ApplePanelsProcessor
- ✅ AstericsGridProcessor

**Note:** Gridset `.gridsetx` encrypted files require Node.js for crypto operations. Regular `.gridset` files work in browser.

Still Node-only (deferred):
- ❌ SnapProcessor (sqlite - needs wasm sqlite)
- ❌ TouchChatProcessor (sqlite - needs wasm sqlite)
- ❌ ExcelProcessor (fs dependencies - needs audit)

## [2.1.0] - 2025-01-28

### 🎨 Major Feature - Comprehensive Styling Support
Expand Down
Loading