# Mobile DAW — Web Components API

This document is the source-reference companion to [`components.html`](./components.html). The live page imports the actual production components and has editable demonstrations. No `.stem` file or audio engine is needed to browse examples.

## Components

- `<stem-daw-track>`

The host application owns file I/O, codec, playback, state persistence, and other operations unless explicitly noted. Components are native Custom Elements. CSS in component Shadow DOM resolves relative to the module file. The app owns any callback-supplied state.

Primary component source: [`components/track-lane.js`](./components/track-lane.js).

## Public methods and properties

- `stem-daw-track.configure(track,pref,{pixelsPerSecond,duration,selected})`: Render lane controls and timeline; owner supplies per-track preferences
- `stem-daw-track.setPeaks(Float32Array)`: Draw waveform peak data supplied by host
- `stem-daw-track.setPlayhead(seconds)`: Position track playhead
- `stem-daw-track.update(pref,selected)`: Refresh presentation
- `stem-insert-chain.configure(effects,library)`: Render selected effects and available library catalog
- `stem-insert-chain.render()`: Refresh after state changes

## Events and callbacks

- `track-action`: detail: {action,id,...} select/mute/solo/seek/scroll
- `insert-action`: detail: {action,id,param,value} add/remove/up/down/bypass/param

## Example

```javascript
import './components/track-lane.js';
import './components/insert-chain.js';
const lane = document.createElement('stem-daw-track');
lane.configure({id:7}, {name:'Vocals',color:'#e89249',gainDb:0,pan:0,mute:false,solo:false}, {pixelsPerSecond:22,duration:16,selected:true});
lane.addEventListener('track-action',event=>console.log(event.detail));
document.body.append(lane);
const rack=document.createElement('stem-insert-chain');
rack.configure(activeEffects, effectCatalog);
rack.addEventListener('insert-action', event=>console.log(event.detail));
document.body.append(rack);
```

## Testing and limitations

- Catalog data and artworks are synthetic demonstration content; they are not loaded from audio files.
- Changing a property in the catalog reconfigures or remounts the real component so modes can be inspected.
- The catalog's events log is not a replacement for host-state management.
- For production integration, always copy the **entire relevant mini-app folder** with its sibling suite dependencies rather than a partial HTML patch.
