Skip to content

Commit 1d25c69

Browse files
committed
inital migration to a sqlite wasm
1 parent 3805fda commit 1d25c69

14 files changed

Lines changed: 432 additions & 82 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ const texts = await snap.extractTexts('board.sps');
3030
Browser-safe entry that avoids Node-only dependencies. It expects `Buffer`,
3131
`Uint8Array`, or `ArrayBuffer` inputs rather than file paths.
3232

33+
SQLite-backed formats (Snap `.sps/.spb` and TouchChat `.ce`) require a WASM
34+
SQLite engine. Configure `sql.js` in your bundler before loading those formats:
35+
36+
```ts
37+
import { configureSqlJs, SnapProcessor } from '@willwade/aac-processors/browser';
38+
39+
configureSqlJs({
40+
locateFile: (file) => new URL(`./${file}`, import.meta.url).toString(),
41+
});
42+
43+
const snap = new SnapProcessor();
44+
const tree = await snap.loadIntoTree(snapUint8Array);
45+
```
46+
3347
```ts
3448
import { GridsetProcessor } from '@willwade/aac-processors/browser';
3549

examples/vitedemo/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A real browser demo that uses Vite to bundle AACProcessors for browser use.
55
## Features
66

77
-**Real file processing** - Upload and process actual AAC files
8-
-**All browser-compatible processors** - Tests Dot, OPML, OBF/OBZ, Gridset, ApplePanels, AstericsGrid
8+
-**All browser-compatible processors** - Tests Dot, OPML, OBF/OBZ, Gridset, Snap, TouchChat, ApplePanels, AstericsGrid
99
-**Interactive UI** - Drag & drop files, view pages and buttons
1010
-**Text-to-speech** - Click SPEAK buttons to hear messages (browser speech API)
1111
-**Navigation** - Click NAVIGATE buttons to jump between pages
@@ -43,7 +43,7 @@ If you need a no-build browser check, use the browser test page served by:
4343
1. **Upload a file**
4444
- Drag & drop an AAC file onto the upload area
4545
- Or click to open file picker
46-
- Supported formats: .dot, .opml, .obf, .obz, .gridset, .plist, .grd
46+
- Supported formats: .dot, .opml, .obf, .obz, .gridset, .sps, .spb, .ce, .plist, .grd
4747

4848
2. **Process the file**
4949
- Click "Process File" button
@@ -57,7 +57,7 @@ If you need a no-build browser check, use the browser test page served by:
5757
4. **Run compatibility tests**
5858
- Click "Run Compatibility Tests"
5959
- See test results in the left panel
60-
- Tests all 6 browser-compatible processors
60+
- Tests all browser-compatible processors
6161

6262
## Supported File Types
6363

@@ -67,6 +67,8 @@ If you need a no-build browser check, use the browser test page served by:
6767
| OPML | .opml | OpmlProcessor |
6868
| OBF/OBZ | .obf, .obz | ObfProcessor |
6969
| Gridset | .gridset | GridsetProcessor |
70+
| Snap | .sps, .spb | SnapProcessor |
71+
| TouchChat| .ce | TouchChatProcessor |
7072
| Apple | .plist | ApplePanelsProcessor |
7173
| Asterics | .grd | AstericsGridProcessor |
7274

@@ -102,10 +104,15 @@ export default defineConfig({
102104

103105
This allows direct TypeScript import without pre-building.
104106

105-
### Import Example
107+
### Import Example (with SQLite WASM)
106108

107109
```typescript
108-
import { getProcessor } from 'aac-processors';
110+
import { configureSqlJs, getProcessor } from 'aac-processors';
111+
import sqlWasmUrl from 'sql.js/dist/sql-wasm.wasm?url';
112+
113+
configureSqlJs({
114+
locateFile: () => sqlWasmUrl
115+
});
109116

110117
// Get processor for file type
111118
const processor = getProcessor('.obf');

examples/vitedemo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,11 @@ <h1>🎯 AAC Processors Browser Demo</h1>
423423
<div class="upload-icon">📤</div>
424424
<p><strong>Drop file here</strong> or click to upload</p>
425425
<p style="font-size: 12px; color: #999; margin-top: 5px;">
426-
Supports: .dot, .opml, .obf, .obz, .gridset, .plist, .grd
426+
Supports: .dot, .opml, .obf, .obz, .gridset, .sps, .spb, .ce, .plist, .grd
427427
</p>
428428
</div>
429429

