@willwade/aac-processors
    Preparing search index...

    Class SnapProcessor

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    capabilities: {
        newCellCreation: "allowed";
        preservesAssetsOnSave: boolean;
        wordList: "none";
    } = ...

    Methods

    • Add audio recording to a button in the database

      Parameters

      • dbPath: string
      • buttonId: number
      • audioData: Uint8Array
      • Optionalmetadata: string

      Returns Promise<number>

    • Helper method to add extracted strings to the map, handling duplicates

      Parameters

      • extractedMap: Map<string, ExtractedString>

        Map to store extracted strings

      • key: string

        Lowercase key for deduplication

      • originalString: string

        Original string with proper casing

      • vocabLocation: VocabLocation

        Metadata about where the string was found

      Returns void

    • Create a copy of the pageset with audio recordings added

      Parameters

      • sourceDbPath: string
      • targetDbPath: string
      • audioMappings: Map<number, { audioData: Uint8Array; metadata?: string }>

      Returns Promise<void>

    • Extract buttons from a specific page that need audio recordings

      Parameters

      • dbPath: string
      • pageUniqueId: string

      Returns { hasAudio: boolean; id: number; label: string; message: string }[]

    • Get available PageLayouts for a Snap file Useful for UI components that want to let users select layout size

      Parameters

      • filePath: string

        Path to the Snap file

      Returns Promise<PageLayoutInfo[]>

      Promise resolving to available PageLayouts with their dimensions

    • Parameters

      • filePathOrBuffer: ProcessorInput
      • translations: Map<string, string>
      • outputPath: string

      Returns Promise<Uint8Array>

    • Save a modified tree while preserving the original SQLite schema and data.

      Strategy: copy the original .sps verbatim, then open the copy and replay page.pendingMutations as targeted SQL UPDATE/INSERT statements. Everything not in the mutation log (PageLayout, ScanGroup, image blobs, ContentTypeData, ButtonPageLink, etc.) is preserved byte-for-byte from the original.

      This is the asset-preserving counterpart to saveFromTree (which builds a stripped-down DB from scratch and is unsuitable for round-tripping real TD Snap page sets).

      Supported mutations:

      • updateButton(id, patch) → UPDATE Button SET Label/Message WHERE Id = ?
      • removeButton(id) → UPDATE ElementPlacement SET Visible = 0 for all placements pointing at the button's ElementReference
      • addButton(button) → INSERT into ElementReference + Button + one ElementPlacement per existing PageLayout for the target page (so the button shows in every layout the user has). Image/audio not yet handled.

      WordList mutations are no-ops on Snap (capabilities.wordList === 'none').

      Parameters

      • originalPath: string
      • tree: AACTree
      • outputPath: string

      Returns Promise<void>