@willwade/aac-processors 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/browser/index.browser.js +15 -1
- package/dist/browser/processors/gridset/password.js +11 -0
- package/dist/browser/processors/gridset/symbols.js +3 -2
- package/dist/browser/processors/gridsetProcessor.js +42 -46
- package/dist/browser/processors/obfProcessor.js +47 -63
- package/dist/browser/processors/snapProcessor.js +1031 -0
- package/dist/browser/processors/touchchatProcessor.js +1004 -0
- package/dist/browser/utils/io.js +21 -1
- package/dist/browser/utils/sqlite.js +109 -0
- package/dist/browser/utils/zip.js +54 -0
- package/dist/browser/validation/gridsetValidator.js +21 -2
- package/dist/browser/validation/obfValidator.js +4 -5
- package/dist/browser/validation/snapValidator.js +200 -0
- package/dist/browser/validation/touchChatValidator.js +202 -0
- package/dist/index.browser.d.ts +7 -0
- package/dist/index.browser.js +19 -2
- package/dist/processors/gridset/helpers.js +3 -4
- package/dist/processors/gridset/index.d.ts +1 -1
- package/dist/processors/gridset/index.js +3 -2
- package/dist/processors/gridset/password.d.ts +3 -2
- package/dist/processors/gridset/password.js +12 -0
- package/dist/processors/gridset/symbols.js +2 -1
- package/dist/processors/gridset/wordlistHelpers.js +107 -51
- package/dist/processors/gridsetProcessor.js +40 -44
- package/dist/processors/obfProcessor.js +46 -62
- package/dist/processors/snapProcessor.js +60 -54
- package/dist/processors/touchchatProcessor.js +38 -36
- package/dist/utils/io.d.ts +5 -0
- package/dist/utils/io.js +23 -0
- package/dist/utils/sqlite.d.ts +21 -0
- package/dist/utils/sqlite.js +137 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.js +80 -0
- package/dist/validation/gridsetValidator.js +20 -24
- package/dist/validation/obfValidator.js +4 -28
- package/docs/BROWSER_USAGE.md +2 -10
- package/examples/README.md +3 -75
- package/examples/vitedemo/README.md +17 -10
- package/examples/vitedemo/index.html +2 -2
- package/examples/vitedemo/package-lock.json +531 -1
- package/examples/vitedemo/package.json +7 -1
- package/examples/vitedemo/src/main.ts +48 -2
- package/examples/vitedemo/src/vite-env.d.ts +1 -0
- package/package.json +3 -1
- package/examples/browser-test-server.js +0 -81
- package/examples/vitedemo/QUICKSTART.md +0 -75
|
@@ -66,12 +66,15 @@ if (typeof (window as any).Buffer === 'undefined') {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
import {
|
|
69
|
+
configureSqlJs,
|
|
69
70
|
getProcessor,
|
|
70
71
|
getSupportedExtensions,
|
|
71
72
|
DotProcessor,
|
|
72
73
|
OpmlProcessor,
|
|
73
74
|
ObfProcessor,
|
|
74
75
|
GridsetProcessor,
|
|
76
|
+
SnapProcessor,
|
|
77
|
+
TouchChatProcessor,
|
|
75
78
|
ApplePanelsProcessor,
|
|
76
79
|
AstericsGridProcessor,
|
|
77
80
|
AACTree,
|
|
@@ -79,6 +82,12 @@ import {
|
|
|
79
82
|
AACButton
|
|
80
83
|
} from 'aac-processors';
|
|
81
84
|
|
|
85
|
+
import sqlWasmUrl from 'sql.js/dist/sql-wasm.wasm?url';
|
|
86
|
+
|
|
87
|
+
configureSqlJs({
|
|
88
|
+
locateFile: () => sqlWasmUrl
|
|
89
|
+
});
|
|
90
|
+
|
|
82
91
|
// UI Elements
|
|
83
92
|
const dropArea = document.getElementById('dropArea') as HTMLElement;
|
|
84
93
|
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
|
|
@@ -717,11 +726,15 @@ runTestsBtn.addEventListener('click', async () => {
|
|
|
717
726
|
const opmlProc = getProcessor('.opml');
|
|
718
727
|
const obfProc = getProcessor('.obf');
|
|
719
728
|
const gridsetProc = getProcessor('.gridset');
|
|
729
|
+
const snapProc = getProcessor('.sps');
|
|
730
|
+
const touchChatProc = getProcessor('.ce');
|
|
720
731
|
return (
|
|
721
732
|
dotProc instanceof DotProcessor &&
|
|
722
733
|
opmlProc instanceof OpmlProcessor &&
|
|
723
734
|
obfProc instanceof ObfProcessor &&
|
|
724
|
-
gridsetProc instanceof GridsetProcessor
|
|
735
|
+
gridsetProc instanceof GridsetProcessor &&
|
|
736
|
+
snapProc instanceof SnapProcessor &&
|
|
737
|
+
touchChatProc instanceof TouchChatProcessor
|
|
725
738
|
);
|
|
726
739
|
}
|
|
727
740
|
},
|
|
@@ -729,7 +742,18 @@ runTestsBtn.addEventListener('click', async () => {
|
|
|
729
742
|
name: 'getSupportedExtensions() returns all extensions',
|
|
730
743
|
fn: async () => {
|
|
731
744
|
const extensions = getSupportedExtensions();
|
|
732
|
-
const expected = [
|
|
745
|
+
const expected = [
|
|
746
|
+
'.dot',
|
|
747
|
+
'.opml',
|
|
748
|
+
'.obf',
|
|
749
|
+
'.obz',
|
|
750
|
+
'.gridset',
|
|
751
|
+
'.spb',
|
|
752
|
+
'.sps',
|
|
753
|
+
'.ce',
|
|
754
|
+
'.plist',
|
|
755
|
+
'.grd'
|
|
756
|
+
];
|
|
733
757
|
return expected.every((ext) => extensions.includes(ext));
|
|
734
758
|
}
|
|
735
759
|
},
|
|
@@ -777,6 +801,28 @@ runTestsBtn.addEventListener('click', async () => {
|
|
|
777
801
|
}
|
|
778
802
|
}
|
|
779
803
|
},
|
|
804
|
+
{
|
|
805
|
+
name: 'SnapProcessor instantiation',
|
|
806
|
+
fn: async () => {
|
|
807
|
+
try {
|
|
808
|
+
new SnapProcessor();
|
|
809
|
+
return true;
|
|
810
|
+
} catch {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: 'TouchChatProcessor instantiation',
|
|
817
|
+
fn: async () => {
|
|
818
|
+
try {
|
|
819
|
+
new TouchChatProcessor();
|
|
820
|
+
return true;
|
|
821
|
+
} catch {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
},
|
|
780
826
|
{
|
|
781
827
|
name: 'ApplePanelsProcessor instantiation',
|
|
782
828
|
fn: async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A comprehensive TypeScript library for processing AAC (Augmentative and Alternative Communication) file formats with translation support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/browser/index.browser.js",
|
|
@@ -151,6 +151,7 @@
|
|
|
151
151
|
"@types/jest": "^29.5.12",
|
|
152
152
|
"@types/node": "^20.11.24",
|
|
153
153
|
"@types/plist": "^3.0.5",
|
|
154
|
+
"@types/sql.js": "^1.4.9",
|
|
154
155
|
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
155
156
|
"@typescript-eslint/parser": "^7.1.0",
|
|
156
157
|
"eslint": "^8.56.0",
|
|
@@ -174,6 +175,7 @@
|
|
|
174
175
|
"fast-xml-parser": "^5.2.0",
|
|
175
176
|
"jszip": "^3.10.1",
|
|
176
177
|
"plist": "^3.1.0",
|
|
178
|
+
"sql.js": "^1.13.0",
|
|
177
179
|
"xml2js": "^0.6.2",
|
|
178
180
|
"yauzl": "^3.2.0"
|
|
179
181
|
},
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Simple HTTP server for testing AACProcessors in a browser
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* node examples/browser-test-server.js
|
|
8
|
-
*
|
|
9
|
-
* Then open: http://localhost:8080/examples/browser-test.html
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const http = require('http');
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
|
|
16
|
-
const PORT = 8080;
|
|
17
|
-
const MIME_TYPES = {
|
|
18
|
-
'.html': 'text/html',
|
|
19
|
-
'.js': 'text/javascript',
|
|
20
|
-
'.css': 'text/css',
|
|
21
|
-
'.json': 'application/json',
|
|
22
|
-
'.png': 'image/png',
|
|
23
|
-
'.jpg': 'image/jpg',
|
|
24
|
-
'.gif': 'image/gif',
|
|
25
|
-
'.svg': 'image/svg+xml',
|
|
26
|
-
'.ico': 'image/x-icon',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const server = http.createServer((req, res) => {
|
|
30
|
-
// Enable CORS
|
|
31
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
32
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
33
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
34
|
-
|
|
35
|
-
if (req.method === 'OPTIONS') {
|
|
36
|
-
res.writeHead(200);
|
|
37
|
-
res.end();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Parse URL
|
|
42
|
-
let filePath = '.' + req.url;
|
|
43
|
-
if (filePath === './') {
|
|
44
|
-
filePath = './examples/browser-test.html';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Get file extension
|
|
48
|
-
const extname = String(path.extname(filePath)).toLowerCase();
|
|
49
|
-
const contentType = MIME_TYPES[extname] || 'application/octet-stream';
|
|
50
|
-
|
|
51
|
-
// Read and serve file
|
|
52
|
-
fs.readFile(filePath, (error, content) => {
|
|
53
|
-
if (error) {
|
|
54
|
-
if (error.code === 'ENOENT') {
|
|
55
|
-
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
56
|
-
res.end('<h1>404 Not Found</h1>', 'utf-8');
|
|
57
|
-
} else {
|
|
58
|
-
res.writeHead(500);
|
|
59
|
-
res.end(`Server Error: ${error.code}`, 'utf-8');
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
res.writeHead(200, { 'Content-Type': contentType });
|
|
63
|
-
res.end(content, 'utf-8');
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
server.listen(PORT, () => {
|
|
69
|
-
console.log(`
|
|
70
|
-
╔════════════════════════════════════════════════════════════╗
|
|
71
|
-
║ AACProcessors Browser Test Server ║
|
|
72
|
-
╠════════════════════════════════════════════════════════════╣
|
|
73
|
-
║ ║
|
|
74
|
-
║ Server running at: ║
|
|
75
|
-
║ 🌐 http://localhost:${PORT}/examples/browser-test.html ║
|
|
76
|
-
║ ║
|
|
77
|
-
║ Press Ctrl+C to stop ║
|
|
78
|
-
║ ║
|
|
79
|
-
╚════════════════════════════════════════════════════════════╝
|
|
80
|
-
`);
|
|
81
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# 🎯 AAC Processors Browser Demo - Quick Start
|
|
2
|
-
|
|
3
|
-
## 🚀 Running the Demo
|
|
4
|
-
|
|
5
|
-
The demo is already running! Open your browser to:
|
|
6
|
-
|
|
7
|
-
**http://localhost:3000**
|
|
8
|
-
|
|
9
|
-
## 📁 Test Files Included
|
|
10
|
-
|
|
11
|
-
The `test-files/` folder contains example AAC files you can use:
|
|
12
|
-
|
|
13
|
-
- `example.dot` (392 bytes) - DOT format board
|
|
14
|
-
- `example.opml` (495 bytes) - OPML outline
|
|
15
|
-
- `simple.obf` (2.1 KB) - Open Board Format
|
|
16
|
-
- `example.obz` (13 MB) - Compressed OBF
|
|
17
|
-
- `example.gridset` (1.4 MB) - Grid 3 gridset
|
|
18
|
-
- `example.grd` (21 KB) - Asterics Grid
|
|
19
|
-
|
|
20
|
-
## 🧪 How to Test
|
|
21
|
-
|
|
22
|
-
### Option 1: Drag & Drop
|
|
23
|
-
1. Open http://localhost:3000
|
|
24
|
-
2. Drag any file from `test-files/` onto the upload area
|
|
25
|
-
3. Click "Process File"
|
|
26
|
-
4. Explore pages and buttons!
|
|
27
|
-
|
|
28
|
-
### Option 2: File Picker
|
|
29
|
-
1. Click the upload area
|
|
30
|
-
2. Select a file from `test-files/`
|
|
31
|
-
3. Click "Process File"
|
|
32
|
-
|
|
33
|
-
### Option 3: Run Tests
|
|
34
|
-
1. Click "Run Compatibility Tests"
|
|
35
|
-
2. See all 9 tests pass!
|
|
36
|
-
|
|
37
|
-
## ✨ Features to Try
|
|
38
|
-
|
|
39
|
-
- **Text-to-Speech**: Click any SPEAK button to hear the message
|
|
40
|
-
- **Navigation**: Click NAVIGATE buttons to jump between pages
|
|
41
|
-
- **Stats**: See page/button/text counts and load time
|
|
42
|
-
- **Logs**: Watch the processing log in real-time
|
|
43
|
-
- **Pageset Lab**: Open the "Create & Convert" tab to generate a sample pageset or convert an upload to OBF/OBZ
|
|
44
|
-
|
|
45
|
-
## 🛠️ Development
|
|
46
|
-
|
|
47
|
-
### Restart Server
|
|
48
|
-
```bash
|
|
49
|
-
cd examples/vitedemo
|
|
50
|
-
npm run dev
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Build for Production
|
|
54
|
-
```bash
|
|
55
|
-
npm run build
|
|
56
|
-
npm run preview
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 📊 What's Being Tested
|
|
60
|
-
|
|
61
|
-
This demo proves AACProcessors works in browsers with:
|
|
62
|
-
- ✅ Vite bundling
|
|
63
|
-
- ✅ All 6 browser-compatible processors
|
|
64
|
-
- ✅ File upload (drag & drop + picker)
|
|
65
|
-
- ✅ ArrayBuffer handling
|
|
66
|
-
- ✅ Tree structure parsing
|
|
67
|
-
- ✅ Text extraction
|
|
68
|
-
- ✅ Button interaction
|
|
69
|
-
- ✅ Browser Speech API integration
|
|
70
|
-
|
|
71
|
-
## 🎉 Success!
|
|
72
|
-
|
|
73
|
-
If you can see the demo and process files, congratulations! You now have a working browser-based AAC processor. This can be used as a template for your own browser applications.
|
|
74
|
-
|
|
75
|
-
See `docs/BROWSER_USAGE.md` for integration guides.
|