Files
Bose-SoundTouch/pkg/service/soundtouchweb/static/js/components/Sources.js
T
Tobias GesellchenandClaude Sonnet 5 6b2c3b5c7c fix(player): use es-module-shims instead of removing import maps
Restores the import map and bare-specifier imports across all
components, and instead polyfills import map support for Safari on
iPadOS 15 (which has ES modules but not import maps) via
es-module-shims, loaded unconditionally since it detects native
support and no-ops there.

The previous approach converted every component to relative imports
through a dependencies.js facade and permanently sed-patched the
vendored preact-hooks build, baking the compatibility workaround into
the whole codebase instead of keeping it encapsulated in index.html.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-29 17:09:36 +02:00

48 lines
1.8 KiB
JavaScript

import { h } from 'preact';
import htm from 'htm';
import { api } from '../api.js';
const html = htm.bind(h);
const SOURCE_ICONS = {
TUNEIN: '📻', SPOTIFY: '🎵', AMAZON: '🛒', PANDORA: '🎶',
BLUETOOTH: '📶', AUX: '🔌', OPTICAL: '💡', HDMI: '📺',
IHEARTRADIO: '❤️', DEEZER: '🎼', LOCAL_INTERNET_RADIO: '📡',
AIRPLAY: '📡', PRODUCT: '🔊',
};
export function Sources({ deviceId, status }) {
const items = status?.sources?.SourceItem ?? [];
const currentSource = status?.nowPlaying?.Source;
const currentAccount = status?.nowPlaying?.SourceAccount;
const ready = items.filter(s => s.Status === 'READY');
if (ready.length === 0) return null;
function select(src) {
api.selectSource(deviceId, src.Source, src.SourceAccount ?? '');
}
return html`
<div class="sources-section">
<h3 class="section-title">Sources</h3>
<div class="source-list">
${ready.map(src => {
const isActive = src.Source === currentSource &&
(!src.SourceAccount || src.SourceAccount === currentAccount);
return html`
<button
key=${src.Source + (src.SourceAccount || '')}
class="source-btn ${isActive ? 'active' : ''} ${src.IsLocal ? 'local' : ''}"
onClick=${() => select(src)}
title=${src.Source}
>
<span class="source-icon">${SOURCE_ICONS[src.Source] || '🔊'}</span>
<span class="source-name">${src.DisplayName || src.Source}</span>
</button>
`;
})}
</div>
</div>
`;
}