430-
<input type="file" id="fileInput" accept=".dot,.opml,.obf,.obz,.gridset,.plist,.grd">
430+
<input type="file" id="fileInput" accept=".dot,.opml,.obf,.obz,.gridset,.sps,.spb,.ce,.plist,.grd">
431431

432432
<div id="fileInfo" style="display: none;">
433433
<div class="processor-info">

examples/vitedemo/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/vitedemo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@willwade/aac-processors": "file:../..",
1717
"events": "^3.3.0",
1818
"jszip": "^3.10.1",
19+
"sql.js": "^1.13.0",
1920
"stream-browserify": "^3.0.0",
2021
"timers-browserify": "^2.0.12",
2122
"util": "^0.12.5"

examples/vitedemo/src/main.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,28 @@ if (typeof (window as any).Buffer === 'undefined') {
6666
}
6767

6868
import {
69+
configureSqlJs,
6970
getProcessor,
7071
getSupportedExtensions,
7172
DotProcessor,
7273
OpmlProcessor,
7374
ObfProcessor,
7475
GridsetProcessor,
76+
SnapProcessor,
77+
TouchChatProcessor,
7578
ApplePanelsProcessor,
7679
AstericsGridProcessor,
7780
AACTree,
7881
AACPage,
7982
AACButton
8083
} from 'aac-processors';
8184

85+
import sqlWasmUrl from 'sql.js/dist/sql-wasm.wasm?url';
86+
87+
configureSqlJs({
88+
locateFile: () => sqlWasmUrl
89+
});
90+
8291
// UI Elements
8392
const dropArea = document.getElementById('dropArea') as HTMLElement;
8493
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
@@ -717,19 +726,34 @@ runTestsBtn.addEventListener('click', async () => {
717726
const opmlProc = getProcessor('.opml');
718727
const obfProc = getProcessor('.obf');
719728
const gridsetProc = getProcessor('.gridset');
729+
const snapProc = getProcessor('.sps');
730+
const touchChatProc = getProcessor('.ce');
720731
return (
721732
dotProc instanceof DotProcessor &&
722733
opmlProc instanceof OpmlProcessor &&
723734
obfProc instanceof ObfProcessor &&
724-
gridsetProc instanceof GridsetProcessor
735+
gridsetProc instanceof GridsetProcessor &&
736+
snapProc instanceof SnapProcessor &&
737+
touchChatProc instanceof TouchChatProcessor
725738
);
726739
}
727740
},
728741
{
729742
name: 'getSupportedExtensions() returns all extensions',
730743
fn: async () => {
731744
const extensions = getSupportedExtensions();
732-
const expected = ['.dot', '.opml', '.obf', '.obz', '.gridset', '.plist', '.grd'];
745+
const expected = [
746+
'.dot',
747+
'.opml',
748+
'.obf',
749+
'.obz',
750+
'.gridset',
751+
'.spb',
752+
'.sps',
753+
'.ce',
754+
'.plist',
755+
'.grd'
756+
];
733757
return expected.every((ext) => extensions.includes(ext));
734758
}
735759
},
@@ -777,6 +801,28 @@ runTestsBtn.addEventListener('click', async () => {
777801
}
778802
}
779803
},
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+
},
780826
{
781827
name: 'ApplePanelsProcessor instantiation',
782828
fn: async () => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
"@types/jest": "^29.5.12",
152152
"@types/node": "^20.11.24",
153153
"@types/plist": "^3.0.5",
154+
"@types/sql.js": "^1.4.9",
154155
"@typescript-eslint/eslint-plugin": "^7.1.0",
155156
"@typescript-eslint/parser": "^7.1.0",
156157
"eslint": "^8.56.0",
@@ -174,6 +175,7 @@
174175
"fast-xml-parser": "^5.2.0",
175176
"jszip": "^3.10.1",
176177
"plist": "^3.1.0",
178+
"sql.js": "^1.13.0",
177179
"xml2js": "^0.6.2",
178180
"yauzl": "^3.2.0"
179181
},

0 commit comments

Comments
 (0)