@willwade/aac-processors 0.2.13 → 0.2.14
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/dist/browser/core/treeStructure.js +15 -0
- package/dist/browser/processors/applePanelsProcessor.js +2 -1
- package/dist/browser/processors/astericsGridProcessor.js +2 -1
- package/dist/browser/processors/dotProcessor.js +4 -2
- package/dist/browser/processors/gridsetProcessor.js +2 -2
- package/dist/browser/processors/opmlProcessor.js +2 -1
- package/dist/browser/processors/snapProcessor.js +2 -1
- package/dist/browser/processors/touchchatProcessor.js +3 -3
- package/dist/core/treeStructure.d.ts +11 -0
- package/dist/core/treeStructure.js +15 -0
- package/dist/processors/applePanelsProcessor.js +2 -1
- package/dist/processors/astericsGridProcessor.js +2 -1
- package/dist/processors/dotProcessor.js +4 -2
- package/dist/processors/gridsetProcessor.js +2 -2
- package/dist/processors/opmlProcessor.js +2 -1
- package/dist/processors/snapProcessor.js +2 -1
- package/dist/processors/touchchatProcessor.js +3 -3
- package/package.json +1 -1
|
@@ -201,6 +201,21 @@ export class AACPage {
|
|
|
201
201
|
// Record the mutation
|
|
202
202
|
this._pendingMutations.push({ type: 'addButton', button });
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Internal load-path button push: adds a button to the page WITHOUT recording a mutation.
|
|
206
|
+
* Used by processors during loadIntoTree so the loaded baseline isn't treated as user changes.
|
|
207
|
+
* Not part of the public API — consumers should always use addButton.
|
|
208
|
+
*/
|
|
209
|
+
_loadButton(button) {
|
|
210
|
+
this.buttons.push(button);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Discard all recorded mutations on this page.
|
|
214
|
+
* Useful as an escape hatch after loadIntoTree if the consumer wants a clean baseline.
|
|
215
|
+
*/
|
|
216
|
+
clearMutations() {
|
|
217
|
+
this._pendingMutations = [];
|
|
218
|
+
}
|
|
204
219
|
/**
|
|
205
220
|
* Get the list of pending mutations for this page (read-only)
|
|
206
221
|
*/
|
|
@@ -219,7 +219,8 @@ class ApplePanelsProcessor extends BaseProcessor {
|
|
|
219
219
|
fontWeight: btn.DisplayImageWeight === 'bold' ? 'bold' : 'normal',
|
|
220
220
|
},
|
|
221
221
|
});
|
|
222
|
-
|
|
222
|
+
// Load path: do not record as a user mutation
|
|
223
|
+
page._loadButton(button);
|
|
223
224
|
if (btn.Rect) {
|
|
224
225
|
const rect = this.parseRect(btn.Rect);
|
|
225
226
|
if (rect) {
|
|
@@ -714,7 +714,8 @@ class AstericsGridProcessor extends BaseProcessor {
|
|
|
714
714
|
}
|
|
715
715
|
grid.gridElements.forEach((element) => {
|
|
716
716
|
const button = this.createButtonFromElement(element, colorConfig, activeColorSchemeDefinition);
|
|
717
|
-
|
|
717
|
+
// Load path: do not record as a user mutation
|
|
718
|
+
page._loadButton(button);
|
|
718
719
|
const buttonX = element.x || 0;
|
|
719
720
|
const buttonY = element.y || 0;
|
|
720
721
|
const buttonWidth = element.width || 1;
|
|
@@ -117,7 +117,8 @@ class DotProcessor extends BaseProcessor {
|
|
|
117
117
|
});
|
|
118
118
|
tree.addPage(page);
|
|
119
119
|
// Add a self button so single-node graphs yield one button
|
|
120
|
-
|
|
120
|
+
// Load path: do not record as a user mutation
|
|
121
|
+
page._loadButton(new AACButton({
|
|
121
122
|
id: `${node.id}_self`,
|
|
122
123
|
label: node.label,
|
|
123
124
|
message: node.label,
|
|
@@ -138,7 +139,8 @@ class DotProcessor extends BaseProcessor {
|
|
|
138
139
|
message: '',
|
|
139
140
|
targetPageId: edge.to,
|
|
140
141
|
});
|
|
141
|
-
|
|
142
|
+
// Load path: do not record as a user mutation
|
|
143
|
+
fromPage._loadButton(button);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
return tree;
|
|
@@ -1571,8 +1571,8 @@ class GridsetProcessor extends BaseProcessor {
|
|
|
1571
1571
|
...(imageData ? { imageData, image_id: resolvedImageEntry } : {}),
|
|
1572
1572
|
},
|
|
1573
1573
|
});
|
|
1574
|
-
// Add button to page
|
|
1575
|
-
page.
|
|
1574
|
+
// Add button to page (load path: do not record as a user mutation)
|
|
1575
|
+
page._loadButton(button);
|
|
1576
1576
|
// Place button in grid layout (handle colspan/rowspan)
|
|
1577
1577
|
for (let r = cellY; r < cellY + rowSpan && r < maxRows; r++) {
|
|
1578
1578
|
for (let c = cellX; c < cellX + colSpan && c < maxCols; c++) {
|
|
@@ -42,7 +42,8 @@ class OpmlProcessor extends BaseProcessor {
|
|
|
42
42
|
message: '',
|
|
43
43
|
targetPageId: childText.replace(/[^a-zA-Z0-9]/g, '_'),
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
// Load path: do not record as a user mutation
|
|
46
|
+
page._loadButton(button);
|
|
46
47
|
const { page: childPage, childPages: grandChildren } = this.processOutline(child, page.id);
|
|
47
48
|
if (childPage && childPage.id)
|
|
48
49
|
childPages.push(childPage, ...grandChildren);
|
|
@@ -579,7 +579,8 @@ class SnapProcessor extends BaseProcessor {
|
|
|
579
579
|
// Add to the intended parent page
|
|
580
580
|
const parentPage = tree.getPage(parentUniqueId);
|
|
581
581
|
if (parentPage) {
|
|
582
|
-
|
|
582
|
+
// Load path: do not record as a user mutation
|
|
583
|
+
parentPage._loadButton(button);
|
|
583
584
|
// Add button to grid layout if position data is available
|
|
584
585
|
const gridPositionStr = String(btnRow.GridPosition || '');
|
|
585
586
|
if (gridPositionStr && gridPositionStr.includes(',')) {
|
|
@@ -266,8 +266,8 @@ class TouchChatProcessor extends BaseProcessor {
|
|
|
266
266
|
// Set button's x and y coordinates
|
|
267
267
|
button.x = absoluteX;
|
|
268
268
|
button.y = absoluteY;
|
|
269
|
-
// Add button to page
|
|
270
|
-
page.
|
|
269
|
+
// Add button to page (load path: do not record as a user mutation)
|
|
270
|
+
page._loadButton(button);
|
|
271
271
|
// Place button in grid (handle span)
|
|
272
272
|
for (let r = absoluteY; r < absoluteY + safeSpanY && r < 10; r++) {
|
|
273
273
|
for (let c = absoluteX; c < absoluteX + safeSpanX && c < 10; c++) {
|
|
@@ -368,7 +368,7 @@ class TouchChatProcessor extends BaseProcessor {
|
|
|
368
368
|
// Find the page that references this resource
|
|
369
369
|
const page = Object.values(tree.pages).find((p) => p.id === (numericToRid.get(btnRow.id) || String(btnRow.id)));
|
|
370
370
|
if (page)
|
|
371
|
-
page.
|
|
371
|
+
page._loadButton(button); // load path: do not record as a user mutation
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
374
|
catch (_e) {
|
|
@@ -249,6 +249,17 @@ export declare class AACPage {
|
|
|
249
249
|
scanType?: AACScanType;
|
|
250
250
|
});
|
|
251
251
|
addButton(button: AACButton): void;
|
|
252
|
+
/**
|
|
253
|
+
* Internal load-path button push: adds a button to the page WITHOUT recording a mutation.
|
|
254
|
+
* Used by processors during loadIntoTree so the loaded baseline isn't treated as user changes.
|
|
255
|
+
* Not part of the public API — consumers should always use addButton.
|
|
256
|
+
*/
|
|
257
|
+
_loadButton(button: AACButton): void;
|
|
258
|
+
/**
|
|
259
|
+
* Discard all recorded mutations on this page.
|
|
260
|
+
* Useful as an escape hatch after loadIntoTree if the consumer wants a clean baseline.
|
|
261
|
+
*/
|
|
262
|
+
clearMutations(): void;
|
|
252
263
|
/**
|
|
253
264
|
* Get the list of pending mutations for this page (read-only)
|
|
254
265
|
*/
|
|
@@ -205,6 +205,21 @@ class AACPage {
|
|
|
205
205
|
// Record the mutation
|
|
206
206
|
this._pendingMutations.push({ type: 'addButton', button });
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Internal load-path button push: adds a button to the page WITHOUT recording a mutation.
|
|
210
|
+
* Used by processors during loadIntoTree so the loaded baseline isn't treated as user changes.
|
|
211
|
+
* Not part of the public API — consumers should always use addButton.
|
|
212
|
+
*/
|
|
213
|
+
_loadButton(button) {
|
|
214
|
+
this.buttons.push(button);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Discard all recorded mutations on this page.
|
|
218
|
+
* Useful as an escape hatch after loadIntoTree if the consumer wants a clean baseline.
|
|
219
|
+
*/
|
|
220
|
+
clearMutations() {
|
|
221
|
+
this._pendingMutations = [];
|
|
222
|
+
}
|
|
208
223
|
/**
|
|
209
224
|
* Get the list of pending mutations for this page (read-only)
|
|
210
225
|
*/
|
|
@@ -225,7 +225,8 @@ class ApplePanelsProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
225
225
|
fontWeight: btn.DisplayImageWeight === 'bold' ? 'bold' : 'normal',
|
|
226
226
|
},
|
|
227
227
|
});
|
|
228
|
-
|
|
228
|
+
// Load path: do not record as a user mutation
|
|
229
|
+
page._loadButton(button);
|
|
229
230
|
if (btn.Rect) {
|
|
230
231
|
const rect = this.parseRect(btn.Rect);
|
|
231
232
|
if (rect) {
|
|
@@ -722,7 +722,8 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
722
722
|
}
|
|
723
723
|
grid.gridElements.forEach((element) => {
|
|
724
724
|
const button = this.createButtonFromElement(element, colorConfig, activeColorSchemeDefinition);
|
|
725
|
-
|
|
725
|
+
// Load path: do not record as a user mutation
|
|
726
|
+
page._loadButton(button);
|
|
726
727
|
const buttonX = element.x || 0;
|
|
727
728
|
const buttonY = element.y || 0;
|
|
728
729
|
const buttonWidth = element.width || 1;
|
|
@@ -120,7 +120,8 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
120
120
|
});
|
|
121
121
|
tree.addPage(page);
|
|
122
122
|
// Add a self button so single-node graphs yield one button
|
|
123
|
-
|
|
123
|
+
// Load path: do not record as a user mutation
|
|
124
|
+
page._loadButton(new treeStructure_1.AACButton({
|
|
124
125
|
id: `${node.id}_self`,
|
|
125
126
|
label: node.label,
|
|
126
127
|
message: node.label,
|
|
@@ -141,7 +142,8 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
141
142
|
message: '',
|
|
142
143
|
targetPageId: edge.to,
|
|
143
144
|
});
|
|
144
|
-
|
|
145
|
+
// Load path: do not record as a user mutation
|
|
146
|
+
fromPage._loadButton(button);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return tree;
|
|
@@ -1597,8 +1597,8 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1597
1597
|
...(imageData ? { imageData, image_id: resolvedImageEntry } : {}),
|
|
1598
1598
|
},
|
|
1599
1599
|
});
|
|
1600
|
-
// Add button to page
|
|
1601
|
-
page.
|
|
1600
|
+
// Add button to page (load path: do not record as a user mutation)
|
|
1601
|
+
page._loadButton(button);
|
|
1602
1602
|
// Place button in grid layout (handle colspan/rowspan)
|
|
1603
1603
|
for (let r = cellY; r < cellY + rowSpan && r < maxRows; r++) {
|
|
1604
1604
|
for (let c = cellX; c < cellX + colSpan && c < maxCols; c++) {
|
|
@@ -45,7 +45,8 @@ class OpmlProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
45
45
|
message: '',
|
|
46
46
|
targetPageId: childText.replace(/[^a-zA-Z0-9]/g, '_'),
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
// Load path: do not record as a user mutation
|
|
49
|
+
page._loadButton(button);
|
|
49
50
|
const { page: childPage, childPages: grandChildren } = this.processOutline(child, page.id);
|
|
50
51
|
if (childPage && childPage.id)
|
|
51
52
|
childPages.push(childPage, ...grandChildren);
|
|
@@ -582,7 +582,8 @@ class SnapProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
582
582
|
// Add to the intended parent page
|
|
583
583
|
const parentPage = tree.getPage(parentUniqueId);
|
|
584
584
|
if (parentPage) {
|
|
585
|
-
|
|
585
|
+
// Load path: do not record as a user mutation
|
|
586
|
+
parentPage._loadButton(button);
|
|
586
587
|
// Add button to grid layout if position data is available
|
|
587
588
|
const gridPositionStr = String(btnRow.GridPosition || '');
|
|
588
589
|
if (gridPositionStr && gridPositionStr.includes(',')) {
|
|
@@ -269,8 +269,8 @@ class TouchChatProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
269
269
|
// Set button's x and y coordinates
|
|
270
270
|
button.x = absoluteX;
|
|
271
271
|
button.y = absoluteY;
|
|
272
|
-
// Add button to page
|
|
273
|
-
page.
|
|
272
|
+
// Add button to page (load path: do not record as a user mutation)
|
|
273
|
+
page._loadButton(button);
|
|
274
274
|
// Place button in grid (handle span)
|
|
275
275
|
for (let r = absoluteY; r < absoluteY + safeSpanY && r < 10; r++) {
|
|
276
276
|
for (let c = absoluteX; c < absoluteX + safeSpanX && c < 10; c++) {
|
|
@@ -371,7 +371,7 @@ class TouchChatProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
371
371
|
// Find the page that references this resource
|
|
372
372
|
const page = Object.values(tree.pages).find((p) => p.id === (numericToRid.get(btnRow.id) || String(btnRow.id)));
|
|
373
373
|
if (page)
|
|
374
|
-
page.
|
|
374
|
+
page._loadButton(button); // load path: do not record as a user mutation
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
377
|
catch (_e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
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",
|