refactor: Convert protected methods to private (#2358)

This commit is contained in:
Dermot Duffy
2026-02-19 20:47:59 -08:00
committed by GitHub
parent 529500ed94
commit 0a67df9a25
122 changed files with 815 additions and 829 deletions
+4 -4
View File
@@ -25,11 +25,11 @@ interface AdvancedCameraCardActionHandlerOptions extends ActionHandlerOptions {
class ActionHandler extends HTMLElement implements ActionHandlerInterface { class ActionHandler extends HTMLElement implements ActionHandlerInterface {
public holdTime = 0.4; public holdTime = 0.4;
protected holdTimer = new Timer(); private holdTimer = new Timer();
protected doubleClickTimer = new Timer(); private doubleClickTimer = new Timer();
protected held = false; private held = false;
protected started = false; private started = false;
public connectedCallback(): void { public connectedCallback(): void {
[ [
+5 -5
View File
@@ -3,10 +3,10 @@ import { DateRange, MemoryRangeSet } from './range';
import { RecordingSegment } from './types'; import { RecordingSegment } from './types';
class MemoryRangedCache<Data> { class MemoryRangedCache<Data> {
protected _ranges: MemoryRangeSet = new MemoryRangeSet(); private _ranges: MemoryRangeSet = new MemoryRangeSet();
protected _data: Data[] = []; private _data: Data[] = [];
protected _timeFunc: (data: Data) => number; private _timeFunc: (data: Data) => number;
protected _idFunc: (data: Data) => string; private _idFunc: (data: Data) => string;
constructor(timeFunc: (data: Data) => number, idFunc: (data: Data) => string) { constructor(timeFunc: (data: Data) => number, idFunc: (data: Data) => string) {
this._timeFunc = timeFunc; this._timeFunc = timeFunc;
@@ -60,7 +60,7 @@ class MemoryRangedCache<Data> {
} }
export class RecordingSegmentsCache { export class RecordingSegmentsCache {
protected _segments: Map<string, MemoryRangedCache<RecordingSegment>> = new Map(); private _segments: Map<string, MemoryRangedCache<RecordingSegment>> = new Map();
public add(cameraID: string, range: DateRange, segments: RecordingSegment[]) { public add(cameraID: string, range: DateRange, segments: RecordingSegment[]) {
let cameraSegmentCache: MemoryRangedCache<RecordingSegment> | undefined = let cameraSegmentCache: MemoryRangedCache<RecordingSegment> | undefined =
+1 -1
View File
@@ -28,7 +28,7 @@ export class Capabilities {
} }
} }
protected _disable(capability: CapabilityKey): void { private _disable(capability: CapabilityKey): void {
delete this._capabilities[capability]; delete this._capabilities[capability];
} }
+2 -2
View File
@@ -19,8 +19,8 @@ interface CameraManagerEngineFactoryOptions {
} }
export class CameraManagerEngineFactory { export class CameraManagerEngineFactory {
protected _entityRegistryManager: EntityRegistryManager; private _entityRegistryManager: EntityRegistryManager;
protected _deviceRegistryManager: DeviceRegistryManager; private _deviceRegistryManager: DeviceRegistryManager;
constructor( constructor(
entityRegistryManager: EntityRegistryManager, entityRegistryManager: EntityRegistryManager,
+10 -10
View File
@@ -106,7 +106,7 @@ export class FrigateCamera extends Camera {
return true; return true;
} }
protected async _initializeConfig( private async _initializeConfig(
hass: HomeAssistant, hass: HomeAssistant,
entityRegistryManager: EntityRegistryManager, entityRegistryManager: EntityRegistryManager,
): Promise<void> { ): Promise<void> {
@@ -193,7 +193,7 @@ export class FrigateCamera extends Camera {
}; };
} }
protected _getFrigateCameraNameFromEntity(entity: Entity): string | null { private _getFrigateCameraNameFromEntity(entity: Entity): string | null {
if ( if (
entity.platform === 'frigate' && entity.platform === 'frigate' &&
entity.unique_id && entity.unique_id &&
@@ -244,7 +244,7 @@ export class FrigateCamera extends Camera {
}); });
} }
protected _getJSMPEGEndpoint(): Endpoint | null { private _getJSMPEGEndpoint(): Endpoint | null {
if (!this._config.frigate.camera_name) { if (!this._config.frigate.camera_name) {
return null; return null;
} }
@@ -301,7 +301,7 @@ export class FrigateCamera extends Camera {
return { endpoint: cameraURL }; return { endpoint: cameraURL };
} }
protected async _getPTZCapabilities( private async _getPTZCapabilities(
hass: HomeAssistant, hass: HomeAssistant,
cameraConfig: CameraConfig, cameraConfig: CameraConfig,
): Promise<PTZCapabilities | null> { ): Promise<PTZCapabilities | null> {
@@ -352,7 +352,7 @@ export class FrigateCamera extends Camera {
* @param cameraConfig The camera config in question. * @param cameraConfig The camera config in question.
* @returns The entity id of the motion sensor or null. * @returns The entity id of the motion sensor or null.
*/ */
protected _getMotionSensor( private _getMotionSensor(
cameraConfig: CameraConfig, cameraConfig: CameraConfig,
entities: Entity[], entities: Entity[],
): string | null { ): string | null {
@@ -376,7 +376,7 @@ export class FrigateCamera extends Camera {
* @param cameraConfig The camera config in question. * @param cameraConfig The camera config in question.
* @returns The entity id of the occupancy sensor or null. * @returns The entity id of the occupancy sensor or null.
*/ */
protected _getOccupancySensor( private _getOccupancySensor(
cameraConfig: CameraConfig, cameraConfig: CameraConfig,
entities: Entity[], entities: Entity[],
): string[] | null { ): string[] | null {
@@ -419,7 +419,7 @@ export class FrigateCamera extends Camera {
return null; return null;
} }
protected async _subscribeToEvents( private async _subscribeToEvents(
hass: HomeAssistant, hass: HomeAssistant,
frigateEventWatcher: FrigateWatcherSubscriptionInterface<FrigateEventChange>, frigateEventWatcher: FrigateWatcherSubscriptionInterface<FrigateEventChange>,
): Promise<void> { ): Promise<void> {
@@ -441,7 +441,7 @@ export class FrigateCamera extends Camera {
this._onDestroy(() => frigateEventWatcher.unsubscribe(request)); this._onDestroy(() => frigateEventWatcher.unsubscribe(request));
} }
protected _frigateEventHandler = (ev: FrigateEventChange): void => { private _frigateEventHandler = (ev: FrigateEventChange): void => {
const snapshotChange = const snapshotChange =
(!ev.before.has_snapshot && ev.after.has_snapshot) || (!ev.before.has_snapshot && ev.after.has_snapshot) ||
ev.before.snapshot?.frame_time !== ev.after.snapshot?.frame_time; ev.before.snapshot?.frame_time !== ev.after.snapshot?.frame_time;
@@ -487,7 +487,7 @@ export class FrigateCamera extends Camera {
}); });
}; };
protected async _subscribeToReviews( private async _subscribeToReviews(
hass: HomeAssistant, hass: HomeAssistant,
frigateReviewWatcher: FrigateWatcherSubscriptionInterface<FrigateReviewChange>, frigateReviewWatcher: FrigateWatcherSubscriptionInterface<FrigateReviewChange>,
): Promise<void> { ): Promise<void> {
@@ -512,7 +512,7 @@ export class FrigateCamera extends Camera {
this._onDestroy(() => frigateReviewWatcher.unsubscribe(request)); this._onDestroy(() => frigateReviewWatcher.unsubscribe(request));
} }
protected _frigateReviewHandler = (review: FrigateReviewChange): void => { private _frigateReviewHandler = (review: FrigateReviewChange): void => {
const config = this.getConfig(); const config = this.getConfig();
const cameraID = this._config.id; const cameraID = this._config.id;
+16 -16
View File
@@ -120,14 +120,14 @@ export class FrigateCameraManagerEngine
extends GenericCameraManagerEngine extends GenericCameraManagerEngine
implements CameraManagerEngine implements CameraManagerEngine
{ {
protected _entityRegistryManager: EntityRegistryManager; private _entityRegistryManager: EntityRegistryManager;
protected _frigateEventWatcher: FrigateEventWatcher; private _frigateEventWatcher: FrigateEventWatcher;
protected _frigateReviewWatcher: FrigateReviewWatcher; private _frigateReviewWatcher: FrigateReviewWatcher;
protected _recordingSegmentsCache: RecordingSegmentsCache; private _recordingSegmentsCache: RecordingSegmentsCache;
protected _requestCache: CameraManagerRequestCache; private _requestCache: CameraManagerRequestCache;
// Garbage collect segments at most once an hour. // Garbage collect segments at most once an hour.
protected _throttledSegmentGarbageCollector = throttle( private _throttledSegmentGarbageCollector = throttle(
this._garbageCollectSegments.bind(this), this._garbageCollectSegments.bind(this),
60 * 60 * 1000, 60 * 60 * 1000,
{ leading: false, trailing: true }, { leading: false, trailing: true },
@@ -272,17 +272,17 @@ export class FrigateCameraManagerEngine
* If all cameras have identical zones/labels config, creates a single batch query. * If all cameras have identical zones/labels config, creates a single batch query.
* Otherwise fans out to per-camera queries. * Otherwise fans out to per-camera queries.
*/ */
protected _generateBatchableQuery( private _generateBatchableQuery(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>, cameraIDs: Set<string>,
query: PartialEventQuery & { type: QueryType.Event }, query: PartialEventQuery & { type: QueryType.Event },
): EventQuery[] | null; ): EventQuery[] | null;
protected _generateBatchableQuery( private _generateBatchableQuery(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>, cameraIDs: Set<string>,
query: PartialReviewQuery & { type: QueryType.Review }, query: PartialReviewQuery & { type: QueryType.Review },
): ReviewQuery[] | null; ): ReviewQuery[] | null;
protected _generateBatchableQuery( private _generateBatchableQuery(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>, cameraIDs: Set<string>,
query: (PartialEventQuery | PartialReviewQuery) & { query: (PartialEventQuery | PartialReviewQuery) & {
@@ -368,7 +368,7 @@ export class FrigateCameraManagerEngine
); );
} }
protected _buildInstanceToCameraIDMapFromQuery( private _buildInstanceToCameraIDMapFromQuery(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>, cameraIDs: Set<string>,
): Map<string, Set<string>> { ): Map<string, Set<string>> {
@@ -386,7 +386,7 @@ export class FrigateCameraManagerEngine
return output; return output;
} }
protected _getFrigateCameraNamesForCameraIDs( private _getFrigateCameraNamesForCameraIDs(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>, cameraIDs: Set<string>,
): Set<string> { ): Set<string> {
@@ -725,7 +725,7 @@ export class FrigateCameraManagerEngine
return output.size ? output : null; return output.size ? output : null;
} }
protected _getCameraIDMatch( private _getCameraIDMatch(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
query: CameraQuery, query: CameraQuery,
instanceID: string, instanceID: string,
@@ -927,7 +927,7 @@ export class FrigateCameraManagerEngine
return null; return null;
} }
protected _getQueryableCameraConfig( private _getQueryableCameraConfig(
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraID: string, cameraID: string,
): CameraConfig | null { ): CameraConfig | null {
@@ -938,7 +938,7 @@ export class FrigateCameraManagerEngine
return cameraConfig; return cameraConfig;
} }
protected _splitSubLabels(input: string): string[] { private _splitSubLabels(input: string): string[] {
// A note on Frigate sub_labels: As of Frigate v0.12 sub_labels is a string // A note on Frigate sub_labels: As of Frigate v0.12 sub_labels is a string
// (not an array) per event, but may contain comma-separated values (e.g. // (not an array) per event, but may contain comma-separated values (e.g.
// double-take (https://github.com/jakowenko/double-take) identifying two // double-take (https://github.com/jakowenko/double-take) identifying two
@@ -1058,7 +1058,7 @@ export class FrigateCameraManagerEngine
* Garbage collect recording segments that no longer feature in the recordings * Garbage collect recording segments that no longer feature in the recordings
* returned by the Frigate backend. * returned by the Frigate backend.
*/ */
protected async _garbageCollectSegments( private async _garbageCollectSegments(
hass: HomeAssistant, hass: HomeAssistant,
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
): Promise<void> { ): Promise<void> {
@@ -1113,7 +1113,7 @@ export class FrigateCameraManagerEngine
* @param segments An array of segments dataset items. Must be sorted from oldest to youngest. * @param segments An array of segments dataset items. Must be sorted from oldest to youngest.
* @returns * @returns
*/ */
protected _getSeekTimeInSegments( private _getSeekTimeInSegments(
startTime: Date, startTime: Date,
targetTime: Date, targetTime: Date,
segments: RecordingSegment[], segments: RecordingSegment[],
+12 -12
View File
@@ -25,10 +25,10 @@ import {
} from './util'; } from './util';
export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia { export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia {
protected _event: FrigateEvent; private _event: FrigateEvent;
protected _contentID: string; private _contentID: string;
protected _thumbnail: string; private _thumbnail: string;
protected _subLabels: string[] | null; private _subLabels: string[] | null;
constructor( constructor(
mediaType: ViewMediaType, mediaType: ViewMediaType,
@@ -107,10 +107,10 @@ export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia {
} }
export class FrigateRecordingViewMedia extends ViewMedia implements RecordingViewMedia { export class FrigateRecordingViewMedia extends ViewMedia implements RecordingViewMedia {
protected _recording: FrigateRecording; private _recording: FrigateRecording;
protected _id: string; private _id: string;
protected _contentID: string; private _contentID: string;
protected _title: string; private _title: string;
constructor( constructor(
mediaType: ViewMediaType, mediaType: ViewMediaType,
@@ -156,10 +156,10 @@ export class FrigateRecordingViewMedia extends ViewMedia implements RecordingVie
} }
export class FrigateReviewViewMedia extends ViewMedia implements ReviewViewMedia { export class FrigateReviewViewMedia extends ViewMedia implements ReviewViewMedia {
protected _review: FrigateReview; private _review: FrigateReview;
protected _contentID: string; private _contentID: string;
protected _thumbnail: string | null; private _thumbnail: string | null;
protected _title: string; private _title: string;
constructor( constructor(
cameraID: string, cameraID: string,
+10 -10
View File
@@ -129,10 +129,10 @@ interface ExtendedMediaQueryResult<T extends MediaQuery> {
} }
export class CameraManager { export class CameraManager {
protected _api: CardCameraAPI; private _api: CardCameraAPI;
protected _engineFactory: CameraManagerEngineFactory; private _engineFactory: CameraManagerEngineFactory;
protected _store: CameraManagerStore; private _store: CameraManagerStore;
protected _requestLimit = new PQueue(); private _requestLimit = new PQueue();
constructor( constructor(
api: CardCameraAPI, api: CardCameraAPI,
@@ -185,7 +185,7 @@ export class CameraManager {
await this._store.reset(); await this._store.reset();
} }
protected async _getEnginesForCameras( private async _getEnginesForCameras(
camerasConfig: CameraConfig[], camerasConfig: CameraConfig[],
): Promise<Map<CameraConfig, CameraManagerEngine>> { ): Promise<Map<CameraConfig, CameraManagerEngine>> {
const output: Map<CameraConfig, CameraManagerEngine> = new Map(); const output: Map<CameraConfig, CameraManagerEngine> = new Map();
@@ -228,7 +228,7 @@ export class CameraManager {
return output; return output;
} }
protected async _initializeCameras(camerasConfig: CameraConfig[]): Promise<void> { private async _initializeCameras(camerasConfig: CameraConfig[]): Promise<void> {
const initializationStartTime = new Date(); const initializationStartTime = new Date();
const hass = this._api.getHASSManager().getHASS(); const hass = this._api.getHASSManager().getHASS();
@@ -364,7 +364,7 @@ export class CameraManager {
}); });
} }
protected _generateDefaultQueries<PQT extends PartialCameraQuery>( private _generateDefaultQueries<PQT extends PartialCameraQuery>(
cameraIDs: string | Set<string>, cameraIDs: string | Set<string>,
partialQuery: PQT, partialQuery: PQT,
): PartialQueryConcreteType<PQT>[] | null { ): PartialQueryConcreteType<PQT>[] | null {
@@ -481,7 +481,7 @@ export class CameraManager {
* properties (other than cameraIDs). This preserves multi-camera batching for * properties (other than cameraIDs). This preserves multi-camera batching for
* engines like Frigate that support querying multiple cameras at once. * engines like Frigate that support querying multiple cameras at once.
*/ */
protected _mergeCompatibleQueries<T extends CameraQuery>(queries: T[]): T[] { private _mergeCompatibleQueries<T extends CameraQuery>(queries: T[]): T[] {
if (queries.length <= 1) { if (queries.length <= 1) {
return queries; return queries;
} }
@@ -720,7 +720,7 @@ export class CameraManager {
); );
} }
protected async _handleQuery<QT extends CameraQuery>( private async _handleQuery<QT extends CameraQuery>(
query: QT | QT[], query: QT | QT[],
engineOptions?: EngineOptions, engineOptions?: EngineOptions,
): Promise<Map<QT, QueryReturnType<QT>>> { ): Promise<Map<QT, QueryReturnType<QT>>> {
@@ -821,7 +821,7 @@ export class CameraManager {
return results; return results;
} }
protected _convertQueryResultsToMedia<QT extends CameraQuery>( private _convertQueryResultsToMedia<QT extends CameraQuery>(
results: ResultsMap<QT>, results: ResultsMap<QT>,
): ViewMedia[] { ): ViewMedia[] {
const mediaArray: ViewMedia[] = []; const mediaArray: ViewMedia[] = [];
@@ -60,8 +60,8 @@ const MOTIONEYE_REPL_SUBSTITUTIONS: Record<string, string> = {
const MOTIONEYE_REPL_REGEXP = new RegExp(/(%Y|%m|%d|%H|%M|%S)/g); const MOTIONEYE_REPL_REGEXP = new RegExp(/(%Y|%m|%d|%H|%M|%S)/g);
export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine { export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine {
protected _directoryCache = new BrowseMediaCache<BrowseMediaMetadata>(); private _directoryCache = new BrowseMediaCache<BrowseMediaMetadata>();
protected _fileCache = new BrowseMediaCache<BrowseMediaMetadata>(); private _fileCache = new BrowseMediaCache<BrowseMediaMetadata>();
public getEngineType(): Engine { public getEngineType(): Engine {
return Engine.MotionEye; return Engine.MotionEye;
@@ -81,7 +81,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine
}); });
} }
protected _convertMotionEyeTimeFormatToDateFNS(part: string): string { private _convertMotionEyeTimeFormatToDateFNS(part: string): string {
return part.replace( return part.replace(
MOTIONEYE_REPL_REGEXP, MOTIONEYE_REPL_REGEXP,
(_, key) => MOTIONEYE_REPL_SUBSTITUTIONS[key], (_, key) => MOTIONEYE_REPL_SUBSTITUTIONS[key],
@@ -89,7 +89,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine
} }
// Get metadata for a MotionEye media file. // Get metadata for a MotionEye media file.
protected _motionEyeMetadataGeneratorFile( private _motionEyeMetadataGeneratorFile(
cameraID: string, cameraID: string,
dateFormat: string | null, dateFormat: string | null,
media: BrowseMedia, media: BrowseMedia,
@@ -112,7 +112,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine
} }
// Get metadata for a MotionEye media directory. // Get metadata for a MotionEye media directory.
protected _motionEyeMetadataGeneratorDirectory( private _motionEyeMetadataGeneratorDirectory(
cameraID: string, cameraID: string,
dateFormat: string | null, dateFormat: string | null,
media: BrowseMedia, media: BrowseMedia,
@@ -134,7 +134,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine
} }
// Get media directories that match a given criteria. // Get media directories that match a given criteria.
protected async _getMatchingDirectories( private async _getMatchingDirectories(
hass: HomeAssistant, hass: HomeAssistant,
store: CameraManagerReadOnlyConfigStore, store: CameraManagerReadOnlyConfigStore,
cameraID: string, cameraID: string,
+3 -3
View File
@@ -15,7 +15,7 @@ interface MemoryRangeSetInterface<T> {
} }
export class MemoryRangeSet implements MemoryRangeSetInterface<DateRange> { export class MemoryRangeSet implements MemoryRangeSetInterface<DateRange> {
protected _ranges: DateRange[]; private _ranges: DateRange[];
constructor(ranges?: DateRange[]) { constructor(ranges?: DateRange[]) {
this._ranges = ranges ?? []; this._ranges = ranges ?? [];
@@ -44,7 +44,7 @@ export interface ExpiringRange<T extends Date | number> extends Range<T> {
export class ExpiringMemoryRangeSet export class ExpiringMemoryRangeSet
implements MemoryRangeSetInterface<ExpiringRange<Date>> implements MemoryRangeSetInterface<ExpiringRange<Date>>
{ {
protected _ranges: ExpiringRange<Date>[]; private _ranges: ExpiringRange<Date>[];
constructor(ranges?: ExpiringRange<Date>[]) { constructor(ranges?: ExpiringRange<Date>[]) {
this._ranges = ranges ?? []; this._ranges = ranges ?? [];
@@ -63,7 +63,7 @@ export class ExpiringMemoryRangeSet
this._expireOldRanges(); this._expireOldRanges();
} }
protected _expireOldRanges(): void { private _expireOldRanges(): void {
const now = new Date(); const now = new Date();
this._ranges = this._ranges.filter((range) => now < range.expires); this._ranges = this._ranges.filter((range) => now < range.expires);
} }
+9 -9
View File
@@ -41,16 +41,16 @@ type PTZEntity = keyof PTZEntities;
export class ReolinkCamera extends EntityCamera { export class ReolinkCamera extends EntityCamera {
// The HostID identifying the camera or NVR. // The HostID identifying the camera or NVR.
protected _reolinkHostID: string | null = null; private _reolinkHostID: string | null = null;
// For NVRs, the Camera UID. // For NVRs, the Camera UID.
protected _reolinkCameraUID: string | null = null; private _reolinkCameraUID: string | null = null;
// The channel number as used by the Reolink integration. // The channel number as used by the Reolink integration.
protected _reolinkChannel: number | null = null; private _reolinkChannel: number | null = null;
// Entities used for PTZ control. // Entities used for PTZ control.
protected _ptzEntities: PTZEntities | null = null; private _ptzEntities: PTZEntities | null = null;
/** /**
* Reolink cameras require additional options not present in the base class * Reolink cameras require additional options not present in the base class
@@ -62,7 +62,7 @@ export class ReolinkCamera extends EntityCamera {
return super.initialize(options); return super.initialize(options);
} }
protected async _getChannelFromConfigurationURL( private async _getChannelFromConfigurationURL(
hass: HomeAssistant, hass: HomeAssistant,
deviceRegistryManager: DeviceRegistryManager, deviceRegistryManager: DeviceRegistryManager,
): Promise<number | null> { ): Promise<number | null> {
@@ -84,7 +84,7 @@ export class ReolinkCamera extends EntityCamera {
} }
} }
protected async _initializeChannel( private async _initializeChannel(
hass: HomeAssistant, hass: HomeAssistant,
deviceRegistryManager: DeviceRegistryManager, deviceRegistryManager: DeviceRegistryManager,
): Promise<void> { ): Promise<void> {
@@ -169,7 +169,7 @@ export class ReolinkCamera extends EntityCamera {
}; };
} }
protected _entitiesToCapabilities( private _entitiesToCapabilities(
hass: HomeAssistant, hass: HomeAssistant,
ptzEntities: PTZEntities, ptzEntities: PTZEntities,
): PTZCapabilities | null { ): PTZCapabilities | null {
@@ -203,7 +203,7 @@ export class ReolinkCamera extends EntityCamera {
return Object.keys(reolinkPTZCapabilities).length ? reolinkPTZCapabilities : null; return Object.keys(reolinkPTZCapabilities).length ? reolinkPTZCapabilities : null;
} }
protected async _getPTZEntities( private async _getPTZEntities(
hass: HomeAssistant, hass: HomeAssistant,
entityRegistry: EntityRegistryManager, entityRegistry: EntityRegistryManager,
): Promise<PTZEntities | null> { ): Promise<PTZEntities | null> {
@@ -264,7 +264,7 @@ export class ReolinkCamera extends EntityCamera {
return this._reolinkChannel; return this._reolinkChannel;
} }
protected _getPTZEntityUniqueIDPrefix(): string { private _getPTZEntityUniqueIDPrefix(): string {
return `${this._reolinkHostID}_${this._reolinkCameraUID ?? this._reolinkChannel}_`; return `${this._reolinkHostID}_${this._reolinkCameraUID ?? this._reolinkChannel}_`;
} }
+7 -7
View File
@@ -53,9 +53,9 @@ export class ReolinkQueryResultsClassifier {
} }
export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
protected _camerasCache = new BrowseMediaCache<BrowseMediaReolinkCameraMetadata>(); private _camerasCache = new BrowseMediaCache<BrowseMediaReolinkCameraMetadata>();
protected _cache = new BrowseMediaCache<BrowseMediaMetadata>(); private _cache = new BrowseMediaCache<BrowseMediaMetadata>();
protected _deviceRegistryManager: DeviceRegistryManager; private _deviceRegistryManager: DeviceRegistryManager;
public constructor( public constructor(
entityRegistryManager: EntityRegistryManager, entityRegistryManager: EntityRegistryManager,
@@ -81,7 +81,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
return Engine.Reolink; return Engine.Reolink;
} }
protected _reolinkFileMetadataGenerator( private _reolinkFileMetadataGenerator(
cameraID: string, cameraID: string,
media: BrowseMedia, media: BrowseMedia,
parent?: RichBrowseMedia<BrowseMediaMetadata>, parent?: RichBrowseMedia<BrowseMediaMetadata>,
@@ -133,7 +133,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
}; };
} }
protected _reolinkDirectoryMetadataGenerator( private _reolinkDirectoryMetadataGenerator(
cameraID: string, cameraID: string,
media: BrowseMedia, media: BrowseMedia,
): BrowseMediaMetadata | null { ): BrowseMediaMetadata | null {
@@ -149,7 +149,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
: null; : null;
} }
protected _reolinkCameraMetadataGenerator( private _reolinkCameraMetadataGenerator(
media: BrowseMedia, media: BrowseMedia,
): BrowseMediaReolinkCameraMetadata | null { ): BrowseMediaReolinkCameraMetadata | null {
// Example: "media-source://reolink/CAM|01J8XHYTNH77WE3C654K03KX1F|0" // Example: "media-source://reolink/CAM|01J8XHYTNH77WE3C654K03KX1F|0"
@@ -179,7 +179,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
}); });
} }
protected async _getMatchingDirectories( private async _getMatchingDirectories(
hass: HomeAssistant, hass: HomeAssistant,
camera: ReolinkCamera, camera: ReolinkCamera,
matchOptions?: { matchOptions?: {
+2 -2
View File
@@ -38,8 +38,8 @@ export interface CameraManagerReadOnlyConfigStore {
} }
export class CameraManagerStore implements CameraManagerReadOnlyConfigStore { export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
protected _cameras: Map<string, Camera> = new Map(); private _cameras: Map<string, Camera> = new Map();
protected _enginesByType: Map<Engine, CameraManagerEngine> = new Map(); private _enginesByType: Map<Engine, CameraManagerEngine> = new Map();
public addCamera(camera: Camera): void { public addCamera(camera: Camera): void {
this._cameras.set(camera.getID(), camera); this._cameras.set(camera.getID(), camera);
+3 -3
View File
@@ -17,7 +17,7 @@ interface PTZEntities {
type PTZEntity = keyof PTZEntities; type PTZEntity = keyof PTZEntities;
export class TPLinkCamera extends EntityCamera { export class TPLinkCamera extends EntityCamera {
protected _ptzEntities: PTZEntities | null = null; private _ptzEntities: PTZEntities | null = null;
protected async _initialize( protected async _initialize(
options: TPLinkCameraInitializationOptions, options: TPLinkCameraInitializationOptions,
@@ -45,7 +45,7 @@ export class TPLinkCamera extends EntityCamera {
}; };
} }
protected async _getPTZEntities( private async _getPTZEntities(
hass: HomeAssistant, hass: HomeAssistant,
entityRegistry: EntityRegistryManager, entityRegistry: EntityRegistryManager,
): Promise<PTZEntities | null> { ): Promise<PTZEntities | null> {
@@ -82,7 +82,7 @@ export class TPLinkCamera extends EntityCamera {
return Object.keys(ptzEntities).length ? ptzEntities : null; return Object.keys(ptzEntities).length ? ptzEntities : null;
} }
protected _entitiesToCapabilities(ptzEntities: PTZEntities): PTZCapabilities { private _entitiesToCapabilities(ptzEntities: PTZEntities): PTZCapabilities {
const tplinkPTZCapabilities: PTZCapabilities = {}; const tplinkPTZCapabilities: PTZCapabilities = {};
// TPLink buttons perform relative movements (no stop button needed) // TPLink buttons perform relative movements (no stop button needed)
for (const key of Object.keys(ptzEntities) as PTZEntity[]) { for (const key of Object.keys(ptzEntities) as PTZEntity[]) {
+1 -1
View File
@@ -8,7 +8,7 @@ import { CameraEventCallback, CameraManagerCameraMetadata, Engine } from '../typ
import { TPLinkCamera } from './camera'; import { TPLinkCamera } from './camera';
export class TPLinkCameraManagerEngine extends GenericCameraManagerEngine { export class TPLinkCameraManagerEngine extends GenericCameraManagerEngine {
protected _entityRegistryManager: EntityRegistryManager; private _entityRegistryManager: EntityRegistryManager;
constructor( constructor(
entityRegistryManager: EntityRegistryManager, entityRegistryManager: EntityRegistryManager,
@@ -29,10 +29,10 @@ const interactionEventSchema = z.object({
}); });
export class ActionsManager implements ActionsExecutor { export class ActionsManager implements ActionsExecutor {
protected _api: CardActionsManagerAPI; private _api: CardActionsManagerAPI;
protected _actionsInFlight: ActionSet[] = []; private _actionsInFlight: ActionSet[] = [];
protected _actionContext: ActionContext = {}; private _actionContext: ActionContext = {};
protected _templateRenderer: TemplateRenderer | null; private _templateRenderer: TemplateRenderer | null;
constructor(api: CardActionsManagerAPI, templateRenderer?: TemplateRenderer) { constructor(api: CardActionsManagerAPI, templateRenderer?: TemplateRenderer) {
this._api = api; this._api = api;
@@ -29,9 +29,9 @@ declare module 'action' {
} }
export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialActionConfig> { export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialActionConfig> {
protected _timer = new Timer(); private _timer = new Timer();
protected async _stepChange(api: CardActionsAPI, targetID: string): Promise<void> { private async _stepChange(api: CardActionsAPI, targetID: string): Promise<void> {
api.getViewManager().setViewWithMergedContext( api.getViewManager().setViewWithMergedContext(
generateViewContextForZoom(targetID, { generateViewContextForZoom(targetID, {
requested: this._convertActionToZoomSettings( requested: this._convertActionToZoomSettings(
@@ -80,9 +80,7 @@ export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialAction
} }
} }
protected _convertActionToZoomSettings( private _convertActionToZoomSettings(base?: PartialZoomSettings): PartialZoomSettings {
base?: PartialZoomSettings,
): PartialZoomSettings {
if (!this._action.absolute && !this._action.ptz_action) { if (!this._action.absolute && !this._action.ptz_action) {
// If neither an absolute position nor an action are specified, the request // If neither an absolute position nor an action are specified, the request
// is assumed to be to return to default. // is assumed to be to return to default.
@@ -33,7 +33,7 @@ export class PTZMultiAction extends AdvancedCameraCardAction<PTZMultiActionConfi
).execute(api); ).execute(api);
} }
protected _toPTZAction(targetID: string): PTZAction { private _toPTZAction(targetID: string): PTZAction {
return new PTZAction( return new PTZAction(
this._context, this._context,
createPTZAction({ createPTZAction({
@@ -47,7 +47,7 @@ export class PTZMultiAction extends AdvancedCameraCardAction<PTZMultiActionConfi
); );
} }
protected _toPTZDigitalAction(targetID: string): PTZDigitalAction { private _toPTZDigitalAction(targetID: string): PTZDigitalAction {
return new PTZDigitalAction( return new PTZDigitalAction(
this._context, this._context,
createPTZDigitalAction({ createPTZDigitalAction({
+2 -2
View File
@@ -22,8 +22,8 @@ declare module 'action' {
} }
export class PTZAction extends AdvancedCameraCardAction<PTZActionConfig> { export class PTZAction extends AdvancedCameraCardAction<PTZActionConfig> {
protected _timer = new Timer(); private _timer = new Timer();
protected _stopped = false; private _stopped = false;
public async stop(): Promise<void> { public async stop(): Promise<void> {
this._stopped = true; this._stopped = true;
+4 -4
View File
@@ -9,10 +9,10 @@ import { ActionFactory } from '../factory';
import { Action } from '../types'; import { Action } from '../types';
export class ActionSet implements Action { export class ActionSet implements Action {
protected _context: ActionContext; private _context: ActionContext;
protected _actions: Action[] = []; private _actions: Action[] = [];
protected _factory = new ActionFactory(); private _factory = new ActionFactory();
protected _stopped = false; private _stopped = false;
constructor( constructor(
context: ActionContext, context: ActionContext,
+4 -4
View File
@@ -7,13 +7,13 @@ import { CardAutomationsAPI, TaggedAutomation } from './types.js';
const MAX_NESTED_AUTOMATION_EXECUTIONS = 10; const MAX_NESTED_AUTOMATION_EXECUTIONS = 10;
export class AutomationsManager { export class AutomationsManager {
protected _api: CardAutomationsAPI; private _api: CardAutomationsAPI;
protected _automations = new Map<TaggedAutomation, ConditionsManager>(); private _automations = new Map<TaggedAutomation, ConditionsManager>();
// A counter to avoid infinite loops, increases every time actions are run, // A counter to avoid infinite loops, increases every time actions are run,
// decreases every time actions are complete. // decreases every time actions are complete.
protected _nestedAutomationExecutions = 0; private _nestedAutomationExecutions = 0;
constructor(api: CardAutomationsAPI) { constructor(api: CardAutomationsAPI) {
this._api = api; this._api = api;
@@ -41,7 +41,7 @@ export class AutomationsManager {
} }
} }
protected _execute(automation: Automation, result: ConditionsEvaluationResult): void { private _execute(automation: Automation, result: ConditionsEvaluationResult): void {
if ( if (
!this._api.getHASSManager().hasHASS() || !this._api.getHASSManager().hasHASS() ||
// Never execute automations if the card hasn't finished initializing, as // Never execute automations if the card hasn't finished initializing, as
+1 -1
View File
@@ -2,7 +2,7 @@ import { ViewItemClassifier } from '../view/item-classifier';
import { CardCameraURLAPI } from './types'; import { CardCameraURLAPI } from './types';
export class CameraURLManager { export class CameraURLManager {
protected _api: CardCameraURLAPI; private _api: CardCameraURLAPI;
constructor(api: CardCameraURLAPI) { constructor(api: CardCameraURLAPI) {
this._api = api; this._api = api;
+5 -5
View File
@@ -19,11 +19,11 @@ export type CardHTMLElement = LitElement &
CardMediaReviewEventTarget; CardMediaReviewEventTarget;
export class CardElementManager { export class CardElementManager {
protected _api: CardElementAPI; private _api: CardElementAPI;
protected _element: CardHTMLElement; private _element: CardHTMLElement;
protected _scrollCallback: ScrollCallback; private _scrollCallback: ScrollCallback;
protected _menuToggleCallback: MenuToggleCallback; private _menuToggleCallback: MenuToggleCallback;
constructor( constructor(
api: CardElementAPI, api: CardElementAPI,
@@ -220,7 +220,7 @@ export class CardElementManager {
); );
} }
protected _handleMediaReviewed = (ev: CustomEvent<ViewItem>): void => { private _handleMediaReviewed = (ev: CustomEvent<ViewItem>): void => {
// If the selected media item has a change of review status, update the card // If the selected media item has a change of review status, update the card
// (e.g. for the menu). // (e.g. for the menu).
if ( if (
+9 -11
View File
@@ -18,19 +18,17 @@ import { setKeyboardShortcutsFromConfig } from './load-keyboard-shortcuts.js';
import { OverridesManager } from './overrides-manager.js'; import { OverridesManager } from './overrides-manager.js';
export class ConfigManager { export class ConfigManager {
protected _api: CardConfigAPI; private _api: CardConfigAPI;
// The main base configuration object. For most usecases use getConfig() to // The main base configuration object. For most usecases use getConfig() to
// get the correct configuration (which will return overrides as appropriate). // get the correct configuration (which will return overrides as appropriate).
// This variable must be called `_config` or `config` to be compatible with // This variable must be called `_config` or `config` to be compatible with
// card-mod. // card-mod.
protected _config: AdvancedCameraCardConfig | null = null; private _config: AdvancedCameraCardConfig | null = null;
protected _overriddenConfig: AdvancedCameraCardConfig | null = null; private _overriddenConfig: AdvancedCameraCardConfig | null = null;
protected _rawConfig: RawAdvancedCameraCardConfig | null = null; private _rawConfig: RawAdvancedCameraCardConfig | null = null;
protected _cardWideConfig: CardWideConfig | null = null; private _cardWideConfig: CardWideConfig | null = null;
protected _overridesManager = new OverridesManager(() => private _overridesManager = new OverridesManager(() => this._processOverrideConfig());
this._processOverrideConfig(),
);
constructor(api: CardConfigAPI) { constructor(api: CardConfigAPI) {
this._api = api; this._api = api;
@@ -123,7 +121,7 @@ export class ConfigManager {
this._api.getCardElementManager().update(); this._api.getCardElementManager().update();
} }
protected _processOverrideConfig(): void { private _processOverrideConfig(): void {
const overriddenConfig = this._getOverriddenConfig(); const overriddenConfig = this._getOverriddenConfig();
// Save on Lit re-rendering costs by only updating the configuration if it // Save on Lit re-rendering costs by only updating the configuration if it
@@ -168,7 +166,7 @@ export class ConfigManager {
/* async */ this._initializeBackgroundAndUpdate(previousConfig); /* async */ this._initializeBackgroundAndUpdate(previousConfig);
} }
protected _getOverriddenConfig(): AdvancedCameraCardConfig | null { private _getOverriddenConfig(): AdvancedCameraCardConfig | null {
/* istanbul ignore if: No (current) way to reach this code -- @preserve */ /* istanbul ignore if: No (current) way to reach this code -- @preserve */
if (!this._config) { if (!this._config) {
return null; return null;
@@ -186,7 +184,7 @@ export class ConfigManager {
* Initialize config dependent items in the background. For items that the * Initialize config dependent items in the background. For items that the
* card hard requires, use InitializationManager instead. * card hard requires, use InitializationManager instead.
*/ */
protected async _initializeBackgroundAndUpdate( private async _initializeBackgroundAndUpdate(
previousConfig: AdvancedCameraCardConfig | null, previousConfig: AdvancedCameraCardConfig | null,
): Promise<void> { ): Promise<void> {
await this._api.getDefaultManager().initializeIfNecessary(previousConfig); await this._api.getDefaultManager().initializeIfNecessary(previousConfig);
+30 -30
View File
@@ -94,41 +94,41 @@ export class CardController
CardViewAPI, CardViewAPI,
ReactiveController ReactiveController
{ {
protected _conditionStateManager = new ConditionStateManager(); private _conditionStateManager = new ConditionStateManager();
protected _effectsManager = new EffectsManager(); private _effectsManager = new EffectsManager();
// These properties may be used in the construction of 'managers' (and should // These properties may be used in the construction of 'managers' (and should
// be created first). // be created first).
protected _deviceRegistryManager = new DeviceRegistryManager(new DeviceCache()); private _deviceRegistryManager = new DeviceRegistryManager(new DeviceCache());
protected _entityRegistryManager = new EntityRegistryManagerLive(new EntityCache()); private _entityRegistryManager = new EntityRegistryManagerLive(new EntityCache());
protected _resolvedMediaCache = new ResolvedMediaCache(); private _resolvedMediaCache = new ResolvedMediaCache();
protected _actionsManager = new ActionsManager(this, new TemplateRenderer()); private _actionsManager = new ActionsManager(this, new TemplateRenderer());
protected _automationsManager = new AutomationsManager(this); private _automationsManager = new AutomationsManager(this);
protected _cameraManager = new CameraManager(this); private _cameraManager = new CameraManager(this);
protected _cameraURLManager = new CameraURLManager(this); private _cameraURLManager = new CameraURLManager(this);
protected _cardElementManager: CardElementManager; private _cardElementManager: CardElementManager;
protected _configManager = new ConfigManager(this); private _configManager = new ConfigManager(this);
protected _defaultManager = new DefaultManager(this); private _defaultManager = new DefaultManager(this);
protected _expandManager = new ExpandManager(this); private _expandManager = new ExpandManager(this);
protected _foldersManager = new FoldersManager(this); private _foldersManager = new FoldersManager(this);
protected _fullscreenManager = new FullscreenManager(this); private _fullscreenManager = new FullscreenManager(this);
protected _hassManager = new HASSManager(this); private _hassManager = new HASSManager(this);
protected _initializationManager = new InitializationManager(this); private _initializationManager = new InitializationManager(this);
protected _interactionManager = new InteractionManager(this); private _interactionManager = new InteractionManager(this);
protected _keyboardStateManager = new KeyboardStateManager(this); private _keyboardStateManager = new KeyboardStateManager(this);
protected _mediaLoadedInfoManager = new MediaLoadedInfoManager(this); private _mediaLoadedInfoManager = new MediaLoadedInfoManager(this);
protected _mediaPlayerManager = new MediaPlayerManager(this); private _mediaPlayerManager = new MediaPlayerManager(this);
protected _messageManager = new MessageManager(this); private _messageManager = new MessageManager(this);
protected _microphoneManager = new MicrophoneManager(this); private _microphoneManager = new MicrophoneManager(this);
protected _overlayMessageManager = new OverlayMessageManager(this); private _overlayMessageManager = new OverlayMessageManager(this);
protected _queryStringManager = new QueryStringManager(this); private _queryStringManager = new QueryStringManager(this);
protected _statusBarItemManager = new StatusBarItemManager(this); private _statusBarItemManager = new StatusBarItemManager(this);
protected _styleManager = new StyleManager(this); private _styleManager = new StyleManager(this);
protected _triggersManager = new TriggersManager(this); private _triggersManager = new TriggersManager(this);
protected _viewManager = new ViewManager(this); private _viewManager = new ViewManager(this);
protected _viewItemManager = new ViewItemManager(this); private _viewItemManager = new ViewItemManager(this);
constructor( constructor(
host: CardHTMLElement, host: CardHTMLElement,
+5 -5
View File
@@ -9,8 +9,8 @@ import { CardDefaultManagerAPI } from './types';
* Manages automated resetting to the default view. * Manages automated resetting to the default view.
*/ */
export class DefaultManager { export class DefaultManager {
protected _timer = new Timer(); private _timer = new Timer();
protected _api: CardDefaultManagerAPI; private _api: CardDefaultManagerAPI;
constructor(api: CardDefaultManagerAPI) { constructor(api: CardDefaultManagerAPI) {
this._api = api; this._api = api;
@@ -75,17 +75,17 @@ export class DefaultManager {
this._api.getAutomationsManager().deleteAutomations(this); this._api.getAutomationsManager().deleteAutomations(this);
} }
protected _stateChangeHandler = (): void => { private _stateChangeHandler = (): void => {
this._setToDefaultIfAllowed(); this._setToDefaultIfAllowed();
}; };
protected _setToDefaultIfAllowed(): void { private _setToDefaultIfAllowed(): void {
if (this._isAutomatedUpdateAllowed()) { if (this._isAutomatedUpdateAllowed()) {
this._api.getViewManager().setViewDefault(); this._api.getViewManager().setViewDefault();
} }
} }
protected _isAutomatedUpdateAllowed(): boolean { private _isAutomatedUpdateAllowed(): boolean {
const interactionMode = this._api.getConfigManager().getConfig()?.view const interactionMode = this._api.getConfigManager().getConfig()?.view
.default_reset.interaction_mode; .default_reset.interaction_mode;
return ( return (
@@ -47,7 +47,7 @@ export class EffectsManager implements EffectsManagerInterface {
// effects can be started). // effects can be started).
private _pendingEffects: Map<EffectName, EffectOptions | undefined> = new Map(); private _pendingEffects: Map<EffectName, EffectOptions | undefined> = new Map();
private _activeEffects: Map<EffectName, EffectComponent | null> = new Map(); private _activeEffects: Map<EffectName, EffectComponent | null> = new Map();
protected _container: EffectsContainer | null = null; private _container: EffectsContainer | null = null;
constructor(importer: EffectModuleImporter = defaultImportEffectModule) { constructor(importer: EffectModuleImporter = defaultImportEffectModule) {
this._importer = importer; this._importer = importer;
+3 -3
View File
@@ -2,8 +2,8 @@ import { setOrRemoveAttribute } from '../utils/basic';
import { CardExpandAPI } from './types'; import { CardExpandAPI } from './types';
export class ExpandManager { export class ExpandManager {
protected _expanded = false; private _expanded = false;
protected _api: CardExpandAPI; private _api: CardExpandAPI;
constructor(api: CardExpandAPI) { constructor(api: CardExpandAPI) {
this._api = api; this._api = api;
@@ -37,7 +37,7 @@ export class ExpandManager {
this._api.getCardElementManager().update(); this._api.getCardElementManager().update();
} }
protected _setConditionState(): void { private _setConditionState(): void {
this._api.getConditionStateManager()?.setState({ this._api.getConditionStateManager()?.setState({
expand: this._expanded, expand: this._expanded,
}); });
@@ -12,7 +12,7 @@ import { regexpExtract } from '../../../utils/regexp-extract';
import { REGEXP_GROUP_VALUE_KEY } from './types'; import { REGEXP_GROUP_VALUE_KEY } from './types';
export class MetadataGenerator { export class MetadataGenerator {
protected _anyDateParser: typeof parser | null = null; private _anyDateParser: typeof parser | null = null;
public async prepare(parsers?: Parser[]): Promise<void> { public async prepare(parsers?: Parser[]): Promise<void> {
if (this._anyDateParser) { if (this._anyDateParser) {
@@ -4,8 +4,8 @@ import { FullscreenProviderFactory } from './factory';
import { FullscreenProvider } from './types'; import { FullscreenProvider } from './types';
export class FullscreenManager { export class FullscreenManager {
protected _api: CardFullscreenAPI; private _api: CardFullscreenAPI;
protected _provider: FullscreenProvider | null; private _provider: FullscreenProvider | null;
constructor(api: CardFullscreenAPI, provider?: FullscreenProvider) { constructor(api: CardFullscreenAPI, provider?: FullscreenProvider) {
this._api = api; this._api = api;
@@ -48,7 +48,7 @@ export class FullscreenManager {
} }
} }
protected _fullscreenHandler = (): void => { private _fullscreenHandler = (): void => {
this._api.getExpandManager().setExpanded(false); this._api.getExpandManager().setExpanded(false);
this._setConditionState(); this._setConditionState();
@@ -59,7 +59,7 @@ export class FullscreenManager {
this._api.getCardElementManager().update(); this._api.getCardElementManager().update();
}; };
protected _setConditionState(): void { private _setConditionState(): void {
this._api.getConditionStateManager()?.setState({ this._api.getConditionStateManager()?.setState({
fullscreen: this.isInFullscreen(), fullscreen: this.isInFullscreen(),
}); });
@@ -15,7 +15,7 @@ export class WebkitFullScreenProvider
extends FullscreenProviderBase extends FullscreenProviderBase
implements FullscreenProvider implements FullscreenProvider
{ {
protected _playTimer = new Timer(); private _playTimer = new Timer();
public connect(): void { public connect(): void {
this._api.getConditionStateManager().addListener(this._stateChangeHandler); this._api.getConditionStateManager().addListener(this._stateChangeHandler);
@@ -25,7 +25,7 @@ export class WebkitFullScreenProvider
this._api.getConditionStateManager().removeListener(this._stateChangeHandler); this._api.getConditionStateManager().removeListener(this._stateChangeHandler);
} }
protected _stateChangeHandler = (change: ConditionStateChange): void => { private _stateChangeHandler = (change: ConditionStateChange): void => {
if ( if (
change.old.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement() !== change.old.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement() !==
change.new.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement() change.new.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement()
@@ -42,7 +42,7 @@ export class WebkitFullScreenProvider
} }
}; };
protected _getVideoElement(): private _getVideoElement():
| (HTMLVideoElement & Partial<WebkitHTMLVideoElement>) | (HTMLVideoElement & Partial<WebkitHTMLVideoElement>)
| null { | null {
const element = this._api const element = this._api
@@ -74,7 +74,7 @@ export class WebkitFullScreenProvider
} }
} }
protected _endHandler = (): void => { private _endHandler = (): void => {
this._handler(); this._handler();
// Webkit on iPhone stops the video when exiting fullscreen (why!). This // Webkit on iPhone stops the video when exiting fullscreen (why!). This
+3 -3
View File
@@ -5,9 +5,9 @@ import { CardHASSAPI } from '../types';
import { StateWatcher, StateWatcherSubscriptionInterface } from './state-watcher'; import { StateWatcher, StateWatcherSubscriptionInterface } from './state-watcher';
export class HASSManager { export class HASSManager {
protected _hass: HomeAssistant | null = null; private _hass: HomeAssistant | null = null;
protected _api: CardHASSAPI; private _api: CardHASSAPI;
protected _stateWatcher: StateWatcher = new StateWatcher(); private _stateWatcher: StateWatcher = new StateWatcher();
constructor(api: CardHASSAPI) { constructor(api: CardHASSAPI) {
this._api = api; this._api = api;
+1 -1
View File
@@ -9,7 +9,7 @@ export interface StateWatcherSubscriptionInterface {
} }
export class StateWatcher implements StateWatcherSubscriptionInterface { export class StateWatcher implements StateWatcherSubscriptionInterface {
protected _watcherCallbacks = new Map<StateWatcherCallback, string[]>(); private _watcherCallbacks = new Map<StateWatcherCallback, string[]>();
public setHASS(oldHass: HomeAssistant | null, hass: HomeAssistant): void { public setHASS(oldHass: HomeAssistant | null, hass: HomeAssistant): void {
if (!oldHass) { if (!oldHass) {
@@ -27,15 +27,15 @@ export enum InitializationAspect {
// ========================================================================= // =========================================================================
export class InitializationManager { export class InitializationManager {
protected _api: CardInitializerAPI; private _api: CardInitializerAPI;
// A concurrency limit is placed to ensure that on card load multiple async // A concurrency limit is placed to ensure that on card load multiple async
// contexts do not attempt to initialize the card at the same time. This is // contexts do not attempt to initialize the card at the same time. This is
// not strictly necessary, just more efficient, as long as the "Rules for // not strictly necessary, just more efficient, as long as the "Rules for
// initialization" (above) are followed. // initialization" (above) are followed.
protected _initializationQueue = new PQueue({ concurrency: 1 }); private _initializationQueue = new PQueue({ concurrency: 1 });
protected _initializer: Initializer; private _initializer: Initializer;
protected _everInitialized = false; private _everInitialized = false;
constructor(api: CardInitializerAPI, initializer?: Initializer) { constructor(api: CardInitializerAPI, initializer?: Initializer) {
this._api = api; this._api = api;
@@ -76,7 +76,7 @@ export class InitializationManager {
await this._initializationQueue.add(() => this._initializeMandatory()); await this._initializationQueue.add(() => this._initializeMandatory());
} }
protected async _initializeMandatory(): Promise<void> { private async _initializeMandatory(): Promise<void> {
const hass = this._api.getHASSManager().getHASS(); const hass = this._api.getHASSManager().getHASS();
if (!hass || this.isInitializedMandatory()) { if (!hass || this.isInitializedMandatory()) {
return; return;
+5 -5
View File
@@ -4,9 +4,9 @@ import { Timer } from '../utils/timer';
import { CardInteractionAPI } from './types'; import { CardInteractionAPI } from './types';
export class InteractionManager { export class InteractionManager {
protected _timer = new Timer(); private _timer = new Timer();
protected _api: CardInteractionAPI; private _api: CardInteractionAPI;
protected _interacted = false; private _interacted = false;
constructor(api: CardInteractionAPI) { constructor(api: CardInteractionAPI) {
this._api = api; this._api = api;
@@ -26,7 +26,7 @@ export class InteractionManager {
return this._interacted; return this._interacted;
} }
protected _setInteraction(val: boolean): void { private _setInteraction(val: boolean): void {
this._interacted = val; this._interacted = val;
setOrRemoveAttribute( setOrRemoveAttribute(
this._api.getCardElementManager().getElement(), this._api.getCardElementManager().getElement(),
@@ -36,7 +36,7 @@ export class InteractionManager {
this._api.getConditionStateManager().setState({ interaction: val }); this._api.getConditionStateManager().setState({ interaction: val });
} }
protected _reportInteraction(): void { private _reportInteraction(): void {
this._timer.stop(); this._timer.stop();
this._setInteraction(true); this._setInteraction(true);
@@ -2,8 +2,8 @@ import { CardKeyboardStateAPI, KeysState } from './types';
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
export class KeyboardStateManager { export class KeyboardStateManager {
protected _api: CardKeyboardStateAPI; private _api: CardKeyboardStateAPI;
protected _state: KeysState = {}; private _state: KeysState = {};
constructor(api: CardKeyboardStateAPI) { constructor(api: CardKeyboardStateAPI) {
this._api = api; this._api = api;
@@ -23,7 +23,7 @@ export class KeyboardStateManager {
element.removeEventListener('blur', this._handleBlur); element.removeEventListener('blur', this._handleBlur);
} }
protected _handleKeydown = (ev: KeyboardEvent): void => { private _handleKeydown = (ev: KeyboardEvent): void => {
const keyObj = { const keyObj = {
state: 'down' as const, state: 'down' as const,
ctrl: ev.ctrlKey, ctrl: ev.ctrlKey,
@@ -38,14 +38,14 @@ export class KeyboardStateManager {
} }
}; };
protected _handleKeyup = (ev: KeyboardEvent): void => { private _handleKeyup = (ev: KeyboardEvent): void => {
if (ev.key in this._state && this._state[ev.key].state === 'down') { if (ev.key in this._state && this._state[ev.key].state === 'down') {
this._state[ev.key].state = 'up'; this._state[ev.key].state = 'up';
this._processStateChange(); this._processStateChange();
} }
}; };
protected _handleBlur = (): void => { private _handleBlur = (): void => {
if (Object.keys(this._state).length) { if (Object.keys(this._state).length) {
// State is emptied if the element loses focus. // State is emptied if the element loses focus.
this._state = {}; this._state = {};
@@ -53,7 +53,7 @@ export class KeyboardStateManager {
} }
}; };
protected _processStateChange(): void { private _processStateChange(): void {
this._api.getConditionStateManager().setState({ keys: this._state }); this._api.getConditionStateManager().setState({ keys: this._state });
} }
} }
+3 -3
View File
@@ -4,9 +4,9 @@ import { isValidMediaLoadedInfo } from '../utils/media-info';
import { CardMediaLoadedAPI } from './types'; import { CardMediaLoadedAPI } from './types';
export class MediaLoadedInfoManager { export class MediaLoadedInfoManager {
protected _api: CardMediaLoadedAPI; private _api: CardMediaLoadedAPI;
protected _current: MediaLoadedInfo | null = null; private _current: MediaLoadedInfo | null = null;
protected _lastKnown: MediaLoadedInfo | null = null; private _lastKnown: MediaLoadedInfo | null = null;
constructor(api: CardMediaLoadedAPI) { constructor(api: CardMediaLoadedAPI) {
this._api = api; this._api = api;
+4 -4
View File
@@ -14,9 +14,9 @@ import { ViewItemClassifier } from '../view/item-classifier';
import { CardMediaPlayerAPI } from './types'; import { CardMediaPlayerAPI } from './types';
export class MediaPlayerManager { export class MediaPlayerManager {
protected _mediaPlayers: string[] = []; private _mediaPlayers: string[] = [];
protected _api: CardMediaPlayerAPI; private _api: CardMediaPlayerAPI;
constructor(api: CardMediaPlayerAPI) { constructor(api: CardMediaPlayerAPI) {
this._api = api; this._api = api;
@@ -128,7 +128,7 @@ export class MediaPlayerManager {
} }
} }
protected async _playLiveStandard( private async _playLiveStandard(
mediaPlayer: string, mediaPlayer: string,
cameraID: string, cameraID: string,
cameraConfig: CameraConfig, cameraConfig: CameraConfig,
@@ -155,7 +155,7 @@ export class MediaPlayerManager {
}); });
} }
protected async _playLiveDashboard( private async _playLiveDashboard(
mediaPlayer: string, mediaPlayer: string,
cameraConfig: CameraConfig, cameraConfig: CameraConfig,
): Promise<void> { ): Promise<void> {
+2 -2
View File
@@ -14,8 +14,8 @@ const MESSAGE_TYPE_PRIORITIES: MessagePriority = {
}; };
export class MessageManager { export class MessageManager {
protected _message: Message | null = null; private _message: Message | null = null;
protected _api: CardMessageAPI; private _api: CardMessageAPI;
constructor(api: CardMessageAPI) { constructor(api: CardMessageAPI) {
this._api = api; this._api = api;
+8 -8
View File
@@ -3,11 +3,11 @@ import { Timer } from '../utils/timer';
import { CardMicrophoneAPI, MicrophoneState } from './types'; import { CardMicrophoneAPI, MicrophoneState } from './types';
export class MicrophoneManager { export class MicrophoneManager {
protected _api: CardMicrophoneAPI; private _api: CardMicrophoneAPI;
protected _stream?: MediaStream | null; private _stream?: MediaStream | null;
protected _timer = new Timer(); private _timer = new Timer();
protected _state: MicrophoneState = { private _state: MicrophoneState = {
connected: false, connected: false,
muted: true, muted: true,
forbidden: false, forbidden: false,
@@ -16,7 +16,7 @@ export class MicrophoneManager {
// We keep desired mute state separate from the overall state so that // We keep desired mute state separate from the overall state so that
// mute/unmute can be expressed before the stream is even created -- and when // mute/unmute can be expressed before the stream is even created -- and when
// it's created it will have the right mute status. // it's created it will have the right mute status.
protected _desireMute = true; private _desireMute = true;
constructor(api: CardMicrophoneAPI) { constructor(api: CardMicrophoneAPI) {
this._api = api; this._api = api;
@@ -115,7 +115,7 @@ export class MicrophoneManager {
return !this._stream || this._stream.getTracks().every((track) => !track.enabled); return !this._stream || this._stream.getTracks().every((track) => !track.enabled);
} }
protected _setDesiredMuteOnStream(): void { private _setDesiredMuteOnStream(): void {
this._stream?.getTracks().forEach((track) => { this._stream?.getTracks().forEach((track) => {
track.enabled = !this._desireMute; track.enabled = !this._desireMute;
}); });
@@ -123,7 +123,7 @@ export class MicrophoneManager {
this._startDisconnectTimer(); this._startDisconnectTimer();
} }
protected _startDisconnectTimer(): void { private _startDisconnectTimer(): void {
const microphoneConfig = this._api.getConfigManager().getConfig()?.live.microphone; const microphoneConfig = this._api.getConfigManager().getConfig()?.live.microphone;
if (microphoneConfig?.always_connected) { if (microphoneConfig?.always_connected) {
@@ -139,7 +139,7 @@ export class MicrophoneManager {
} }
} }
protected _setState(): void { private _setState(): void {
this._state = { this._state = {
stream: this._stream, stream: this._stream,
connected: this.isConnected(), connected: this.isConnected(),
@@ -2,8 +2,8 @@ import { OverlayMessage } from '../types';
import { CardOverlayMessageAPI } from './types'; import { CardOverlayMessageAPI } from './types';
export class OverlayMessageManager { export class OverlayMessageManager {
protected _message: OverlayMessage | null = null; private _message: OverlayMessage | null = null;
protected _api: CardOverlayMessageAPI; private _api: CardOverlayMessageAPI;
constructor(api: CardOverlayMessageAPI) { constructor(api: CardOverlayMessageAPI) {
this._api = api; this._api = api;
+7 -7
View File
@@ -18,8 +18,8 @@ interface QueryStringViewIntent {
} }
export class QueryStringManager { export class QueryStringManager {
protected _api: CardQueryStringAPI; private _api: CardQueryStringAPI;
protected _shouldRun = true; private _shouldRun = true;
constructor(api: CardQueryStringAPI) { constructor(api: CardQueryStringAPI) {
this._api = api; this._api = api;
@@ -42,7 +42,7 @@ export class QueryStringManager {
} }
}; };
protected async _executeViewRelated(intent: QueryStringViewIntent): Promise<void> { private async _executeViewRelated(intent: QueryStringViewIntent): Promise<void> {
if (intent.view) { if (intent.view) {
if (intent.view.default) { if (intent.view.default) {
await this._api.getViewManager().setViewDefaultWithNewQuery({ await this._api.getViewManager().setViewDefaultWithNewQuery({
@@ -67,13 +67,13 @@ export class QueryStringManager {
} }
} }
protected async _executeNonViewRelated(intent: QueryStringViewIntent): Promise<void> { private async _executeNonViewRelated(intent: QueryStringViewIntent): Promise<void> {
if (intent.other) { if (intent.other) {
await this._api.getActionsManager().executeActions({ actions: intent.other }); await this._api.getActionsManager().executeActions({ actions: intent.other });
} }
} }
protected _calculateIntent(): QueryStringViewIntent { private _calculateIntent(): QueryStringViewIntent {
const result: QueryStringViewIntent = {}; const result: QueryStringViewIntent = {};
for (const action of this._getActions()) { for (const action of this._getActions()) {
if (this._isViewAction(action)) { if (this._isViewAction(action)) {
@@ -93,7 +93,7 @@ export class QueryStringManager {
return result; return result;
} }
protected _getActions(): AdvancedCameraCardCustomActionConfig[] { private _getActions(): AdvancedCameraCardCustomActionConfig[] {
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
const actions: AdvancedCameraCardCustomActionConfig[] = []; const actions: AdvancedCameraCardCustomActionConfig[] = [];
const configuredCardID = this._api.getConfigManager().getConfig()?.card_id; const configuredCardID = this._api.getConfigManager().getConfig()?.card_id;
@@ -158,7 +158,7 @@ export class QueryStringManager {
return actions; return actions;
} }
protected _isViewAction = ( private _isViewAction = (
action: AdvancedCameraCardCustomActionConfig, action: AdvancedCameraCardCustomActionConfig,
): action is ViewActionConfig => { ): action is ViewActionConfig => {
switch (action.advanced_camera_card_action) { switch (action.advanced_camera_card_action) {
@@ -9,14 +9,14 @@ import { CardStatusBarAPI } from './types';
const RESOLUTION_TOLERANCE_PCT = 0.01; const RESOLUTION_TOLERANCE_PCT = 0.01;
export class StatusBarItemManager { export class StatusBarItemManager {
protected _api: CardStatusBarAPI; private _api: CardStatusBarAPI;
constructor(api: CardStatusBarAPI) { constructor(api: CardStatusBarAPI) {
this._api = api; this._api = api;
} }
protected _items: StatusBarItem[] = []; private _items: StatusBarItem[] = [];
protected _dynamicItems: StatusBarItem[] = []; private _dynamicItems: StatusBarItem[] = [];
public addDynamicStatusBarItem(item: StatusBarItem): void { public addDynamicStatusBarItem(item: StatusBarItem): void {
if (!this._dynamicItems.includes(item)) { if (!this._dynamicItems.includes(item)) {
@@ -128,7 +128,7 @@ export class StatusBarItemManager {
]; ];
} }
protected _matchesWidthHeight( private _matchesWidthHeight(
mediaLoadedInfo: MediaLoadedInfo | null, mediaLoadedInfo: MediaLoadedInfo | null,
width: number, width: number,
height: number, height: number,
@@ -153,7 +153,7 @@ export class StatusBarItemManager {
); );
} }
protected _calculateResolution(mediaLoadedInfo: MediaLoadedInfo): string { private _calculateResolution(mediaLoadedInfo: MediaLoadedInfo): string {
// Ordered roughly by a guess at most common towards the top. // Ordered roughly by a guess at most common towards the top.
if (this._matchesWidthHeight(mediaLoadedInfo, 1920, 1080)) { if (this._matchesWidthHeight(mediaLoadedInfo, 1920, 1080)) {
return '1080p'; return '1080p';
+6 -6
View File
@@ -10,7 +10,7 @@ import { View } from '../view/view';
import { CardStyleAPI } from './types'; import { CardStyleAPI } from './types';
export class StyleManager { export class StyleManager {
protected _api: CardStyleAPI; private _api: CardStyleAPI;
constructor(api: CardStyleAPI) { constructor(api: CardStyleAPI) {
this._api = api; this._api = api;
@@ -73,13 +73,13 @@ export class StyleManager {
} }
} }
protected _getThemeNames(themeConfig: ThemeConfig): ThemeName[] | null { private _getThemeNames(themeConfig: ThemeConfig): ThemeName[] | null {
return themeConfig.themes.length return themeConfig.themes.length
? themeConfig.themes ? themeConfig.themes
: configDefaults.view.theme.themes; : configDefaults.view.theme.themes;
} }
protected _setDimmable(): void { private _setDimmable(): void {
const config = this._api.getConfigManager().getConfig(); const config = this._api.getConfigManager().getConfig();
setOrRemoveAttribute( setOrRemoveAttribute(
this._api.getCardElementManager().getElement(), this._api.getCardElementManager().getElement(),
@@ -88,7 +88,7 @@ export class StyleManager {
); );
} }
protected _setMinMaxHeight(): void { private _setMinMaxHeight(): void {
const config = this._api.getConfigManager().getConfig(); const config = this._api.getConfigManager().getConfig();
if (config) { if (config) {
const card = this._api.getCardElementManager().getElement(); const card = this._api.getCardElementManager().getElement();
@@ -96,7 +96,7 @@ export class StyleManager {
} }
} }
protected _setPerformance(): void { private _setPerformance(): void {
const STYLE_DISABLE_MAP = { const STYLE_DISABLE_MAP = {
box_shadow: { box_shadow: {
cssKey: '--advanced-camera-card-box-shadow-override', cssKey: '--advanced-camera-card-box-shadow-override',
@@ -122,7 +122,7 @@ export class StyleManager {
} }
} }
protected _isAspectRatioEnforced( private _isAspectRatioEnforced(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
view?: View | null, view?: View | null,
): boolean { ): boolean {
+2 -2
View File
@@ -39,7 +39,7 @@ export class TemplateRenderer {
); );
}; };
protected _generateTemplateContext( private _generateTemplateContext(
options?: TemplateRenderOptions, options?: TemplateRenderOptions,
): TemplateContext | undefined { ): TemplateContext | undefined {
if ( if (
@@ -64,7 +64,7 @@ export class TemplateRenderer {
}; };
} }
protected _renderTemplateRecursively( private _renderTemplateRecursively(
hass: HomeAssistant, hass: HomeAssistant,
data: unknown, data: unknown,
templateContext?: TemplateContext, templateContext?: TemplateContext,
+21 -21
View File
@@ -27,10 +27,10 @@ interface CameraTriggerState {
} }
export class TriggersManager { export class TriggersManager {
protected _api: CardTriggersAPI; private _api: CardTriggersAPI;
protected _states: Map<string, CameraTriggerState> = new Map(); private _states: Map<string, CameraTriggerState> = new Map();
protected _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, { private _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, {
trailing: true, trailing: true,
}); });
@@ -149,7 +149,7 @@ export class TriggersManager {
return true; return true;
} }
protected async _handleEndEvent(ev: CameraEvent): Promise<boolean> { private async _handleEndEvent(ev: CameraEvent): Promise<boolean> {
this._deleteIgnoredEventID(ev.cameraID, ev.id); this._deleteIgnoredEventID(ev.cameraID, ev.id);
const state = this._states.get(ev.cameraID); const state = this._states.get(ev.cameraID);
@@ -160,14 +160,14 @@ export class TriggersManager {
return true; return true;
} }
protected _isIgnoredUpdateEvent(ev: CameraEvent): boolean { private _isIgnoredUpdateEvent(ev: CameraEvent): boolean {
return ( return (
(ev.type === 'update' || ev.type === 'genai') && (ev.type === 'update' || ev.type === 'genai') &&
this._hasIgnoredEventID(ev.cameraID, ev.id) this._hasIgnoredEventID(ev.cameraID, ev.id)
); );
} }
protected _hasAllowableInteractionStateForAction(): boolean { private _hasAllowableInteractionStateForAction(): boolean {
const triggersConfig = this._api.getConfigManager().getConfig()?.view.triggers; const triggersConfig = this._api.getConfigManager().getConfig()?.view.triggers;
const hasInteraction = this._api.getInteractionManager().hasInteraction(); const hasInteraction = this._api.getInteractionManager().hasInteraction();
@@ -179,7 +179,7 @@ export class TriggersManager {
); );
} }
protected async _triggerAction(ev: CameraEvent): Promise<void> { private async _triggerAction(ev: CameraEvent): Promise<void> {
const config = this._api.getConfigManager().getConfig(); const config = this._api.getConfigManager().getConfig();
const triggerAction = config?.view?.triggers.actions.trigger; const triggerAction = config?.view?.triggers.actions.trigger;
const defaultView = config?.view?.default; const defaultView = config?.view?.default;
@@ -248,14 +248,14 @@ export class TriggersManager {
this._api.getCardElementManager().update(); this._api.getCardElementManager().update();
} }
protected _setConditionStateIfNecessary(): void { private _setConditionStateIfNecessary(): void {
const triggeredCameraIDs = this.getTriggeredCameraIDs(); const triggeredCameraIDs = this.getTriggeredCameraIDs();
this._api.getConditionStateManager().setState({ this._api.getConditionStateManager().setState({
triggered: triggeredCameraIDs.size ? triggeredCameraIDs : undefined, triggered: triggeredCameraIDs.size ? triggeredCameraIDs : undefined,
}); });
} }
protected async _executeUntriggerAction(): Promise<boolean> { private async _executeUntriggerAction(): Promise<boolean> {
const action = this._api.getConfigManager().getConfig()?.view?.triggers const action = this._api.getConfigManager().getConfig()?.view?.triggers
.actions.untrigger; .actions.untrigger;
@@ -269,7 +269,7 @@ export class TriggersManager {
return true; return true;
} }
protected async _untriggerAction(cameraID: string): Promise<void> { private async _untriggerAction(cameraID: string): Promise<void> {
this._deleteUntriggerDelayTimer(cameraID); this._deleteUntriggerDelayTimer(cameraID);
this._deleteForceUntriggerTimer(cameraID); this._deleteForceUntriggerTimer(cameraID);
@@ -282,7 +282,7 @@ export class TriggersManager {
this._api.getCardElementManager().update(); this._api.getCardElementManager().update();
} }
protected async _startUntrigger(cameraID: string): Promise<void> { private async _startUntrigger(cameraID: string): Promise<void> {
this._deleteUntriggerDelayTimer(cameraID); this._deleteUntriggerDelayTimer(cameraID);
this._deleteForceUntriggerTimer(cameraID); this._deleteForceUntriggerTimer(cameraID);
@@ -304,7 +304,7 @@ export class TriggersManager {
} }
} }
protected _startForceUntriggerTimerIfNecessary( private _startForceUntriggerTimerIfNecessary(
cameraID: string, cameraID: string,
forceUntriggerSeconds: number, forceUntriggerSeconds: number,
): void { ): void {
@@ -324,7 +324,7 @@ export class TriggersManager {
}); });
} }
protected async _forceUntrigger( private async _forceUntrigger(
state: CameraTriggerState, state: CameraTriggerState,
cameraID: string, cameraID: string,
): Promise<void> { ): Promise<void> {
@@ -334,12 +334,12 @@ export class TriggersManager {
await this._startUntrigger(cameraID); await this._startUntrigger(cameraID);
} }
protected _addIgnoredEventID(cameraID: string, eventID: string): void { private _addIgnoredEventID(cameraID: string, eventID: string): void {
const state = this._getOrCreateState(cameraID); const state = this._getOrCreateState(cameraID);
state.ignoredSources.add(eventID); state.ignoredSources.add(eventID);
} }
protected _deleteIgnoredEventID(cameraID: string, eventID: string): void { private _deleteIgnoredEventID(cameraID: string, eventID: string): void {
const state = this._states.get(cameraID); const state = this._states.get(cameraID);
if (!state) { if (!state) {
return; return;
@@ -349,11 +349,11 @@ export class TriggersManager {
this._deleteStateIfIdle(cameraID); this._deleteStateIfIdle(cameraID);
} }
protected _hasIgnoredEventID(cameraID: string, eventID: string): boolean { private _hasIgnoredEventID(cameraID: string, eventID: string): boolean {
return !!this._states.get(cameraID)?.ignoredSources.has(eventID); return !!this._states.get(cameraID)?.ignoredSources.has(eventID);
} }
protected _getOrCreateState(cameraID: string): CameraTriggerState { private _getOrCreateState(cameraID: string): CameraTriggerState {
let state = this._states.get(cameraID); let state = this._states.get(cameraID);
if (!state) { if (!state) {
state = { state = {
@@ -366,7 +366,7 @@ export class TriggersManager {
return state; return state;
} }
protected _deleteStateIfIdle(cameraID: string): void { private _deleteStateIfIdle(cameraID: string): void {
const state = this._states.get(cameraID); const state = this._states.get(cameraID);
if ( if (
state && state &&
@@ -379,7 +379,7 @@ export class TriggersManager {
} }
} }
protected _deleteUntriggerDelayTimer(cameraID: string): void { private _deleteUntriggerDelayTimer(cameraID: string): void {
const state = this._states.get(cameraID); const state = this._states.get(cameraID);
if (state?.untriggerDelayTimer) { if (state?.untriggerDelayTimer) {
state.untriggerDelayTimer.stop(); state.untriggerDelayTimer.stop();
@@ -387,7 +387,7 @@ export class TriggersManager {
} }
} }
protected _deleteForceUntriggerTimer(cameraID: string): void { private _deleteForceUntriggerTimer(cameraID: string): void {
const state = this._states.get(cameraID); const state = this._states.get(cameraID);
if (state?.untriggerForceTimer) { if (state?.untriggerForceTimer) {
state.untriggerForceTimer.stop(); state.untriggerForceTimer.stop();
@@ -395,7 +395,7 @@ export class TriggersManager {
} }
} }
protected _isStateTriggered(state: CameraTriggerState): boolean { private _isStateTriggered(state: CameraTriggerState): boolean {
return !!(state.sources.size || state.untriggerDelayTimer); return !!(state.sources.size || state.untriggerDelayTimer);
} }
} }
+10 -10
View File
@@ -19,7 +19,7 @@ interface ResolvedViewTarget {
} }
export class ViewFactory { export class ViewFactory {
protected _api: CardViewAPI; private _api: CardViewAPI;
constructor(api: CardViewAPI) { constructor(api: CardViewAPI) {
this._api = api; this._api = api;
@@ -43,7 +43,7 @@ export class ViewFactory {
}); });
} }
protected _getDefaultViewName = ( private _getDefaultViewName = (
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
): AdvancedCameraCardView => ): AdvancedCameraCardView =>
resolveViewName( resolveViewName(
@@ -52,7 +52,7 @@ export class ViewFactory {
this._api.getFoldersManager(), this._api.getFoldersManager(),
); );
protected _getDefaultCameraID( private _getDefaultCameraID(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
@@ -114,7 +114,7 @@ export class ViewFactory {
return view; return view;
} }
protected _resolveViewName( private _resolveViewName(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
): AdvancedCameraCardView { ): AdvancedCameraCardView {
@@ -128,7 +128,7 @@ export class ViewFactory {
return options?.baseView?.view ?? this._getDefaultViewName(config); return options?.baseView?.view ?? this._getDefaultViewName(config);
} }
protected _resolveCameraID( private _resolveCameraID(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
): string | null { ): string | null {
@@ -148,7 +148,7 @@ export class ViewFactory {
return viewCameraIDs?.keys().next().value ?? null; return viewCameraIDs?.keys().next().value ?? null;
} }
protected _ensureViewCompatibility( private _ensureViewCompatibility(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
cameraID: string | null, cameraID: string | null,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
@@ -173,7 +173,7 @@ export class ViewFactory {
return { viewName, cameraID }; return { viewName, cameraID };
} }
protected _handleNoCameraForView( private _handleNoCameraForView(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
@@ -195,7 +195,7 @@ export class ViewFactory {
}); });
} }
protected _handleUnsupportedView( private _handleUnsupportedView(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
cameraID: string, cameraID: string,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
@@ -229,7 +229,7 @@ export class ViewFactory {
}); });
} }
protected _resolveDisplayMode( private _resolveDisplayMode(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
@@ -247,7 +247,7 @@ export class ViewFactory {
); );
} }
protected _getConfiguredDisplayMode( private _getConfiguredDisplayMode(
viewName: AdvancedCameraCardView, viewName: AdvancedCameraCardView,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
): ViewDisplayMode | null { ): ViewDisplayMode | null {
@@ -3,7 +3,7 @@ import { View } from '../../../view/view';
import { ViewModifier } from '../types'; import { ViewModifier } from '../types';
export class MergeContextViewModifier implements ViewModifier { export class MergeContextViewModifier implements ViewModifier {
protected _context?: ViewContext | null; private _context?: ViewContext | null;
constructor(context?: ViewContext | null) { constructor(context?: ViewContext | null) {
this._context = context; this._context = context;
@@ -3,8 +3,8 @@ import { View } from '../../../view/view';
import { ViewModifier } from '../types'; import { ViewModifier } from '../types';
export class RemoveContextPropertyViewModifier implements ViewModifier { export class RemoveContextPropertyViewModifier implements ViewModifier {
protected _key: keyof ViewContext; private _key: keyof ViewContext;
protected _property: PropertyKey; private _property: PropertyKey;
constructor(key: keyof ViewContext, property: PropertyKey) { constructor(key: keyof ViewContext, property: PropertyKey) {
this._key = key; this._key = key;
@@ -3,7 +3,7 @@ import { View } from '../../../view/view';
import { ViewModifier } from '../types'; import { ViewModifier } from '../types';
export class RemoveContextViewModifier implements ViewModifier { export class RemoveContextViewModifier implements ViewModifier {
protected _keys: (keyof ViewContext)[]; private _keys: (keyof ViewContext)[];
constructor(keys: (keyof ViewContext)[]) { constructor(keys: (keyof ViewContext)[]) {
this._keys = keys; this._keys = keys;
@@ -4,8 +4,8 @@ import { View } from '../../../view/view';
import { ViewModifier } from '../types'; import { ViewModifier } from '../types';
export class SetQueryViewModifier implements ViewModifier { export class SetQueryViewModifier implements ViewModifier {
protected _query?: UnifiedQuery | null; private _query?: UnifiedQuery | null;
protected _queryResults?: QueryResults | null; private _queryResults?: QueryResults | null;
constructor(options?: { constructor(options?: {
query?: UnifiedQuery | null; query?: UnifiedQuery | null;
@@ -8,7 +8,7 @@ interface SubstreamOnViewModifierAPI {
} }
export class SubstreamOnViewModifier implements ViewModifier { export class SubstreamOnViewModifier implements ViewModifier {
protected _api: SubstreamOnViewModifierAPI; private _api: SubstreamOnViewModifierAPI;
constructor(api: SubstreamOnViewModifierAPI) { constructor(api: SubstreamOnViewModifierAPI) {
this._api = api; this._api = api;
@@ -3,7 +3,7 @@ import { View } from '../../../view/view';
import { ViewModifier } from '../types'; import { ViewModifier } from '../types';
export class SubstreamSelectViewModifier implements ViewModifier { export class SubstreamSelectViewModifier implements ViewModifier {
protected _substreamID: string; private _substreamID: string;
constructor(substreamID: string) { constructor(substreamID: string) {
this._substreamID = substreamID; this._substreamID = substreamID;
+14 -14
View File
@@ -16,15 +16,15 @@ import {
import { ViewQueryExecutor } from './view-query-executor'; import { ViewQueryExecutor } from './view-query-executor';
export class ViewManager implements ViewManagerInterface { export class ViewManager implements ViewManagerInterface {
protected _view: View | null = null; private _view: View | null = null;
protected _viewFactory: ViewFactory; private _viewFactory: ViewFactory;
protected _viewQueryExecutor: ViewQueryExecutor; private _viewQueryExecutor: ViewQueryExecutor;
protected _api: CardViewAPI; private _api: CardViewAPI;
protected _epoch: ViewManagerEpoch = this._createEpoch(); private _epoch: ViewManagerEpoch = this._createEpoch();
// Used to mark as a view as "loading" with a given index. Each subsequent // Used to mark as a view as "loading" with a given index. Each subsequent
// async update will use a higher index. // async update will use a higher index.
protected _loadingIndex = 1; private _loadingIndex = 1;
constructor( constructor(
api: CardViewAPI, api: CardViewAPI,
@@ -41,7 +41,7 @@ export class ViewManager implements ViewManagerInterface {
public getEpoch(): ViewManagerEpoch { public getEpoch(): ViewManagerEpoch {
return this._epoch; return this._epoch;
} }
protected _createEpoch(oldView?: View | null): ViewManagerEpoch { private _createEpoch(oldView?: View | null): ViewManagerEpoch {
return { return {
manager: this, manager: this,
...(oldView && { oldView }), ...(oldView && { oldView }),
@@ -97,7 +97,7 @@ export class ViewManager implements ViewManagerInterface {
options, options,
); );
protected _setViewGeneric( private _setViewGeneric(
viewFactoryFunc: (options?: ViewFactoryOptions) => View | null, viewFactoryFunc: (options?: ViewFactoryOptions) => View | null,
options?: ViewFactoryOptions, options?: ViewFactoryOptions,
): void { ): void {
@@ -119,14 +119,14 @@ export class ViewManager implements ViewManagerInterface {
} }
} }
protected _markViewLoadingQuery(view: View, index: number): View { private _markViewLoadingQuery(view: View, index: number): View {
return view.mergeInContext({ loading: { query: index } }); return view.mergeInContext({ loading: { query: index } });
} }
protected _markViewAsNotLoadingQuery(view: View): View { private _markViewAsNotLoadingQuery(view: View): View {
return view.removeContextProperty('loading', 'query'); return view.removeContextProperty('loading', 'query');
} }
protected _isAllowedToSetView(): boolean { private _isAllowedToSetView(): boolean {
// It is possible to have a race condition where the view is being set at // It is possible to have a race condition where the view is being set at
// the same time as the cameras being initialized. Test case: Open // the same time as the cameras being initialized. Test case: Open
// folder-based media in the media viewer carousel, then attempt to edit the // folder-based media in the media viewer carousel, then attempt to edit the
@@ -139,7 +139,7 @@ export class ViewManager implements ViewManagerInterface {
.isInitialized(InitializationAspect.CAMERAS); .isInitialized(InitializationAspect.CAMERAS);
} }
protected async _setViewThenModifyAsync( private async _setViewThenModifyAsync(
viewFactoryFunc: (options?: ViewFactoryOptions) => View | null, viewFactoryFunc: (options?: ViewFactoryOptions) => View | null,
viewModifiersFunc: ( viewModifiersFunc: (
view: View, view: View,
@@ -229,7 +229,7 @@ export class ViewManager implements ViewManagerInterface {
this._setView(newView); this._setView(newView);
} }
protected _shouldAdoptQueryAndResults(newView: View): boolean { private _shouldAdoptQueryAndResults(newView: View): boolean {
// If the user is currently using the viewer, and then switches to the // If the user is currently using the viewer, and then switches to the
// gallery we make an attempt to keep the query/queryResults the same so // gallery we make an attempt to keep the query/queryResults the same so
// the gallery can be used to click back and forth to the viewer, and the // the gallery can be used to click back and forth to the viewer, and the
@@ -292,7 +292,7 @@ export class ViewManager implements ViewManagerInterface {
return true; return true;
}; };
protected _setView(view: Readonly<View> | null): void { private _setView(view: Readonly<View> | null): void {
const oldView = this._view; const oldView = this._view;
log( log(
@@ -2,13 +2,13 @@ import { ReactiveController, ReactiveControllerHost } from 'lit';
import { Timer } from '../utils/timer'; import { Timer } from '../utils/timer';
export class CachedValueController<T> implements ReactiveController { export class CachedValueController<T> implements ReactiveController {
protected _value?: T; private _value?: T;
protected _host: ReactiveControllerHost; private _host: ReactiveControllerHost;
protected _timerSeconds: number; private _timerSeconds: number;
protected _callback: () => T; private _callback: () => T;
protected _timerStartCallback?: () => void; private _timerStartCallback?: () => void;
protected _timerStopCallback?: () => void; private _timerStopCallback?: () => void;
protected _timer = new Timer(); private _timer = new Timer();
constructor( constructor(
host: ReactiveControllerHost, host: ReactiveControllerHost,
@@ -4,9 +4,9 @@ import { KeyboardShortcut } from '../config/schema/view';
import { setOrRemoveAttribute } from '../utils/basic'; import { setOrRemoveAttribute } from '../utils/basic';
export class KeyAssignerController implements ReactiveController { export class KeyAssignerController implements ReactiveController {
protected _host: LitElement; private _host: LitElement;
protected _assigning = false; private _assigning = false;
protected _value: KeyboardShortcut | null = null; private _value: KeyboardShortcut | null = null;
constructor(host: LitElement) { constructor(host: LitElement) {
this._host = host; this._host = host;
@@ -40,7 +40,7 @@ export class KeyAssignerController implements ReactiveController {
public toggleAssigning(): void { public toggleAssigning(): void {
this._setAssigning(!this._assigning); this._setAssigning(!this._assigning);
} }
protected _setAssigning(assigning: boolean): void { private _setAssigning(assigning: boolean): void {
this._assigning = assigning; this._assigning = assigning;
setOrRemoveAttribute(this._host, this._assigning, 'assigning'); setOrRemoveAttribute(this._host, this._assigning, 'assigning');
@@ -53,11 +53,11 @@ export class KeyAssignerController implements ReactiveController {
this._host.requestUpdate(); this._host.requestUpdate();
} }
protected _blurEventHandler = (): void => { private _blurEventHandler = (): void => {
this._setAssigning(false); this._setAssigning(false);
}; };
protected _keydownEventHandler = (ev: KeyboardEvent): void => { private _keydownEventHandler = (ev: KeyboardEvent): void => {
// Don't allow _only_ a modifier. // Don't allow _only_ a modifier.
if (!ev.key || ['Control', 'Alt', 'Shift', 'Meta'].includes(ev.key)) { if (!ev.key || ['Control', 'Alt', 'Shift', 'Meta'].includes(ev.key)) {
return; return;
+6 -6
View File
@@ -28,20 +28,20 @@ type LiveControllerHost = LitElement &
AdvancedCameraCardMessageEventTarget; AdvancedCameraCardMessageEventTarget;
export class LiveController implements ReactiveController { export class LiveController implements ReactiveController {
protected _host: LiveControllerHost; private _host: LiveControllerHost;
// Whether or not the live view is currently in the background (i.e. preloaded // Whether or not the live view is currently in the background (i.e. preloaded
// but not visible). // but not visible).
protected _inBackground = false; private _inBackground = false;
// Intersection handler is used to detect when the live view flips between // Intersection handler is used to detect when the live view flips between
// foreground and background (in preload mode). // foreground and background (in preload mode).
protected _intersectionObserver: IntersectionObserver; private _intersectionObserver: IntersectionObserver;
// MediaLoadedInfo object and target from the underlying live media. In the // MediaLoadedInfo object and target from the underlying live media. In the
// case of pre-loading these may be propagated later (from the original // case of pre-loading these may be propagated later (from the original
// source). // source).
protected _lastMediaLoadedInfo: LastMediaLoadedInfo | null = null; private _lastMediaLoadedInfo: LastMediaLoadedInfo | null = null;
constructor(host: LiveControllerHost) { constructor(host: LiveControllerHost) {
this._host = host; this._host = host;
@@ -75,7 +75,7 @@ export class LiveController implements ReactiveController {
return this._inBackground; return this._inBackground;
} }
protected _handleMediaLoaded = (ev: CustomEvent<MediaLoadedInfo>): void => { private _handleMediaLoaded = (ev: CustomEvent<MediaLoadedInfo>): void => {
this._lastMediaLoadedInfo = { this._lastMediaLoadedInfo = {
source: ev.composedPath()[0], source: ev.composedPath()[0],
mediaLoadedInfo: ev.detail, mediaLoadedInfo: ev.detail,
@@ -86,7 +86,7 @@ export class LiveController implements ReactiveController {
} }
}; };
protected _intersectionHandler(entries: IntersectionObserverEntry[]): void { private _intersectionHandler(entries: IntersectionObserverEntry[]): void {
const wasInBackground = this._inBackground; const wasInBackground = this._inBackground;
this._inBackground = !entries.some((entry) => entry.isIntersecting); this._inBackground = !entries.some((entry) => entry.isIntersecting);
+27 -29
View File
@@ -36,16 +36,16 @@ type MediaActionsTarget = {
}; };
export class MediaActionsController { export class MediaActionsController {
protected _options: MediaActionsControllerOptions | null = null; private _options: MediaActionsControllerOptions | null = null;
protected _viewportIntersecting: boolean | null = null; private _viewportIntersecting: boolean | null = null;
protected _microphoneMuteTimer = new Timer(); private _microphoneMuteTimer = new Timer();
protected _root: RenderRoot | null = null; private _root: RenderRoot | null = null;
protected _eventListeners = new Map<HTMLElement, () => void>(); private _eventListeners = new Map<HTMLElement, () => void>();
protected _children: MediaPlayerElement[] = []; private _children: MediaPlayerElement[] = [];
protected _target: MediaActionsTarget | null = null; private _target: MediaActionsTarget | null = null;
protected _mutationObserver = new MutationObserver(this._mutationHandler.bind(this)); private _mutationObserver = new MutationObserver(this._mutationHandler.bind(this));
protected _intersectionObserver = new IntersectionObserver( private _intersectionObserver = new IntersectionObserver(
this._intersectionHandler.bind(this), this._intersectionHandler.bind(this),
); );
@@ -110,7 +110,7 @@ export class MediaActionsController {
this._target = null; this._target = null;
} }
protected async _playTargetIfConfigured(condition: AutoPlayCondition): Promise<void> { private async _playTargetIfConfigured(condition: AutoPlayCondition): Promise<void> {
if ( if (
this._target !== null && this._target !== null &&
this._options?.autoPlayConditions?.includes(condition) this._options?.autoPlayConditions?.includes(condition)
@@ -118,10 +118,10 @@ export class MediaActionsController {
await this._play(this._target.index); await this._play(this._target.index);
} }
} }
protected async _play(index: number): Promise<void> { private async _play(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.play(); await (await this._children[index]?.getMediaPlayerController())?.play();
} }
protected async _unmuteTargetIfConfigured( private async _unmuteTargetIfConfigured(
condition: AutoUnmuteCondition, condition: AutoUnmuteCondition,
): Promise<void> { ): Promise<void> {
if ( if (
@@ -131,20 +131,18 @@ export class MediaActionsController {
await this._unmute(this._target.index); await this._unmute(this._target.index);
} }
} }
protected async _unmute(index: number): Promise<void> { private async _unmute(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.unmute(); await (await this._children[index]?.getMediaPlayerController())?.unmute();
} }
protected async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise<void> { private async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise<void> {
if (this._options?.autoPauseConditions?.includes(condition)) { if (this._options?.autoPauseConditions?.includes(condition)) {
for (const index of this._children.keys()) { for (const index of this._children.keys()) {
await this._pause(index); await this._pause(index);
} }
} }
} }
protected async _pauseTargetIfConfigured( private async _pauseTargetIfConfigured(condition: AutoPauseCondition): Promise<void> {
condition: AutoPauseCondition,
): Promise<void> {
if ( if (
this._target !== null && this._target !== null &&
this._options?.autoPauseConditions?.includes(condition) this._options?.autoPauseConditions?.includes(condition)
@@ -152,18 +150,18 @@ export class MediaActionsController {
await this._pause(this._target.index); await this._pause(this._target.index);
} }
} }
protected async _pause(index: number): Promise<void> { private async _pause(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.pause(); await (await this._children[index]?.getMediaPlayerController())?.pause();
} }
protected async _muteAllIfConfigured(condition: AutoMuteCondition): Promise<void> { private async _muteAllIfConfigured(condition: AutoMuteCondition): Promise<void> {
if (this._options?.autoMuteConditions?.includes(condition)) { if (this._options?.autoMuteConditions?.includes(condition)) {
for (const index of this._children.keys()) { for (const index of this._children.keys()) {
await this._mute(index); await this._mute(index);
} }
} }
} }
protected async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise<void> { private async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise<void> {
if ( if (
this._target !== null && this._target !== null &&
this._options?.autoMuteConditions?.includes(condition) this._options?.autoMuteConditions?.includes(condition)
@@ -171,11 +169,11 @@ export class MediaActionsController {
await this._mute(this._target.index); await this._mute(this._target.index);
} }
} }
protected async _mute(index: number): Promise<void> { private async _mute(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.mute(); await (await this._children[index]?.getMediaPlayerController())?.mute();
} }
protected _mutationHandler( private _mutationHandler(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
_mutations: MutationRecord[], _mutations: MutationRecord[],
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -184,7 +182,7 @@ export class MediaActionsController {
this._initializeRoot(); this._initializeRoot();
} }
protected _mediaLoadedHandler = async (index: number): Promise<void> => { private _mediaLoadedHandler = async (index: number): Promise<void> => {
if (this._target?.index !== index) { if (this._target?.index !== index) {
return; return;
} }
@@ -192,7 +190,7 @@ export class MediaActionsController {
await this._playTargetIfConfigured(this._target.selected ? 'selected' : 'visible'); await this._playTargetIfConfigured(this._target.selected ? 'selected' : 'visible');
}; };
protected _removeChildHandlers(): void { private _removeChildHandlers(): void {
for (const [child, callback] of this._eventListeners.entries()) { for (const [child, callback] of this._eventListeners.entries()) {
child.removeEventListener('advanced-camera-card:media:loaded', callback); child.removeEventListener('advanced-camera-card:media:loaded', callback);
} }
@@ -216,7 +214,7 @@ export class MediaActionsController {
return true; return true;
} }
protected _initializeRoot(): void { private _initializeRoot(): void {
if (!this._options || !this._root) { if (!this._options || !this._root) {
return; return;
} }
@@ -234,7 +232,7 @@ export class MediaActionsController {
} }
} }
protected async _intersectionHandler( private async _intersectionHandler(
entries: IntersectionObserverEntry[], entries: IntersectionObserverEntry[],
): Promise<void> { ): Promise<void> {
const wasIntersecting = this._viewportIntersecting; const wasIntersecting = this._viewportIntersecting;
@@ -248,11 +246,11 @@ export class MediaActionsController {
} }
} }
protected _visibilityHandler = async (): Promise<void> => { private _visibilityHandler = async (): Promise<void> => {
await this._changeVisibility(document.visibilityState === 'visible'); await this._changeVisibility(document.visibilityState === 'visible');
}; };
protected _changeVisibility = async (visible: boolean): Promise<void> => { private _changeVisibility = async (visible: boolean): Promise<void> => {
if (visible) { if (visible) {
await this._unmuteTargetIfConfigured('visible'); await this._unmuteTargetIfConfigured('visible');
await this._playTargetIfConfigured('visible'); await this._playTargetIfConfigured('visible');
@@ -262,7 +260,7 @@ export class MediaActionsController {
} }
}; };
protected async _microphoneStateChangeHandler( private async _microphoneStateChangeHandler(
oldState?: MicrophoneState, oldState?: MicrophoneState,
newState?: MicrophoneState, newState?: MicrophoneState,
): Promise<void> { ): Promise<void> {
+19 -19
View File
@@ -68,24 +68,24 @@ export enum MediaFilterMediaType {
} }
export class MediaFilterController { export class MediaFilterController {
protected _host: LitElement; private _host: LitElement;
protected _mediaTypeOptions: SelectOption[]; private _mediaTypeOptions: SelectOption[];
protected _cameraOptions: SelectOption[] = []; private _cameraOptions: SelectOption[] = [];
protected _whenOptions: SelectOption[] = []; private _whenOptions: SelectOption[] = [];
protected _staticWhenOptions: SelectOption[]; private _staticWhenOptions: SelectOption[];
protected _metaDataWhenOptions: SelectOption[] = []; private _metaDataWhenOptions: SelectOption[] = [];
protected _whatOptions: SelectOption[] = []; private _whatOptions: SelectOption[] = [];
protected _whereOptions: SelectOption[] = []; private _whereOptions: SelectOption[] = [];
protected _tagsOptions: SelectOption[] = []; private _tagsOptions: SelectOption[] = [];
protected _favoriteOptions: SelectOption[]; private _favoriteOptions: SelectOption[];
protected _reviewedOptions: SelectOption[]; private _reviewedOptions: SelectOption[];
protected _severityOptions: SelectOption[]; private _severityOptions: SelectOption[];
protected _defaults: MediaFilterCoreDefaults | null = null; private _defaults: MediaFilterCoreDefaults | null = null;
protected _viewManager: ViewManagerInterface | null = null; private _viewManager: ViewManagerInterface | null = null;
constructor(host: LitElement) { constructor(host: LitElement) {
this._host = host; this._host = host;
@@ -450,15 +450,15 @@ export class MediaFilterController {
this._host.requestUpdate(); this._host.requestUpdate();
} }
protected _computeWhenOptions(): void { private _computeWhenOptions(): void {
this._whenOptions = [...this._staticWhenOptions, ...this._metaDataWhenOptions]; this._whenOptions = [...this._staticWhenOptions, ...this._metaDataWhenOptions];
} }
protected _dateRangeToString(when: DateRange): string { private _dateRangeToString(when: DateRange): string {
return `${formatDate(when.start)},${formatDate(when.end)}`; return `${formatDate(when.start)},${formatDate(when.end)}`;
} }
protected _stringToDateRange(input: string): DateRange { private _stringToDateRange(input: string): DateRange {
const dates = input.split(','); const dates = input.split(',');
return { return {
start: parse(dates[0], 'yyyy-MM-dd', new Date()), start: parse(dates[0], 'yyyy-MM-dd', new Date()),
@@ -466,7 +466,7 @@ export class MediaFilterController {
}; };
} }
protected _getWhen(values: { private _getWhen(values: {
selected?: string | string[]; selected?: string | string[];
from?: Date | null; from?: Date | null;
to?: Date | null; to?: Date | null;
@@ -499,7 +499,7 @@ export class MediaFilterController {
} }
} }
protected _hasSingleUniqueValue(sets: (Set<unknown> | undefined)[]): boolean { private _hasSingleUniqueValue(sets: (Set<unknown> | undefined)[]): boolean {
if (sets.length === 0) { if (sets.length === 0) {
return false; return false;
} }
+29 -29
View File
@@ -47,18 +47,18 @@ export interface ExtendedMasonry extends Masonry {
} }
export class MediaGridController { export class MediaGridController {
protected _host: HTMLElement; private _host: HTMLElement;
protected _selected: GridID | null; private _selected: GridID | null;
protected _mediaLoadedInfoMap: Map<GridID, MediaLoadedInfo> = new Map(); private _mediaLoadedInfoMap: Map<GridID, MediaLoadedInfo> = new Map();
protected _gridContents: MediaGridContents = new Map(); private _gridContents: MediaGridContents = new Map();
protected _masonry: ExtendedMasonry | null = null; private _masonry: ExtendedMasonry | null = null;
protected _displayConfig: ViewDisplayConfig | null = null; private _displayConfig: ViewDisplayConfig | null = null;
protected _hostWidth: number; private _hostWidth: number;
protected _idAttribute: string; private _idAttribute: string;
protected _widthFactorAttribute: string; private _widthFactorAttribute: string;
protected _throttledLayout = throttle( private _throttledLayout = throttle(
() => this._masonry?.layout?.(), () => this._masonry?.layout?.(),
// Throttle layout calls to larger than the masonry.js transitionDuration // Throttle layout calls to larger than the masonry.js transitionDuration
// value specified below. // value specified below.
@@ -68,18 +68,18 @@ export class MediaGridController {
// If the order in which the observers are declared changes, the unittest must // If the order in which the observers are declared changes, the unittest must
// be updated in triggerResizeObserver and triggerMutationObserver. // be updated in triggerResizeObserver and triggerMutationObserver.
protected _hostMutationObserver = new MutationObserver( private _hostMutationObserver = new MutationObserver(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(_mutations: MutationRecord[], _observer: MutationObserver) => (_mutations: MutationRecord[], _observer: MutationObserver) =>
this._calculateGridContentsFromHost(), this._calculateGridContentsFromHost(),
); );
protected _cellMutationObserver = new MutationObserver( private _cellMutationObserver = new MutationObserver(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(_mutations: MutationRecord[], _observer: MutationObserver) => (_mutations: MutationRecord[], _observer: MutationObserver) =>
this._calculateGridContentsFromHost(), this._calculateGridContentsFromHost(),
); );
protected _hostResizeObserver = new ResizeObserver(this._hostResizeHandler.bind(this)); private _hostResizeObserver = new ResizeObserver(this._hostResizeHandler.bind(this));
protected _cellResizeObserver = new ResizeObserver(this._cellResizeHandler.bind(this)); private _cellResizeObserver = new ResizeObserver(this._cellResizeHandler.bind(this));
constructor(host: HTMLElement, options?: MediaGridConstructorOptions) { constructor(host: HTMLElement, options?: MediaGridConstructorOptions) {
this._host = host; this._host = host;
@@ -142,7 +142,7 @@ export class MediaGridController {
return this._selected; return this._selected;
} }
protected _sortItemsInGrid(): void { private _sortItemsInGrid(): void {
const existingItems = this._masonry?.items; const existingItems = this._masonry?.items;
const selectedItem = existingItems?.find( const selectedItem = existingItems?.find(
(item) => item.element.getAttribute(this._idAttribute) === this._selected, (item) => item.element.getAttribute(this._idAttribute) === this._selected,
@@ -201,7 +201,7 @@ export class MediaGridController {
this._updateSelectedStylesOnElements(); this._updateSelectedStylesOnElements();
} }
protected _calculateGridContentsFromHost = (): void => { private _calculateGridContentsFromHost = (): void => {
const children = getChildrenFromElement(this._host); const children = getChildrenFromElement(this._host);
const gridContents: MediaGridContents = new Map(); const gridContents: MediaGridContents = new Map();
for (const child of children) { for (const child of children) {
@@ -212,7 +212,7 @@ export class MediaGridController {
this._setGridContents(gridContents); this._setGridContents(gridContents);
}; };
protected _setGridContents(gridContents: MediaGridContents): void { private _setGridContents(gridContents: MediaGridContents): void {
this._gridContents = gridContents; this._gridContents = gridContents;
// Remove media loaded info objects that belong to objects no longer in the // Remove media loaded info objects that belong to objects no longer in the
@@ -252,7 +252,7 @@ export class MediaGridController {
this._setColumnSizeStyles(); this._setColumnSizeStyles();
} }
protected _handleMediaLoadedInfoEvent = (ev: CustomEvent<MediaLoadedInfo>): void => { private _handleMediaLoadedInfoEvent = (ev: CustomEvent<MediaLoadedInfo>): void => {
const eventPath = ev.composedPath(); const eventPath = ev.composedPath();
for (const [id, element] of this._gridContents.entries()) { for (const [id, element] of this._gridContents.entries()) {
@@ -267,7 +267,7 @@ export class MediaGridController {
} }
}; };
protected _hostResizeHandler(): void { private _hostResizeHandler(): void {
const dimensions = this._host.getBoundingClientRect(); const dimensions = this._host.getBoundingClientRect();
// Only resize things if the width has changed. It is expected that the // Only resize things if the width has changed. It is expected that the
@@ -283,11 +283,11 @@ export class MediaGridController {
} }
} }
protected _cellResizeHandler(): void { private _cellResizeHandler(): void {
this._throttledLayout(); this._throttledLayout();
} }
protected _addChildEventListeners(child: MediaGridChild): void { private _addChildEventListeners(child: MediaGridChild): void {
child.addEventListener('click', this._handleSelectGridCellEvent, { child.addEventListener('click', this._handleSelectGridCellEvent, {
capture: true, capture: true,
}); });
@@ -298,7 +298,7 @@ export class MediaGridController {
); );
} }
protected _removeChildEventListeners(child: MediaGridChild): void { private _removeChildEventListeners(child: MediaGridChild): void {
child.removeEventListener('click', this._handleSelectGridCellEvent, { child.removeEventListener('click', this._handleSelectGridCellEvent, {
capture: true, capture: true,
}); });
@@ -309,7 +309,7 @@ export class MediaGridController {
); );
} }
protected _createMasonry(): void { private _createMasonry(): void {
if (this._masonry) { if (this._masonry) {
this._masonry.destroy?.(); this._masonry.destroy?.();
} }
@@ -325,7 +325,7 @@ export class MediaGridController {
this._throttledLayout(); this._throttledLayout();
} }
protected _handleSelectGridCellEvent = (ev: Event): void => { private _handleSelectGridCellEvent = (ev: Event): void => {
const eventPath = ev.composedPath(); const eventPath = ev.composedPath();
for (const [id, element] of this._gridContents.entries()) { for (const [id, element] of this._gridContents.entries()) {
@@ -340,7 +340,7 @@ export class MediaGridController {
} }
}; };
protected _updateSelectedStylesOnElements(): void { private _updateSelectedStylesOnElements(): void {
for (const [id, element] of this._gridContents.entries()) { for (const [id, element] of this._gridContents.entries()) {
setOrRemoveAttribute(element, id === this._selected, 'selected'); setOrRemoveAttribute(element, id === this._selected, 'selected');
@@ -351,7 +351,7 @@ export class MediaGridController {
} }
} }
protected _updateWidthFactorStyles(): void { private _updateWidthFactorStyles(): void {
for (const element of this._gridContents.values()) { for (const element of this._gridContents.values()) {
const widthFactor = element.getAttribute(this._widthFactorAttribute); const widthFactor = element.getAttribute(this._widthFactorAttribute);
setOrRemoveStyleProperty( setOrRemoveStyleProperty(
@@ -363,7 +363,7 @@ export class MediaGridController {
} }
} }
protected _getColumnSize(): number { private _getColumnSize(): number {
const columns = this._getColumns(); const columns = this._getColumns();
if (columns === 1) { if (columns === 1) {
return this._hostWidth; return this._hostWidth;
@@ -372,7 +372,7 @@ export class MediaGridController {
return Math.max(0, this._hostWidth / columns - MEDIA_GRID_HORIZONTAL_GUTTER_WIDTH); return Math.max(0, this._hostWidth / columns - MEDIA_GRID_HORIZONTAL_GUTTER_WIDTH);
} }
protected _getColumns(): number { private _getColumns(): number {
if (this._displayConfig?.grid_columns) { if (this._displayConfig?.grid_columns) {
return this._displayConfig?.grid_columns; return this._displayConfig?.grid_columns;
} }
@@ -397,7 +397,7 @@ export class MediaGridController {
return Math.max(1, minColumns); return Math.max(1, minColumns);
} }
protected _setColumnSizeStyles(): void { private _setColumnSizeStyles(): void {
this._host.style.setProperty( this._host.style.setProperty(
'--advanced-camera-card-grid-column-size', '--advanced-camera-card-grid-column-size',
`${this._getColumnSize()}px`, `${this._getColumnSize()}px`,
@@ -219,7 +219,7 @@ export class MediaDetailsController {
}; };
} }
protected _getControls(context: OverlayControlsContext): OverlayMessageControl[] { private _getControls(context: OverlayControlsContext): OverlayMessageControl[] {
const controls: OverlayMessageControl[] = []; const controls: OverlayMessageControl[] = [];
const item = this._item; const item = this._item;
+29 -29
View File
@@ -51,7 +51,7 @@ export interface MenuButtonControllerOptions {
export class MenuButtonController { export class MenuButtonController {
// Array of dynamic menu buttons to be added to menu. // Array of dynamic menu buttons to be added to menu.
protected _dynamicMenuButtons: MenuItem[] = []; private _dynamicMenuButtons: MenuItem[] = [];
public addDynamicMenuButton(button: MenuItem): void { public addDynamicMenuButton(button: MenuItem): void {
if (!this._dynamicMenuButtons.includes(button)) { if (!this._dynamicMenuButtons.includes(button)) {
@@ -128,7 +128,7 @@ export class MenuButtonController {
].filter(isTruthy); ].filter(isTruthy);
} }
protected _getIrisButton(config: AdvancedCameraCardConfig): MenuItem { private _getIrisButton(config: AdvancedCameraCardConfig): MenuItem {
return { return {
icon: 'iris', icon: 'iris',
...config.menu.buttons.iris, ...config.menu.buttons.iris,
@@ -145,7 +145,7 @@ export class MenuButtonController {
}; };
} }
protected _getCamerasButton( private _getCamerasButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -180,7 +180,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getSubstreamsButton( private _getSubstreamsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -243,7 +243,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getLiveButton( private _getLiveButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -261,7 +261,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getClipsButton( private _getClipsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -280,7 +280,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getSnapshotsButton( private _getSnapshotsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -299,7 +299,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getRecordingsButton( private _getRecordingsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -318,7 +318,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getReviewsButton( private _getReviewsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -337,7 +337,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getGalleryButton( private _getGalleryButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -356,7 +356,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getImageButton( private _getImageButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -374,7 +374,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getTimelineButton( private _getTimelineButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -392,7 +392,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getDownloadButton( private _getDownloadButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -414,7 +414,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getInfoButton( private _getInfoButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
_cameraManager: CameraManager, _cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -435,7 +435,7 @@ export class MenuButtonController {
}; };
} }
protected _getSetReviewButton( private _getSetReviewButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
view?: View | null, view?: View | null,
): MenuItem | null { ): MenuItem | null {
@@ -460,7 +460,7 @@ export class MenuButtonController {
}; };
} }
protected _getCameraUIButton( private _getCameraUIButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
showCameraUIButton?: boolean, showCameraUIButton?: boolean,
): MenuItem | null { ): MenuItem | null {
@@ -475,7 +475,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getMicrophoneButton( private _getMicrophoneButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -519,7 +519,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getExpandButton( private _getExpandButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
inExpandedMode?: boolean, inExpandedMode?: boolean,
): MenuItem { ): MenuItem {
@@ -533,7 +533,7 @@ export class MenuButtonController {
}; };
} }
protected _getFullscreenButton( private _getFullscreenButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
fullscreenManager?: FullscreenManager | null, fullscreenManager?: FullscreenManager | null,
): MenuItem | null { ): MenuItem | null {
@@ -550,7 +550,7 @@ export class MenuButtonController {
: null; : null;
} }
protected _getCastButton( private _getCastButton(
hass: HomeAssistant, hass: HomeAssistant,
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
@@ -599,7 +599,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getPlayPauseButton( private _getPlayPauseButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null, currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null { ): MenuItem | null {
@@ -620,7 +620,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getMuteUnmuteButton( private _getMuteUnmuteButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null, currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null { ): MenuItem | null {
@@ -641,7 +641,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getScreenshotButton( private _getScreenshotButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null, currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null { ): MenuItem | null {
@@ -657,7 +657,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getDisplayModeButton( private _getDisplayModeButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
@@ -686,7 +686,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getPTZControlsButton( private _getPTZControlsButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -723,7 +723,7 @@ export class MenuButtonController {
return null; return null;
} }
protected _getPTZHomeButton( private _getPTZHomeButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
view?: View | null, view?: View | null,
@@ -754,7 +754,7 @@ export class MenuButtonController {
}; };
} }
protected _getFoldersButton( private _getFoldersButton(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
foldersManager?: FoldersManager | null, foldersManager?: FoldersManager | null,
view?: View | null, view?: View | null,
@@ -808,7 +808,7 @@ export class MenuButtonController {
* Get the style of emphasized menu items. * Get the style of emphasized menu items.
* @returns A StyleInfo. * @returns A StyleInfo.
*/ */
protected _getEmphasizedStyle(critical?: boolean): StyleInfo { private _getEmphasizedStyle(critical?: boolean): StyleInfo {
if (critical) { if (critical) {
return { return {
animation: 'pulse 3s infinite', animation: 'pulse 3s infinite',
@@ -826,7 +826,7 @@ export class MenuButtonController {
* @param button The button to examine. * @param button The button to examine.
* @returns A StyleInfo object. * @returns A StyleInfo object.
*/ */
protected _getStyleFromActions( private _getStyleFromActions(
config: AdvancedCameraCardConfig, config: AdvancedCameraCardConfig,
cameraManager: CameraManager, cameraManager: CameraManager,
foldersManager: FoldersManager, foldersManager: FoldersManager,
+7 -7
View File
@@ -11,10 +11,10 @@ import { getActionConfigGivenAction } from '../utils/action';
import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js'; import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js';
export class MenuController { export class MenuController {
protected _host: LitElement; private _host: LitElement;
protected _config: MenuConfig | null = null; private _config: MenuConfig | null = null;
protected _buttons: MenuItem[] = []; private _buttons: MenuItem[] = [];
protected _expanded = false; private _expanded = false;
constructor(host: LitElement) { constructor(host: LitElement) {
this._host = host; this._host = host;
@@ -146,7 +146,7 @@ export class MenuController {
} }
} }
protected _sortButtons(): void { private _sortButtons(): void {
this._buttons = orderBy( this._buttons = orderBy(
this._buttons, this._buttons,
(button) => { (button) => {
@@ -161,11 +161,11 @@ export class MenuController {
); );
} }
protected _isHidingMenu(): boolean { private _isHidingMenu(): boolean {
return this._config?.style === 'hidden'; return this._config?.style === 'hidden';
} }
protected _isMenuToggleAction(action: ActionConfig): boolean { private _isMenuToggleAction(action: ActionConfig): boolean {
return ( return (
action.action === 'fire-dom-event' && action.action === 'fire-dom-event' &&
action.advanced_camera_card_action === 'menu_toggle' action.advanced_camera_card_action === 'menu_toggle'
+8 -8
View File
@@ -9,11 +9,11 @@ import { arrayify, setOrRemoveAttribute } from '../utils/basic';
import { Timer } from '../utils/timer'; import { Timer } from '../utils/timer';
export class StatusBarController { export class StatusBarController {
protected _host: LitElement; private _host: LitElement;
protected _config: StatusBarConfig | null = null; private _config: StatusBarConfig | null = null;
protected _popupTimer = new Timer(); private _popupTimer = new Timer();
protected _items: StatusBarItem[] = []; private _items: StatusBarItem[] = [];
constructor(host: LitElement) { constructor(host: LitElement) {
this._host = host; this._host = host;
@@ -90,7 +90,7 @@ export class StatusBarController {
}); });
} }
protected _getSufficientValue(item: StatusBarItem): string | null { private _getSufficientValue(item: StatusBarItem): string | null {
/* istanbul ignore else: cannot happen -- @preserve */ /* istanbul ignore else: cannot happen -- @preserve */
if (item.type === 'custom:advanced-camera-card-status-bar-icon') { if (item.type === 'custom:advanced-camera-card-status-bar-icon') {
return item.icon; return item.icon;
@@ -103,17 +103,17 @@ export class StatusBarController {
} }
} }
protected _getSufficientValues(items: StatusBarItem[]): (string | null)[] { private _getSufficientValues(items: StatusBarItem[]): (string | null)[] {
return items return items
.filter((item) => item.enabled !== false && item.sufficient) .filter((item) => item.enabled !== false && item.sufficient)
.map((item) => this._getSufficientValue(item)); .map((item) => this._getSufficientValue(item));
} }
protected _show(): void { private _show(): void {
setOrRemoveAttribute(this._host, false, 'hide'); setOrRemoveAttribute(this._host, false, 'hide');
} }
protected _hide(): void { private _hide(): void {
setOrRemoveAttribute(this._host, true, 'hide'); setOrRemoveAttribute(this._host, true, 'hide');
} }
} }
+28 -28
View File
@@ -13,30 +13,30 @@ import {
} from './types'; } from './types';
export class ZoomController { export class ZoomController {
protected _element: HTMLElement; private _element: HTMLElement;
protected _panzoom?: PanzoomObject; private _panzoom?: PanzoomObject;
// Is the controller zoomed in at all? // Is the controller zoomed in at all?
protected _zoomed = false; private _zoomed = false;
// Is the controller set to the default zoom/pan settings? // Is the controller set to the default zoom/pan settings?
protected _default = true; private _default = true;
// Should clicks be allowed to propagate, or consumed as a pan/zoom action? // Should clicks be allowed to propagate, or consumed as a pan/zoom action?
protected _allowClick = true; private _allowClick = true;
protected _defaultSettings: PartialZoomSettings | null; private _defaultSettings: PartialZoomSettings | null;
protected _settings: PartialZoomSettings | null; private _settings: PartialZoomSettings | null;
// These values should be suitably less than the value of STEP_DELAY_SECONDS // These values should be suitably less than the value of STEP_DELAY_SECONDS
// in the ptz_digital action, in order to ensure smooth movements of the // in the ptz_digital action, in order to ensure smooth movements of the
// digital PTZ actions. // digital PTZ actions.
protected _debouncedChangeHandler = throttle(this._changeHandler.bind(this), 50); private _debouncedChangeHandler = throttle(this._changeHandler.bind(this), 50);
protected _debouncedUpdater = throttle(this._updateBasedOnConfig.bind(this), 50); private _debouncedUpdater = throttle(this._updateBasedOnConfig.bind(this), 50);
protected _resizeObserver = new ResizeObserver(this._debouncedUpdater); private _resizeObserver = new ResizeObserver(this._debouncedUpdater);
protected _events = isHoverableDevice() private _events = isHoverableDevice()
? { ? {
down: ['pointerdown'], down: ['pointerdown'],
move: ['pointermove'], move: ['pointermove'],
@@ -48,7 +48,7 @@ export class ZoomController {
up: ['touchend', 'touchcancel'], up: ['touchend', 'touchcancel'],
}; };
protected _downHandler = (ev: Event) => { private _downHandler = (ev: Event) => {
if (this._shouldZoomOrPan(ev)) { if (this._shouldZoomOrPan(ev)) {
this._panzoom?.handleDown(ev as PointerEvent); this._panzoom?.handleDown(ev as PointerEvent);
ev.stopPropagation(); ev.stopPropagation();
@@ -61,7 +61,7 @@ export class ZoomController {
} }
}; };
protected _clickHandler = (ev: Event) => { private _clickHandler = (ev: Event) => {
// When mouse clicking is used to pan, need to avoid that causing a click // When mouse clicking is used to pan, need to avoid that causing a click
// handler elsewhere in the card being called. Example: Viewing a snapshot, // handler elsewhere in the card being called. Example: Viewing a snapshot,
// and panning within it should not cause a related clip to play (the click // and panning within it should not cause a related clip to play (the click
@@ -77,21 +77,21 @@ export class ZoomController {
this._allowClick = true; this._allowClick = true;
}; };
protected _moveHandler = (ev: Event) => { private _moveHandler = (ev: Event) => {
if (this._shouldZoomOrPan(ev)) { if (this._shouldZoomOrPan(ev)) {
this._panzoom?.handleMove(ev as PointerEvent); this._panzoom?.handleMove(ev as PointerEvent);
ev.stopPropagation(); ev.stopPropagation();
} }
}; };
protected _upHandler = (ev: Event) => { private _upHandler = (ev: Event) => {
if (this._shouldZoomOrPan(ev)) { if (this._shouldZoomOrPan(ev)) {
this._panzoom?.handleUp(ev as PointerEvent); this._panzoom?.handleUp(ev as PointerEvent);
ev.stopPropagation(); ev.stopPropagation();
} }
}; };
protected _wheelHandler = (ev: Event) => { private _wheelHandler = (ev: Event) => {
if (ev instanceof WheelEvent && this._shouldZoomOrPan(ev)) { if (ev instanceof WheelEvent && this._shouldZoomOrPan(ev)) {
this._panzoom?.zoomWithWheel(ev); this._panzoom?.zoomWithWheel(ev);
ev.stopPropagation(); ev.stopPropagation();
@@ -198,7 +198,7 @@ export class ZoomController {
this._debouncedUpdater(); this._debouncedUpdater();
} }
protected _changeHandler(ev: Event): void { private _changeHandler(ev: Event): void {
const pz = (<CustomEvent<PanzoomEventDetail>>ev).detail; const pz = (<CustomEvent<PanzoomEventDetail>>ev).detail;
const unzoomed = this._isUnzoomed(pz.scale); const unzoomed = this._isUnzoomed(pz.scale);
@@ -228,7 +228,7 @@ export class ZoomController {
fireAdvancedCameraCardEvent(this._element, 'zoom:change', observed); fireAdvancedCameraCardEvent(this._element, 'zoom:change', observed);
} }
protected _isZoomEqual(a: PartialZoomSettings, b: PartialZoomSettings): boolean { private _isZoomEqual(a: PartialZoomSettings, b: PartialZoomSettings): boolean {
// The ?? clauses below cannot be reached since this function is only ever // The ?? clauses below cannot be reached since this function is only ever
// used fully specified by this object. It's kept as-is for completeness. // used fully specified by this object. It's kept as-is for completeness.
return ( return (
@@ -256,11 +256,11 @@ export class ZoomController {
); );
} }
protected _getConfigToUse(): PartialZoomSettings | null { private _getConfigToUse(): PartialZoomSettings | null {
return isZoomEmpty(this._settings) ? this._defaultSettings : this._settings; return isZoomEmpty(this._settings) ? this._defaultSettings : this._settings;
} }
protected _updateBasedOnConfig(): void { private _updateBasedOnConfig(): void {
if (!this._panzoom) { if (!this._panzoom) {
return; return;
} }
@@ -329,7 +329,7 @@ export class ZoomController {
* @param scale The desired (not current) scale. * @param scale The desired (not current) scale.
* @returns An object with x/y pan % values or null on error. * @returns An object with x/y pan % values or null on error.
*/ */
protected _convertPercentToXYPan( private _convertPercentToXYPan(
x: number, x: number,
y: number, y: number,
scale: number, scale: number,
@@ -345,7 +345,7 @@ export class ZoomController {
}; };
} }
protected _convertXYPanToPercent( private _convertXYPanToPercent(
x: number, x: number,
y: number, y: number,
scale: number, scale: number,
@@ -367,7 +367,7 @@ export class ZoomController {
}; };
} }
protected _getTransformMinMax( private _getTransformMinMax(
desiredScale: number, desiredScale: number,
currentScale?: number, currentScale?: number,
): { ): {
@@ -397,7 +397,7 @@ export class ZoomController {
}; };
} }
protected _getRenderedSize(scale?: number): { width: number; height: number } { private _getRenderedSize(scale?: number): { width: number; height: number } {
const rect = this._element.getBoundingClientRect(); const rect = this._element.getBoundingClientRect();
return { return {
width: rect.width / (scale ?? ZOOM_DEFAULT_SCALE), width: rect.width / (scale ?? ZOOM_DEFAULT_SCALE),
@@ -405,11 +405,11 @@ export class ZoomController {
}; };
} }
protected _isUnzoomed(scale?: number): boolean { private _isUnzoomed(scale?: number): boolean {
return scale !== undefined && round(scale, ZOOM_PRECISION) <= 1; return scale !== undefined && round(scale, ZOOM_PRECISION) <= 1;
} }
protected _isAtDefaultZoomAndPan(x: number, y: number, scale: number): boolean { private _isAtDefaultZoomAndPan(x: number, y: number, scale: number): boolean {
if (!this._defaultSettings) { if (!this._defaultSettings) {
return this._isUnzoomed(scale); return this._isUnzoomed(scale);
} }
@@ -438,7 +438,7 @@ export class ZoomController {
); );
} }
protected _shouldZoomOrPan(ev: Event): boolean { private _shouldZoomOrPan(ev: Event): boolean {
return ( return (
!this._isUnzoomed(this._panzoom?.getScale()) || !this._isUnzoomed(this._panzoom?.getScale()) ||
// TouchEvent does not exist on Firefox on non-touch events. See: // TouchEvent does not exist on Firefox on non-touch events. See:
@@ -448,7 +448,7 @@ export class ZoomController {
); );
} }
protected _setTouchAction(touchEnabled: boolean): void { private _setTouchAction(touchEnabled: boolean): void {
this._element.style.touchAction = touchEnabled ? '' : 'none'; this._element.style.touchAction = touchEnabled ? '' : 'none';
} }
} }
+4 -4
View File
@@ -48,12 +48,12 @@ export class AdvancedCameraCardCarousel extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public selected = 0; public selected = 0;
protected _refParent: Ref<HTMLSlotElement> = createRef(); private _refParent: Ref<HTMLSlotElement> = createRef();
protected _refRoot: Ref<HTMLElement> = createRef(); private _refRoot: Ref<HTMLElement> = createRef();
protected _carousel: CarouselController | null = null; private _carousel: CarouselController | null = null;
// Track slide count to distinguish user-navigation from content changes. // Track slide count to distinguish user-navigation from content changes.
protected _previousSlideCount: number | null = null; private _previousSlideCount: number | null = null;
connectedCallback(): void { connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
+1 -1
View File
@@ -16,7 +16,7 @@ export class AdvancedCameraCardDatePicker extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public icon?: string; public icon?: string;
protected _refInput: Ref<HTMLInputElement> = createRef(); private _refInput: Ref<HTMLInputElement> = createRef();
get value(): Date | null { get value(): Date | null {
return this._refInput.value?.value ? new Date(this._refInput.value.value) : null; return this._refInput.value?.value ? new Date(this._refInput.value.value) : null;
+1 -1
View File
@@ -20,7 +20,7 @@ export class AdvancedCameraCardDiagnostics extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public rawConfig?: RawAdvancedCameraCardConfig; public rawConfig?: RawAdvancedCameraCardConfig;
protected async _renderDiagnostics(): Promise<TemplateResult> { private async _renderDiagnostics(): Promise<TemplateResult> {
const diagnostics = await getDiagnostics( const diagnostics = await getDiagnostics(
this.hass, this.hass,
this.deviceRegistryManager, this.deviceRegistryManager,
+6 -6
View File
@@ -42,12 +42,12 @@ export class AdvancedCameraCardDrawer extends LitElement {
@property({ type: Boolean, reflect: true, attribute: true }) @property({ type: Boolean, reflect: true, attribute: true })
public empty = true; public empty = true;
protected _refDrawer: Ref<HTMLElement & { open: boolean }> = createRef(); private _refDrawer: Ref<HTMLElement & { open: boolean }> = createRef();
protected _refSlot: Ref<HTMLSlotElement> = createRef(); private _refSlot: Ref<HTMLSlotElement> = createRef();
protected _resizeObserver = new ResizeObserver(() => this._hideDrawerIfNecessary()); private _resizeObserver = new ResizeObserver(() => this._hideDrawerIfNecessary());
protected readonly _isHoverableDevice = isHoverableDevice(); private readonly _isHoverableDevice = isHoverableDevice();
/** /**
* Called on the first update. * Called on the first update.
@@ -64,7 +64,7 @@ export class AdvancedCameraCardDrawer extends LitElement {
this._refDrawer.value?.shadowRoot?.appendChild(style); this._refDrawer.value?.shadowRoot?.appendChild(style);
} }
protected _slotChanged(): void { private _slotChanged(): void {
const children = this._refSlot.value const children = this._refSlot.value
? getChildrenFromElement(this._refSlot.value) ? getChildrenFromElement(this._refSlot.value)
: []; : [];
@@ -77,7 +77,7 @@ export class AdvancedCameraCardDrawer extends LitElement {
this._hideDrawerIfNecessary(); this._hideDrawerIfNecessary();
} }
protected _hideDrawerIfNecessary(): void { private _hideDrawerIfNecessary(): void {
if (!this._refDrawer.value) { if (!this._refDrawer.value) {
return; return;
} }
+9 -9
View File
@@ -103,7 +103,7 @@ export class AdvancedCameraCardElementsCore extends LitElement {
* Create the root node for our picture elements. * Create the root node for our picture elements.
* @returns The newly created root. * @returns The newly created root.
*/ */
protected _createRoot(): HuiConditionalElement { private _createRoot(): HuiConditionalElement {
const elementConstructor = customElements.get('hui-conditional-element'); const elementConstructor = customElements.get('hui-conditional-element');
if (!elementConstructor || !this.hass) { if (!elementConstructor || !this.hass) {
throw new Error(localize('error.could_not_render_elements')); throw new Error(localize('error.could_not_render_elements'));
@@ -201,7 +201,7 @@ export class AdvancedCameraCardElements extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public conditionStateManager?: ConditionStateManager; public conditionStateManager?: ConditionStateManager;
protected _addHandler( private _addHandler(
target: EventTarget, target: EventTarget,
eventName: string, eventName: string,
handler: (ev: Event) => void, handler: (ev: Event) => void,
@@ -211,7 +211,7 @@ export class AdvancedCameraCardElements extends LitElement {
target.addEventListener(eventName, handler); target.addEventListener(eventName, handler);
} }
protected _menuRemoveHandler = (ev: Event): void => { private _menuRemoveHandler = (ev: Event): void => {
// Re-dispatch event from this element (instead of the disconnected one, as // Re-dispatch event from this element (instead of the disconnected one, as
// there is no parent of the disconnected element). // there is no parent of the disconnected element).
fireAdvancedCameraCardEvent<MenuItem>( fireAdvancedCameraCardEvent<MenuItem>(
@@ -221,7 +221,7 @@ export class AdvancedCameraCardElements extends LitElement {
); );
}; };
protected _statusBarRemoveHandler = (ev: Event): void => { private _statusBarRemoveHandler = (ev: Event): void => {
// Re-dispatch event from this element (instead of the disconnected one, as // Re-dispatch event from this element (instead of the disconnected one, as
// there is no parent of the disconnected element). // there is no parent of the disconnected element).
fireAdvancedCameraCardEvent<StatusBarItem>( fireAdvancedCameraCardEvent<StatusBarItem>(
@@ -231,7 +231,7 @@ export class AdvancedCameraCardElements extends LitElement {
); );
}; };
protected _menuAddHandler = (ev: Event): void => { private _menuAddHandler = (ev: Event): void => {
ev = ev as CustomEvent<MenuItem>; ev = ev as CustomEvent<MenuItem>;
const path = ev.composedPath(); const path = ev.composedPath();
if (!path.length) { if (!path.length) {
@@ -244,7 +244,7 @@ export class AdvancedCameraCardElements extends LitElement {
); );
}; };
protected _statusBarAddHandler = (ev: Event): void => { private _statusBarAddHandler = (ev: Event): void => {
ev = ev as CustomEvent<MenuItem>; ev = ev as CustomEvent<MenuItem>;
const path = ev.composedPath(); const path = ev.composedPath();
if (!path.length) { if (!path.length) {
@@ -299,8 +299,8 @@ export class AdvancedCameraCardElements extends LitElement {
*/ */
@customElement('advanced-camera-card-conditional') @customElement('advanced-camera-card-conditional')
export class AdvancedCameraCardElementsConditional extends LitElement { export class AdvancedCameraCardElementsConditional extends LitElement {
protected _config?: AdvancedCameraCardConditional; private _config?: AdvancedCameraCardConditional;
protected _conditionManager: ConditionsManager | null = null; private _conditionManager: ConditionsManager | null = null;
// A note on hass as an update mechanism: // A note on hass as an update mechanism:
// //
@@ -344,7 +344,7 @@ export class AdvancedCameraCardElementsConditional extends LitElement {
super.disconnectedCallback(); super.disconnectedCallback();
} }
protected _createConditionManager(): void { private _createConditionManager(): void {
const conditionStateManager = getConditionStateManagerViaEvent(this); const conditionStateManager = getConditionStateManagerViaEvent(this);
if (!this._config || !conditionStateManager) { if (!this._config || !conditionStateManager) {
return; return;
+8 -8
View File
@@ -74,9 +74,9 @@ export class AdvancedCameraCardGallery extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public conditionStateManager?: ConditionStateManagerReadonlyInterface; public conditionStateManager?: ConditionStateManagerReadonlyInterface;
protected _controller = new GalleryController(this); private _controller = new GalleryController(this);
protected _upFolderItem: ViewFolder | null = null; private _upFolderItem: ViewFolder | null = null;
protected _builder: UnifiedQueryBuilder | null = null; private _builder: UnifiedQueryBuilder | null = null;
protected willUpdate(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
if ( if (
@@ -98,14 +98,14 @@ export class AdvancedCameraCardGallery extends LitElement {
} }
} }
protected _getLimit(): number { private _getLimit(): number {
return ( return (
this.cardWideConfig?.performance?.features?.media_chunk_size ?? this.cardWideConfig?.performance?.features?.media_chunk_size ??
MEDIA_CHUNK_SIZE_DEFAULT MEDIA_CHUNK_SIZE_DEFAULT
); );
} }
protected _getFolderNavigationParameters(): FolderNavigationParamaters | null { private _getFolderNavigationParameters(): FolderNavigationParamaters | null {
return this._builder && this.viewManagerEpoch return this._builder && this.viewManagerEpoch
? { ? {
builder: this._builder, builder: this._builder,
@@ -115,7 +115,7 @@ export class AdvancedCameraCardGallery extends LitElement {
: null; : null;
} }
protected _renderUpFolder(): TemplateResult | void { private _renderUpFolder(): TemplateResult | void {
if (!this._upFolderItem) { if (!this._upFolderItem) {
return; return;
} }
@@ -133,7 +133,7 @@ export class AdvancedCameraCardGallery extends LitElement {
</advanced-camera-card-thumbnail>`; </advanced-camera-card-thumbnail>`;
} }
protected _renderThumbnails(): TemplateResult | void { private _renderThumbnails(): TemplateResult | void {
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
const selected = view?.queryResults?.getSelectedResult(); const selected = view?.queryResults?.getSelectedResult();
@@ -255,7 +255,7 @@ export class AdvancedCameraCardGallery extends LitElement {
`; `;
} }
protected async _extendGallery( private async _extendGallery(
ev: CustomEvent<GalleryExtendEvent>, ev: CustomEvent<GalleryExtendEvent>,
direction: 'earlier' | 'later', direction: 'earlier' | 'later',
useCache = true, useCache = true,
+2 -2
View File
@@ -23,8 +23,8 @@ export class AdvancedCameraCardImagePlayer extends LitElement implements MediaPl
@property() @property()
public technology?: MediaTechnology; public technology?: MediaTechnology;
protected _refImage: Ref<MediaPlayerElement<HTMLImageElement>> = createRef(); private _refImage: Ref<MediaPlayerElement<HTMLImageElement>> = createRef();
protected _mediaPlayerController = new ImageMediaPlayerController( private _mediaPlayerController = new ImageMediaPlayerController(
this, this,
() => this._refImage.value ?? null, () => this._refImage.value ?? null,
); );
+13 -13
View File
@@ -89,16 +89,16 @@ export class AdvancedCameraCardImageUpdatingPlayer
public imageConfig?: ImageBaseConfig; public imageConfig?: ImageBaseConfig;
@state() @state()
protected _message: Message | null = null; private _message: Message | null = null;
protected _refImage: Ref<HTMLImageElement> = createRef(); private _refImage: Ref<HTMLImageElement> = createRef();
protected _cachedValueController?: CachedValueController<string>; private _cachedValueController?: CachedValueController<string>;
protected _boundVisibilityHandler = this._visibilityHandler.bind(this); private _boundVisibilityHandler = this._visibilityHandler.bind(this);
protected _mediaLoadedInfo: MediaLoadedInfo | null = null; private _mediaLoadedInfo: MediaLoadedInfo | null = null;
protected _mediaPlayerController = new UpdatingImageMediaPlayerController( private _mediaPlayerController = new UpdatingImageMediaPlayerController(
this, this,
() => this._refImage.value ?? null, () => this._refImage.value ?? null,
() => this._cachedValueController ?? null, () => this._cachedValueController ?? null,
@@ -195,7 +195,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
* @param entity The entity. * @param entity The entity.
* @returns The state or null if not acceptable. * @returns The state or null if not acceptable.
*/ */
protected _getAcceptableState(entity: string | null): HassEntity | null { private _getAcceptableState(entity: string | null): HassEntity | null {
const state = (entity ? this.hass?.states[entity] : null) ?? null; const state = (entity ? this.hass?.states[entity] : null) ?? null;
return !!this.hass && return !!this.hass &&
@@ -228,7 +228,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
/** /**
* Handle document visibility changes. * Handle document visibility changes.
*/ */
protected _visibilityHandler(): void { private _visibilityHandler(): void {
if (!this._refImage.value) { if (!this._refImage.value) {
return; return;
} }
@@ -258,12 +258,12 @@ export class AdvancedCameraCardImageUpdatingPlayer
* @param url An input URL (may be relative to document origin) * @param url An input URL (may be relative to document origin)
* @returns A new URL as a string (absolute, will not be browser cached). * @returns A new URL as a string (absolute, will not be browser cached).
*/ */
protected _buildImageURL(url: URL): string { private _buildImageURL(url: URL): string {
url.searchParams.append('_t', String(Date.now())); url.searchParams.append('_t', String(Date.now()));
return url.toString(); return url.toString();
} }
protected _addQueryParametersToURL(url: URL, parameters?: string): URL { private _addQueryParametersToURL(url: URL, parameters?: string): URL {
if (parameters) { if (parameters) {
const searchParams = new URLSearchParams(parameters); const searchParams = new URLSearchParams(parameters);
for (const [key, value] of searchParams.entries()) { for (const [key, value] of searchParams.entries()) {
@@ -273,7 +273,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
return url; return url;
} }
protected _getRelevantEntityForMode(mode: Exclude<ImageMode, 'auto'>): string | null { private _getRelevantEntityForMode(mode: Exclude<ImageMode, 'auto'>): string | null {
return mode === 'camera' return mode === 'camera'
? getCameraEntityFromConfig(this.cameraConfig) ? getCameraEntityFromConfig(this.cameraConfig)
: mode === 'entity' : mode === 'entity'
@@ -281,7 +281,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
: null; : null;
} }
protected _getImageSource(): string { private _getImageSource(): string {
const mode = resolveImageMode({ const mode = resolveImageMode({
imageConfig: this.imageConfig, imageConfig: this.imageConfig,
cameraConfig: this.cameraConfig, cameraConfig: this.cameraConfig,
@@ -317,7 +317,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
/** /**
* Force the img element to a safe image. * Force the img element to a safe image.
*/ */
protected _forceSafeImage(stockOnly?: boolean): void { private _forceSafeImage(stockOnly?: boolean): void {
if (this._refImage.value) { if (this._refImage.value) {
this._refImage.value.src = this._refImage.value.src =
!stockOnly && this.imageConfig?.url ? this.imageConfig.url : defaultImage; !stockOnly && this.imageConfig?.url ? this.imageConfig.url : defaultImage;
+2 -2
View File
@@ -36,14 +36,14 @@ export class AdvancedCameraCardImage extends LitElement implements MediaPlayer {
@property({ attribute: false }) @property({ attribute: false })
public imageConfig?: ImageViewConfig; public imageConfig?: ImageViewConfig;
protected _refImage: Ref<MediaPlayerElement> = createRef(); private _refImage: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> { public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete; await this.updateComplete;
return (await this._refImage.value?.getMediaPlayerController()) ?? null; return (await this._refImage.value?.getMediaPlayerController()) ?? null;
} }
protected _renderContainer(template: TemplateResult): TemplateResult { private _renderContainer(template: TemplateResult): TemplateResult {
const zoomTarget = IMAGE_VIEW_ZOOM_TARGET_SENTINEL; const zoomTarget = IMAGE_VIEW_ZOOM_TARGET_SENTINEL;
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
const mode = resolveImageMode({ const mode = resolveImageMode({
+1 -1
View File
@@ -21,7 +21,7 @@ export class AdvancedCameraCardKeyAssigner extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public value?: KeyboardShortcut | null; public value?: KeyboardShortcut | null;
protected _controller = new KeyAssignerController(this); private _controller = new KeyAssignerController(this);
protected willUpdate(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('value')) { if (changedProps.has('value')) {
+18 -18
View File
@@ -71,15 +71,15 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
public viewFilterCameraID?: string; public viewFilterCameraID?: string;
// Index between camera name and slide number. // Index between camera name and slide number.
protected _cameraToSlide: Record<string, number> = {}; private _cameraToSlide: Record<string, number> = {};
protected _refPTZControl: Ref<AdvancedCameraCardPTZ> = createRef(); private _refPTZControl: Ref<AdvancedCameraCardPTZ> = createRef();
protected _refCarousel: Ref<HTMLElement> = createRef(); private _refCarousel: Ref<HTMLElement> = createRef();
protected _mediaActionsController = new MediaActionsController(); private _mediaActionsController = new MediaActionsController();
protected _mediaHeightController = new MediaHeightController(this, '.embla__slide'); private _mediaHeightController = new MediaHeightController(this, '.embla__slide');
@state() @state()
protected _mediaHasLoaded = false; private _mediaHasLoaded = false;
public connectedCallback(): void { public connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
@@ -96,11 +96,11 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
super.disconnectedCallback(); super.disconnectedCallback();
} }
protected _getTransitionEffect(): TransitionEffect { private _getTransitionEffect(): TransitionEffect {
return this.liveConfig?.transition_effect ?? configDefaults.live.transition_effect; return this.liveConfig?.transition_effect ?? configDefaults.live.transition_effect;
} }
protected _getSelectedCameraIndex(): number { private _getSelectedCameraIndex(): number {
if (this.viewFilterCameraID) { if (this.viewFilterCameraID) {
// If the carousel is limited to a single cameraID, the first (only) // If the carousel is limited to a single cameraID, the first (only)
// element is always the selected one. // element is always the selected one.
@@ -140,7 +140,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
} }
} }
protected _getPlugins(): EmblaCarouselPlugins { private _getPlugins(): EmblaCarouselPlugins {
return [AutoMediaLoadedInfo()]; return [AutoMediaLoadedInfo()];
} }
@@ -151,12 +151,12 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
* should load simultaneously. * should load simultaneously.
* @returns * @returns
*/ */
protected _getLazyLoadCount(): number | null { private _getLazyLoadCount(): number | null {
// Defaults to fully-lazy loading. // Defaults to fully-lazy loading.
return this.liveConfig?.lazy_load === false ? null : 0; return this.liveConfig?.lazy_load === false ? null : 0;
} }
protected _getSlides(): [TemplateResult[], Record<string, number>] { private _getSlides(): [TemplateResult[], Record<string, number>] {
if (!this.cameraManager) { if (!this.cameraManager) {
return [[], {}]; return [[], {}];
} }
@@ -179,14 +179,14 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
return [slides, cameraToSlide]; return [slides, cameraToSlide];
} }
protected _setViewHandler(ev: CustomEvent<CarouselSelected>): void { private _setViewHandler(ev: CustomEvent<CarouselSelected>): void {
const cameraIDs = this.cameraManager?.getStore().getCameraIDsWithCapability('live'); const cameraIDs = this.cameraManager?.getStore().getCameraIDsWithCapability('live');
if (cameraIDs?.size && ev.detail.index !== this._getSelectedCameraIndex()) { if (cameraIDs?.size && ev.detail.index !== this._getSelectedCameraIndex()) {
this._setViewCameraID([...cameraIDs][ev.detail.index]); this._setViewCameraID([...cameraIDs][ev.detail.index]);
} }
} }
protected _setViewCameraID(cameraID?: string | null): void { private _setViewCameraID(cameraID?: string | null): void {
if (cameraID) { if (cameraID) {
this.viewManagerEpoch?.manager.setViewByParametersWithNewQuery({ this.viewManagerEpoch?.manager.setViewByParametersWithNewQuery({
params: { params: {
@@ -196,7 +196,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
} }
} }
protected _renderLive(cameraID: string): TemplateResult | void { private _renderLive(cameraID: string): TemplateResult | void {
const camera = this.cameraManager?.getStore().getCamera(cameraID); const camera = this.cameraManager?.getStore().getCamera(cameraID);
if (!this.liveConfig || !this.hass || !this.cameraManager || !camera) { if (!this.liveConfig || !this.hass || !this.cameraManager || !camera) {
return; return;
@@ -233,11 +233,11 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
`; `;
} }
protected _getSubstreamCameraID(cameraID: string, view?: View | null): string { private _getSubstreamCameraID(cameraID: string, view?: View | null): string {
return view?.context?.live?.overrides?.get(cameraID) ?? cameraID; return view?.context?.live?.overrides?.get(cameraID) ?? cameraID;
} }
protected _getCameraNeighbors(): CameraNeighbors | null { private _getCameraNeighbors(): CameraNeighbors | null {
const cameraIDs = this.cameraManager const cameraIDs = this.cameraManager
? [...this.cameraManager?.getStore().getCameraIDsWithCapability('live')] ? [...this.cameraManager?.getStore().getCameraIDsWithCapability('live')]
: []; : [];
@@ -279,7 +279,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
}; };
} }
protected _renderNextPrevious( private _renderNextPrevious(
side: 'left' | 'right', side: 'left' | 'right',
neighbors: CameraNeighbors | null, neighbors: CameraNeighbors | null,
): TemplateResult { ): TemplateResult {
@@ -370,7 +370,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
`; `;
} }
protected _setMediaTarget(): void { private _setMediaTarget(): void {
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
const selectedCameraIndex = this._getSelectedCameraIndex(); const selectedCameraIndex = this._getSelectedCameraIndex();
+3 -3
View File
@@ -41,7 +41,7 @@ export class AdvancedCameraCardLiveGrid extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public triggeredCameraIDs?: Set<string>; public triggeredCameraIDs?: Set<string>;
protected _renderCarousel(cameraID?: string): TemplateResult { private _renderCarousel(cameraID?: string): TemplateResult {
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
const triggeredCameraID = cameraID ?? view?.camera; const triggeredCameraID = cameraID ?? view?.camera;
@@ -69,7 +69,7 @@ export class AdvancedCameraCardLiveGrid extends LitElement {
`; `;
} }
protected _gridSelectCamera(cameraID: string): void { private _gridSelectCamera(cameraID: string): void {
this.viewManagerEpoch?.manager.setViewByParameters({ this.viewManagerEpoch?.manager.setViewByParameters({
params: { params: {
camera: cameraID, camera: cameraID,
@@ -77,7 +77,7 @@ export class AdvancedCameraCardLiveGrid extends LitElement {
}); });
} }
protected _needsGrid(): boolean { private _needsGrid(): boolean {
const cameraIDs = this.cameraManager?.getStore().getCameraIDsWithCapability('live'); const cameraIDs = this.cameraManager?.getStore().getCameraIDsWithCapability('live');
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
return ( return (
+1 -1
View File
@@ -33,7 +33,7 @@ export class AdvancedCameraCardLive extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public triggeredCameraIDs?: Set<string>; public triggeredCameraIDs?: Set<string>;
protected _controller = new LiveController(this); private _controller = new LiveController(this);
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
if (!this.hass || !this.cameraManager) { if (!this.hass || !this.cameraManager) {
+10 -10
View File
@@ -62,17 +62,17 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
public zoomSettings?: PartialZoomSettings | null; public zoomSettings?: PartialZoomSettings | null;
@state() @state()
protected _isVideoMediaLoaded = false; private _isVideoMediaLoaded = false;
@state() @state()
protected _hasProviderError = false; private _hasProviderError = false;
@state() @state()
protected _showStreamTroubleshooting = false; private _showStreamTroubleshooting = false;
protected _refProvider: Ref<MediaPlayerElement> = createRef(); private _refProvider: Ref<MediaPlayerElement> = createRef();
protected _lazyLoadController: LazyLoadController = new LazyLoadController(this); private _lazyLoadController: LazyLoadController = new LazyLoadController(this);
// A note on dynamic imports: // A note on dynamic imports:
// //
@@ -84,7 +84,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
// Test case: A card with a non-live view, but live pre-loaded, attempts to // Test case: A card with a non-live view, but live pre-loaded, attempts to
// call mute() when the <advanced-camera-card-live> element first renders in // call mute() when the <advanced-camera-card-live> element first renders in
// the background. These calls fail without waiting for loading here. // the background. These calls fail without waiting for loading here.
protected _importPromises: Promise<unknown>[] = []; private _importPromises: Promise<unknown>[] = [];
constructor() { constructor() {
super(); super();
@@ -106,7 +106,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
* whilst loading. * whilst loading.
* @returns`true` if an image should be shown. * @returns`true` if an image should be shown.
*/ */
protected _shouldShowImageDuringLoading(): boolean { private _shouldShowImageDuringLoading(): boolean {
return ( return (
!this._isVideoMediaLoaded && !this._isVideoMediaLoaded &&
!!this.camera?.getConfig()?.camera_entity && !!this.camera?.getConfig()?.camera_entity &&
@@ -123,12 +123,12 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
super.disconnectedCallback(); super.disconnectedCallback();
} }
protected _videoMediaShowHandler(): void { private _videoMediaShowHandler(): void {
this._isVideoMediaLoaded = true; this._isVideoMediaLoaded = true;
this._showStreamTroubleshooting = false; this._showStreamTroubleshooting = false;
} }
protected _providerErrorHandler(): void { private _providerErrorHandler(): void {
this._hasProviderError = true; this._hasProviderError = true;
} }
@@ -177,7 +177,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
return result; return result;
} }
protected _renderContainer(template: TemplateResult): TemplateResult { private _renderContainer(template: TemplateResult): TemplateResult {
const config = this.camera?.getConfig(); const config = this.camera?.getConfig();
const intermediateTemplate = html` <advanced-camera-card-media-dimensions-container const intermediateTemplate = html` <advanced-camera-card-media-dimensions-container
.dimensionsConfig=${config?.dimensions} .dimensionsConfig=${config?.dimensions}
@@ -53,11 +53,11 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer
public controls = false; public controls = false;
@state() @state()
protected _message: Message | null = null; private _message: Message | null = null;
protected _player?: VideoRTC; private _player?: VideoRTC;
protected _mediaPlayerController = new VideoMediaPlayerController( private _mediaPlayerController = new VideoMediaPlayerController(
this, this,
() => this._player?.video ?? null, () => this._player?.video ?? null,
() => this.controls, () => this.controls,
@@ -81,7 +81,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer
this.requestUpdate(); this.requestUpdate();
} }
protected _handleError(message: Message, e?: Error): void { private _handleError(message: Message, e?: Error): void {
if (e) { if (e) {
errorToConsole(e as Error); errorToConsole(e as Error);
} }
@@ -94,7 +94,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer
return; return;
} }
protected async _getPlayerSource(): Promise<string | null> { private async _getPlayerSource(): Promise<string | null> {
const cameraConfig = this.camera?.getConfig(); const cameraConfig = this.camera?.getConfig();
const proxyConfig = this.camera?.getProxyConfig(); const proxyConfig = this.camera?.getProxyConfig();
if (!this.hass || !cameraConfig) { if (!this.hass || !cameraConfig) {
@@ -155,7 +155,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer
return result; return result;
} }
protected async _createPlayer(): Promise<void> { private async _createPlayer(): Promise<void> {
const src = await this._getPlayerSource(); const src = await this._getPlayerSource();
if (!src) { if (!src) {
return; return;
+1 -1
View File
@@ -24,7 +24,7 @@ export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer
@property({ attribute: true, type: Boolean }) @property({ attribute: true, type: Boolean })
public controls = false; public controls = false;
protected _playerRef: Ref<MediaPlayerElement> = createRef(); private _playerRef: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> { public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete; await this.updateComplete;
+1 -1
View File
@@ -19,7 +19,7 @@ export class AdvancedCameraCardLiveImage extends LitElement implements MediaPlay
@property({ attribute: false }) @property({ attribute: false })
public cameraConfig?: CameraConfig; public cameraConfig?: CameraConfig;
protected _refImage: Ref<MediaPlayerElement> = createRef(); private _refImage: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> { public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete; await this.updateComplete;
+9 -9
View File
@@ -39,7 +39,7 @@ const JSMPEG_URL_SIGN_REFRESH_THRESHOLD_SECONDS = 1 * 60 * 60;
@customElement('advanced-camera-card-live-jsmpeg') @customElement('advanced-camera-card-live-jsmpeg')
export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPlayer { export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPlayer {
protected hass?: HomeAssistant; private hass?: HomeAssistant;
@property({ attribute: false }) @property({ attribute: false })
public cameraConfig?: CameraConfig; public cameraConfig?: CameraConfig;
@@ -51,13 +51,13 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla
public cardWideConfig?: CardWideConfig; public cardWideConfig?: CardWideConfig;
@state() @state()
protected _message: Message | null = null; private _message: Message | null = null;
protected _jsmpegCanvasElement?: HTMLCanvasElement; private _jsmpegCanvasElement?: HTMLCanvasElement;
protected _jsmpegVideoPlayer?: JSMpeg.VideoElement; private _jsmpegVideoPlayer?: JSMpeg.VideoElement;
protected _refreshPlayerTimer = new Timer(); private _refreshPlayerTimer = new Timer();
protected _mediaPlayerController = new JSMPEGMediaPlayerController( private _mediaPlayerController = new JSMPEGMediaPlayerController(
this, this,
() => this._jsmpegVideoPlayer ?? null, () => this._jsmpegVideoPlayer ?? null,
() => this._jsmpegCanvasElement ?? null, () => this._jsmpegCanvasElement ?? null,
@@ -75,7 +75,7 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla
} }
} }
protected async _createJSMPEGPlayer(url: string): Promise<JSMpeg.VideoElement> { private async _createJSMPEGPlayer(url: string): Promise<JSMpeg.VideoElement> {
this._jsmpegVideoPlayer = await new Promise<JSMpeg.VideoElement>((resolve) => { this._jsmpegVideoPlayer = await new Promise<JSMpeg.VideoElement>((resolve) => {
let videoDecoded = false; let videoDecoded = false;
const player = new JSMpeg.VideoElement( const player = new JSMpeg.VideoElement(
@@ -132,7 +132,7 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla
} }
} }
protected _resetPlayer(): void { private _resetPlayer(): void {
this._message = null; this._message = null;
this._refreshPlayerTimer.stop(); this._refreshPlayerTimer.stop();
if (this._jsmpegVideoPlayer) { if (this._jsmpegVideoPlayer) {
@@ -164,7 +164,7 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla
super.disconnectedCallback(); super.disconnectedCallback();
} }
protected async _refreshPlayer(): Promise<void> { private async _refreshPlayer(): Promise<void> {
if (!this.hass) { if (!this.hass) {
return; return;
} }
+8 -10
View File
@@ -59,11 +59,11 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi
public controls = false; public controls = false;
@state() @state()
protected _message: Message | null = null; private _message: Message | null = null;
protected hass?: HomeAssistant; private hass?: HomeAssistant;
protected _mediaPlayerController = new VideoMediaPlayerController( private _mediaPlayerController = new VideoMediaPlayerController(
this, this,
() => this._getVideo(), () => this._getVideo(),
() => this.controls, () => this.controls,
@@ -74,7 +74,7 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi
} }
// A task to await the load of the WebRTC component. // A task to await the load of the WebRTC component.
protected _webrtcTask = new Task(this, this._getWebRTCCardElement, () => [1]); private _webrtcTask = new Task(this, this._getWebRTCCardElement, () => [1]);
connectedCallback(): void { connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
@@ -97,7 +97,7 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi
} }
} }
protected _getVideoRTC(): VideoRTC | null { private _getVideoRTC(): VideoRTC | null {
return (this.renderRoot?.querySelector('#webrtc') ?? null) as VideoRTC | null; return (this.renderRoot?.querySelector('#webrtc') ?? null) as VideoRTC | null;
} }
@@ -105,13 +105,11 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi
* Get the underlying video player. * Get the underlying video player.
* @returns The player or `null` if not found. * @returns The player or `null` if not found.
*/ */
protected _getVideo(): HTMLVideoElement | null { private _getVideo(): HTMLVideoElement | null {
return this._getVideoRTC()?.video ?? null; return this._getVideoRTC()?.video ?? null;
} }
protected async _getWebRTCCardElement(): Promise< private async _getWebRTCCardElement(): Promise<CustomElementConstructor | undefined> {
CustomElementConstructor | undefined
> {
await customElements.whenDefined('webrtc-camera'); await customElements.whenDefined('webrtc-camera');
return customElements.get('webrtc-camera'); return customElements.get('webrtc-camera');
} }
@@ -119,7 +117,7 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi
/** /**
* Create the WebRTC element. May throw. * Create the WebRTC element. May throw.
*/ */
protected _createWebRTC(): HTMLElement | null { private _createWebRTC(): HTMLElement | null {
const webrtcElement = this._webrtcTask.value; const webrtcElement = this._webrtcTask.value;
if (webrtcElement && this.hass && this.cameraConfig) { if (webrtcElement && this.hass && this.cameraConfig) {
const webrtc = new webrtcElement() as HTMLElement & { const webrtc = new webrtcElement() as HTMLElement & {
+3 -3
View File
@@ -17,10 +17,10 @@ export class AdvancedCameraCardMediaDimensionsContainer extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public dimensionsConfig?: CameraDimensionsConfig; public dimensionsConfig?: CameraDimensionsConfig;
protected _controller = new MediaDimensionsContainerController(this); private _controller = new MediaDimensionsContainerController(this);
protected _refInnerContainer: Ref<HTMLElement> = createRef(); private _refInnerContainer: Ref<HTMLElement> = createRef();
protected _refOuterContainer: Ref<HTMLElement> = createRef(); private _refOuterContainer: Ref<HTMLElement> = createRef();
protected willUpdate(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('dimensionsConfig')) { if (changedProps.has('dimensionsConfig')) {
+12 -12
View File
@@ -48,19 +48,19 @@ class AdvancedCameraCardMediaFilter extends ScopedRegistryHost(LitElement) {
'advanced-camera-card-date-picker': AdvancedCameraCardDatePicker, 'advanced-camera-card-date-picker': AdvancedCameraCardDatePicker,
}; };
protected _mediaFilterController = new MediaFilterController(this); private _mediaFilterController = new MediaFilterController(this);
protected _refMediaType: Ref<AdvancedCameraCardSelect> = createRef(); private _refMediaType: Ref<AdvancedCameraCardSelect> = createRef();
protected _refCamera: Ref<AdvancedCameraCardSelect> = createRef(); private _refCamera: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhen: Ref<AdvancedCameraCardSelect> = createRef(); private _refWhen: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhenFrom: Ref<AdvancedCameraCardDatePicker> = createRef(); private _refWhenFrom: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refWhenTo: Ref<AdvancedCameraCardDatePicker> = createRef(); private _refWhenTo: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refWhat: Ref<AdvancedCameraCardSelect> = createRef(); private _refWhat: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhere: Ref<AdvancedCameraCardSelect> = createRef(); private _refWhere: Ref<AdvancedCameraCardSelect> = createRef();
protected _refFavorite: Ref<AdvancedCameraCardSelect> = createRef(); private _refFavorite: Ref<AdvancedCameraCardSelect> = createRef();
protected _refReviewed: Ref<AdvancedCameraCardSelect> = createRef(); private _refReviewed: Ref<AdvancedCameraCardSelect> = createRef();
protected _refSeverity: Ref<AdvancedCameraCardSelect> = createRef(); private _refSeverity: Ref<AdvancedCameraCardSelect> = createRef();
protected _refTags: Ref<AdvancedCameraCardSelect> = createRef(); private _refTags: Ref<AdvancedCameraCardSelect> = createRef();
protected willUpdate(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('viewManagerEpoch')) { if (changedProps.has('viewManagerEpoch')) {
+2 -2
View File
@@ -20,8 +20,8 @@ export class AdvancedCameraCardMediaGrid extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public displayConfig?: ViewDisplayConfig; public displayConfig?: ViewDisplayConfig;
protected _controller: MediaGridController | null = null; private _controller: MediaGridController | null = null;
protected _refSlot: Ref<HTMLSlotElement> = createRef(); private _refSlot: Ref<HTMLSlotElement> = createRef();
connectedCallback(): void { connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
+3 -3
View File
@@ -16,7 +16,7 @@ import './submenu/submenu-button';
@customElement('advanced-camera-card-menu') @customElement('advanced-camera-card-menu')
export class AdvancedCameraCardMenu extends LitElement { export class AdvancedCameraCardMenu extends LitElement {
protected _controller = new MenuController(this); private _controller = new MenuController(this);
@property({ attribute: false }) @property({ attribute: false })
public entityRegistryManager?: EntityRegistryManager; public entityRegistryManager?: EntityRegistryManager;
@@ -40,7 +40,7 @@ export class AdvancedCameraCardMenu extends LitElement {
this._controller.toggleExpanded(); this._controller.toggleExpanded();
} }
protected _renderButton(button: MenuItem): TemplateResult | void { private _renderButton(button: MenuItem): TemplateResult | void {
if (!this.hass) { if (!this.hass) {
return; return;
} }
@@ -100,7 +100,7 @@ export class AdvancedCameraCardMenu extends LitElement {
* specificity, so the most specific theme variable will match, followed by * specificity, so the most specific theme variable will match, followed by
* the next most specific, etc. * the next most specific, etc.
*/ */
protected _renderPerInstanceStyle(): TemplateResult | void { private _renderPerInstanceStyle(): TemplateResult | void {
const config = this._controller.getMenuConfig(); const config = this._controller.getMenuConfig();
if (!config) { if (!config) {
return; return;
+2 -2
View File
@@ -27,7 +27,7 @@ export class AdvancedCameraCardNextPreviousControl extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
@state() @state()
protected _controlConfig?: NextPreviousControlConfig; private _controlConfig?: NextPreviousControlConfig;
@property({ attribute: false }) @property({ attribute: false })
public thumbnail?: string; public thumbnail?: string;
@@ -41,7 +41,7 @@ export class AdvancedCameraCardNextPreviousControl extends LitElement {
// Label that is used for ARIA support and as tooltip. // Label that is used for ARIA support and as tooltip.
@property() label = ''; @property() label = '';
protected _embedThumbnailTask = createFetchThumbnailTask( private _embedThumbnailTask = createFetchThumbnailTask(
this, this,
() => this.hass, () => this.hass,
() => this.thumbnail, () => this.thumbnail,
+8 -8
View File
@@ -12,7 +12,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public message: OverlayMessage | null = null; public message: OverlayMessage | null = null;
protected _refMessage: Ref<HTMLElement> = createRef(); private _refMessage: Ref<HTMLElement> = createRef();
public connectedCallback(): void { public connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
@@ -64,7 +64,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
`; `;
} }
protected _renderControl(control: OverlayMessageControl): TemplateResult { private _renderControl(control: OverlayMessageControl): TemplateResult {
const emphasisClass = control.emphasis ? `emphasis-${control.emphasis}` : ''; const emphasisClass = control.emphasis ? `emphasis-${control.emphasis}` : '';
return html` return html`
<div <div
@@ -81,7 +81,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
`; `;
} }
protected async _handleControlClick(control: OverlayMessageControl): Promise<void> { private async _handleControlClick(control: OverlayMessageControl): Promise<void> {
const result = await control.callback(); const result = await control.callback();
if (result === null) { if (result === null) {
// null = close the message // null = close the message
@@ -92,7 +92,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
} }
} }
protected _renderDetail(detail: MetadataField, isHeading = false): TemplateResult { private _renderDetail(detail: MetadataField, isHeading = false): TemplateResult {
const classes = { const classes = {
detail: true, detail: true,
heading: isHeading, heading: isHeading,
@@ -111,23 +111,23 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
`; `;
} }
protected _dismiss = (): void => { private _dismiss = (): void => {
this._refMessage.value?.classList.add('exiting'); this._refMessage.value?.classList.add('exiting');
}; };
protected _handleAnimationEnd = (ev: AnimationEvent): void => { private _handleAnimationEnd = (ev: AnimationEvent): void => {
if (ev.animationName === 'slideDown') { if (ev.animationName === 'slideDown') {
dispatchDismissOverlayMessageEvent(this); dispatchDismissOverlayMessageEvent(this);
} }
}; };
protected _handleOutsideInteraction = (ev: Event): void => { private _handleOutsideInteraction = (ev: Event): void => {
if (!ev.composedPath().includes(this)) { if (!ev.composedPath().includes(this)) {
this._dismiss(); this._dismiss();
} }
}; };
protected _handleKeyDown = (ev: KeyboardEvent): void => { private _handleKeyDown = (ev: KeyboardEvent): void => {
if (ev.key === 'Escape') { if (ev.key === 'Escape') {
this._dismiss(); this._dismiss();
ev.stopPropagation(); ev.stopPropagation();
+2 -2
View File
@@ -40,8 +40,8 @@ export class AdvancedCameraCardPTZ extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public forceVisibility?: boolean; public forceVisibility?: boolean;
protected _controller = new PTZController(this); private _controller = new PTZController(this);
protected _actions: PTZControllerActions | null = null; private _actions: PTZControllerActions | null = null;
protected willUpdate(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('config')) { if (changedProps.has('config')) {
+3 -3
View File
@@ -49,8 +49,8 @@ export class AdvancedCameraCardSelect extends ScopedRegistryHost(LitElement) {
@property({ attribute: true, type: Boolean }) @property({ attribute: true, type: Boolean })
public clearable?: boolean = false; public clearable?: boolean = false;
protected _previouslyReportedValue?: SelectValues; private _previouslyReportedValue?: SelectValues;
protected _refSelect: Ref<SelectElement> = createRef(); private _refSelect: Ref<SelectElement> = createRef();
static elementDefinitions = { static elementDefinitions = {
...grSelectElements, ...grSelectElements,
@@ -61,7 +61,7 @@ export class AdvancedCameraCardSelect extends ScopedRegistryHost(LitElement) {
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
protected _valueChangedHandler(_ev: CustomEvent<{ value: unknown }>): void { private _valueChangedHandler(_ev: CustomEvent<{ value: unknown }>): void {
const value: SelectValues | undefined = this._refSelect.value?.value; const value: SelectValues | undefined = this._refSelect.value?.value;
// The underlying gr-select element is very sensitive and occasionally fires // The underlying gr-select element is very sensitive and occasionally fires
// the change event even if the value has not actually changed. Prevent that // the change event even if the value has not actually changed. Prevent that
+2 -2
View File
@@ -18,7 +18,7 @@ import './icon.js';
@customElement('advanced-camera-card-status-bar') @customElement('advanced-camera-card-status-bar')
export class AdvancedCameraCardStatusBar extends LitElement { export class AdvancedCameraCardStatusBar extends LitElement {
protected _controller = new StatusBarController(this); private _controller = new StatusBarController(this);
@property({ attribute: false }) @property({ attribute: false })
public items?: StatusBarItem[]; public items?: StatusBarItem[];
@@ -44,7 +44,7 @@ export class AdvancedCameraCardStatusBar extends LitElement {
* specificity, so the most specific theme variable will match, followed by * specificity, so the most specific theme variable will match, followed by
* the next most specific, etc. * the next most specific, etc.
*/ */
protected _renderPerInstanceStyle(): TemplateResult | void { private _renderPerInstanceStyle(): TemplateResult | void {
const config = this._controller.getConfig(); const config = this._controller.getConfig();
if (!config) { if (!config) {
return; return;
+1 -1
View File
@@ -20,7 +20,7 @@ export class AdvancedCameraCardSubmenu extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public items?: SubmenuItem[]; public items?: SubmenuItem[];
protected _renderItem(item: SubmenuItem): TemplateResult | void { private _renderItem(item: SubmenuItem): TemplateResult | void {
if (!this.hass) { if (!this.hass) {
return; return;
} }
+4 -4
View File
@@ -34,10 +34,10 @@ export class AdvancedCameraCardSubmenuSelectButton extends LitElement {
public entityRegistryManager?: EntityRegistryManager; public entityRegistryManager?: EntityRegistryManager;
@state() @state()
protected _optionTitles?: Record<string, string>; private _optionTitles?: Record<string, string>;
protected _generatedSubmenuItems?: MenuSubmenuItem[]; private _generatedSubmenuItems?: MenuSubmenuItem[];
protected _generatedIcon?: Icon; private _generatedIcon?: Icon;
protected shouldUpdate(changedProps: PropertyValues): boolean { protected shouldUpdate(changedProps: PropertyValues): boolean {
// No need to update the submenu unless the select entity has changed. // No need to update the submenu unless the select entity has changed.
@@ -50,7 +50,7 @@ export class AdvancedCameraCardSubmenuSelectButton extends LitElement {
); );
} }
protected async _refreshOptionTitles(): Promise<void> { private async _refreshOptionTitles(): Promise<void> {
if (!this.hass || !this.submenuSelect) { if (!this.hass || !this.submenuSelect) {
return; return;
} }
+4 -4
View File
@@ -19,9 +19,9 @@ export class AdvancedCameraCardSurroundBasic extends LitElement {
right?: DrawerIcons; right?: DrawerIcons;
}; };
protected _refDrawerLeft: Ref<AdvancedCameraCardDrawer> = createRef(); private _refDrawerLeft: Ref<AdvancedCameraCardDrawer> = createRef();
protected _refDrawerRight: Ref<AdvancedCameraCardDrawer> = createRef(); private _refDrawerRight: Ref<AdvancedCameraCardDrawer> = createRef();
protected _boundDrawerHandler = this._drawerHandler.bind(this); private _boundDrawerHandler = this._drawerHandler.bind(this);
connectedCallback(): void { connectedCallback(): void {
super.connectedCallback(); super.connectedCallback();
@@ -41,7 +41,7 @@ export class AdvancedCameraCardSurroundBasic extends LitElement {
super.disconnectedCallback(); super.disconnectedCallback();
} }
protected _drawerHandler(ev: Event) { private _drawerHandler(ev: Event) {
const drawer = (ev as CustomEvent<AdvancedCameraCardDrawerOpen>).detail.drawer; const drawer = (ev as CustomEvent<AdvancedCameraCardDrawerOpen>).detail.drawer;
const open = ev.type.endsWith(':open'); const open = ev.type.endsWith(':open');
if (drawer === 'left' && this._refDrawerLeft.value) { if (drawer === 'left' && this._refDrawerLeft.value) {
+1 -1
View File
@@ -54,7 +54,7 @@ export class AdvancedCameraCardSurround extends LitElement {
/** /**
* Determine if a drawer is being used. * Determine if a drawer is being used.
*/ */
protected _hasDrawer(): boolean { private _hasDrawer(): boolean {
return ( return (
!!this.thumbnailConfig && ['left', 'right'].includes(this.thumbnailConfig.mode) !!this.thumbnailConfig && ['left', 'right'].includes(this.thumbnailConfig.mode)
); );
+9 -9
View File
@@ -65,17 +65,17 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public fadeThumbnails = false; public fadeThumbnails = false;
protected _thumbnails: TemplateResult[] = []; private _thumbnails: TemplateResult[] = [];
protected _builder: UnifiedQueryBuilder | null = null; private _builder: UnifiedQueryBuilder | null = null;
protected _getLimit(): number { private _getLimit(): number {
return ( return (
this.cardWideConfig?.performance?.features?.media_chunk_size ?? this.cardWideConfig?.performance?.features?.media_chunk_size ??
MEDIA_CHUNK_SIZE_DEFAULT MEDIA_CHUNK_SIZE_DEFAULT
); );
} }
protected _getFolderNavOptions(): FolderNavigationParamaters | undefined { private _getFolderNavOptions(): FolderNavigationParamaters | undefined {
return this._builder && this.viewManagerEpoch return this._builder && this.viewManagerEpoch
? { ? {
builder: this._builder, builder: this._builder,
@@ -127,13 +127,13 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
} }
} }
protected _getSelectedSlide(): number | null { private _getSelectedSlide(): number | null {
return ( return (
this.viewManagerEpoch?.manager.getView()?.queryResults?.getSelectedIndex() ?? null this.viewManagerEpoch?.manager.getView()?.queryResults?.getSelectedIndex() ?? null
); );
} }
protected _handleMediaClick(item: ViewMedia): void { private _handleMediaClick(item: ViewMedia): void {
fireAdvancedCameraCardEvent<ThumbnailMediaSelect>( fireAdvancedCameraCardEvent<ThumbnailMediaSelect>(
this, this,
'thumbnails-carousel:media-select', 'thumbnails-carousel:media-select',
@@ -147,7 +147,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
} }
} }
protected _renderThumbnail( private _renderThumbnail(
item: ViewItem, item: ViewItem,
selected: boolean, selected: boolean,
clickCallback: (item: ViewItem, ev: Event) => void, clickCallback: (item: ViewItem, ev: Event) => void,
@@ -183,7 +183,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
</advanced-camera-card-thumbnail>`; </advanced-camera-card-thumbnail>`;
} }
protected _renderThumbnails(): TemplateResult[] { private _renderThumbnails(): TemplateResult[] {
const upFolderItem = getUpFolderItem( const upFolderItem = getUpFolderItem(
this.viewManagerEpoch?.manager.getView()?.query, this.viewManagerEpoch?.manager.getView()?.query,
); );
@@ -221,7 +221,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
return thumbnails; return thumbnails;
} }
protected _getDirection(): CarouselDirection | null { private _getDirection(): CarouselDirection | null {
if (this.config?.mode === 'left' || this.config?.mode === 'right') { if (this.config?.mode === 'left' || this.config?.mode === 'right') {
return 'vertical'; return 'vertical';
} else if (this.config?.mode === 'above' || this.config?.mode === 'below') { } else if (this.config?.mode === 'above' || this.config?.mode === 'below') {
@@ -25,10 +25,10 @@ export class AdvancedCameraCardThumbnailFeatureThumbnail extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public hass?: HomeAssistant; public hass?: HomeAssistant;
protected _embedThumbnailTask?: Task<FetchThumbnailTaskArgs, string | null>; private _embedThumbnailTask?: Task<FetchThumbnailTaskArgs, string | null>;
// Only load thumbnails on view in case there is a very large number of them. // Only load thumbnails on view in case there is a very large number of them.
protected _intersectionObserver = new IntersectionObserver( private _intersectionObserver = new IntersectionObserver(
this._intersectionHandler.bind(this), this._intersectionHandler.bind(this),
); );
@@ -57,7 +57,7 @@ export class AdvancedCameraCardThumbnailFeatureThumbnail extends LitElement {
} }
} }
protected _intersectionHandler(entries: IntersectionObserverEntry[]): void { private _intersectionHandler(entries: IntersectionObserverEntry[]): void {
if ( if (
this._embedThumbnailTask?.status === TaskStatus.INITIAL && this._embedThumbnailTask?.status === TaskStatus.INITIAL &&
entries.some((entry) => entry.isIntersecting) entries.some((entry) => entry.isIntersecting)
+3 -3
View File
@@ -137,9 +137,9 @@ export class AdvancedCameraCardTimelineCore extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public itemClickAction?: TimelineItemClickAction; public itemClickAction?: TimelineItemClickAction;
protected _refDatePicker: Ref<AdvancedCameraCardDatePicker> = createRef(); private _refDatePicker: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refTimeline: Ref<HTMLElement> = createRef(); private _refTimeline: Ref<HTMLElement> = createRef();
protected _controller: TimelineController = new TimelineController(this); private _controller: TimelineController = new TimelineController(this);
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
if (!this.hass || !this.timelineConfig) { if (!this.hass || !this.timelineConfig) {

Some files were not shown because too many files have changed in this diff Show More