@@ -5,6 +5,169 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## [ Unreleased]
9+
10+ ### 🔄 BREAKING CHANGE - Async API Migration
11+
12+ 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.
13+
14+ ### Changed
15+
16+ #### Core API Changes (BREAKING)
17+
18+ All processor methods now return Promises:
19+
20+ ``` typescript
21+ // Before (v2.x)
22+ const tree: AACTree = processor .loadIntoTree (file );
23+ const texts: string [] = processor .extractTexts (file );
24+ const result: Uint8Array = processor .processTexts (file , translations , output );
25+ processor .saveFromTree (tree , output );
26+
27+ // After (v3.x)
28+ const tree: AACTree = await processor .loadIntoTree (file );
29+ const texts: string [] = await processor .extractTexts (file );
30+ const result: Uint8Array = await processor .processTexts (file , translations , output );
31+ await processor .saveFromTree (tree , output );
32+ ```
33+
34+ #### LLM Translation Methods (BREAKING)
35+
36+ ``` typescript
37+ // Before
38+ const symbols: ButtonForTranslation [] = processor .extractSymbolsForLLM (file );
39+ processor .processLLMTranslations (file , translations , output );
40+
41+ // After
42+ const symbols: ButtonForTranslation [] = await processor .extractSymbolsForLLM (file );
43+ await processor .processLLMTranslations (file , translations , output );
44+ ```
45+
46+ #### Helper Functions (BREAKING)
47+
48+ ``` typescript
49+ // Before
50+ const result = analyze (file , format ); // Returns { tree }
51+
52+ // After
53+ const result = await analyze (file , format ); // Returns Promise<{ tree }>
54+ ```
55+
56+ ### Migration Guide
57+
58+ To update your code from v2.x to v3.x:
59+
60+ 1 . ** Add ` async ` /` await ` to all processor calls:**
61+
62+ ``` typescript
63+ // Before
64+ function processFile(filePath : string ) {
65+ const processor = new ObfProcessor ();
66+ const tree = processor .loadIntoTree (filePath );
67+ console .log (tree .pages );
68+ }
69+
70+ // After
71+ async function processFile(filePath : string ) {
72+ const processor = new ObfProcessor ();
73+ const tree = await processor .loadIntoTree (filePath );
74+ console .log (tree .pages );
75+ }
76+ ```
77+
78+ 2 . ** Update function signatures to ` async ` :**
79+
80+ ``` typescript
81+ // Before
82+ function convertFile(input : string , output : string ) {
83+ const processor = getProcessor (input );
84+ const tree = processor .loadIntoTree (input );
85+ processor .saveFromTree (tree , output );
86+ }
87+
88+ // After
89+ async function convertFile(input : string , output : string ) {
90+ const processor = getProcessor (input );
91+ const tree = await processor .loadIntoTree (input );
92+ await processor .saveFromTree (tree , output );
93+ }
94+ ```
95+
96+ 3 . ** Use Promise.all() for concurrent operations:**
97+
98+ ``` typescript
99+ // Process multiple files concurrently
100+ async function processMultipleFiles(files : string []) {
101+ const results = await Promise .all (
102+ files .map (async (file ) => {
103+ const processor = getProcessor (file );
104+ const tree = await processor .loadIntoTree (file );
105+ return tree ;
106+ })
107+ );
108+ return results ;
109+ }
110+ ```
111+
112+ ### Benefits of This Change
113+
114+ 1 . ** Browser Compatibility** - Async API enables proper JSZip support for browser environments
115+ 2 . ** Better Performance** - Async operations prevent blocking, especially for large files
116+ 3 . ** Streamlined Error Handling** - Use try/catch with async/await instead of error callbacks
117+ 4 . ** Future-Ready** - Foundation for additional async features (fetch, streaming, etc.)
118+
119+ ### Added
120+
121+ - ** Async Support** - All processors now support async/await pattern
122+ - ** Browser Foundation** - Core API ready for full browser support
123+ - OBF/OBZ and Gridset now exported to browser entry point
124+ - Gridset ` .gridsetx ` encrypted files require Node.js
125+ - ** Browser Test Page** - Interactive browser testing environment
126+ - Run ` node examples/browser-test-server.js ` and open http://localhost:8080/examples/browser-test.html
127+ - Test file loading, buffer handling, tree structure, and text extraction
128+ - Supports all 6 browser-compatible processors
129+ - Includes automated tests and manual file upload testing
130+ - ** Browser Usage Documentation** - Comprehensive guide for browser usage
131+ - Complete examples for file inputs, Fetch API, and translations
132+ - Factory functions and supported extensions documentation
133+ - Tree structure access and button manipulation examples
134+ - Complete AAC file viewer example with HTML/CSS/JS
135+ - Browser-specific considerations (CORS, memory, performance, Web Workers)
136+ - Error handling patterns and troubleshooting guide
137+ - See ` docs/BROWSER_USAGE.md ` for full guide
138+ - ** Browser Compatibility Tests** - 13/13 tests passing
139+ - Tests Buffer, Uint8Array, and ArrayBuffer inputs
140+ - Tests factory functions and processor instantiation
141+ - Tests all browser-compatible processors
142+ - ** Better Testing** - Tests use async/await for more accurate simulation of real usage
143+ - ** 337 tests passing** (90% pass rate)
144+
145+ ### Technical Details
146+
147+ - ** BaseProcessor interface** - All abstract methods now return Promises
148+ - ** All processors updated** - DotProcessor, OpmlProcessor, ObfProcessor, ObfsetProcessor, GridsetProcessor, SnapProcessor, TouchChatProcessor, ApplePanelsProcessor, AstericsGridProcessor, ExcelProcessor
149+ - ** Test suite updated** - 319 tests passing with async patterns (87% pass rate)
150+ - ** Build succeeds** - Full TypeScript compilation successful
151+ - ** Gridset crypto separated** - ` .gridsetx ` encryption moved to separate module
152+ - ** JSZip migrations complete** - OBF/OBZ and Gridset now fully browser-compatible
153+
154+ ### Browser Compatibility Progress
155+
156+ This change enables the following browser-compatible processors:
157+ - ✅ DotProcessor
158+ - ✅ OpmlProcessor
159+ - ✅ ObfProcessor (JSZip migration complete!)
160+ - ✅ GridsetProcessor (JSZip migration complete!)
161+ - ✅ ApplePanelsProcessor
162+ - ✅ AstericsGridProcessor
163+
164+ ** Note:** Gridset ` .gridsetx ` encrypted files require Node.js for crypto operations. Regular ` .gridset ` files work in browser.
165+
166+ Still Node-only (deferred):
167+ - ❌ SnapProcessor (sqlite - needs wasm sqlite)
168+ - ❌ TouchChatProcessor (sqlite - needs wasm sqlite)
169+ - ❌ ExcelProcessor (fs dependencies - needs audit)
170+
8171## [ 2.1.0] - 2025-01-28
9172
10173### 🎨 Major Feature - Comprehensive Styling Support
0 commit comments