@@ -8,6 +8,9 @@ import type {
88 TouchChatMetadata ,
99 CellScanningOrder ,
1010 ScanningSelectionMethod ,
11+ AACWordListItem ,
12+ AACPageMutation ,
13+ ProcessorCapabilities ,
1114} from '../types/aac' ;
1215
1316// Re-export for consumers
@@ -20,6 +23,9 @@ export type {
2023 TouchChatMetadata ,
2124 CellScanningOrder ,
2225 ScanningSelectionMethod ,
26+ AACWordListItem ,
27+ AACPageMutation ,
28+ ProcessorCapabilities ,
2329} ;
2430
2531// Semantic action categories for cross-platform compatibility
@@ -414,6 +420,9 @@ export class AACPage {
414420 scanType ?: AACScanType ;
415421 scanBlocksConfig ?: AACScanBlock [ ] ;
416422
423+ // Mutation tracking
424+ private _pendingMutations : AACPageMutation [ ] = [ ] ;
425+
417426 constructor ( {
418427 id,
419428 name = '' ,
@@ -474,6 +483,55 @@ export class AACPage {
474483
475484 addButton ( button : AACButton ) : void {
476485 this . buttons . push ( button ) ;
486+ // Record the mutation
487+ this . _pendingMutations . push ( { type : 'addButton' , button } ) ;
488+ }
489+
490+ /**
491+ * Get the list of pending mutations for this page (read-only)
492+ */
493+ get pendingMutations ( ) : readonly AACPageMutation [ ] {
494+ return Object . freeze ( [ ...this . _pendingMutations ] ) ;
495+ }
496+
497+ /**
498+ * Remove a button by ID
499+ * @param buttonId - The ID of the button to remove
500+ */
501+ removeButton ( buttonId : string ) : void {
502+ this . _pendingMutations . push ( { type : 'removeButton' , buttonId } ) ;
503+ }
504+
505+ /**
506+ * Update a button by merging a patch
507+ * @param buttonId - The ID of the button to update
508+ * @param patch - Partial button object with fields to update
509+ */
510+ updateButton ( buttonId : string , patch : Partial < AACButton > ) : void {
511+ this . _pendingMutations . push ( { type : 'updateButton' , buttonId, patch } ) ;
512+ }
513+
514+ /**
515+ * Add an item to the page's WordList (for formats with dynamic content cells)
516+ * @param item - WordList item to add
517+ */
518+ addWordListItem ( item : AACWordListItem ) : void {
519+ this . _pendingMutations . push ( { type : 'addWordListItem' , item } ) ;
520+ }
521+
522+ /**
523+ * Remove items from the page's WordList
524+ * @param textOrPredicate - Text to match or predicate function to filter items
525+ */
526+ removeWordListItem ( textOrPredicate : string | ( ( item : AACWordListItem ) => boolean ) ) : void {
527+ this . _pendingMutations . push ( { type : 'removeWordListItem' , match : textOrPredicate } ) ;
528+ }
529+
530+ /**
531+ * Clear all items from the page's WordList
532+ */
533+ clearWordList ( ) : void {
534+ this . _pendingMutations . push ( { type : 'clearWordList' } ) ;
477535 }
478536}
479537
0 commit comments