From 0a67df9a256dea4d61b9798e6e9f496c1721ed72 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Fri, 20 Feb 2026 04:47:59 +0000 Subject: [PATCH] refactor: Convert protected methods to private (#2358) --- src/action-handler-directive.ts | 8 +- src/camera-manager/cache.ts | 10 +- src/camera-manager/capabilities.ts | 2 +- src/camera-manager/engine-factory.ts | 4 +- src/camera-manager/frigate/camera.ts | 20 +- src/camera-manager/frigate/engine-frigate.ts | 32 +-- src/camera-manager/frigate/media.ts | 24 +-- src/camera-manager/manager.ts | 20 +- .../motioneye/engine-motioneye.ts | 12 +- src/camera-manager/range.ts | 6 +- src/camera-manager/reolink/camera.ts | 18 +- src/camera-manager/reolink/engine-reolink.ts | 14 +- src/camera-manager/store.ts | 4 +- src/camera-manager/tplink/camera.ts | 6 +- src/camera-manager/tplink/engine-tplink.ts | 2 +- .../actions/actions-manager.ts | 8 +- .../actions/actions/ptz-digital.ts | 8 +- .../actions/actions/ptz-multi.ts | 4 +- src/card-controller/actions/actions/ptz.ts | 4 +- src/card-controller/actions/actions/set.ts | 8 +- src/card-controller/automations-manager.ts | 8 +- src/card-controller/camera-url-manager.ts | 2 +- src/card-controller/card-element-manager.ts | 10 +- src/card-controller/config/config-manager.ts | 20 +- src/card-controller/controller.ts | 60 +++--- src/card-controller/default-manager.ts | 10 +- .../effects/effects-manager.ts | 2 +- src/card-controller/expand-manager.ts | 6 +- .../folders/ha/metadata-generator.ts | 2 +- .../fullscreen/fullscreen-manager.ts | 8 +- .../fullscreen/webkit/index.ts | 8 +- src/card-controller/hass/hass-manager.ts | 6 +- src/card-controller/hass/state-watcher.ts | 2 +- src/card-controller/initialization-manager.ts | 10 +- src/card-controller/interaction-manager.ts | 10 +- src/card-controller/keyboard-state-manager.ts | 12 +- src/card-controller/media-info-manager.ts | 6 +- src/card-controller/media-player-manager.ts | 8 +- src/card-controller/message-manager.ts | 4 +- src/card-controller/microphone-manager.ts | 16 +- .../overlay-message-manager.ts | 4 +- src/card-controller/query-string-manager.ts | 14 +- .../status-bar-item-manager.ts | 10 +- src/card-controller/style-manager.ts | 12 +- src/card-controller/templates/index.ts | 4 +- src/card-controller/triggers-manager.ts | 42 ++-- src/card-controller/view/factory.ts | 20 +- .../view/modifiers/merge-context.ts | 2 +- .../view/modifiers/remove-context-property.ts | 4 +- .../view/modifiers/remove-context.ts | 2 +- .../view/modifiers/set-query.ts | 4 +- .../view/modifiers/substream-on.ts | 2 +- .../view/modifiers/substream-select.ts | 2 +- src/card-controller/view/view-manager.ts | 28 +-- src/components-lib/cached-value-controller.ts | 14 +- src/components-lib/key-assigner-controller.ts | 12 +- src/components-lib/live/live-controller.ts | 12 +- .../media-actions-controller.ts | 56 +++--- src/components-lib/media-filter-controller.ts | 38 ++-- src/components-lib/media-grid-controller.ts | 58 +++--- .../media/details-controller.ts | 2 +- src/components-lib/menu-button-controller.ts | 58 +++--- src/components-lib/menu-controller.ts | 14 +- src/components-lib/status-bar-controller.ts | 16 +- src/components-lib/zoom/zoom-controller.ts | 56 +++--- src/components/carousel.ts | 8 +- src/components/date-picker.ts | 2 +- src/components/diagnostics.ts | 2 +- src/components/drawer.ts | 12 +- src/components/elements.ts | 18 +- src/components/gallery/gallery.ts | 16 +- src/components/image-player.ts | 4 +- src/components/image-updating-player.ts | 26 +-- src/components/image.ts | 4 +- src/components/key-assigner.ts | 2 +- src/components/live/carousel.ts | 36 ++-- src/components/live/grid.ts | 6 +- src/components/live/index.ts | 2 +- src/components/live/provider.ts | 20 +- src/components/live/providers/go2rtc/index.ts | 12 +- src/components/live/providers/ha.ts | 2 +- src/components/live/providers/image.ts | 2 +- src/components/live/providers/jsmpeg.ts | 18 +- src/components/live/providers/webrtc-card.ts | 18 +- src/components/media-dimensions-container.ts | 6 +- src/components/media-filter.ts | 24 +-- src/components/media-grid.ts | 4 +- src/components/menu.ts | 6 +- src/components/next-prev-control.ts | 4 +- src/components/overlay-message.ts | 16 +- src/components/ptz.ts | 4 +- src/components/select.ts | 6 +- src/components/status-bar.ts | 4 +- src/components/submenu/index.ts | 2 +- src/components/submenu/select-button.ts | 8 +- src/components/surround-basic.ts | 8 +- src/components/surround.ts | 2 +- src/components/thumbnail-carousel.ts | 18 +- src/components/thumbnail/feature/thumbnail.ts | 6 +- src/components/timeline-core.ts | 6 +- src/components/video-player.ts | 4 +- src/components/viewer/carousel.ts | 30 +-- src/components/viewer/grid.ts | 6 +- src/components/viewer/provider.ts | 14 +- src/components/views.ts | 2 +- src/components/zoomer.ts | 8 +- src/conditions/conditions-manager.ts | 20 +- src/conditions/state-manager.ts | 10 +- src/editor.ts | 183 +++++++++--------- src/ha/browse-media/item.ts | 6 +- src/ha/browse-media/walker.ts | 4 +- src/ha/registry/device/index.ts | 6 +- src/ha/registry/entity/index.ts | 4 +- src/patches/ha-camera-stream.ts | 11 +- src/patches/ha-hls-player.ts | 2 +- src/patches/ha-web-rtc-player.ts | 2 +- src/utils/embla/carousel-controller.ts | 30 +-- src/utils/initializer/initializer.ts | 2 +- src/utils/timer.ts | 4 +- src/view/query-results.ts | 16 +- tests/ha/registry/entity/mock.ts | 4 +- tests/test-utils.ts | 32 +-- 122 files changed, 815 insertions(+), 829 deletions(-) diff --git a/src/action-handler-directive.ts b/src/action-handler-directive.ts index 18a4fcd9..36611d83 100644 --- a/src/action-handler-directive.ts +++ b/src/action-handler-directive.ts @@ -25,11 +25,11 @@ interface AdvancedCameraCardActionHandlerOptions extends ActionHandlerOptions { class ActionHandler extends HTMLElement implements ActionHandlerInterface { public holdTime = 0.4; - protected holdTimer = new Timer(); - protected doubleClickTimer = new Timer(); + private holdTimer = new Timer(); + private doubleClickTimer = new Timer(); - protected held = false; - protected started = false; + private held = false; + private started = false; public connectedCallback(): void { [ diff --git a/src/camera-manager/cache.ts b/src/camera-manager/cache.ts index 1755caa7..e2063e20 100644 --- a/src/camera-manager/cache.ts +++ b/src/camera-manager/cache.ts @@ -3,10 +3,10 @@ import { DateRange, MemoryRangeSet } from './range'; import { RecordingSegment } from './types'; class MemoryRangedCache { - protected _ranges: MemoryRangeSet = new MemoryRangeSet(); - protected _data: Data[] = []; - protected _timeFunc: (data: Data) => number; - protected _idFunc: (data: Data) => string; + private _ranges: MemoryRangeSet = new MemoryRangeSet(); + private _data: Data[] = []; + private _timeFunc: (data: Data) => number; + private _idFunc: (data: Data) => string; constructor(timeFunc: (data: Data) => number, idFunc: (data: Data) => string) { this._timeFunc = timeFunc; @@ -60,7 +60,7 @@ class MemoryRangedCache { } export class RecordingSegmentsCache { - protected _segments: Map> = new Map(); + private _segments: Map> = new Map(); public add(cameraID: string, range: DateRange, segments: RecordingSegment[]) { let cameraSegmentCache: MemoryRangedCache | undefined = diff --git a/src/camera-manager/capabilities.ts b/src/camera-manager/capabilities.ts index b8da5ec2..0dbce529 100644 --- a/src/camera-manager/capabilities.ts +++ b/src/camera-manager/capabilities.ts @@ -28,7 +28,7 @@ export class Capabilities { } } - protected _disable(capability: CapabilityKey): void { + private _disable(capability: CapabilityKey): void { delete this._capabilities[capability]; } diff --git a/src/camera-manager/engine-factory.ts b/src/camera-manager/engine-factory.ts index 76ec4589..59e3a36c 100644 --- a/src/camera-manager/engine-factory.ts +++ b/src/camera-manager/engine-factory.ts @@ -19,8 +19,8 @@ interface CameraManagerEngineFactoryOptions { } export class CameraManagerEngineFactory { - protected _entityRegistryManager: EntityRegistryManager; - protected _deviceRegistryManager: DeviceRegistryManager; + private _entityRegistryManager: EntityRegistryManager; + private _deviceRegistryManager: DeviceRegistryManager; constructor( entityRegistryManager: EntityRegistryManager, diff --git a/src/camera-manager/frigate/camera.ts b/src/camera-manager/frigate/camera.ts index d6a0a583..81453649 100644 --- a/src/camera-manager/frigate/camera.ts +++ b/src/camera-manager/frigate/camera.ts @@ -106,7 +106,7 @@ export class FrigateCamera extends Camera { return true; } - protected async _initializeConfig( + private async _initializeConfig( hass: HomeAssistant, entityRegistryManager: EntityRegistryManager, ): Promise { @@ -193,7 +193,7 @@ export class FrigateCamera extends Camera { }; } - protected _getFrigateCameraNameFromEntity(entity: Entity): string | null { + private _getFrigateCameraNameFromEntity(entity: Entity): string | null { if ( entity.platform === 'frigate' && 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) { return null; } @@ -301,7 +301,7 @@ export class FrigateCamera extends Camera { return { endpoint: cameraURL }; } - protected async _getPTZCapabilities( + private async _getPTZCapabilities( hass: HomeAssistant, cameraConfig: CameraConfig, ): Promise { @@ -352,7 +352,7 @@ export class FrigateCamera extends Camera { * @param cameraConfig The camera config in question. * @returns The entity id of the motion sensor or null. */ - protected _getMotionSensor( + private _getMotionSensor( cameraConfig: CameraConfig, entities: Entity[], ): string | null { @@ -376,7 +376,7 @@ export class FrigateCamera extends Camera { * @param cameraConfig The camera config in question. * @returns The entity id of the occupancy sensor or null. */ - protected _getOccupancySensor( + private _getOccupancySensor( cameraConfig: CameraConfig, entities: Entity[], ): string[] | null { @@ -419,7 +419,7 @@ export class FrigateCamera extends Camera { return null; } - protected async _subscribeToEvents( + private async _subscribeToEvents( hass: HomeAssistant, frigateEventWatcher: FrigateWatcherSubscriptionInterface, ): Promise { @@ -441,7 +441,7 @@ export class FrigateCamera extends Camera { this._onDestroy(() => frigateEventWatcher.unsubscribe(request)); } - protected _frigateEventHandler = (ev: FrigateEventChange): void => { + private _frigateEventHandler = (ev: FrigateEventChange): void => { const snapshotChange = (!ev.before.has_snapshot && ev.after.has_snapshot) || 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, frigateReviewWatcher: FrigateWatcherSubscriptionInterface, ): Promise { @@ -512,7 +512,7 @@ export class FrigateCamera extends Camera { this._onDestroy(() => frigateReviewWatcher.unsubscribe(request)); } - protected _frigateReviewHandler = (review: FrigateReviewChange): void => { + private _frigateReviewHandler = (review: FrigateReviewChange): void => { const config = this.getConfig(); const cameraID = this._config.id; diff --git a/src/camera-manager/frigate/engine-frigate.ts b/src/camera-manager/frigate/engine-frigate.ts index e1f15472..17e4c1e5 100644 --- a/src/camera-manager/frigate/engine-frigate.ts +++ b/src/camera-manager/frigate/engine-frigate.ts @@ -120,14 +120,14 @@ export class FrigateCameraManagerEngine extends GenericCameraManagerEngine implements CameraManagerEngine { - protected _entityRegistryManager: EntityRegistryManager; - protected _frigateEventWatcher: FrigateEventWatcher; - protected _frigateReviewWatcher: FrigateReviewWatcher; - protected _recordingSegmentsCache: RecordingSegmentsCache; - protected _requestCache: CameraManagerRequestCache; + private _entityRegistryManager: EntityRegistryManager; + private _frigateEventWatcher: FrigateEventWatcher; + private _frigateReviewWatcher: FrigateReviewWatcher; + private _recordingSegmentsCache: RecordingSegmentsCache; + private _requestCache: CameraManagerRequestCache; // Garbage collect segments at most once an hour. - protected _throttledSegmentGarbageCollector = throttle( + private _throttledSegmentGarbageCollector = throttle( this._garbageCollectSegments.bind(this), 60 * 60 * 1000, { leading: false, trailing: true }, @@ -272,17 +272,17 @@ export class FrigateCameraManagerEngine * If all cameras have identical zones/labels config, creates a single batch query. * Otherwise fans out to per-camera queries. */ - protected _generateBatchableQuery( + private _generateBatchableQuery( store: CameraManagerReadOnlyConfigStore, cameraIDs: Set, query: PartialEventQuery & { type: QueryType.Event }, ): EventQuery[] | null; - protected _generateBatchableQuery( + private _generateBatchableQuery( store: CameraManagerReadOnlyConfigStore, cameraIDs: Set, query: PartialReviewQuery & { type: QueryType.Review }, ): ReviewQuery[] | null; - protected _generateBatchableQuery( + private _generateBatchableQuery( store: CameraManagerReadOnlyConfigStore, cameraIDs: Set, query: (PartialEventQuery | PartialReviewQuery) & { @@ -368,7 +368,7 @@ export class FrigateCameraManagerEngine ); } - protected _buildInstanceToCameraIDMapFromQuery( + private _buildInstanceToCameraIDMapFromQuery( store: CameraManagerReadOnlyConfigStore, cameraIDs: Set, ): Map> { @@ -386,7 +386,7 @@ export class FrigateCameraManagerEngine return output; } - protected _getFrigateCameraNamesForCameraIDs( + private _getFrigateCameraNamesForCameraIDs( store: CameraManagerReadOnlyConfigStore, cameraIDs: Set, ): Set { @@ -725,7 +725,7 @@ export class FrigateCameraManagerEngine return output.size ? output : null; } - protected _getCameraIDMatch( + private _getCameraIDMatch( store: CameraManagerReadOnlyConfigStore, query: CameraQuery, instanceID: string, @@ -927,7 +927,7 @@ export class FrigateCameraManagerEngine return null; } - protected _getQueryableCameraConfig( + private _getQueryableCameraConfig( store: CameraManagerReadOnlyConfigStore, cameraID: string, ): CameraConfig | null { @@ -938,7 +938,7 @@ export class FrigateCameraManagerEngine 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 // (not an array) per event, but may contain comma-separated values (e.g. // 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 * returned by the Frigate backend. */ - protected async _garbageCollectSegments( + private async _garbageCollectSegments( hass: HomeAssistant, store: CameraManagerReadOnlyConfigStore, ): Promise { @@ -1113,7 +1113,7 @@ export class FrigateCameraManagerEngine * @param segments An array of segments dataset items. Must be sorted from oldest to youngest. * @returns */ - protected _getSeekTimeInSegments( + private _getSeekTimeInSegments( startTime: Date, targetTime: Date, segments: RecordingSegment[], diff --git a/src/camera-manager/frigate/media.ts b/src/camera-manager/frigate/media.ts index ad7be211..32fe3f2b 100644 --- a/src/camera-manager/frigate/media.ts +++ b/src/camera-manager/frigate/media.ts @@ -25,10 +25,10 @@ import { } from './util'; export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia { - protected _event: FrigateEvent; - protected _contentID: string; - protected _thumbnail: string; - protected _subLabels: string[] | null; + private _event: FrigateEvent; + private _contentID: string; + private _thumbnail: string; + private _subLabels: string[] | null; constructor( mediaType: ViewMediaType, @@ -107,10 +107,10 @@ export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia { } export class FrigateRecordingViewMedia extends ViewMedia implements RecordingViewMedia { - protected _recording: FrigateRecording; - protected _id: string; - protected _contentID: string; - protected _title: string; + private _recording: FrigateRecording; + private _id: string; + private _contentID: string; + private _title: string; constructor( mediaType: ViewMediaType, @@ -156,10 +156,10 @@ export class FrigateRecordingViewMedia extends ViewMedia implements RecordingVie } export class FrigateReviewViewMedia extends ViewMedia implements ReviewViewMedia { - protected _review: FrigateReview; - protected _contentID: string; - protected _thumbnail: string | null; - protected _title: string; + private _review: FrigateReview; + private _contentID: string; + private _thumbnail: string | null; + private _title: string; constructor( cameraID: string, diff --git a/src/camera-manager/manager.ts b/src/camera-manager/manager.ts index a672918d..5ce3e118 100644 --- a/src/camera-manager/manager.ts +++ b/src/camera-manager/manager.ts @@ -129,10 +129,10 @@ interface ExtendedMediaQueryResult { } export class CameraManager { - protected _api: CardCameraAPI; - protected _engineFactory: CameraManagerEngineFactory; - protected _store: CameraManagerStore; - protected _requestLimit = new PQueue(); + private _api: CardCameraAPI; + private _engineFactory: CameraManagerEngineFactory; + private _store: CameraManagerStore; + private _requestLimit = new PQueue(); constructor( api: CardCameraAPI, @@ -185,7 +185,7 @@ export class CameraManager { await this._store.reset(); } - protected async _getEnginesForCameras( + private async _getEnginesForCameras( camerasConfig: CameraConfig[], ): Promise> { const output: Map = new Map(); @@ -228,7 +228,7 @@ export class CameraManager { return output; } - protected async _initializeCameras(camerasConfig: CameraConfig[]): Promise { + private async _initializeCameras(camerasConfig: CameraConfig[]): Promise { const initializationStartTime = new Date(); const hass = this._api.getHASSManager().getHASS(); @@ -364,7 +364,7 @@ export class CameraManager { }); } - protected _generateDefaultQueries( + private _generateDefaultQueries( cameraIDs: string | Set, partialQuery: PQT, ): PartialQueryConcreteType[] | null { @@ -481,7 +481,7 @@ export class CameraManager { * properties (other than cameraIDs). This preserves multi-camera batching for * engines like Frigate that support querying multiple cameras at once. */ - protected _mergeCompatibleQueries(queries: T[]): T[] { + private _mergeCompatibleQueries(queries: T[]): T[] { if (queries.length <= 1) { return queries; } @@ -720,7 +720,7 @@ export class CameraManager { ); } - protected async _handleQuery( + private async _handleQuery( query: QT | QT[], engineOptions?: EngineOptions, ): Promise>> { @@ -821,7 +821,7 @@ export class CameraManager { return results; } - protected _convertQueryResultsToMedia( + private _convertQueryResultsToMedia( results: ResultsMap, ): ViewMedia[] { const mediaArray: ViewMedia[] = []; diff --git a/src/camera-manager/motioneye/engine-motioneye.ts b/src/camera-manager/motioneye/engine-motioneye.ts index 50a9d979..f6ea8b08 100644 --- a/src/camera-manager/motioneye/engine-motioneye.ts +++ b/src/camera-manager/motioneye/engine-motioneye.ts @@ -60,8 +60,8 @@ const MOTIONEYE_REPL_SUBSTITUTIONS: Record = { const MOTIONEYE_REPL_REGEXP = new RegExp(/(%Y|%m|%d|%H|%M|%S)/g); export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine { - protected _directoryCache = new BrowseMediaCache(); - protected _fileCache = new BrowseMediaCache(); + private _directoryCache = new BrowseMediaCache(); + private _fileCache = new BrowseMediaCache(); public getEngineType(): Engine { 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( MOTIONEYE_REPL_REGEXP, (_, key) => MOTIONEYE_REPL_SUBSTITUTIONS[key], @@ -89,7 +89,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine } // Get metadata for a MotionEye media file. - protected _motionEyeMetadataGeneratorFile( + private _motionEyeMetadataGeneratorFile( cameraID: string, dateFormat: string | null, media: BrowseMedia, @@ -112,7 +112,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine } // Get metadata for a MotionEye media directory. - protected _motionEyeMetadataGeneratorDirectory( + private _motionEyeMetadataGeneratorDirectory( cameraID: string, dateFormat: string | null, media: BrowseMedia, @@ -134,7 +134,7 @@ export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine } // Get media directories that match a given criteria. - protected async _getMatchingDirectories( + private async _getMatchingDirectories( hass: HomeAssistant, store: CameraManagerReadOnlyConfigStore, cameraID: string, diff --git a/src/camera-manager/range.ts b/src/camera-manager/range.ts index f01cb1a6..4788cf1b 100644 --- a/src/camera-manager/range.ts +++ b/src/camera-manager/range.ts @@ -15,7 +15,7 @@ interface MemoryRangeSetInterface { } export class MemoryRangeSet implements MemoryRangeSetInterface { - protected _ranges: DateRange[]; + private _ranges: DateRange[]; constructor(ranges?: DateRange[]) { this._ranges = ranges ?? []; @@ -44,7 +44,7 @@ export interface ExpiringRange extends Range { export class ExpiringMemoryRangeSet implements MemoryRangeSetInterface> { - protected _ranges: ExpiringRange[]; + private _ranges: ExpiringRange[]; constructor(ranges?: ExpiringRange[]) { this._ranges = ranges ?? []; @@ -63,7 +63,7 @@ export class ExpiringMemoryRangeSet this._expireOldRanges(); } - protected _expireOldRanges(): void { + private _expireOldRanges(): void { const now = new Date(); this._ranges = this._ranges.filter((range) => now < range.expires); } diff --git a/src/camera-manager/reolink/camera.ts b/src/camera-manager/reolink/camera.ts index de7ff246..6e6c4931 100644 --- a/src/camera-manager/reolink/camera.ts +++ b/src/camera-manager/reolink/camera.ts @@ -41,16 +41,16 @@ type PTZEntity = keyof PTZEntities; export class ReolinkCamera extends EntityCamera { // The HostID identifying the camera or NVR. - protected _reolinkHostID: string | null = null; + private _reolinkHostID: string | null = null; // For NVRs, the Camera UID. - protected _reolinkCameraUID: string | null = null; + private _reolinkCameraUID: string | null = null; // The channel number as used by the Reolink integration. - protected _reolinkChannel: number | null = null; + private _reolinkChannel: number | null = null; // 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 @@ -62,7 +62,7 @@ export class ReolinkCamera extends EntityCamera { return super.initialize(options); } - protected async _getChannelFromConfigurationURL( + private async _getChannelFromConfigurationURL( hass: HomeAssistant, deviceRegistryManager: DeviceRegistryManager, ): Promise { @@ -84,7 +84,7 @@ export class ReolinkCamera extends EntityCamera { } } - protected async _initializeChannel( + private async _initializeChannel( hass: HomeAssistant, deviceRegistryManager: DeviceRegistryManager, ): Promise { @@ -169,7 +169,7 @@ export class ReolinkCamera extends EntityCamera { }; } - protected _entitiesToCapabilities( + private _entitiesToCapabilities( hass: HomeAssistant, ptzEntities: PTZEntities, ): PTZCapabilities | null { @@ -203,7 +203,7 @@ export class ReolinkCamera extends EntityCamera { return Object.keys(reolinkPTZCapabilities).length ? reolinkPTZCapabilities : null; } - protected async _getPTZEntities( + private async _getPTZEntities( hass: HomeAssistant, entityRegistry: EntityRegistryManager, ): Promise { @@ -264,7 +264,7 @@ export class ReolinkCamera extends EntityCamera { return this._reolinkChannel; } - protected _getPTZEntityUniqueIDPrefix(): string { + private _getPTZEntityUniqueIDPrefix(): string { return `${this._reolinkHostID}_${this._reolinkCameraUID ?? this._reolinkChannel}_`; } diff --git a/src/camera-manager/reolink/engine-reolink.ts b/src/camera-manager/reolink/engine-reolink.ts index ee9c3e55..9e4f9058 100644 --- a/src/camera-manager/reolink/engine-reolink.ts +++ b/src/camera-manager/reolink/engine-reolink.ts @@ -53,9 +53,9 @@ export class ReolinkQueryResultsClassifier { } export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { - protected _camerasCache = new BrowseMediaCache(); - protected _cache = new BrowseMediaCache(); - protected _deviceRegistryManager: DeviceRegistryManager; + private _camerasCache = new BrowseMediaCache(); + private _cache = new BrowseMediaCache(); + private _deviceRegistryManager: DeviceRegistryManager; public constructor( entityRegistryManager: EntityRegistryManager, @@ -81,7 +81,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { return Engine.Reolink; } - protected _reolinkFileMetadataGenerator( + private _reolinkFileMetadataGenerator( cameraID: string, media: BrowseMedia, parent?: RichBrowseMedia, @@ -133,7 +133,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { }; } - protected _reolinkDirectoryMetadataGenerator( + private _reolinkDirectoryMetadataGenerator( cameraID: string, media: BrowseMedia, ): BrowseMediaMetadata | null { @@ -149,7 +149,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { : null; } - protected _reolinkCameraMetadataGenerator( + private _reolinkCameraMetadataGenerator( media: BrowseMedia, ): BrowseMediaReolinkCameraMetadata | null { // Example: "media-source://reolink/CAM|01J8XHYTNH77WE3C654K03KX1F|0" @@ -179,7 +179,7 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine { }); } - protected async _getMatchingDirectories( + private async _getMatchingDirectories( hass: HomeAssistant, camera: ReolinkCamera, matchOptions?: { diff --git a/src/camera-manager/store.ts b/src/camera-manager/store.ts index 061c82ef..eaccb4f8 100644 --- a/src/camera-manager/store.ts +++ b/src/camera-manager/store.ts @@ -38,8 +38,8 @@ export interface CameraManagerReadOnlyConfigStore { } export class CameraManagerStore implements CameraManagerReadOnlyConfigStore { - protected _cameras: Map = new Map(); - protected _enginesByType: Map = new Map(); + private _cameras: Map = new Map(); + private _enginesByType: Map = new Map(); public addCamera(camera: Camera): void { this._cameras.set(camera.getID(), camera); diff --git a/src/camera-manager/tplink/camera.ts b/src/camera-manager/tplink/camera.ts index 70f81f61..272923b5 100644 --- a/src/camera-manager/tplink/camera.ts +++ b/src/camera-manager/tplink/camera.ts @@ -17,7 +17,7 @@ interface PTZEntities { type PTZEntity = keyof PTZEntities; export class TPLinkCamera extends EntityCamera { - protected _ptzEntities: PTZEntities | null = null; + private _ptzEntities: PTZEntities | null = null; protected async _initialize( options: TPLinkCameraInitializationOptions, @@ -45,7 +45,7 @@ export class TPLinkCamera extends EntityCamera { }; } - protected async _getPTZEntities( + private async _getPTZEntities( hass: HomeAssistant, entityRegistry: EntityRegistryManager, ): Promise { @@ -82,7 +82,7 @@ export class TPLinkCamera extends EntityCamera { return Object.keys(ptzEntities).length ? ptzEntities : null; } - protected _entitiesToCapabilities(ptzEntities: PTZEntities): PTZCapabilities { + private _entitiesToCapabilities(ptzEntities: PTZEntities): PTZCapabilities { const tplinkPTZCapabilities: PTZCapabilities = {}; // TPLink buttons perform relative movements (no stop button needed) for (const key of Object.keys(ptzEntities) as PTZEntity[]) { diff --git a/src/camera-manager/tplink/engine-tplink.ts b/src/camera-manager/tplink/engine-tplink.ts index 8c35cd0a..3b7e59ed 100644 --- a/src/camera-manager/tplink/engine-tplink.ts +++ b/src/camera-manager/tplink/engine-tplink.ts @@ -8,7 +8,7 @@ import { CameraEventCallback, CameraManagerCameraMetadata, Engine } from '../typ import { TPLinkCamera } from './camera'; export class TPLinkCameraManagerEngine extends GenericCameraManagerEngine { - protected _entityRegistryManager: EntityRegistryManager; + private _entityRegistryManager: EntityRegistryManager; constructor( entityRegistryManager: EntityRegistryManager, diff --git a/src/card-controller/actions/actions-manager.ts b/src/card-controller/actions/actions-manager.ts index 1ff5795d..b111ac0a 100644 --- a/src/card-controller/actions/actions-manager.ts +++ b/src/card-controller/actions/actions-manager.ts @@ -29,10 +29,10 @@ const interactionEventSchema = z.object({ }); export class ActionsManager implements ActionsExecutor { - protected _api: CardActionsManagerAPI; - protected _actionsInFlight: ActionSet[] = []; - protected _actionContext: ActionContext = {}; - protected _templateRenderer: TemplateRenderer | null; + private _api: CardActionsManagerAPI; + private _actionsInFlight: ActionSet[] = []; + private _actionContext: ActionContext = {}; + private _templateRenderer: TemplateRenderer | null; constructor(api: CardActionsManagerAPI, templateRenderer?: TemplateRenderer) { this._api = api; diff --git a/src/card-controller/actions/actions/ptz-digital.ts b/src/card-controller/actions/actions/ptz-digital.ts index 570be3ec..16be607e 100644 --- a/src/card-controller/actions/actions/ptz-digital.ts +++ b/src/card-controller/actions/actions/ptz-digital.ts @@ -29,9 +29,9 @@ declare module 'action' { } export class PTZDigitalAction extends AdvancedCameraCardAction { - protected _timer = new Timer(); + private _timer = new Timer(); - protected async _stepChange(api: CardActionsAPI, targetID: string): Promise { + private async _stepChange(api: CardActionsAPI, targetID: string): Promise { api.getViewManager().setViewWithMergedContext( generateViewContextForZoom(targetID, { requested: this._convertActionToZoomSettings( @@ -80,9 +80,7 @@ export class PTZDigitalAction extends AdvancedCameraCardAction { - protected _timer = new Timer(); - protected _stopped = false; + private _timer = new Timer(); + private _stopped = false; public async stop(): Promise { this._stopped = true; diff --git a/src/card-controller/actions/actions/set.ts b/src/card-controller/actions/actions/set.ts index dac84207..d4abcceb 100644 --- a/src/card-controller/actions/actions/set.ts +++ b/src/card-controller/actions/actions/set.ts @@ -9,10 +9,10 @@ import { ActionFactory } from '../factory'; import { Action } from '../types'; export class ActionSet implements Action { - protected _context: ActionContext; - protected _actions: Action[] = []; - protected _factory = new ActionFactory(); - protected _stopped = false; + private _context: ActionContext; + private _actions: Action[] = []; + private _factory = new ActionFactory(); + private _stopped = false; constructor( context: ActionContext, diff --git a/src/card-controller/automations-manager.ts b/src/card-controller/automations-manager.ts index 4624eac6..25a8575f 100644 --- a/src/card-controller/automations-manager.ts +++ b/src/card-controller/automations-manager.ts @@ -7,13 +7,13 @@ import { CardAutomationsAPI, TaggedAutomation } from './types.js'; const MAX_NESTED_AUTOMATION_EXECUTIONS = 10; export class AutomationsManager { - protected _api: CardAutomationsAPI; + private _api: CardAutomationsAPI; - protected _automations = new Map(); + private _automations = new Map(); // A counter to avoid infinite loops, increases every time actions are run, // decreases every time actions are complete. - protected _nestedAutomationExecutions = 0; + private _nestedAutomationExecutions = 0; constructor(api: CardAutomationsAPI) { 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 ( !this._api.getHASSManager().hasHASS() || // Never execute automations if the card hasn't finished initializing, as diff --git a/src/card-controller/camera-url-manager.ts b/src/card-controller/camera-url-manager.ts index a7c6edfe..ec923743 100644 --- a/src/card-controller/camera-url-manager.ts +++ b/src/card-controller/camera-url-manager.ts @@ -2,7 +2,7 @@ import { ViewItemClassifier } from '../view/item-classifier'; import { CardCameraURLAPI } from './types'; export class CameraURLManager { - protected _api: CardCameraURLAPI; + private _api: CardCameraURLAPI; constructor(api: CardCameraURLAPI) { this._api = api; diff --git a/src/card-controller/card-element-manager.ts b/src/card-controller/card-element-manager.ts index 45c0db1a..d42ab04f 100644 --- a/src/card-controller/card-element-manager.ts +++ b/src/card-controller/card-element-manager.ts @@ -19,11 +19,11 @@ export type CardHTMLElement = LitElement & CardMediaReviewEventTarget; export class CardElementManager { - protected _api: CardElementAPI; + private _api: CardElementAPI; - protected _element: CardHTMLElement; - protected _scrollCallback: ScrollCallback; - protected _menuToggleCallback: MenuToggleCallback; + private _element: CardHTMLElement; + private _scrollCallback: ScrollCallback; + private _menuToggleCallback: MenuToggleCallback; constructor( api: CardElementAPI, @@ -220,7 +220,7 @@ export class CardElementManager { ); } - protected _handleMediaReviewed = (ev: CustomEvent): void => { + private _handleMediaReviewed = (ev: CustomEvent): void => { // If the selected media item has a change of review status, update the card // (e.g. for the menu). if ( diff --git a/src/card-controller/config/config-manager.ts b/src/card-controller/config/config-manager.ts index 2dabab9f..b17849d6 100644 --- a/src/card-controller/config/config-manager.ts +++ b/src/card-controller/config/config-manager.ts @@ -18,19 +18,17 @@ import { setKeyboardShortcutsFromConfig } from './load-keyboard-shortcuts.js'; import { OverridesManager } from './overrides-manager.js'; export class ConfigManager { - protected _api: CardConfigAPI; + private _api: CardConfigAPI; // The main base configuration object. For most usecases use getConfig() to // get the correct configuration (which will return overrides as appropriate). // This variable must be called `_config` or `config` to be compatible with // card-mod. - protected _config: AdvancedCameraCardConfig | null = null; - protected _overriddenConfig: AdvancedCameraCardConfig | null = null; - protected _rawConfig: RawAdvancedCameraCardConfig | null = null; - protected _cardWideConfig: CardWideConfig | null = null; - protected _overridesManager = new OverridesManager(() => - this._processOverrideConfig(), - ); + private _config: AdvancedCameraCardConfig | null = null; + private _overriddenConfig: AdvancedCameraCardConfig | null = null; + private _rawConfig: RawAdvancedCameraCardConfig | null = null; + private _cardWideConfig: CardWideConfig | null = null; + private _overridesManager = new OverridesManager(() => this._processOverrideConfig()); constructor(api: CardConfigAPI) { this._api = api; @@ -123,7 +121,7 @@ export class ConfigManager { this._api.getCardElementManager().update(); } - protected _processOverrideConfig(): void { + private _processOverrideConfig(): void { const overriddenConfig = this._getOverriddenConfig(); // Save on Lit re-rendering costs by only updating the configuration if it @@ -168,7 +166,7 @@ export class ConfigManager { /* async */ this._initializeBackgroundAndUpdate(previousConfig); } - protected _getOverriddenConfig(): AdvancedCameraCardConfig | null { + private _getOverriddenConfig(): AdvancedCameraCardConfig | null { /* istanbul ignore if: No (current) way to reach this code -- @preserve */ if (!this._config) { return null; @@ -186,7 +184,7 @@ export class ConfigManager { * Initialize config dependent items in the background. For items that the * card hard requires, use InitializationManager instead. */ - protected async _initializeBackgroundAndUpdate( + private async _initializeBackgroundAndUpdate( previousConfig: AdvancedCameraCardConfig | null, ): Promise { await this._api.getDefaultManager().initializeIfNecessary(previousConfig); diff --git a/src/card-controller/controller.ts b/src/card-controller/controller.ts index 021c86b1..85b1a027 100644 --- a/src/card-controller/controller.ts +++ b/src/card-controller/controller.ts @@ -94,41 +94,41 @@ export class CardController CardViewAPI, ReactiveController { - protected _conditionStateManager = new ConditionStateManager(); - protected _effectsManager = new EffectsManager(); + private _conditionStateManager = new ConditionStateManager(); + private _effectsManager = new EffectsManager(); // These properties may be used in the construction of 'managers' (and should // be created first). - protected _deviceRegistryManager = new DeviceRegistryManager(new DeviceCache()); - protected _entityRegistryManager = new EntityRegistryManagerLive(new EntityCache()); - protected _resolvedMediaCache = new ResolvedMediaCache(); + private _deviceRegistryManager = new DeviceRegistryManager(new DeviceCache()); + private _entityRegistryManager = new EntityRegistryManagerLive(new EntityCache()); + private _resolvedMediaCache = new ResolvedMediaCache(); - protected _actionsManager = new ActionsManager(this, new TemplateRenderer()); - protected _automationsManager = new AutomationsManager(this); - protected _cameraManager = new CameraManager(this); - protected _cameraURLManager = new CameraURLManager(this); - protected _cardElementManager: CardElementManager; - protected _configManager = new ConfigManager(this); - protected _defaultManager = new DefaultManager(this); - protected _expandManager = new ExpandManager(this); - protected _foldersManager = new FoldersManager(this); - protected _fullscreenManager = new FullscreenManager(this); - protected _hassManager = new HASSManager(this); - protected _initializationManager = new InitializationManager(this); - protected _interactionManager = new InteractionManager(this); - protected _keyboardStateManager = new KeyboardStateManager(this); - protected _mediaLoadedInfoManager = new MediaLoadedInfoManager(this); + private _actionsManager = new ActionsManager(this, new TemplateRenderer()); + private _automationsManager = new AutomationsManager(this); + private _cameraManager = new CameraManager(this); + private _cameraURLManager = new CameraURLManager(this); + private _cardElementManager: CardElementManager; + private _configManager = new ConfigManager(this); + private _defaultManager = new DefaultManager(this); + private _expandManager = new ExpandManager(this); + private _foldersManager = new FoldersManager(this); + private _fullscreenManager = new FullscreenManager(this); + private _hassManager = new HASSManager(this); + private _initializationManager = new InitializationManager(this); + private _interactionManager = new InteractionManager(this); + private _keyboardStateManager = new KeyboardStateManager(this); + private _mediaLoadedInfoManager = new MediaLoadedInfoManager(this); - protected _mediaPlayerManager = new MediaPlayerManager(this); - protected _messageManager = new MessageManager(this); - protected _microphoneManager = new MicrophoneManager(this); - protected _overlayMessageManager = new OverlayMessageManager(this); - protected _queryStringManager = new QueryStringManager(this); - protected _statusBarItemManager = new StatusBarItemManager(this); - protected _styleManager = new StyleManager(this); - protected _triggersManager = new TriggersManager(this); - protected _viewManager = new ViewManager(this); - protected _viewItemManager = new ViewItemManager(this); + private _mediaPlayerManager = new MediaPlayerManager(this); + private _messageManager = new MessageManager(this); + private _microphoneManager = new MicrophoneManager(this); + private _overlayMessageManager = new OverlayMessageManager(this); + private _queryStringManager = new QueryStringManager(this); + private _statusBarItemManager = new StatusBarItemManager(this); + private _styleManager = new StyleManager(this); + private _triggersManager = new TriggersManager(this); + private _viewManager = new ViewManager(this); + private _viewItemManager = new ViewItemManager(this); constructor( host: CardHTMLElement, diff --git a/src/card-controller/default-manager.ts b/src/card-controller/default-manager.ts index 7aa45bf8..4d7ed437 100644 --- a/src/card-controller/default-manager.ts +++ b/src/card-controller/default-manager.ts @@ -9,8 +9,8 @@ import { CardDefaultManagerAPI } from './types'; * Manages automated resetting to the default view. */ export class DefaultManager { - protected _timer = new Timer(); - protected _api: CardDefaultManagerAPI; + private _timer = new Timer(); + private _api: CardDefaultManagerAPI; constructor(api: CardDefaultManagerAPI) { this._api = api; @@ -75,17 +75,17 @@ export class DefaultManager { this._api.getAutomationsManager().deleteAutomations(this); } - protected _stateChangeHandler = (): void => { + private _stateChangeHandler = (): void => { this._setToDefaultIfAllowed(); }; - protected _setToDefaultIfAllowed(): void { + private _setToDefaultIfAllowed(): void { if (this._isAutomatedUpdateAllowed()) { this._api.getViewManager().setViewDefault(); } } - protected _isAutomatedUpdateAllowed(): boolean { + private _isAutomatedUpdateAllowed(): boolean { const interactionMode = this._api.getConfigManager().getConfig()?.view .default_reset.interaction_mode; return ( diff --git a/src/card-controller/effects/effects-manager.ts b/src/card-controller/effects/effects-manager.ts index 01ee783a..604fcb05 100644 --- a/src/card-controller/effects/effects-manager.ts +++ b/src/card-controller/effects/effects-manager.ts @@ -47,7 +47,7 @@ export class EffectsManager implements EffectsManagerInterface { // effects can be started). private _pendingEffects: Map = new Map(); private _activeEffects: Map = new Map(); - protected _container: EffectsContainer | null = null; + private _container: EffectsContainer | null = null; constructor(importer: EffectModuleImporter = defaultImportEffectModule) { this._importer = importer; diff --git a/src/card-controller/expand-manager.ts b/src/card-controller/expand-manager.ts index 6820a1d4..6b9310aa 100644 --- a/src/card-controller/expand-manager.ts +++ b/src/card-controller/expand-manager.ts @@ -2,8 +2,8 @@ import { setOrRemoveAttribute } from '../utils/basic'; import { CardExpandAPI } from './types'; export class ExpandManager { - protected _expanded = false; - protected _api: CardExpandAPI; + private _expanded = false; + private _api: CardExpandAPI; constructor(api: CardExpandAPI) { this._api = api; @@ -37,7 +37,7 @@ export class ExpandManager { this._api.getCardElementManager().update(); } - protected _setConditionState(): void { + private _setConditionState(): void { this._api.getConditionStateManager()?.setState({ expand: this._expanded, }); diff --git a/src/card-controller/folders/ha/metadata-generator.ts b/src/card-controller/folders/ha/metadata-generator.ts index 3d8ee4f9..97c71a2b 100644 --- a/src/card-controller/folders/ha/metadata-generator.ts +++ b/src/card-controller/folders/ha/metadata-generator.ts @@ -12,7 +12,7 @@ import { regexpExtract } from '../../../utils/regexp-extract'; import { REGEXP_GROUP_VALUE_KEY } from './types'; export class MetadataGenerator { - protected _anyDateParser: typeof parser | null = null; + private _anyDateParser: typeof parser | null = null; public async prepare(parsers?: Parser[]): Promise { if (this._anyDateParser) { diff --git a/src/card-controller/fullscreen/fullscreen-manager.ts b/src/card-controller/fullscreen/fullscreen-manager.ts index 25ca3843..7b015e2b 100644 --- a/src/card-controller/fullscreen/fullscreen-manager.ts +++ b/src/card-controller/fullscreen/fullscreen-manager.ts @@ -4,8 +4,8 @@ import { FullscreenProviderFactory } from './factory'; import { FullscreenProvider } from './types'; export class FullscreenManager { - protected _api: CardFullscreenAPI; - protected _provider: FullscreenProvider | null; + private _api: CardFullscreenAPI; + private _provider: FullscreenProvider | null; constructor(api: CardFullscreenAPI, provider?: FullscreenProvider) { this._api = api; @@ -48,7 +48,7 @@ export class FullscreenManager { } } - protected _fullscreenHandler = (): void => { + private _fullscreenHandler = (): void => { this._api.getExpandManager().setExpanded(false); this._setConditionState(); @@ -59,7 +59,7 @@ export class FullscreenManager { this._api.getCardElementManager().update(); }; - protected _setConditionState(): void { + private _setConditionState(): void { this._api.getConditionStateManager()?.setState({ fullscreen: this.isInFullscreen(), }); diff --git a/src/card-controller/fullscreen/webkit/index.ts b/src/card-controller/fullscreen/webkit/index.ts index 6163684f..899242f6 100644 --- a/src/card-controller/fullscreen/webkit/index.ts +++ b/src/card-controller/fullscreen/webkit/index.ts @@ -15,7 +15,7 @@ export class WebkitFullScreenProvider extends FullscreenProviderBase implements FullscreenProvider { - protected _playTimer = new Timer(); + private _playTimer = new Timer(); public connect(): void { this._api.getConditionStateManager().addListener(this._stateChangeHandler); @@ -25,7 +25,7 @@ export class WebkitFullScreenProvider this._api.getConditionStateManager().removeListener(this._stateChangeHandler); } - protected _stateChangeHandler = (change: ConditionStateChange): void => { + private _stateChangeHandler = (change: ConditionStateChange): void => { if ( change.old.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement() !== change.new.mediaLoadedInfo?.mediaPlayerController?.getFullscreenElement() @@ -42,7 +42,7 @@ export class WebkitFullScreenProvider } }; - protected _getVideoElement(): + private _getVideoElement(): | (HTMLVideoElement & Partial) | null { const element = this._api @@ -74,7 +74,7 @@ export class WebkitFullScreenProvider } } - protected _endHandler = (): void => { + private _endHandler = (): void => { this._handler(); // Webkit on iPhone stops the video when exiting fullscreen (why!). This diff --git a/src/card-controller/hass/hass-manager.ts b/src/card-controller/hass/hass-manager.ts index c65fc5cf..a7e86f4d 100644 --- a/src/card-controller/hass/hass-manager.ts +++ b/src/card-controller/hass/hass-manager.ts @@ -5,9 +5,9 @@ import { CardHASSAPI } from '../types'; import { StateWatcher, StateWatcherSubscriptionInterface } from './state-watcher'; export class HASSManager { - protected _hass: HomeAssistant | null = null; - protected _api: CardHASSAPI; - protected _stateWatcher: StateWatcher = new StateWatcher(); + private _hass: HomeAssistant | null = null; + private _api: CardHASSAPI; + private _stateWatcher: StateWatcher = new StateWatcher(); constructor(api: CardHASSAPI) { this._api = api; diff --git a/src/card-controller/hass/state-watcher.ts b/src/card-controller/hass/state-watcher.ts index 0baff18d..74e602bf 100644 --- a/src/card-controller/hass/state-watcher.ts +++ b/src/card-controller/hass/state-watcher.ts @@ -9,7 +9,7 @@ export interface StateWatcherSubscriptionInterface { } export class StateWatcher implements StateWatcherSubscriptionInterface { - protected _watcherCallbacks = new Map(); + private _watcherCallbacks = new Map(); public setHASS(oldHass: HomeAssistant | null, hass: HomeAssistant): void { if (!oldHass) { diff --git a/src/card-controller/initialization-manager.ts b/src/card-controller/initialization-manager.ts index 48b53c99..92f9210e 100644 --- a/src/card-controller/initialization-manager.ts +++ b/src/card-controller/initialization-manager.ts @@ -27,15 +27,15 @@ export enum InitializationAspect { // ========================================================================= export class InitializationManager { - protected _api: CardInitializerAPI; + private _api: CardInitializerAPI; // 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 // not strictly necessary, just more efficient, as long as the "Rules for // initialization" (above) are followed. - protected _initializationQueue = new PQueue({ concurrency: 1 }); - protected _initializer: Initializer; - protected _everInitialized = false; + private _initializationQueue = new PQueue({ concurrency: 1 }); + private _initializer: Initializer; + private _everInitialized = false; constructor(api: CardInitializerAPI, initializer?: Initializer) { this._api = api; @@ -76,7 +76,7 @@ export class InitializationManager { await this._initializationQueue.add(() => this._initializeMandatory()); } - protected async _initializeMandatory(): Promise { + private async _initializeMandatory(): Promise { const hass = this._api.getHASSManager().getHASS(); if (!hass || this.isInitializedMandatory()) { return; diff --git a/src/card-controller/interaction-manager.ts b/src/card-controller/interaction-manager.ts index 6edc4e2a..ad0e1b35 100644 --- a/src/card-controller/interaction-manager.ts +++ b/src/card-controller/interaction-manager.ts @@ -4,9 +4,9 @@ import { Timer } from '../utils/timer'; import { CardInteractionAPI } from './types'; export class InteractionManager { - protected _timer = new Timer(); - protected _api: CardInteractionAPI; - protected _interacted = false; + private _timer = new Timer(); + private _api: CardInteractionAPI; + private _interacted = false; constructor(api: CardInteractionAPI) { this._api = api; @@ -26,7 +26,7 @@ export class InteractionManager { return this._interacted; } - protected _setInteraction(val: boolean): void { + private _setInteraction(val: boolean): void { this._interacted = val; setOrRemoveAttribute( this._api.getCardElementManager().getElement(), @@ -36,7 +36,7 @@ export class InteractionManager { this._api.getConditionStateManager().setState({ interaction: val }); } - protected _reportInteraction(): void { + private _reportInteraction(): void { this._timer.stop(); this._setInteraction(true); diff --git a/src/card-controller/keyboard-state-manager.ts b/src/card-controller/keyboard-state-manager.ts index ca5c7f8d..fd6bb2a0 100644 --- a/src/card-controller/keyboard-state-manager.ts +++ b/src/card-controller/keyboard-state-manager.ts @@ -2,8 +2,8 @@ import { CardKeyboardStateAPI, KeysState } from './types'; import { isEqual } from 'lodash-es'; export class KeyboardStateManager { - protected _api: CardKeyboardStateAPI; - protected _state: KeysState = {}; + private _api: CardKeyboardStateAPI; + private _state: KeysState = {}; constructor(api: CardKeyboardStateAPI) { this._api = api; @@ -23,7 +23,7 @@ export class KeyboardStateManager { element.removeEventListener('blur', this._handleBlur); } - protected _handleKeydown = (ev: KeyboardEvent): void => { + private _handleKeydown = (ev: KeyboardEvent): void => { const keyObj = { state: 'down' as const, 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') { this._state[ev.key].state = 'up'; this._processStateChange(); } }; - protected _handleBlur = (): void => { + private _handleBlur = (): void => { if (Object.keys(this._state).length) { // State is emptied if the element loses focus. this._state = {}; @@ -53,7 +53,7 @@ export class KeyboardStateManager { } }; - protected _processStateChange(): void { + private _processStateChange(): void { this._api.getConditionStateManager().setState({ keys: this._state }); } } diff --git a/src/card-controller/media-info-manager.ts b/src/card-controller/media-info-manager.ts index e7c04b75..dc0aba66 100644 --- a/src/card-controller/media-info-manager.ts +++ b/src/card-controller/media-info-manager.ts @@ -4,9 +4,9 @@ import { isValidMediaLoadedInfo } from '../utils/media-info'; import { CardMediaLoadedAPI } from './types'; export class MediaLoadedInfoManager { - protected _api: CardMediaLoadedAPI; - protected _current: MediaLoadedInfo | null = null; - protected _lastKnown: MediaLoadedInfo | null = null; + private _api: CardMediaLoadedAPI; + private _current: MediaLoadedInfo | null = null; + private _lastKnown: MediaLoadedInfo | null = null; constructor(api: CardMediaLoadedAPI) { this._api = api; diff --git a/src/card-controller/media-player-manager.ts b/src/card-controller/media-player-manager.ts index d7c92826..81f2426f 100644 --- a/src/card-controller/media-player-manager.ts +++ b/src/card-controller/media-player-manager.ts @@ -14,9 +14,9 @@ import { ViewItemClassifier } from '../view/item-classifier'; import { CardMediaPlayerAPI } from './types'; export class MediaPlayerManager { - protected _mediaPlayers: string[] = []; + private _mediaPlayers: string[] = []; - protected _api: CardMediaPlayerAPI; + private _api: CardMediaPlayerAPI; constructor(api: CardMediaPlayerAPI) { this._api = api; @@ -128,7 +128,7 @@ export class MediaPlayerManager { } } - protected async _playLiveStandard( + private async _playLiveStandard( mediaPlayer: string, cameraID: string, cameraConfig: CameraConfig, @@ -155,7 +155,7 @@ export class MediaPlayerManager { }); } - protected async _playLiveDashboard( + private async _playLiveDashboard( mediaPlayer: string, cameraConfig: CameraConfig, ): Promise { diff --git a/src/card-controller/message-manager.ts b/src/card-controller/message-manager.ts index b9fbf9f3..a5666190 100644 --- a/src/card-controller/message-manager.ts +++ b/src/card-controller/message-manager.ts @@ -14,8 +14,8 @@ const MESSAGE_TYPE_PRIORITIES: MessagePriority = { }; export class MessageManager { - protected _message: Message | null = null; - protected _api: CardMessageAPI; + private _message: Message | null = null; + private _api: CardMessageAPI; constructor(api: CardMessageAPI) { this._api = api; diff --git a/src/card-controller/microphone-manager.ts b/src/card-controller/microphone-manager.ts index 80667d3f..718896c3 100644 --- a/src/card-controller/microphone-manager.ts +++ b/src/card-controller/microphone-manager.ts @@ -3,11 +3,11 @@ import { Timer } from '../utils/timer'; import { CardMicrophoneAPI, MicrophoneState } from './types'; export class MicrophoneManager { - protected _api: CardMicrophoneAPI; - protected _stream?: MediaStream | null; - protected _timer = new Timer(); + private _api: CardMicrophoneAPI; + private _stream?: MediaStream | null; + private _timer = new Timer(); - protected _state: MicrophoneState = { + private _state: MicrophoneState = { connected: false, muted: true, forbidden: false, @@ -16,7 +16,7 @@ export class MicrophoneManager { // 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 // it's created it will have the right mute status. - protected _desireMute = true; + private _desireMute = true; constructor(api: CardMicrophoneAPI) { this._api = api; @@ -115,7 +115,7 @@ export class MicrophoneManager { return !this._stream || this._stream.getTracks().every((track) => !track.enabled); } - protected _setDesiredMuteOnStream(): void { + private _setDesiredMuteOnStream(): void { this._stream?.getTracks().forEach((track) => { track.enabled = !this._desireMute; }); @@ -123,7 +123,7 @@ export class MicrophoneManager { this._startDisconnectTimer(); } - protected _startDisconnectTimer(): void { + private _startDisconnectTimer(): void { const microphoneConfig = this._api.getConfigManager().getConfig()?.live.microphone; if (microphoneConfig?.always_connected) { @@ -139,7 +139,7 @@ export class MicrophoneManager { } } - protected _setState(): void { + private _setState(): void { this._state = { stream: this._stream, connected: this.isConnected(), diff --git a/src/card-controller/overlay-message-manager.ts b/src/card-controller/overlay-message-manager.ts index 8a9a5375..86157065 100644 --- a/src/card-controller/overlay-message-manager.ts +++ b/src/card-controller/overlay-message-manager.ts @@ -2,8 +2,8 @@ import { OverlayMessage } from '../types'; import { CardOverlayMessageAPI } from './types'; export class OverlayMessageManager { - protected _message: OverlayMessage | null = null; - protected _api: CardOverlayMessageAPI; + private _message: OverlayMessage | null = null; + private _api: CardOverlayMessageAPI; constructor(api: CardOverlayMessageAPI) { this._api = api; diff --git a/src/card-controller/query-string-manager.ts b/src/card-controller/query-string-manager.ts index 703e0f06..edea27f2 100644 --- a/src/card-controller/query-string-manager.ts +++ b/src/card-controller/query-string-manager.ts @@ -18,8 +18,8 @@ interface QueryStringViewIntent { } export class QueryStringManager { - protected _api: CardQueryStringAPI; - protected _shouldRun = true; + private _api: CardQueryStringAPI; + private _shouldRun = true; constructor(api: CardQueryStringAPI) { this._api = api; @@ -42,7 +42,7 @@ export class QueryStringManager { } }; - protected async _executeViewRelated(intent: QueryStringViewIntent): Promise { + private async _executeViewRelated(intent: QueryStringViewIntent): Promise { if (intent.view) { if (intent.view.default) { await this._api.getViewManager().setViewDefaultWithNewQuery({ @@ -67,13 +67,13 @@ export class QueryStringManager { } } - protected async _executeNonViewRelated(intent: QueryStringViewIntent): Promise { + private async _executeNonViewRelated(intent: QueryStringViewIntent): Promise { if (intent.other) { await this._api.getActionsManager().executeActions({ actions: intent.other }); } } - protected _calculateIntent(): QueryStringViewIntent { + private _calculateIntent(): QueryStringViewIntent { const result: QueryStringViewIntent = {}; for (const action of this._getActions()) { if (this._isViewAction(action)) { @@ -93,7 +93,7 @@ export class QueryStringManager { return result; } - protected _getActions(): AdvancedCameraCardCustomActionConfig[] { + private _getActions(): AdvancedCameraCardCustomActionConfig[] { const params = new URLSearchParams(window.location.search); const actions: AdvancedCameraCardCustomActionConfig[] = []; const configuredCardID = this._api.getConfigManager().getConfig()?.card_id; @@ -158,7 +158,7 @@ export class QueryStringManager { return actions; } - protected _isViewAction = ( + private _isViewAction = ( action: AdvancedCameraCardCustomActionConfig, ): action is ViewActionConfig => { switch (action.advanced_camera_card_action) { diff --git a/src/card-controller/status-bar-item-manager.ts b/src/card-controller/status-bar-item-manager.ts index d905b001..6124803d 100644 --- a/src/card-controller/status-bar-item-manager.ts +++ b/src/card-controller/status-bar-item-manager.ts @@ -9,14 +9,14 @@ import { CardStatusBarAPI } from './types'; const RESOLUTION_TOLERANCE_PCT = 0.01; export class StatusBarItemManager { - protected _api: CardStatusBarAPI; + private _api: CardStatusBarAPI; constructor(api: CardStatusBarAPI) { this._api = api; } - protected _items: StatusBarItem[] = []; - protected _dynamicItems: StatusBarItem[] = []; + private _items: StatusBarItem[] = []; + private _dynamicItems: StatusBarItem[] = []; public addDynamicStatusBarItem(item: StatusBarItem): void { if (!this._dynamicItems.includes(item)) { @@ -128,7 +128,7 @@ export class StatusBarItemManager { ]; } - protected _matchesWidthHeight( + private _matchesWidthHeight( mediaLoadedInfo: MediaLoadedInfo | null, width: 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. if (this._matchesWidthHeight(mediaLoadedInfo, 1920, 1080)) { return '1080p'; diff --git a/src/card-controller/style-manager.ts b/src/card-controller/style-manager.ts index f2446b7a..b86d1a29 100644 --- a/src/card-controller/style-manager.ts +++ b/src/card-controller/style-manager.ts @@ -10,7 +10,7 @@ import { View } from '../view/view'; import { CardStyleAPI } from './types'; export class StyleManager { - protected _api: CardStyleAPI; + private _api: CardStyleAPI; constructor(api: CardStyleAPI) { 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 ? themeConfig.themes : configDefaults.view.theme.themes; } - protected _setDimmable(): void { + private _setDimmable(): void { const config = this._api.getConfigManager().getConfig(); setOrRemoveAttribute( this._api.getCardElementManager().getElement(), @@ -88,7 +88,7 @@ export class StyleManager { ); } - protected _setMinMaxHeight(): void { + private _setMinMaxHeight(): void { const config = this._api.getConfigManager().getConfig(); if (config) { const card = this._api.getCardElementManager().getElement(); @@ -96,7 +96,7 @@ export class StyleManager { } } - protected _setPerformance(): void { + private _setPerformance(): void { const STYLE_DISABLE_MAP = { box_shadow: { cssKey: '--advanced-camera-card-box-shadow-override', @@ -122,7 +122,7 @@ export class StyleManager { } } - protected _isAspectRatioEnforced( + private _isAspectRatioEnforced( config: AdvancedCameraCardConfig, view?: View | null, ): boolean { diff --git a/src/card-controller/templates/index.ts b/src/card-controller/templates/index.ts index 82ccd941..a7328323 100644 --- a/src/card-controller/templates/index.ts +++ b/src/card-controller/templates/index.ts @@ -39,7 +39,7 @@ export class TemplateRenderer { ); }; - protected _generateTemplateContext( + private _generateTemplateContext( options?: TemplateRenderOptions, ): TemplateContext | undefined { if ( @@ -64,7 +64,7 @@ export class TemplateRenderer { }; } - protected _renderTemplateRecursively( + private _renderTemplateRecursively( hass: HomeAssistant, data: unknown, templateContext?: TemplateContext, diff --git a/src/card-controller/triggers-manager.ts b/src/card-controller/triggers-manager.ts index 652f18d0..48c91b71 100644 --- a/src/card-controller/triggers-manager.ts +++ b/src/card-controller/triggers-manager.ts @@ -27,10 +27,10 @@ interface CameraTriggerState { } export class TriggersManager { - protected _api: CardTriggersAPI; - protected _states: Map = new Map(); + private _api: CardTriggersAPI; + private _states: Map = new Map(); - protected _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, { + private _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, { trailing: true, }); @@ -149,7 +149,7 @@ export class TriggersManager { return true; } - protected async _handleEndEvent(ev: CameraEvent): Promise { + private async _handleEndEvent(ev: CameraEvent): Promise { this._deleteIgnoredEventID(ev.cameraID, ev.id); const state = this._states.get(ev.cameraID); @@ -160,14 +160,14 @@ export class TriggersManager { return true; } - protected _isIgnoredUpdateEvent(ev: CameraEvent): boolean { + private _isIgnoredUpdateEvent(ev: CameraEvent): boolean { return ( (ev.type === 'update' || ev.type === 'genai') && this._hasIgnoredEventID(ev.cameraID, ev.id) ); } - protected _hasAllowableInteractionStateForAction(): boolean { + private _hasAllowableInteractionStateForAction(): boolean { const triggersConfig = this._api.getConfigManager().getConfig()?.view.triggers; const hasInteraction = this._api.getInteractionManager().hasInteraction(); @@ -179,7 +179,7 @@ export class TriggersManager { ); } - protected async _triggerAction(ev: CameraEvent): Promise { + private async _triggerAction(ev: CameraEvent): Promise { const config = this._api.getConfigManager().getConfig(); const triggerAction = config?.view?.triggers.actions.trigger; const defaultView = config?.view?.default; @@ -248,14 +248,14 @@ export class TriggersManager { this._api.getCardElementManager().update(); } - protected _setConditionStateIfNecessary(): void { + private _setConditionStateIfNecessary(): void { const triggeredCameraIDs = this.getTriggeredCameraIDs(); this._api.getConditionStateManager().setState({ triggered: triggeredCameraIDs.size ? triggeredCameraIDs : undefined, }); } - protected async _executeUntriggerAction(): Promise { + private async _executeUntriggerAction(): Promise { const action = this._api.getConfigManager().getConfig()?.view?.triggers .actions.untrigger; @@ -269,7 +269,7 @@ export class TriggersManager { return true; } - protected async _untriggerAction(cameraID: string): Promise { + private async _untriggerAction(cameraID: string): Promise { this._deleteUntriggerDelayTimer(cameraID); this._deleteForceUntriggerTimer(cameraID); @@ -282,7 +282,7 @@ export class TriggersManager { this._api.getCardElementManager().update(); } - protected async _startUntrigger(cameraID: string): Promise { + private async _startUntrigger(cameraID: string): Promise { this._deleteUntriggerDelayTimer(cameraID); this._deleteForceUntriggerTimer(cameraID); @@ -304,7 +304,7 @@ export class TriggersManager { } } - protected _startForceUntriggerTimerIfNecessary( + private _startForceUntriggerTimerIfNecessary( cameraID: string, forceUntriggerSeconds: number, ): void { @@ -324,7 +324,7 @@ export class TriggersManager { }); } - protected async _forceUntrigger( + private async _forceUntrigger( state: CameraTriggerState, cameraID: string, ): Promise { @@ -334,12 +334,12 @@ export class TriggersManager { await this._startUntrigger(cameraID); } - protected _addIgnoredEventID(cameraID: string, eventID: string): void { + private _addIgnoredEventID(cameraID: string, eventID: string): void { const state = this._getOrCreateState(cameraID); state.ignoredSources.add(eventID); } - protected _deleteIgnoredEventID(cameraID: string, eventID: string): void { + private _deleteIgnoredEventID(cameraID: string, eventID: string): void { const state = this._states.get(cameraID); if (!state) { return; @@ -349,11 +349,11 @@ export class TriggersManager { 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); } - protected _getOrCreateState(cameraID: string): CameraTriggerState { + private _getOrCreateState(cameraID: string): CameraTriggerState { let state = this._states.get(cameraID); if (!state) { state = { @@ -366,7 +366,7 @@ export class TriggersManager { return state; } - protected _deleteStateIfIdle(cameraID: string): void { + private _deleteStateIfIdle(cameraID: string): void { const state = this._states.get(cameraID); if ( state && @@ -379,7 +379,7 @@ export class TriggersManager { } } - protected _deleteUntriggerDelayTimer(cameraID: string): void { + private _deleteUntriggerDelayTimer(cameraID: string): void { const state = this._states.get(cameraID); if (state?.untriggerDelayTimer) { 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); if (state?.untriggerForceTimer) { 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); } } diff --git a/src/card-controller/view/factory.ts b/src/card-controller/view/factory.ts index b0250d19..b758150c 100644 --- a/src/card-controller/view/factory.ts +++ b/src/card-controller/view/factory.ts @@ -19,7 +19,7 @@ interface ResolvedViewTarget { } export class ViewFactory { - protected _api: CardViewAPI; + private _api: CardViewAPI; constructor(api: CardViewAPI) { this._api = api; @@ -43,7 +43,7 @@ export class ViewFactory { }); } - protected _getDefaultViewName = ( + private _getDefaultViewName = ( config: AdvancedCameraCardConfig, ): AdvancedCameraCardView => resolveViewName( @@ -52,7 +52,7 @@ export class ViewFactory { this._api.getFoldersManager(), ); - protected _getDefaultCameraID( + private _getDefaultCameraID( config: AdvancedCameraCardConfig, viewName: AdvancedCameraCardView, options?: ViewFactoryOptions, @@ -114,7 +114,7 @@ export class ViewFactory { return view; } - protected _resolveViewName( + private _resolveViewName( config: AdvancedCameraCardConfig, options?: ViewFactoryOptions, ): AdvancedCameraCardView { @@ -128,7 +128,7 @@ export class ViewFactory { return options?.baseView?.view ?? this._getDefaultViewName(config); } - protected _resolveCameraID( + private _resolveCameraID( viewName: AdvancedCameraCardView, options?: ViewFactoryOptions, ): string | null { @@ -148,7 +148,7 @@ export class ViewFactory { return viewCameraIDs?.keys().next().value ?? null; } - protected _ensureViewCompatibility( + private _ensureViewCompatibility( viewName: AdvancedCameraCardView, cameraID: string | null, config: AdvancedCameraCardConfig, @@ -173,7 +173,7 @@ export class ViewFactory { return { viewName, cameraID }; } - protected _handleNoCameraForView( + private _handleNoCameraForView( viewName: AdvancedCameraCardView, config: AdvancedCameraCardConfig, options?: ViewFactoryOptions, @@ -195,7 +195,7 @@ export class ViewFactory { }); } - protected _handleUnsupportedView( + private _handleUnsupportedView( viewName: AdvancedCameraCardView, cameraID: string, config: AdvancedCameraCardConfig, @@ -229,7 +229,7 @@ export class ViewFactory { }); } - protected _resolveDisplayMode( + private _resolveDisplayMode( viewName: AdvancedCameraCardView, config: AdvancedCameraCardConfig, options?: ViewFactoryOptions, @@ -247,7 +247,7 @@ export class ViewFactory { ); } - protected _getConfiguredDisplayMode( + private _getConfiguredDisplayMode( viewName: AdvancedCameraCardView, config: AdvancedCameraCardConfig, ): ViewDisplayMode | null { diff --git a/src/card-controller/view/modifiers/merge-context.ts b/src/card-controller/view/modifiers/merge-context.ts index f6aaea42..a031c534 100644 --- a/src/card-controller/view/modifiers/merge-context.ts +++ b/src/card-controller/view/modifiers/merge-context.ts @@ -3,7 +3,7 @@ import { View } from '../../../view/view'; import { ViewModifier } from '../types'; export class MergeContextViewModifier implements ViewModifier { - protected _context?: ViewContext | null; + private _context?: ViewContext | null; constructor(context?: ViewContext | null) { this._context = context; diff --git a/src/card-controller/view/modifiers/remove-context-property.ts b/src/card-controller/view/modifiers/remove-context-property.ts index 75c2d9eb..5795641f 100644 --- a/src/card-controller/view/modifiers/remove-context-property.ts +++ b/src/card-controller/view/modifiers/remove-context-property.ts @@ -3,8 +3,8 @@ import { View } from '../../../view/view'; import { ViewModifier } from '../types'; export class RemoveContextPropertyViewModifier implements ViewModifier { - protected _key: keyof ViewContext; - protected _property: PropertyKey; + private _key: keyof ViewContext; + private _property: PropertyKey; constructor(key: keyof ViewContext, property: PropertyKey) { this._key = key; diff --git a/src/card-controller/view/modifiers/remove-context.ts b/src/card-controller/view/modifiers/remove-context.ts index a0139166..1c785710 100644 --- a/src/card-controller/view/modifiers/remove-context.ts +++ b/src/card-controller/view/modifiers/remove-context.ts @@ -3,7 +3,7 @@ import { View } from '../../../view/view'; import { ViewModifier } from '../types'; export class RemoveContextViewModifier implements ViewModifier { - protected _keys: (keyof ViewContext)[]; + private _keys: (keyof ViewContext)[]; constructor(keys: (keyof ViewContext)[]) { this._keys = keys; diff --git a/src/card-controller/view/modifiers/set-query.ts b/src/card-controller/view/modifiers/set-query.ts index c472c1b0..5b3d0431 100644 --- a/src/card-controller/view/modifiers/set-query.ts +++ b/src/card-controller/view/modifiers/set-query.ts @@ -4,8 +4,8 @@ import { View } from '../../../view/view'; import { ViewModifier } from '../types'; export class SetQueryViewModifier implements ViewModifier { - protected _query?: UnifiedQuery | null; - protected _queryResults?: QueryResults | null; + private _query?: UnifiedQuery | null; + private _queryResults?: QueryResults | null; constructor(options?: { query?: UnifiedQuery | null; diff --git a/src/card-controller/view/modifiers/substream-on.ts b/src/card-controller/view/modifiers/substream-on.ts index a9ebfa25..631c5327 100644 --- a/src/card-controller/view/modifiers/substream-on.ts +++ b/src/card-controller/view/modifiers/substream-on.ts @@ -8,7 +8,7 @@ interface SubstreamOnViewModifierAPI { } export class SubstreamOnViewModifier implements ViewModifier { - protected _api: SubstreamOnViewModifierAPI; + private _api: SubstreamOnViewModifierAPI; constructor(api: SubstreamOnViewModifierAPI) { this._api = api; diff --git a/src/card-controller/view/modifiers/substream-select.ts b/src/card-controller/view/modifiers/substream-select.ts index af36777c..e90302f8 100644 --- a/src/card-controller/view/modifiers/substream-select.ts +++ b/src/card-controller/view/modifiers/substream-select.ts @@ -3,7 +3,7 @@ import { View } from '../../../view/view'; import { ViewModifier } from '../types'; export class SubstreamSelectViewModifier implements ViewModifier { - protected _substreamID: string; + private _substreamID: string; constructor(substreamID: string) { this._substreamID = substreamID; diff --git a/src/card-controller/view/view-manager.ts b/src/card-controller/view/view-manager.ts index 783dd0d3..5b8ded02 100644 --- a/src/card-controller/view/view-manager.ts +++ b/src/card-controller/view/view-manager.ts @@ -16,15 +16,15 @@ import { import { ViewQueryExecutor } from './view-query-executor'; export class ViewManager implements ViewManagerInterface { - protected _view: View | null = null; - protected _viewFactory: ViewFactory; - protected _viewQueryExecutor: ViewQueryExecutor; - protected _api: CardViewAPI; - protected _epoch: ViewManagerEpoch = this._createEpoch(); + private _view: View | null = null; + private _viewFactory: ViewFactory; + private _viewQueryExecutor: ViewQueryExecutor; + private _api: CardViewAPI; + private _epoch: ViewManagerEpoch = this._createEpoch(); // Used to mark as a view as "loading" with a given index. Each subsequent // async update will use a higher index. - protected _loadingIndex = 1; + private _loadingIndex = 1; constructor( api: CardViewAPI, @@ -41,7 +41,7 @@ export class ViewManager implements ViewManagerInterface { public getEpoch(): ViewManagerEpoch { return this._epoch; } - protected _createEpoch(oldView?: View | null): ViewManagerEpoch { + private _createEpoch(oldView?: View | null): ViewManagerEpoch { return { manager: this, ...(oldView && { oldView }), @@ -97,7 +97,7 @@ export class ViewManager implements ViewManagerInterface { options, ); - protected _setViewGeneric( + private _setViewGeneric( viewFactoryFunc: (options?: ViewFactoryOptions) => View | null, options?: ViewFactoryOptions, ): 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 } }); } - protected _markViewAsNotLoadingQuery(view: View): View { + private _markViewAsNotLoadingQuery(view: View): View { 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 // the same time as the cameras being initialized. Test case: Open // 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); } - protected async _setViewThenModifyAsync( + private async _setViewThenModifyAsync( viewFactoryFunc: (options?: ViewFactoryOptions) => View | null, viewModifiersFunc: ( view: View, @@ -229,7 +229,7 @@ export class ViewManager implements ViewManagerInterface { 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 // 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 @@ -292,7 +292,7 @@ export class ViewManager implements ViewManagerInterface { return true; }; - protected _setView(view: Readonly | null): void { + private _setView(view: Readonly | null): void { const oldView = this._view; log( diff --git a/src/components-lib/cached-value-controller.ts b/src/components-lib/cached-value-controller.ts index b1a87158..056f24f1 100644 --- a/src/components-lib/cached-value-controller.ts +++ b/src/components-lib/cached-value-controller.ts @@ -2,13 +2,13 @@ import { ReactiveController, ReactiveControllerHost } from 'lit'; import { Timer } from '../utils/timer'; export class CachedValueController implements ReactiveController { - protected _value?: T; - protected _host: ReactiveControllerHost; - protected _timerSeconds: number; - protected _callback: () => T; - protected _timerStartCallback?: () => void; - protected _timerStopCallback?: () => void; - protected _timer = new Timer(); + private _value?: T; + private _host: ReactiveControllerHost; + private _timerSeconds: number; + private _callback: () => T; + private _timerStartCallback?: () => void; + private _timerStopCallback?: () => void; + private _timer = new Timer(); constructor( host: ReactiveControllerHost, diff --git a/src/components-lib/key-assigner-controller.ts b/src/components-lib/key-assigner-controller.ts index fac9be28..b0273d3c 100644 --- a/src/components-lib/key-assigner-controller.ts +++ b/src/components-lib/key-assigner-controller.ts @@ -4,9 +4,9 @@ import { KeyboardShortcut } from '../config/schema/view'; import { setOrRemoveAttribute } from '../utils/basic'; export class KeyAssignerController implements ReactiveController { - protected _host: LitElement; - protected _assigning = false; - protected _value: KeyboardShortcut | null = null; + private _host: LitElement; + private _assigning = false; + private _value: KeyboardShortcut | null = null; constructor(host: LitElement) { this._host = host; @@ -40,7 +40,7 @@ export class KeyAssignerController implements ReactiveController { public toggleAssigning(): void { this._setAssigning(!this._assigning); } - protected _setAssigning(assigning: boolean): void { + private _setAssigning(assigning: boolean): void { this._assigning = assigning; setOrRemoveAttribute(this._host, this._assigning, 'assigning'); @@ -53,11 +53,11 @@ export class KeyAssignerController implements ReactiveController { this._host.requestUpdate(); } - protected _blurEventHandler = (): void => { + private _blurEventHandler = (): void => { this._setAssigning(false); }; - protected _keydownEventHandler = (ev: KeyboardEvent): void => { + private _keydownEventHandler = (ev: KeyboardEvent): void => { // Don't allow _only_ a modifier. if (!ev.key || ['Control', 'Alt', 'Shift', 'Meta'].includes(ev.key)) { return; diff --git a/src/components-lib/live/live-controller.ts b/src/components-lib/live/live-controller.ts index f2121fda..ca5260d1 100644 --- a/src/components-lib/live/live-controller.ts +++ b/src/components-lib/live/live-controller.ts @@ -28,20 +28,20 @@ type LiveControllerHost = LitElement & AdvancedCameraCardMessageEventTarget; 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 // but not visible). - protected _inBackground = false; + private _inBackground = false; // Intersection handler is used to detect when the live view flips between // foreground and background (in preload mode). - protected _intersectionObserver: IntersectionObserver; + private _intersectionObserver: IntersectionObserver; // MediaLoadedInfo object and target from the underlying live media. In the // case of pre-loading these may be propagated later (from the original // source). - protected _lastMediaLoadedInfo: LastMediaLoadedInfo | null = null; + private _lastMediaLoadedInfo: LastMediaLoadedInfo | null = null; constructor(host: LiveControllerHost) { this._host = host; @@ -75,7 +75,7 @@ export class LiveController implements ReactiveController { return this._inBackground; } - protected _handleMediaLoaded = (ev: CustomEvent): void => { + private _handleMediaLoaded = (ev: CustomEvent): void => { this._lastMediaLoadedInfo = { source: ev.composedPath()[0], 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; this._inBackground = !entries.some((entry) => entry.isIntersecting); diff --git a/src/components-lib/media-actions-controller.ts b/src/components-lib/media-actions-controller.ts index 54cf136d..f6b6fb4a 100644 --- a/src/components-lib/media-actions-controller.ts +++ b/src/components-lib/media-actions-controller.ts @@ -36,16 +36,16 @@ type MediaActionsTarget = { }; export class MediaActionsController { - protected _options: MediaActionsControllerOptions | null = null; - protected _viewportIntersecting: boolean | null = null; - protected _microphoneMuteTimer = new Timer(); - protected _root: RenderRoot | null = null; + private _options: MediaActionsControllerOptions | null = null; + private _viewportIntersecting: boolean | null = null; + private _microphoneMuteTimer = new Timer(); + private _root: RenderRoot | null = null; - protected _eventListeners = new Map void>(); - protected _children: MediaPlayerElement[] = []; - protected _target: MediaActionsTarget | null = null; - protected _mutationObserver = new MutationObserver(this._mutationHandler.bind(this)); - protected _intersectionObserver = new IntersectionObserver( + private _eventListeners = new Map void>(); + private _children: MediaPlayerElement[] = []; + private _target: MediaActionsTarget | null = null; + private _mutationObserver = new MutationObserver(this._mutationHandler.bind(this)); + private _intersectionObserver = new IntersectionObserver( this._intersectionHandler.bind(this), ); @@ -110,7 +110,7 @@ export class MediaActionsController { this._target = null; } - protected async _playTargetIfConfigured(condition: AutoPlayCondition): Promise { + private async _playTargetIfConfigured(condition: AutoPlayCondition): Promise { if ( this._target !== null && this._options?.autoPlayConditions?.includes(condition) @@ -118,10 +118,10 @@ export class MediaActionsController { await this._play(this._target.index); } } - protected async _play(index: number): Promise { + private async _play(index: number): Promise { await (await this._children[index]?.getMediaPlayerController())?.play(); } - protected async _unmuteTargetIfConfigured( + private async _unmuteTargetIfConfigured( condition: AutoUnmuteCondition, ): Promise { if ( @@ -131,20 +131,18 @@ export class MediaActionsController { await this._unmute(this._target.index); } } - protected async _unmute(index: number): Promise { + private async _unmute(index: number): Promise { await (await this._children[index]?.getMediaPlayerController())?.unmute(); } - protected async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise { + private async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise { if (this._options?.autoPauseConditions?.includes(condition)) { for (const index of this._children.keys()) { await this._pause(index); } } } - protected async _pauseTargetIfConfigured( - condition: AutoPauseCondition, - ): Promise { + private async _pauseTargetIfConfigured(condition: AutoPauseCondition): Promise { if ( this._target !== null && this._options?.autoPauseConditions?.includes(condition) @@ -152,18 +150,18 @@ export class MediaActionsController { await this._pause(this._target.index); } } - protected async _pause(index: number): Promise { + private async _pause(index: number): Promise { await (await this._children[index]?.getMediaPlayerController())?.pause(); } - protected async _muteAllIfConfigured(condition: AutoMuteCondition): Promise { + private async _muteAllIfConfigured(condition: AutoMuteCondition): Promise { if (this._options?.autoMuteConditions?.includes(condition)) { for (const index of this._children.keys()) { await this._mute(index); } } } - protected async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise { + private async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise { if ( this._target !== null && this._options?.autoMuteConditions?.includes(condition) @@ -171,11 +169,11 @@ export class MediaActionsController { await this._mute(this._target.index); } } - protected async _mute(index: number): Promise { + private async _mute(index: number): Promise { await (await this._children[index]?.getMediaPlayerController())?.mute(); } - protected _mutationHandler( + private _mutationHandler( // eslint-disable-next-line @typescript-eslint/no-unused-vars _mutations: MutationRecord[], // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -184,7 +182,7 @@ export class MediaActionsController { this._initializeRoot(); } - protected _mediaLoadedHandler = async (index: number): Promise => { + private _mediaLoadedHandler = async (index: number): Promise => { if (this._target?.index !== index) { return; } @@ -192,7 +190,7 @@ export class MediaActionsController { await this._playTargetIfConfigured(this._target.selected ? 'selected' : 'visible'); }; - protected _removeChildHandlers(): void { + private _removeChildHandlers(): void { for (const [child, callback] of this._eventListeners.entries()) { child.removeEventListener('advanced-camera-card:media:loaded', callback); } @@ -216,7 +214,7 @@ export class MediaActionsController { return true; } - protected _initializeRoot(): void { + private _initializeRoot(): void { if (!this._options || !this._root) { return; } @@ -234,7 +232,7 @@ export class MediaActionsController { } } - protected async _intersectionHandler( + private async _intersectionHandler( entries: IntersectionObserverEntry[], ): Promise { const wasIntersecting = this._viewportIntersecting; @@ -248,11 +246,11 @@ export class MediaActionsController { } } - protected _visibilityHandler = async (): Promise => { + private _visibilityHandler = async (): Promise => { await this._changeVisibility(document.visibilityState === 'visible'); }; - protected _changeVisibility = async (visible: boolean): Promise => { + private _changeVisibility = async (visible: boolean): Promise => { if (visible) { await this._unmuteTargetIfConfigured('visible'); await this._playTargetIfConfigured('visible'); @@ -262,7 +260,7 @@ export class MediaActionsController { } }; - protected async _microphoneStateChangeHandler( + private async _microphoneStateChangeHandler( oldState?: MicrophoneState, newState?: MicrophoneState, ): Promise { diff --git a/src/components-lib/media-filter-controller.ts b/src/components-lib/media-filter-controller.ts index 27ecc87d..e89506c8 100644 --- a/src/components-lib/media-filter-controller.ts +++ b/src/components-lib/media-filter-controller.ts @@ -68,24 +68,24 @@ export enum MediaFilterMediaType { } export class MediaFilterController { - protected _host: LitElement; + private _host: LitElement; - protected _mediaTypeOptions: SelectOption[]; - protected _cameraOptions: SelectOption[] = []; + private _mediaTypeOptions: SelectOption[]; + private _cameraOptions: SelectOption[] = []; - protected _whenOptions: SelectOption[] = []; - protected _staticWhenOptions: SelectOption[]; - protected _metaDataWhenOptions: SelectOption[] = []; + private _whenOptions: SelectOption[] = []; + private _staticWhenOptions: SelectOption[]; + private _metaDataWhenOptions: SelectOption[] = []; - protected _whatOptions: SelectOption[] = []; - protected _whereOptions: SelectOption[] = []; - protected _tagsOptions: SelectOption[] = []; - protected _favoriteOptions: SelectOption[]; - protected _reviewedOptions: SelectOption[]; - protected _severityOptions: SelectOption[]; + private _whatOptions: SelectOption[] = []; + private _whereOptions: SelectOption[] = []; + private _tagsOptions: SelectOption[] = []; + private _favoriteOptions: SelectOption[]; + private _reviewedOptions: SelectOption[]; + private _severityOptions: SelectOption[]; - protected _defaults: MediaFilterCoreDefaults | null = null; - protected _viewManager: ViewManagerInterface | null = null; + private _defaults: MediaFilterCoreDefaults | null = null; + private _viewManager: ViewManagerInterface | null = null; constructor(host: LitElement) { this._host = host; @@ -450,15 +450,15 @@ export class MediaFilterController { this._host.requestUpdate(); } - protected _computeWhenOptions(): void { + private _computeWhenOptions(): void { this._whenOptions = [...this._staticWhenOptions, ...this._metaDataWhenOptions]; } - protected _dateRangeToString(when: DateRange): string { + private _dateRangeToString(when: DateRange): string { return `${formatDate(when.start)},${formatDate(when.end)}`; } - protected _stringToDateRange(input: string): DateRange { + private _stringToDateRange(input: string): DateRange { const dates = input.split(','); return { 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[]; from?: Date | null; to?: Date | null; @@ -499,7 +499,7 @@ export class MediaFilterController { } } - protected _hasSingleUniqueValue(sets: (Set | undefined)[]): boolean { + private _hasSingleUniqueValue(sets: (Set | undefined)[]): boolean { if (sets.length === 0) { return false; } diff --git a/src/components-lib/media-grid-controller.ts b/src/components-lib/media-grid-controller.ts index 34e95372..7d4ac9fe 100644 --- a/src/components-lib/media-grid-controller.ts +++ b/src/components-lib/media-grid-controller.ts @@ -47,18 +47,18 @@ export interface ExtendedMasonry extends Masonry { } export class MediaGridController { - protected _host: HTMLElement; + private _host: HTMLElement; - protected _selected: GridID | null; - protected _mediaLoadedInfoMap: Map = new Map(); - protected _gridContents: MediaGridContents = new Map(); - protected _masonry: ExtendedMasonry | null = null; - protected _displayConfig: ViewDisplayConfig | null = null; - protected _hostWidth: number; - protected _idAttribute: string; - protected _widthFactorAttribute: string; + private _selected: GridID | null; + private _mediaLoadedInfoMap: Map = new Map(); + private _gridContents: MediaGridContents = new Map(); + private _masonry: ExtendedMasonry | null = null; + private _displayConfig: ViewDisplayConfig | null = null; + private _hostWidth: number; + private _idAttribute: string; + private _widthFactorAttribute: string; - protected _throttledLayout = throttle( + private _throttledLayout = throttle( () => this._masonry?.layout?.(), // Throttle layout calls to larger than the masonry.js transitionDuration // value specified below. @@ -68,18 +68,18 @@ export class MediaGridController { // If the order in which the observers are declared changes, the unittest must // be updated in triggerResizeObserver and triggerMutationObserver. - protected _hostMutationObserver = new MutationObserver( + private _hostMutationObserver = new MutationObserver( // eslint-disable-next-line @typescript-eslint/no-unused-vars (_mutations: MutationRecord[], _observer: MutationObserver) => this._calculateGridContentsFromHost(), ); - protected _cellMutationObserver = new MutationObserver( + private _cellMutationObserver = new MutationObserver( // eslint-disable-next-line @typescript-eslint/no-unused-vars (_mutations: MutationRecord[], _observer: MutationObserver) => this._calculateGridContentsFromHost(), ); - protected _hostResizeObserver = new ResizeObserver(this._hostResizeHandler.bind(this)); - protected _cellResizeObserver = new ResizeObserver(this._cellResizeHandler.bind(this)); + private _hostResizeObserver = new ResizeObserver(this._hostResizeHandler.bind(this)); + private _cellResizeObserver = new ResizeObserver(this._cellResizeHandler.bind(this)); constructor(host: HTMLElement, options?: MediaGridConstructorOptions) { this._host = host; @@ -142,7 +142,7 @@ export class MediaGridController { return this._selected; } - protected _sortItemsInGrid(): void { + private _sortItemsInGrid(): void { const existingItems = this._masonry?.items; const selectedItem = existingItems?.find( (item) => item.element.getAttribute(this._idAttribute) === this._selected, @@ -201,7 +201,7 @@ export class MediaGridController { this._updateSelectedStylesOnElements(); } - protected _calculateGridContentsFromHost = (): void => { + private _calculateGridContentsFromHost = (): void => { const children = getChildrenFromElement(this._host); const gridContents: MediaGridContents = new Map(); for (const child of children) { @@ -212,7 +212,7 @@ export class MediaGridController { this._setGridContents(gridContents); }; - protected _setGridContents(gridContents: MediaGridContents): void { + private _setGridContents(gridContents: MediaGridContents): void { this._gridContents = gridContents; // Remove media loaded info objects that belong to objects no longer in the @@ -252,7 +252,7 @@ export class MediaGridController { this._setColumnSizeStyles(); } - protected _handleMediaLoadedInfoEvent = (ev: CustomEvent): void => { + private _handleMediaLoadedInfoEvent = (ev: CustomEvent): void => { const eventPath = ev.composedPath(); 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(); // 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(); } - protected _addChildEventListeners(child: MediaGridChild): void { + private _addChildEventListeners(child: MediaGridChild): void { child.addEventListener('click', this._handleSelectGridCellEvent, { capture: true, }); @@ -298,7 +298,7 @@ export class MediaGridController { ); } - protected _removeChildEventListeners(child: MediaGridChild): void { + private _removeChildEventListeners(child: MediaGridChild): void { child.removeEventListener('click', this._handleSelectGridCellEvent, { capture: true, }); @@ -309,7 +309,7 @@ export class MediaGridController { ); } - protected _createMasonry(): void { + private _createMasonry(): void { if (this._masonry) { this._masonry.destroy?.(); } @@ -325,7 +325,7 @@ export class MediaGridController { this._throttledLayout(); } - protected _handleSelectGridCellEvent = (ev: Event): void => { + private _handleSelectGridCellEvent = (ev: Event): void => { const eventPath = ev.composedPath(); 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()) { 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()) { const widthFactor = element.getAttribute(this._widthFactorAttribute); setOrRemoveStyleProperty( @@ -363,7 +363,7 @@ export class MediaGridController { } } - protected _getColumnSize(): number { + private _getColumnSize(): number { const columns = this._getColumns(); if (columns === 1) { return this._hostWidth; @@ -372,7 +372,7 @@ export class MediaGridController { return Math.max(0, this._hostWidth / columns - MEDIA_GRID_HORIZONTAL_GUTTER_WIDTH); } - protected _getColumns(): number { + private _getColumns(): number { if (this._displayConfig?.grid_columns) { return this._displayConfig?.grid_columns; } @@ -397,7 +397,7 @@ export class MediaGridController { return Math.max(1, minColumns); } - protected _setColumnSizeStyles(): void { + private _setColumnSizeStyles(): void { this._host.style.setProperty( '--advanced-camera-card-grid-column-size', `${this._getColumnSize()}px`, diff --git a/src/components-lib/media/details-controller.ts b/src/components-lib/media/details-controller.ts index cf04a30c..66be934d 100644 --- a/src/components-lib/media/details-controller.ts +++ b/src/components-lib/media/details-controller.ts @@ -219,7 +219,7 @@ export class MediaDetailsController { }; } - protected _getControls(context: OverlayControlsContext): OverlayMessageControl[] { + private _getControls(context: OverlayControlsContext): OverlayMessageControl[] { const controls: OverlayMessageControl[] = []; const item = this._item; diff --git a/src/components-lib/menu-button-controller.ts b/src/components-lib/menu-button-controller.ts index 153f5b9d..494f8902 100644 --- a/src/components-lib/menu-button-controller.ts +++ b/src/components-lib/menu-button-controller.ts @@ -51,7 +51,7 @@ export interface MenuButtonControllerOptions { export class MenuButtonController { // Array of dynamic menu buttons to be added to menu. - protected _dynamicMenuButtons: MenuItem[] = []; + private _dynamicMenuButtons: MenuItem[] = []; public addDynamicMenuButton(button: MenuItem): void { if (!this._dynamicMenuButtons.includes(button)) { @@ -128,7 +128,7 @@ export class MenuButtonController { ].filter(isTruthy); } - protected _getIrisButton(config: AdvancedCameraCardConfig): MenuItem { + private _getIrisButton(config: AdvancedCameraCardConfig): MenuItem { return { icon: 'iris', ...config.menu.buttons.iris, @@ -145,7 +145,7 @@ export class MenuButtonController { }; } - protected _getCamerasButton( + private _getCamerasButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -180,7 +180,7 @@ export class MenuButtonController { return null; } - protected _getSubstreamsButton( + private _getSubstreamsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -243,7 +243,7 @@ export class MenuButtonController { return null; } - protected _getLiveButton( + private _getLiveButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -261,7 +261,7 @@ export class MenuButtonController { : null; } - protected _getClipsButton( + private _getClipsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -280,7 +280,7 @@ export class MenuButtonController { : null; } - protected _getSnapshotsButton( + private _getSnapshotsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -299,7 +299,7 @@ export class MenuButtonController { : null; } - protected _getRecordingsButton( + private _getRecordingsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -318,7 +318,7 @@ export class MenuButtonController { : null; } - protected _getReviewsButton( + private _getReviewsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -337,7 +337,7 @@ export class MenuButtonController { : null; } - protected _getGalleryButton( + private _getGalleryButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -356,7 +356,7 @@ export class MenuButtonController { : null; } - protected _getImageButton( + private _getImageButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -374,7 +374,7 @@ export class MenuButtonController { : null; } - protected _getTimelineButton( + private _getTimelineButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -392,7 +392,7 @@ export class MenuButtonController { : null; } - protected _getDownloadButton( + private _getDownloadButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -414,7 +414,7 @@ export class MenuButtonController { return null; } - protected _getInfoButton( + private _getInfoButton( config: AdvancedCameraCardConfig, _cameraManager: CameraManager, view?: View | null, @@ -435,7 +435,7 @@ export class MenuButtonController { }; } - protected _getSetReviewButton( + private _getSetReviewButton( config: AdvancedCameraCardConfig, view?: View | null, ): MenuItem | null { @@ -460,7 +460,7 @@ export class MenuButtonController { }; } - protected _getCameraUIButton( + private _getCameraUIButton( config: AdvancedCameraCardConfig, showCameraUIButton?: boolean, ): MenuItem | null { @@ -475,7 +475,7 @@ export class MenuButtonController { : null; } - protected _getMicrophoneButton( + private _getMicrophoneButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -519,7 +519,7 @@ export class MenuButtonController { return null; } - protected _getExpandButton( + private _getExpandButton( config: AdvancedCameraCardConfig, inExpandedMode?: boolean, ): MenuItem { @@ -533,7 +533,7 @@ export class MenuButtonController { }; } - protected _getFullscreenButton( + private _getFullscreenButton( config: AdvancedCameraCardConfig, fullscreenManager?: FullscreenManager | null, ): MenuItem | null { @@ -550,7 +550,7 @@ export class MenuButtonController { : null; } - protected _getCastButton( + private _getCastButton( hass: HomeAssistant, config: AdvancedCameraCardConfig, cameraManager: CameraManager, @@ -599,7 +599,7 @@ export class MenuButtonController { return null; } - protected _getPlayPauseButton( + private _getPlayPauseButton( config: AdvancedCameraCardConfig, currentMediaLoadedInfo?: MediaLoadedInfo | null, ): MenuItem | null { @@ -620,7 +620,7 @@ export class MenuButtonController { return null; } - protected _getMuteUnmuteButton( + private _getMuteUnmuteButton( config: AdvancedCameraCardConfig, currentMediaLoadedInfo?: MediaLoadedInfo | null, ): MenuItem | null { @@ -641,7 +641,7 @@ export class MenuButtonController { return null; } - protected _getScreenshotButton( + private _getScreenshotButton( config: AdvancedCameraCardConfig, currentMediaLoadedInfo?: MediaLoadedInfo | null, ): MenuItem | null { @@ -657,7 +657,7 @@ export class MenuButtonController { return null; } - protected _getDisplayModeButton( + private _getDisplayModeButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, @@ -686,7 +686,7 @@ export class MenuButtonController { return null; } - protected _getPTZControlsButton( + private _getPTZControlsButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -723,7 +723,7 @@ export class MenuButtonController { return null; } - protected _getPTZHomeButton( + private _getPTZHomeButton( config: AdvancedCameraCardConfig, cameraManager: CameraManager, view?: View | null, @@ -754,7 +754,7 @@ export class MenuButtonController { }; } - protected _getFoldersButton( + private _getFoldersButton( config: AdvancedCameraCardConfig, foldersManager?: FoldersManager | null, view?: View | null, @@ -808,7 +808,7 @@ export class MenuButtonController { * Get the style of emphasized menu items. * @returns A StyleInfo. */ - protected _getEmphasizedStyle(critical?: boolean): StyleInfo { + private _getEmphasizedStyle(critical?: boolean): StyleInfo { if (critical) { return { animation: 'pulse 3s infinite', @@ -826,7 +826,7 @@ export class MenuButtonController { * @param button The button to examine. * @returns A StyleInfo object. */ - protected _getStyleFromActions( + private _getStyleFromActions( config: AdvancedCameraCardConfig, cameraManager: CameraManager, foldersManager: FoldersManager, diff --git a/src/components-lib/menu-controller.ts b/src/components-lib/menu-controller.ts index 73fb2632..083f17b7 100644 --- a/src/components-lib/menu-controller.ts +++ b/src/components-lib/menu-controller.ts @@ -11,10 +11,10 @@ import { getActionConfigGivenAction } from '../utils/action'; import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js'; export class MenuController { - protected _host: LitElement; - protected _config: MenuConfig | null = null; - protected _buttons: MenuItem[] = []; - protected _expanded = false; + private _host: LitElement; + private _config: MenuConfig | null = null; + private _buttons: MenuItem[] = []; + private _expanded = false; constructor(host: LitElement) { this._host = host; @@ -146,7 +146,7 @@ export class MenuController { } } - protected _sortButtons(): void { + private _sortButtons(): void { this._buttons = orderBy( this._buttons, (button) => { @@ -161,11 +161,11 @@ export class MenuController { ); } - protected _isHidingMenu(): boolean { + private _isHidingMenu(): boolean { return this._config?.style === 'hidden'; } - protected _isMenuToggleAction(action: ActionConfig): boolean { + private _isMenuToggleAction(action: ActionConfig): boolean { return ( action.action === 'fire-dom-event' && action.advanced_camera_card_action === 'menu_toggle' diff --git a/src/components-lib/status-bar-controller.ts b/src/components-lib/status-bar-controller.ts index 1bebda38..8debe13c 100644 --- a/src/components-lib/status-bar-controller.ts +++ b/src/components-lib/status-bar-controller.ts @@ -9,11 +9,11 @@ import { arrayify, setOrRemoveAttribute } from '../utils/basic'; import { Timer } from '../utils/timer'; export class StatusBarController { - protected _host: LitElement; - protected _config: StatusBarConfig | null = null; + private _host: LitElement; + private _config: StatusBarConfig | null = null; - protected _popupTimer = new Timer(); - protected _items: StatusBarItem[] = []; + private _popupTimer = new Timer(); + private _items: StatusBarItem[] = []; constructor(host: LitElement) { 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 */ if (item.type === 'custom:advanced-camera-card-status-bar-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 .filter((item) => item.enabled !== false && item.sufficient) .map((item) => this._getSufficientValue(item)); } - protected _show(): void { + private _show(): void { setOrRemoveAttribute(this._host, false, 'hide'); } - protected _hide(): void { + private _hide(): void { setOrRemoveAttribute(this._host, true, 'hide'); } } diff --git a/src/components-lib/zoom/zoom-controller.ts b/src/components-lib/zoom/zoom-controller.ts index 3c659614..b8aba3db 100644 --- a/src/components-lib/zoom/zoom-controller.ts +++ b/src/components-lib/zoom/zoom-controller.ts @@ -13,30 +13,30 @@ import { } from './types'; export class ZoomController { - protected _element: HTMLElement; - protected _panzoom?: PanzoomObject; + private _element: HTMLElement; + private _panzoom?: PanzoomObject; // Is the controller zoomed in at all? - protected _zoomed = false; + private _zoomed = false; // 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? - protected _allowClick = true; + private _allowClick = true; - protected _defaultSettings: PartialZoomSettings | null; - protected _settings: PartialZoomSettings | null; + private _defaultSettings: PartialZoomSettings | null; + private _settings: PartialZoomSettings | null; // 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 // digital PTZ actions. - protected _debouncedChangeHandler = throttle(this._changeHandler.bind(this), 50); - protected _debouncedUpdater = throttle(this._updateBasedOnConfig.bind(this), 50); + private _debouncedChangeHandler = throttle(this._changeHandler.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'], move: ['pointermove'], @@ -48,7 +48,7 @@ export class ZoomController { up: ['touchend', 'touchcancel'], }; - protected _downHandler = (ev: Event) => { + private _downHandler = (ev: Event) => { if (this._shouldZoomOrPan(ev)) { this._panzoom?.handleDown(ev as PointerEvent); 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 // 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 @@ -77,21 +77,21 @@ export class ZoomController { this._allowClick = true; }; - protected _moveHandler = (ev: Event) => { + private _moveHandler = (ev: Event) => { if (this._shouldZoomOrPan(ev)) { this._panzoom?.handleMove(ev as PointerEvent); ev.stopPropagation(); } }; - protected _upHandler = (ev: Event) => { + private _upHandler = (ev: Event) => { if (this._shouldZoomOrPan(ev)) { this._panzoom?.handleUp(ev as PointerEvent); ev.stopPropagation(); } }; - protected _wheelHandler = (ev: Event) => { + private _wheelHandler = (ev: Event) => { if (ev instanceof WheelEvent && this._shouldZoomOrPan(ev)) { this._panzoom?.zoomWithWheel(ev); ev.stopPropagation(); @@ -198,7 +198,7 @@ export class ZoomController { this._debouncedUpdater(); } - protected _changeHandler(ev: Event): void { + private _changeHandler(ev: Event): void { const pz = (>ev).detail; const unzoomed = this._isUnzoomed(pz.scale); @@ -228,7 +228,7 @@ export class ZoomController { 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 // used fully specified by this object. It's kept as-is for completeness. return ( @@ -256,11 +256,11 @@ export class ZoomController { ); } - protected _getConfigToUse(): PartialZoomSettings | null { + private _getConfigToUse(): PartialZoomSettings | null { return isZoomEmpty(this._settings) ? this._defaultSettings : this._settings; } - protected _updateBasedOnConfig(): void { + private _updateBasedOnConfig(): void { if (!this._panzoom) { return; } @@ -329,7 +329,7 @@ export class ZoomController { * @param scale The desired (not current) scale. * @returns An object with x/y pan % values or null on error. */ - protected _convertPercentToXYPan( + private _convertPercentToXYPan( x: number, y: number, scale: number, @@ -345,7 +345,7 @@ export class ZoomController { }; } - protected _convertXYPanToPercent( + private _convertXYPanToPercent( x: number, y: number, scale: number, @@ -367,7 +367,7 @@ export class ZoomController { }; } - protected _getTransformMinMax( + private _getTransformMinMax( desiredScale: 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(); return { 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; } - protected _isAtDefaultZoomAndPan(x: number, y: number, scale: number): boolean { + private _isAtDefaultZoomAndPan(x: number, y: number, scale: number): boolean { if (!this._defaultSettings) { return this._isUnzoomed(scale); } @@ -438,7 +438,7 @@ export class ZoomController { ); } - protected _shouldZoomOrPan(ev: Event): boolean { + private _shouldZoomOrPan(ev: Event): boolean { return ( !this._isUnzoomed(this._panzoom?.getScale()) || // 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'; } } diff --git a/src/components/carousel.ts b/src/components/carousel.ts index d2ae0d46..b9987e6c 100644 --- a/src/components/carousel.ts +++ b/src/components/carousel.ts @@ -48,12 +48,12 @@ export class AdvancedCameraCardCarousel extends LitElement { @property({ attribute: false }) public selected = 0; - protected _refParent: Ref = createRef(); - protected _refRoot: Ref = createRef(); - protected _carousel: CarouselController | null = null; + private _refParent: Ref = createRef(); + private _refRoot: Ref = createRef(); + private _carousel: CarouselController | null = null; // Track slide count to distinguish user-navigation from content changes. - protected _previousSlideCount: number | null = null; + private _previousSlideCount: number | null = null; connectedCallback(): void { super.connectedCallback(); diff --git a/src/components/date-picker.ts b/src/components/date-picker.ts index 89fb9e04..fa4f4b94 100644 --- a/src/components/date-picker.ts +++ b/src/components/date-picker.ts @@ -16,7 +16,7 @@ export class AdvancedCameraCardDatePicker extends LitElement { @property({ attribute: false }) public icon?: string; - protected _refInput: Ref = createRef(); + private _refInput: Ref = createRef(); get value(): Date | null { return this._refInput.value?.value ? new Date(this._refInput.value.value) : null; diff --git a/src/components/diagnostics.ts b/src/components/diagnostics.ts index 53c92c8f..dc68b406 100644 --- a/src/components/diagnostics.ts +++ b/src/components/diagnostics.ts @@ -20,7 +20,7 @@ export class AdvancedCameraCardDiagnostics extends LitElement { @property({ attribute: false }) public rawConfig?: RawAdvancedCameraCardConfig; - protected async _renderDiagnostics(): Promise { + private async _renderDiagnostics(): Promise { const diagnostics = await getDiagnostics( this.hass, this.deviceRegistryManager, diff --git a/src/components/drawer.ts b/src/components/drawer.ts index 8a8ee19e..2c0aa2bf 100644 --- a/src/components/drawer.ts +++ b/src/components/drawer.ts @@ -42,12 +42,12 @@ export class AdvancedCameraCardDrawer extends LitElement { @property({ type: Boolean, reflect: true, attribute: true }) public empty = true; - protected _refDrawer: Ref = createRef(); - protected _refSlot: Ref = createRef(); + private _refDrawer: Ref = createRef(); + private _refSlot: Ref = 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. @@ -64,7 +64,7 @@ export class AdvancedCameraCardDrawer extends LitElement { this._refDrawer.value?.shadowRoot?.appendChild(style); } - protected _slotChanged(): void { + private _slotChanged(): void { const children = this._refSlot.value ? getChildrenFromElement(this._refSlot.value) : []; @@ -77,7 +77,7 @@ export class AdvancedCameraCardDrawer extends LitElement { this._hideDrawerIfNecessary(); } - protected _hideDrawerIfNecessary(): void { + private _hideDrawerIfNecessary(): void { if (!this._refDrawer.value) { return; } diff --git a/src/components/elements.ts b/src/components/elements.ts index 3bb6ae68..74eed6f4 100644 --- a/src/components/elements.ts +++ b/src/components/elements.ts @@ -103,7 +103,7 @@ export class AdvancedCameraCardElementsCore extends LitElement { * Create the root node for our picture elements. * @returns The newly created root. */ - protected _createRoot(): HuiConditionalElement { + private _createRoot(): HuiConditionalElement { const elementConstructor = customElements.get('hui-conditional-element'); if (!elementConstructor || !this.hass) { throw new Error(localize('error.could_not_render_elements')); @@ -201,7 +201,7 @@ export class AdvancedCameraCardElements extends LitElement { @property({ attribute: false }) public conditionStateManager?: ConditionStateManager; - protected _addHandler( + private _addHandler( target: EventTarget, eventName: string, handler: (ev: Event) => void, @@ -211,7 +211,7 @@ export class AdvancedCameraCardElements extends LitElement { 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 // there is no parent of the disconnected element). fireAdvancedCameraCardEvent( @@ -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 // there is no parent of the disconnected element). fireAdvancedCameraCardEvent( @@ -231,7 +231,7 @@ export class AdvancedCameraCardElements extends LitElement { ); }; - protected _menuAddHandler = (ev: Event): void => { + private _menuAddHandler = (ev: Event): void => { ev = ev as CustomEvent; const path = ev.composedPath(); 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; const path = ev.composedPath(); if (!path.length) { @@ -299,8 +299,8 @@ export class AdvancedCameraCardElements extends LitElement { */ @customElement('advanced-camera-card-conditional') export class AdvancedCameraCardElementsConditional extends LitElement { - protected _config?: AdvancedCameraCardConditional; - protected _conditionManager: ConditionsManager | null = null; + private _config?: AdvancedCameraCardConditional; + private _conditionManager: ConditionsManager | null = null; // A note on hass as an update mechanism: // @@ -344,7 +344,7 @@ export class AdvancedCameraCardElementsConditional extends LitElement { super.disconnectedCallback(); } - protected _createConditionManager(): void { + private _createConditionManager(): void { const conditionStateManager = getConditionStateManagerViaEvent(this); if (!this._config || !conditionStateManager) { return; diff --git a/src/components/gallery/gallery.ts b/src/components/gallery/gallery.ts index a314500d..9a4aa7a9 100644 --- a/src/components/gallery/gallery.ts +++ b/src/components/gallery/gallery.ts @@ -74,9 +74,9 @@ export class AdvancedCameraCardGallery extends LitElement { @property({ attribute: false }) public conditionStateManager?: ConditionStateManagerReadonlyInterface; - protected _controller = new GalleryController(this); - protected _upFolderItem: ViewFolder | null = null; - protected _builder: UnifiedQueryBuilder | null = null; + private _controller = new GalleryController(this); + private _upFolderItem: ViewFolder | null = null; + private _builder: UnifiedQueryBuilder | null = null; protected willUpdate(changedProps: PropertyValues): void { if ( @@ -98,14 +98,14 @@ export class AdvancedCameraCardGallery extends LitElement { } } - protected _getLimit(): number { + private _getLimit(): number { return ( this.cardWideConfig?.performance?.features?.media_chunk_size ?? MEDIA_CHUNK_SIZE_DEFAULT ); } - protected _getFolderNavigationParameters(): FolderNavigationParamaters | null { + private _getFolderNavigationParameters(): FolderNavigationParamaters | null { return this._builder && this.viewManagerEpoch ? { builder: this._builder, @@ -115,7 +115,7 @@ export class AdvancedCameraCardGallery extends LitElement { : null; } - protected _renderUpFolder(): TemplateResult | void { + private _renderUpFolder(): TemplateResult | void { if (!this._upFolderItem) { return; } @@ -133,7 +133,7 @@ export class AdvancedCameraCardGallery extends LitElement { `; } - protected _renderThumbnails(): TemplateResult | void { + private _renderThumbnails(): TemplateResult | void { const view = this.viewManagerEpoch?.manager.getView(); const selected = view?.queryResults?.getSelectedResult(); @@ -255,7 +255,7 @@ export class AdvancedCameraCardGallery extends LitElement { `; } - protected async _extendGallery( + private async _extendGallery( ev: CustomEvent, direction: 'earlier' | 'later', useCache = true, diff --git a/src/components/image-player.ts b/src/components/image-player.ts index 6c70f6ae..486cc36d 100644 --- a/src/components/image-player.ts +++ b/src/components/image-player.ts @@ -23,8 +23,8 @@ export class AdvancedCameraCardImagePlayer extends LitElement implements MediaPl @property() public technology?: MediaTechnology; - protected _refImage: Ref> = createRef(); - protected _mediaPlayerController = new ImageMediaPlayerController( + private _refImage: Ref> = createRef(); + private _mediaPlayerController = new ImageMediaPlayerController( this, () => this._refImage.value ?? null, ); diff --git a/src/components/image-updating-player.ts b/src/components/image-updating-player.ts index 2fd32975..c4100c01 100644 --- a/src/components/image-updating-player.ts +++ b/src/components/image-updating-player.ts @@ -89,16 +89,16 @@ export class AdvancedCameraCardImageUpdatingPlayer public imageConfig?: ImageBaseConfig; @state() - protected _message: Message | null = null; + private _message: Message | null = null; - protected _refImage: Ref = createRef(); + private _refImage: Ref = createRef(); - protected _cachedValueController?: CachedValueController; - protected _boundVisibilityHandler = this._visibilityHandler.bind(this); + private _cachedValueController?: CachedValueController; + 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._refImage.value ?? null, () => this._cachedValueController ?? null, @@ -195,7 +195,7 @@ export class AdvancedCameraCardImageUpdatingPlayer * @param entity The entity. * @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; return !!this.hass && @@ -228,7 +228,7 @@ export class AdvancedCameraCardImageUpdatingPlayer /** * Handle document visibility changes. */ - protected _visibilityHandler(): void { + private _visibilityHandler(): void { if (!this._refImage.value) { return; } @@ -258,12 +258,12 @@ export class AdvancedCameraCardImageUpdatingPlayer * @param url An input URL (may be relative to document origin) * @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())); return url.toString(); } - protected _addQueryParametersToURL(url: URL, parameters?: string): URL { + private _addQueryParametersToURL(url: URL, parameters?: string): URL { if (parameters) { const searchParams = new URLSearchParams(parameters); for (const [key, value] of searchParams.entries()) { @@ -273,7 +273,7 @@ export class AdvancedCameraCardImageUpdatingPlayer return url; } - protected _getRelevantEntityForMode(mode: Exclude): string | null { + private _getRelevantEntityForMode(mode: Exclude): string | null { return mode === 'camera' ? getCameraEntityFromConfig(this.cameraConfig) : mode === 'entity' @@ -281,7 +281,7 @@ export class AdvancedCameraCardImageUpdatingPlayer : null; } - protected _getImageSource(): string { + private _getImageSource(): string { const mode = resolveImageMode({ imageConfig: this.imageConfig, cameraConfig: this.cameraConfig, @@ -317,7 +317,7 @@ export class AdvancedCameraCardImageUpdatingPlayer /** * Force the img element to a safe image. */ - protected _forceSafeImage(stockOnly?: boolean): void { + private _forceSafeImage(stockOnly?: boolean): void { if (this._refImage.value) { this._refImage.value.src = !stockOnly && this.imageConfig?.url ? this.imageConfig.url : defaultImage; diff --git a/src/components/image.ts b/src/components/image.ts index 76ee3f9c..669ecf21 100644 --- a/src/components/image.ts +++ b/src/components/image.ts @@ -36,14 +36,14 @@ export class AdvancedCameraCardImage extends LitElement implements MediaPlayer { @property({ attribute: false }) public imageConfig?: ImageViewConfig; - protected _refImage: Ref = createRef(); + private _refImage: Ref = createRef(); public async getMediaPlayerController(): Promise { await this.updateComplete; 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 view = this.viewManagerEpoch?.manager.getView(); const mode = resolveImageMode({ diff --git a/src/components/key-assigner.ts b/src/components/key-assigner.ts index a39dd02c..3792888e 100644 --- a/src/components/key-assigner.ts +++ b/src/components/key-assigner.ts @@ -21,7 +21,7 @@ export class AdvancedCameraCardKeyAssigner extends LitElement { @property({ attribute: false }) public value?: KeyboardShortcut | null; - protected _controller = new KeyAssignerController(this); + private _controller = new KeyAssignerController(this); protected willUpdate(changedProps: PropertyValues): void { if (changedProps.has('value')) { diff --git a/src/components/live/carousel.ts b/src/components/live/carousel.ts index 4ca61ea3..3da43fdf 100644 --- a/src/components/live/carousel.ts +++ b/src/components/live/carousel.ts @@ -71,15 +71,15 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { public viewFilterCameraID?: string; // Index between camera name and slide number. - protected _cameraToSlide: Record = {}; - protected _refPTZControl: Ref = createRef(); - protected _refCarousel: Ref = createRef(); + private _cameraToSlide: Record = {}; + private _refPTZControl: Ref = createRef(); + private _refCarousel: Ref = createRef(); - protected _mediaActionsController = new MediaActionsController(); - protected _mediaHeightController = new MediaHeightController(this, '.embla__slide'); + private _mediaActionsController = new MediaActionsController(); + private _mediaHeightController = new MediaHeightController(this, '.embla__slide'); @state() - protected _mediaHasLoaded = false; + private _mediaHasLoaded = false; public connectedCallback(): void { super.connectedCallback(); @@ -96,11 +96,11 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { super.disconnectedCallback(); } - protected _getTransitionEffect(): TransitionEffect { + private _getTransitionEffect(): TransitionEffect { return this.liveConfig?.transition_effect ?? configDefaults.live.transition_effect; } - protected _getSelectedCameraIndex(): number { + private _getSelectedCameraIndex(): number { if (this.viewFilterCameraID) { // If the carousel is limited to a single cameraID, the first (only) // element is always the selected one. @@ -140,7 +140,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { } } - protected _getPlugins(): EmblaCarouselPlugins { + private _getPlugins(): EmblaCarouselPlugins { return [AutoMediaLoadedInfo()]; } @@ -151,12 +151,12 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { * should load simultaneously. * @returns */ - protected _getLazyLoadCount(): number | null { + private _getLazyLoadCount(): number | null { // Defaults to fully-lazy loading. return this.liveConfig?.lazy_load === false ? null : 0; } - protected _getSlides(): [TemplateResult[], Record] { + private _getSlides(): [TemplateResult[], Record] { if (!this.cameraManager) { return [[], {}]; } @@ -179,14 +179,14 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { return [slides, cameraToSlide]; } - protected _setViewHandler(ev: CustomEvent): void { + private _setViewHandler(ev: CustomEvent): void { const cameraIDs = this.cameraManager?.getStore().getCameraIDsWithCapability('live'); if (cameraIDs?.size && ev.detail.index !== this._getSelectedCameraIndex()) { this._setViewCameraID([...cameraIDs][ev.detail.index]); } } - protected _setViewCameraID(cameraID?: string | null): void { + private _setViewCameraID(cameraID?: string | null): void { if (cameraID) { this.viewManagerEpoch?.manager.setViewByParametersWithNewQuery({ 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); if (!this.liveConfig || !this.hass || !this.cameraManager || !camera) { 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; } - protected _getCameraNeighbors(): CameraNeighbors | null { + private _getCameraNeighbors(): CameraNeighbors | null { const cameraIDs = this.cameraManager ? [...this.cameraManager?.getStore().getCameraIDsWithCapability('live')] : []; @@ -279,7 +279,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { }; } - protected _renderNextPrevious( + private _renderNextPrevious( side: 'left' | 'right', neighbors: CameraNeighbors | null, ): TemplateResult { @@ -370,7 +370,7 @@ export class AdvancedCameraCardLiveCarousel extends LitElement { `; } - protected _setMediaTarget(): void { + private _setMediaTarget(): void { const view = this.viewManagerEpoch?.manager.getView(); const selectedCameraIndex = this._getSelectedCameraIndex(); diff --git a/src/components/live/grid.ts b/src/components/live/grid.ts index 310f70b1..41d13334 100644 --- a/src/components/live/grid.ts +++ b/src/components/live/grid.ts @@ -41,7 +41,7 @@ export class AdvancedCameraCardLiveGrid extends LitElement { @property({ attribute: false }) public triggeredCameraIDs?: Set; - protected _renderCarousel(cameraID?: string): TemplateResult { + private _renderCarousel(cameraID?: string): TemplateResult { const view = this.viewManagerEpoch?.manager.getView(); 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({ params: { 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 view = this.viewManagerEpoch?.manager.getView(); return ( diff --git a/src/components/live/index.ts b/src/components/live/index.ts index af6cb7f8..2b73a962 100644 --- a/src/components/live/index.ts +++ b/src/components/live/index.ts @@ -33,7 +33,7 @@ export class AdvancedCameraCardLive extends LitElement { @property({ attribute: false }) public triggeredCameraIDs?: Set; - protected _controller = new LiveController(this); + private _controller = new LiveController(this); protected render(): TemplateResult | void { if (!this.hass || !this.cameraManager) { diff --git a/src/components/live/provider.ts b/src/components/live/provider.ts index aace3d81..4cec5f2e 100644 --- a/src/components/live/provider.ts +++ b/src/components/live/provider.ts @@ -62,17 +62,17 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP public zoomSettings?: PartialZoomSettings | null; @state() - protected _isVideoMediaLoaded = false; + private _isVideoMediaLoaded = false; @state() - protected _hasProviderError = false; + private _hasProviderError = false; @state() - protected _showStreamTroubleshooting = false; + private _showStreamTroubleshooting = false; - protected _refProvider: Ref = createRef(); + private _refProvider: Ref = createRef(); - protected _lazyLoadController: LazyLoadController = new LazyLoadController(this); + private _lazyLoadController: LazyLoadController = new LazyLoadController(this); // 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 // call mute() when the element first renders in // the background. These calls fail without waiting for loading here. - protected _importPromises: Promise[] = []; + private _importPromises: Promise[] = []; constructor() { super(); @@ -106,7 +106,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP * whilst loading. * @returns`true` if an image should be shown. */ - protected _shouldShowImageDuringLoading(): boolean { + private _shouldShowImageDuringLoading(): boolean { return ( !this._isVideoMediaLoaded && !!this.camera?.getConfig()?.camera_entity && @@ -123,12 +123,12 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP super.disconnectedCallback(); } - protected _videoMediaShowHandler(): void { + private _videoMediaShowHandler(): void { this._isVideoMediaLoaded = true; this._showStreamTroubleshooting = false; } - protected _providerErrorHandler(): void { + private _providerErrorHandler(): void { this._hasProviderError = true; } @@ -177,7 +177,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP return result; } - protected _renderContainer(template: TemplateResult): TemplateResult { + private _renderContainer(template: TemplateResult): TemplateResult { const config = this.camera?.getConfig(); const intermediateTemplate = html` this._player?.video ?? null, () => this.controls, @@ -81,7 +81,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer this.requestUpdate(); } - protected _handleError(message: Message, e?: Error): void { + private _handleError(message: Message, e?: Error): void { if (e) { errorToConsole(e as Error); } @@ -94,7 +94,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer return; } - protected async _getPlayerSource(): Promise { + private async _getPlayerSource(): Promise { const cameraConfig = this.camera?.getConfig(); const proxyConfig = this.camera?.getProxyConfig(); if (!this.hass || !cameraConfig) { @@ -155,7 +155,7 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer return result; } - protected async _createPlayer(): Promise { + private async _createPlayer(): Promise { const src = await this._getPlayerSource(); if (!src) { return; diff --git a/src/components/live/providers/ha.ts b/src/components/live/providers/ha.ts index 3ef62b13..5c3b1985 100644 --- a/src/components/live/providers/ha.ts +++ b/src/components/live/providers/ha.ts @@ -24,7 +24,7 @@ export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer @property({ attribute: true, type: Boolean }) public controls = false; - protected _playerRef: Ref = createRef(); + private _playerRef: Ref = createRef(); public async getMediaPlayerController(): Promise { await this.updateComplete; diff --git a/src/components/live/providers/image.ts b/src/components/live/providers/image.ts index 653f44eb..5433fb8b 100644 --- a/src/components/live/providers/image.ts +++ b/src/components/live/providers/image.ts @@ -19,7 +19,7 @@ export class AdvancedCameraCardLiveImage extends LitElement implements MediaPlay @property({ attribute: false }) public cameraConfig?: CameraConfig; - protected _refImage: Ref = createRef(); + private _refImage: Ref = createRef(); public async getMediaPlayerController(): Promise { await this.updateComplete; diff --git a/src/components/live/providers/jsmpeg.ts b/src/components/live/providers/jsmpeg.ts index c7a197b6..350f964e 100644 --- a/src/components/live/providers/jsmpeg.ts +++ b/src/components/live/providers/jsmpeg.ts @@ -39,7 +39,7 @@ const JSMPEG_URL_SIGN_REFRESH_THRESHOLD_SECONDS = 1 * 60 * 60; @customElement('advanced-camera-card-live-jsmpeg') export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPlayer { - protected hass?: HomeAssistant; + private hass?: HomeAssistant; @property({ attribute: false }) public cameraConfig?: CameraConfig; @@ -51,13 +51,13 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla public cardWideConfig?: CardWideConfig; @state() - protected _message: Message | null = null; + private _message: Message | null = null; - protected _jsmpegCanvasElement?: HTMLCanvasElement; - protected _jsmpegVideoPlayer?: JSMpeg.VideoElement; - protected _refreshPlayerTimer = new Timer(); + private _jsmpegCanvasElement?: HTMLCanvasElement; + private _jsmpegVideoPlayer?: JSMpeg.VideoElement; + private _refreshPlayerTimer = new Timer(); - protected _mediaPlayerController = new JSMPEGMediaPlayerController( + private _mediaPlayerController = new JSMPEGMediaPlayerController( this, () => this._jsmpegVideoPlayer ?? null, () => this._jsmpegCanvasElement ?? null, @@ -75,7 +75,7 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla } } - protected async _createJSMPEGPlayer(url: string): Promise { + private async _createJSMPEGPlayer(url: string): Promise { this._jsmpegVideoPlayer = await new Promise((resolve) => { let videoDecoded = false; 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._refreshPlayerTimer.stop(); if (this._jsmpegVideoPlayer) { @@ -164,7 +164,7 @@ export class AdvancedCameraCardLiveJSMPEG extends LitElement implements MediaPla super.disconnectedCallback(); } - protected async _refreshPlayer(): Promise { + private async _refreshPlayer(): Promise { if (!this.hass) { return; } diff --git a/src/components/live/providers/webrtc-card.ts b/src/components/live/providers/webrtc-card.ts index b666ea67..9db970ec 100644 --- a/src/components/live/providers/webrtc-card.ts +++ b/src/components/live/providers/webrtc-card.ts @@ -59,11 +59,11 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi public controls = false; @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._getVideo(), () => this.controls, @@ -74,7 +74,7 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi } // 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 { 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; } @@ -105,13 +105,11 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi * Get the underlying video player. * @returns The player or `null` if not found. */ - protected _getVideo(): HTMLVideoElement | null { + private _getVideo(): HTMLVideoElement | null { return this._getVideoRTC()?.video ?? null; } - protected async _getWebRTCCardElement(): Promise< - CustomElementConstructor | undefined - > { + private async _getWebRTCCardElement(): Promise { await customElements.whenDefined('webrtc-camera'); return customElements.get('webrtc-camera'); } @@ -119,7 +117,7 @@ export class AdvancedCameraCardLiveWebRTCCard extends LitElement implements Medi /** * Create the WebRTC element. May throw. */ - protected _createWebRTC(): HTMLElement | null { + private _createWebRTC(): HTMLElement | null { const webrtcElement = this._webrtcTask.value; if (webrtcElement && this.hass && this.cameraConfig) { const webrtc = new webrtcElement() as HTMLElement & { diff --git a/src/components/media-dimensions-container.ts b/src/components/media-dimensions-container.ts index 92bd7cad..f351aecd 100644 --- a/src/components/media-dimensions-container.ts +++ b/src/components/media-dimensions-container.ts @@ -17,10 +17,10 @@ export class AdvancedCameraCardMediaDimensionsContainer extends LitElement { @property({ attribute: false }) public dimensionsConfig?: CameraDimensionsConfig; - protected _controller = new MediaDimensionsContainerController(this); + private _controller = new MediaDimensionsContainerController(this); - protected _refInnerContainer: Ref = createRef(); - protected _refOuterContainer: Ref = createRef(); + private _refInnerContainer: Ref = createRef(); + private _refOuterContainer: Ref = createRef(); protected willUpdate(changedProps: PropertyValues): void { if (changedProps.has('dimensionsConfig')) { diff --git a/src/components/media-filter.ts b/src/components/media-filter.ts index a48d1a71..abe8061f 100644 --- a/src/components/media-filter.ts +++ b/src/components/media-filter.ts @@ -48,19 +48,19 @@ class AdvancedCameraCardMediaFilter extends ScopedRegistryHost(LitElement) { 'advanced-camera-card-date-picker': AdvancedCameraCardDatePicker, }; - protected _mediaFilterController = new MediaFilterController(this); + private _mediaFilterController = new MediaFilterController(this); - protected _refMediaType: Ref = createRef(); - protected _refCamera: Ref = createRef(); - protected _refWhen: Ref = createRef(); - protected _refWhenFrom: Ref = createRef(); - protected _refWhenTo: Ref = createRef(); - protected _refWhat: Ref = createRef(); - protected _refWhere: Ref = createRef(); - protected _refFavorite: Ref = createRef(); - protected _refReviewed: Ref = createRef(); - protected _refSeverity: Ref = createRef(); - protected _refTags: Ref = createRef(); + private _refMediaType: Ref = createRef(); + private _refCamera: Ref = createRef(); + private _refWhen: Ref = createRef(); + private _refWhenFrom: Ref = createRef(); + private _refWhenTo: Ref = createRef(); + private _refWhat: Ref = createRef(); + private _refWhere: Ref = createRef(); + private _refFavorite: Ref = createRef(); + private _refReviewed: Ref = createRef(); + private _refSeverity: Ref = createRef(); + private _refTags: Ref = createRef(); protected willUpdate(changedProps: PropertyValues): void { if (changedProps.has('viewManagerEpoch')) { diff --git a/src/components/media-grid.ts b/src/components/media-grid.ts index 8ccfdae7..31e80267 100644 --- a/src/components/media-grid.ts +++ b/src/components/media-grid.ts @@ -20,8 +20,8 @@ export class AdvancedCameraCardMediaGrid extends LitElement { @property({ attribute: false }) public displayConfig?: ViewDisplayConfig; - protected _controller: MediaGridController | null = null; - protected _refSlot: Ref = createRef(); + private _controller: MediaGridController | null = null; + private _refSlot: Ref = createRef(); connectedCallback(): void { super.connectedCallback(); diff --git a/src/components/menu.ts b/src/components/menu.ts index ebf354e3..041d1bf4 100644 --- a/src/components/menu.ts +++ b/src/components/menu.ts @@ -16,7 +16,7 @@ import './submenu/submenu-button'; @customElement('advanced-camera-card-menu') export class AdvancedCameraCardMenu extends LitElement { - protected _controller = new MenuController(this); + private _controller = new MenuController(this); @property({ attribute: false }) public entityRegistryManager?: EntityRegistryManager; @@ -40,7 +40,7 @@ export class AdvancedCameraCardMenu extends LitElement { this._controller.toggleExpanded(); } - protected _renderButton(button: MenuItem): TemplateResult | void { + private _renderButton(button: MenuItem): TemplateResult | void { if (!this.hass) { return; } @@ -100,7 +100,7 @@ export class AdvancedCameraCardMenu extends LitElement { * specificity, so the most specific theme variable will match, followed by * the next most specific, etc. */ - protected _renderPerInstanceStyle(): TemplateResult | void { + private _renderPerInstanceStyle(): TemplateResult | void { const config = this._controller.getMenuConfig(); if (!config) { return; diff --git a/src/components/next-prev-control.ts b/src/components/next-prev-control.ts index 62d0f9f9..dd9fa52c 100644 --- a/src/components/next-prev-control.ts +++ b/src/components/next-prev-control.ts @@ -27,7 +27,7 @@ export class AdvancedCameraCardNextPreviousControl extends LitElement { public hass?: HomeAssistant; @state() - protected _controlConfig?: NextPreviousControlConfig; + private _controlConfig?: NextPreviousControlConfig; @property({ attribute: false }) public thumbnail?: string; @@ -41,7 +41,7 @@ export class AdvancedCameraCardNextPreviousControl extends LitElement { // Label that is used for ARIA support and as tooltip. @property() label = ''; - protected _embedThumbnailTask = createFetchThumbnailTask( + private _embedThumbnailTask = createFetchThumbnailTask( this, () => this.hass, () => this.thumbnail, diff --git a/src/components/overlay-message.ts b/src/components/overlay-message.ts index 50db9ac1..c2563325 100644 --- a/src/components/overlay-message.ts +++ b/src/components/overlay-message.ts @@ -12,7 +12,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement { @property({ attribute: false }) public message: OverlayMessage | null = null; - protected _refMessage: Ref = createRef(); + private _refMessage: Ref = createRef(); public connectedCallback(): void { 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}` : ''; return html`
{ + private async _handleControlClick(control: OverlayMessageControl): Promise { const result = await control.callback(); if (result === null) { // 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 = { detail: true, heading: isHeading, @@ -111,23 +111,23 @@ export class AdvancedCameraCardOverlayMessage extends LitElement { `; } - protected _dismiss = (): void => { + private _dismiss = (): void => { this._refMessage.value?.classList.add('exiting'); }; - protected _handleAnimationEnd = (ev: AnimationEvent): void => { + private _handleAnimationEnd = (ev: AnimationEvent): void => { if (ev.animationName === 'slideDown') { dispatchDismissOverlayMessageEvent(this); } }; - protected _handleOutsideInteraction = (ev: Event): void => { + private _handleOutsideInteraction = (ev: Event): void => { if (!ev.composedPath().includes(this)) { this._dismiss(); } }; - protected _handleKeyDown = (ev: KeyboardEvent): void => { + private _handleKeyDown = (ev: KeyboardEvent): void => { if (ev.key === 'Escape') { this._dismiss(); ev.stopPropagation(); diff --git a/src/components/ptz.ts b/src/components/ptz.ts index 2fd93d69..873e1315 100644 --- a/src/components/ptz.ts +++ b/src/components/ptz.ts @@ -40,8 +40,8 @@ export class AdvancedCameraCardPTZ extends LitElement { @property({ attribute: false }) public forceVisibility?: boolean; - protected _controller = new PTZController(this); - protected _actions: PTZControllerActions | null = null; + private _controller = new PTZController(this); + private _actions: PTZControllerActions | null = null; protected willUpdate(changedProps: PropertyValues): void { if (changedProps.has('config')) { diff --git a/src/components/select.ts b/src/components/select.ts index 850200e9..57d44a96 100644 --- a/src/components/select.ts +++ b/src/components/select.ts @@ -49,8 +49,8 @@ export class AdvancedCameraCardSelect extends ScopedRegistryHost(LitElement) { @property({ attribute: true, type: Boolean }) public clearable?: boolean = false; - protected _previouslyReportedValue?: SelectValues; - protected _refSelect: Ref = createRef(); + private _previouslyReportedValue?: SelectValues; + private _refSelect: Ref = createRef(); static elementDefinitions = { ...grSelectElements, @@ -61,7 +61,7 @@ export class AdvancedCameraCardSelect extends ScopedRegistryHost(LitElement) { } // 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; // The underlying gr-select element is very sensitive and occasionally fires // the change event even if the value has not actually changed. Prevent that diff --git a/src/components/status-bar.ts b/src/components/status-bar.ts index 65bf22f0..edab5077 100644 --- a/src/components/status-bar.ts +++ b/src/components/status-bar.ts @@ -18,7 +18,7 @@ import './icon.js'; @customElement('advanced-camera-card-status-bar') export class AdvancedCameraCardStatusBar extends LitElement { - protected _controller = new StatusBarController(this); + private _controller = new StatusBarController(this); @property({ attribute: false }) public items?: StatusBarItem[]; @@ -44,7 +44,7 @@ export class AdvancedCameraCardStatusBar extends LitElement { * specificity, so the most specific theme variable will match, followed by * the next most specific, etc. */ - protected _renderPerInstanceStyle(): TemplateResult | void { + private _renderPerInstanceStyle(): TemplateResult | void { const config = this._controller.getConfig(); if (!config) { return; diff --git a/src/components/submenu/index.ts b/src/components/submenu/index.ts index d567b3c3..07692f1f 100644 --- a/src/components/submenu/index.ts +++ b/src/components/submenu/index.ts @@ -20,7 +20,7 @@ export class AdvancedCameraCardSubmenu extends LitElement { @property({ attribute: false }) public items?: SubmenuItem[]; - protected _renderItem(item: SubmenuItem): TemplateResult | void { + private _renderItem(item: SubmenuItem): TemplateResult | void { if (!this.hass) { return; } diff --git a/src/components/submenu/select-button.ts b/src/components/submenu/select-button.ts index b07ef5dc..c6417dfb 100644 --- a/src/components/submenu/select-button.ts +++ b/src/components/submenu/select-button.ts @@ -34,10 +34,10 @@ export class AdvancedCameraCardSubmenuSelectButton extends LitElement { public entityRegistryManager?: EntityRegistryManager; @state() - protected _optionTitles?: Record; + private _optionTitles?: Record; - protected _generatedSubmenuItems?: MenuSubmenuItem[]; - protected _generatedIcon?: Icon; + private _generatedSubmenuItems?: MenuSubmenuItem[]; + private _generatedIcon?: Icon; protected shouldUpdate(changedProps: PropertyValues): boolean { // 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 { + private async _refreshOptionTitles(): Promise { if (!this.hass || !this.submenuSelect) { return; } diff --git a/src/components/surround-basic.ts b/src/components/surround-basic.ts index 41b5a87f..b0e10e7d 100644 --- a/src/components/surround-basic.ts +++ b/src/components/surround-basic.ts @@ -19,9 +19,9 @@ export class AdvancedCameraCardSurroundBasic extends LitElement { right?: DrawerIcons; }; - protected _refDrawerLeft: Ref = createRef(); - protected _refDrawerRight: Ref = createRef(); - protected _boundDrawerHandler = this._drawerHandler.bind(this); + private _refDrawerLeft: Ref = createRef(); + private _refDrawerRight: Ref = createRef(); + private _boundDrawerHandler = this._drawerHandler.bind(this); connectedCallback(): void { super.connectedCallback(); @@ -41,7 +41,7 @@ export class AdvancedCameraCardSurroundBasic extends LitElement { super.disconnectedCallback(); } - protected _drawerHandler(ev: Event) { + private _drawerHandler(ev: Event) { const drawer = (ev as CustomEvent).detail.drawer; const open = ev.type.endsWith(':open'); if (drawer === 'left' && this._refDrawerLeft.value) { diff --git a/src/components/surround.ts b/src/components/surround.ts index 60534adf..cb90f9d1 100644 --- a/src/components/surround.ts +++ b/src/components/surround.ts @@ -54,7 +54,7 @@ export class AdvancedCameraCardSurround extends LitElement { /** * Determine if a drawer is being used. */ - protected _hasDrawer(): boolean { + private _hasDrawer(): boolean { return ( !!this.thumbnailConfig && ['left', 'right'].includes(this.thumbnailConfig.mode) ); diff --git a/src/components/thumbnail-carousel.ts b/src/components/thumbnail-carousel.ts index e2435abc..215b4b20 100644 --- a/src/components/thumbnail-carousel.ts +++ b/src/components/thumbnail-carousel.ts @@ -65,17 +65,17 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement { @property({ attribute: false }) public fadeThumbnails = false; - protected _thumbnails: TemplateResult[] = []; - protected _builder: UnifiedQueryBuilder | null = null; + private _thumbnails: TemplateResult[] = []; + private _builder: UnifiedQueryBuilder | null = null; - protected _getLimit(): number { + private _getLimit(): number { return ( this.cardWideConfig?.performance?.features?.media_chunk_size ?? MEDIA_CHUNK_SIZE_DEFAULT ); } - protected _getFolderNavOptions(): FolderNavigationParamaters | undefined { + private _getFolderNavOptions(): FolderNavigationParamaters | undefined { return this._builder && this.viewManagerEpoch ? { builder: this._builder, @@ -127,13 +127,13 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement { } } - protected _getSelectedSlide(): number | null { + private _getSelectedSlide(): number | null { return ( this.viewManagerEpoch?.manager.getView()?.queryResults?.getSelectedIndex() ?? null ); } - protected _handleMediaClick(item: ViewMedia): void { + private _handleMediaClick(item: ViewMedia): void { fireAdvancedCameraCardEvent( this, 'thumbnails-carousel:media-select', @@ -147,7 +147,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement { } } - protected _renderThumbnail( + private _renderThumbnail( item: ViewItem, selected: boolean, clickCallback: (item: ViewItem, ev: Event) => void, @@ -183,7 +183,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement { `; } - protected _renderThumbnails(): TemplateResult[] { + private _renderThumbnails(): TemplateResult[] { const upFolderItem = getUpFolderItem( this.viewManagerEpoch?.manager.getView()?.query, ); @@ -221,7 +221,7 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement { return thumbnails; } - protected _getDirection(): CarouselDirection | null { + private _getDirection(): CarouselDirection | null { if (this.config?.mode === 'left' || this.config?.mode === 'right') { return 'vertical'; } else if (this.config?.mode === 'above' || this.config?.mode === 'below') { diff --git a/src/components/thumbnail/feature/thumbnail.ts b/src/components/thumbnail/feature/thumbnail.ts index f0d07e43..415b4d6d 100644 --- a/src/components/thumbnail/feature/thumbnail.ts +++ b/src/components/thumbnail/feature/thumbnail.ts @@ -25,10 +25,10 @@ export class AdvancedCameraCardThumbnailFeatureThumbnail extends LitElement { @property({ attribute: false }) public hass?: HomeAssistant; - protected _embedThumbnailTask?: Task; + private _embedThumbnailTask?: Task; // 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), ); @@ -57,7 +57,7 @@ export class AdvancedCameraCardThumbnailFeatureThumbnail extends LitElement { } } - protected _intersectionHandler(entries: IntersectionObserverEntry[]): void { + private _intersectionHandler(entries: IntersectionObserverEntry[]): void { if ( this._embedThumbnailTask?.status === TaskStatus.INITIAL && entries.some((entry) => entry.isIntersecting) diff --git a/src/components/timeline-core.ts b/src/components/timeline-core.ts index ef56010a..859cb350 100644 --- a/src/components/timeline-core.ts +++ b/src/components/timeline-core.ts @@ -137,9 +137,9 @@ export class AdvancedCameraCardTimelineCore extends LitElement { @property({ attribute: false }) public itemClickAction?: TimelineItemClickAction; - protected _refDatePicker: Ref = createRef(); - protected _refTimeline: Ref = createRef(); - protected _controller: TimelineController = new TimelineController(this); + private _refDatePicker: Ref = createRef(); + private _refTimeline: Ref = createRef(); + private _controller: TimelineController = new TimelineController(this); protected render(): TemplateResult | void { if (!this.hass || !this.timelineConfig) { diff --git a/src/components/video-player.ts b/src/components/video-player.ts index 543caf78..17967572 100644 --- a/src/components/video-player.ts +++ b/src/components/video-player.ts @@ -25,8 +25,8 @@ export class AdvancedCameraCardVideoPlayer extends LitElement implements MediaPl @property({ type: Boolean }) public controls = false; - protected _refVideo: Ref> = createRef(); - protected _mediaPlayerController = new VideoMediaPlayerController( + private _refVideo: Ref> = createRef(); + private _mediaPlayerController = new VideoMediaPlayerController( this, () => this._refVideo.value ?? null, () => this.controls, diff --git a/src/components/viewer/carousel.ts b/src/components/viewer/carousel.ts index 1e8cfa3a..886b1ca9 100644 --- a/src/components/viewer/carousel.ts +++ b/src/components/viewer/carousel.ts @@ -81,13 +81,13 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { public showControls = true; @state() - protected _selected: number | null = null; + private _selected: number | null = null; - protected _media: ViewMedia[] | null = null; - protected _mediaActionsController = new MediaActionsController(); - protected _mediaHeightController = new MediaHeightController(this, '.embla__slide'); - protected _loadedMediaPlayerController: MediaPlayerController | null = null; - protected _refCarousel: Ref = createRef(); + private _media: ViewMedia[] | null = null; + private _mediaActionsController = new MediaActionsController(); + private _mediaHeightController = new MediaHeightController(this, '.embla__slide'); + private _loadedMediaPlayerController: MediaPlayerController | null = null; + private _refCarousel: Ref = createRef(); public connectedCallback(): void { super.connectedCallback(); @@ -108,7 +108,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { * Get the transition effect to use. * @returns An TransitionEffect object. */ - protected _getTransitionEffect(): TransitionEffect { + private _getTransitionEffect(): TransitionEffect { return ( this.viewerConfig?.transition_effect ?? configDefaults.media_viewer.transition_effect @@ -119,7 +119,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { * Get the Embla plugins to use. * @returns A list of EmblaOptionsTypes. */ - protected _getPlugins(): EmblaCarouselPlugins { + private _getPlugins(): EmblaCarouselPlugins { return [AutoMediaLoadedInfo()]; } @@ -128,7 +128,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { * @returns A BrowseMediaNeighbors with indices and objects of true media * neighbors. */ - protected _getMediaNeighbors(): MediaNeighbors | null { + private _getMediaNeighbors(): MediaNeighbors | null { const mediaCount = this._media?.length ?? 0; if (!this._media || this._selected === null) { return null; @@ -152,7 +152,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { }; } - protected _setViewSelectedIndex(index: number): void { + private _setViewSelectedIndex(index: number): void { const view = this.viewManagerEpoch?.manager.getView(); if (!this._media || !view) { @@ -194,7 +194,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { * Get slides to include in the render. * @returns The slides to include in the render. */ - protected _getSlides(): TemplateResult[] { + private _getSlides(): TemplateResult[] { if (!this._media) { return []; } @@ -273,7 +273,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { } } - protected _renderNextPrevious( + private _renderNextPrevious( side: 'left' | 'right', neighbors?: MediaNeighbors | null, ): TemplateResult { @@ -402,7 +402,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { } } - protected _setMediaTarget(): void { + private _setMediaTarget(): void { if (!this._media?.length || this._selected === null) { this._mediaActionsController.unsetTarget(); } else { @@ -421,7 +421,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { /** * Fire a media show event when a slide is selected. */ - protected async _seekHandler(): Promise { + private async _seekHandler(): Promise { if ( !this.hass || !this._media || @@ -458,7 +458,7 @@ export class AdvancedCameraCardViewerCarousel extends LitElement { } } - protected _renderMediaItem(media: ViewMedia): TemplateResult | null { + private _renderMediaItem(media: ViewMedia): TemplateResult | null { const view = this.viewManagerEpoch?.manager.getView(); if (!this.hass || !view || !this.viewerConfig) { return null; diff --git a/src/components/viewer/grid.ts b/src/components/viewer/grid.ts index df0d9978..16704b39 100644 --- a/src/components/viewer/grid.ts +++ b/src/components/viewer/grid.ts @@ -43,7 +43,7 @@ export class AdvancedCameraCardViewerGrid extends LitElement { @property({ attribute: false }) public viewItemManager?: ViewItemManager; - protected _renderCarousel(filterCamera?: string): TemplateResult { + private _renderCarousel(filterCamera?: string): TemplateResult { const selectedCameraID = this.viewManagerEpoch?.manager.getView()?.camera; // Get the camera's grid width factor from its dimensions config. @@ -76,7 +76,7 @@ export class AdvancedCameraCardViewerGrid extends LitElement { } } - protected _needsGrid(): boolean { + private _needsGrid(): boolean { const view = this.viewManagerEpoch?.manager.getView(); const cameraIDs = view?.queryResults?.getCameraIDs(); return ( @@ -86,7 +86,7 @@ export class AdvancedCameraCardViewerGrid extends LitElement { ); } - protected _gridSelectCamera(cameraID: string): void { + private _gridSelectCamera(cameraID: string): void { const view = this.viewManagerEpoch?.manager.getView(); this.viewManagerEpoch?.manager.setViewByParameters({ params: { diff --git a/src/components/viewer/provider.ts b/src/components/viewer/provider.ts index 40249d53..52559c4c 100644 --- a/src/components/viewer/provider.ts +++ b/src/components/viewer/provider.ts @@ -59,12 +59,12 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi @property({ attribute: false }) public cardWideConfig?: CardWideConfig; - protected _refProvider: Ref = createRef(); - protected _refContainer: Ref = createRef(); - protected _lazyLoadController: LazyLoadController = new LazyLoadController(this); + private _refProvider: Ref = createRef(); + private _refContainer: Ref = createRef(); + private _lazyLoadController: LazyLoadController = new LazyLoadController(this); @state() - protected _url: string | null = null; + private _url: string | null = null; constructor() { super(); @@ -76,7 +76,7 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi return (await this._refProvider.value?.getMediaPlayerController()) ?? null; } - protected async _switchToRelatedClipView(): Promise { + private async _switchToRelatedClipView(): Promise { const view = this.viewManagerEpoch?.manager.getView(); if ( !this.hass || @@ -108,7 +108,7 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi }); } - protected async _setURL(): Promise { + private async _setURL(): Promise { const mediaContentID = this.media?.getContentID(); if ( !this.media || @@ -202,7 +202,7 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi : null; } - protected _renderContainer(template: TemplateResult): TemplateResult { + private _renderContainer(template: TemplateResult): TemplateResult { if (!this.media) { return template; } diff --git a/src/components/views.ts b/src/components/views.ts index fa26a6eb..ddefe7a9 100644 --- a/src/components/views.ts +++ b/src/components/views.ts @@ -96,7 +96,7 @@ export class AdvancedCameraCardViews extends LitElement { } } - protected _shouldLivePreload(): boolean { + private _shouldLivePreload(): boolean { const view = this.viewManagerEpoch?.manager.getView(); return ( // Special case: Never preload for diagnostics -- we want that to be as diff --git a/src/components/zoomer.ts b/src/components/zoomer.ts index 1c7f5190..9ba06131 100644 --- a/src/components/zoomer.ts +++ b/src/components/zoomer.ts @@ -13,7 +13,7 @@ import { PartialZoomSettings } from '../components-lib/zoom/types.js'; @customElement('advanced-camera-card-zoomer') export class AdvancedCameraCardZoomer extends LitElement { - protected _zoom: ZoomController | null = null; + private _zoom: ZoomController | null = null; @property({ attribute: false }) public defaultSettings?: PartialZoomSettings; @@ -22,10 +22,10 @@ export class AdvancedCameraCardZoomer extends LitElement { public settings?: PartialZoomSettings | null; @state() - protected _zoomed = false; + private _zoomed = false; - protected _zoomHandler = () => (this._zoomed = true); - protected _unzoomHandler = () => (this._zoomed = false); + private _zoomHandler = () => (this._zoomed = true); + private _unzoomHandler = () => (this._zoomed = false); connectedCallback(): void { super.connectedCallback(); diff --git a/src/conditions/conditions-manager.ts b/src/conditions/conditions-manager.ts index 6ca004b8..85d94d23 100644 --- a/src/conditions/conditions-manager.ts +++ b/src/conditions/conditions-manager.ts @@ -18,13 +18,13 @@ import { * associated with a result). */ export class ConditionsManager implements ConditionsManagerReadonlyInterface { - protected _conditions: AdvancedCameraCardCondition[]; - protected _stateManager: ConditionStateManagerReadonlyInterface | null; + private _conditions: AdvancedCameraCardCondition[]; + private _stateManager: ConditionStateManagerReadonlyInterface | null; - protected _listeners: ConditionsListener[] = []; - protected _mediaQueries: MediaQueryList[] = []; - protected _evaluation: ConditionsEvaluationResult = { result: false }; - protected _templateRenderer: TemplateRenderer = new TemplateRenderer(); + private _listeners: ConditionsListener[] = []; + private _mediaQueries: MediaQueryList[] = []; + private _evaluation: ConditionsEvaluationResult = { result: false }; + private _templateRenderer: TemplateRenderer = new TemplateRenderer(); constructor( conditions: AdvancedCameraCardCondition[], @@ -73,13 +73,13 @@ export class ConditionsManager implements ConditionsManagerReadonlyInterface { return this._evaluation; } - protected _mediaQueryHandler = () => this._evaluate(); + private _mediaQueryHandler = () => this._evaluate(); - protected _stateManagerHandler = (stateChange: ConditionStateChange): void => { + private _stateManagerHandler = (stateChange: ConditionStateChange): void => { this._evaluate({ stateChange }); }; - protected _evaluate(options?: { + private _evaluate(options?: { stateChange?: ConditionStateChange; callListeners?: boolean; }): void { @@ -121,7 +121,7 @@ export class ConditionsManager implements ConditionsManagerReadonlyInterface { } } - protected _evaluateCondition( + private _evaluateCondition( condition: AdvancedCameraCardCondition, newState?: ConditionState, oldState?: ConditionState, diff --git a/src/conditions/state-manager.ts b/src/conditions/state-manager.ts index e0146125..61c69c6f 100644 --- a/src/conditions/state-manager.ts +++ b/src/conditions/state-manager.ts @@ -10,8 +10,8 @@ import { * A class to manage state used in the evaluation of conditions. */ export class ConditionStateManager implements ConditionStateManagerReadonlyInterface { - protected _listeners: ConditionStateListener[] = []; - protected _state: ConditionState = {}; + private _listeners: ConditionStateListener[] = []; + private _state: ConditionState = {}; public addListener(listener: ConditionStateListener): void { this._listeners.push(listener); @@ -29,7 +29,7 @@ export class ConditionStateManager implements ConditionStateManagerReadonlyInter this._processStateChange(this._calculateTrueChange(state)); } - protected _processStateChange(changeState: ConditionState): void { + private _processStateChange(changeState: ConditionState): void { if (!Object.keys(changeState).length) { return; } @@ -42,7 +42,7 @@ export class ConditionStateManager implements ConditionStateManagerReadonlyInter this._callListeners({ old: oldState, change: changeState, new: this._state }); } - protected _calculateTrueChange(change: ConditionState): ConditionState { + private _calculateTrueChange(change: ConditionState): ConditionState { const changeState: ConditionState = {}; for (const key of Object.keys(change)) { @@ -54,7 +54,7 @@ export class ConditionStateManager implements ConditionStateManagerReadonlyInter return changeState; } - protected _callListeners = (stateChange: ConditionStateChange): void => { + private _callListeners = (stateChange: ConditionStateChange): void => { this._listeners.forEach((listener) => listener(stateChange)); }; } diff --git a/src/editor.ts b/src/editor.ts index e71a4618..92236766 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -419,16 +419,16 @@ const options: EditorOptions = { @customElement('advanced-camera-card-editor') export class AdvancedCameraCardEditor extends LitElement implements LovelaceCardEditor { @property({ attribute: false }) public hass?: HomeAssistant; - @state() protected _config?: RawAdvancedCameraCardConfig; - @state() protected _defaults = copyConfig(configDefaults); + @state() private _config?: RawAdvancedCameraCardConfig; + @state() private _defaults = copyConfig(configDefaults); - protected _initialized = false; - protected _configUpgradeable = false; + private _initialized = false; + private _configUpgradeable = false; @state() - protected _expandedMenus: Record = {}; + private _expandedMenus: Record = {}; - protected _viewModes: EditorSelectOption[] = [ + private _viewModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', label: localize('config.view.views.auto') }, { value: 'clip', label: localize('config.view.views.clip') }, @@ -448,12 +448,12 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'timeline', label: localize('config.view.views.timeline') }, ]; - protected _cameraSelectViewModes: EditorSelectOption[] = [ + private _cameraSelectViewModes: EditorSelectOption[] = [ ...this._viewModes, { value: 'current', label: localize('config.view.views.current') }, ]; - protected _filterModes: EditorSelectOption[] = [ + private _filterModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'none', @@ -469,7 +469,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _menuStyles: EditorSelectOption[] = [ + private _menuStyles: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'none', label: localize('config.menu.styles.none') }, { value: 'hidden', label: localize('config.menu.styles.hidden') }, @@ -479,7 +479,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'outside', label: localize('config.menu.styles.outside') }, ]; - protected _menuPositions: EditorSelectOption[] = [ + private _menuPositions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'left', label: localize('config.menu.positions.left') }, { value: 'right', label: localize('config.menu.positions.right') }, @@ -487,7 +487,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'bottom', label: localize('config.menu.positions.bottom') }, ]; - protected _menuAlignments: EditorSelectOption[] = [ + private _menuAlignments: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'left', label: localize('config.menu.alignments.left') }, { value: 'right', label: localize('config.menu.alignments.right') }, @@ -495,7 +495,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'bottom', label: localize('config.menu.alignments.bottom') }, ]; - protected _nextPreviousControlStyles: EditorSelectOption[] = [ + private _nextPreviousControlStyles: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'chevrons', @@ -515,7 +515,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _aspectRatioModes: EditorSelectOption[] = [ + private _aspectRatioModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'dynamic', @@ -528,7 +528,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _thumbnailModes: EditorSelectOption[] = [ + private _thumbnailModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'none', @@ -552,7 +552,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _thumbnailMediaTypes: EditorSelectOption[] = [ + private _thumbnailMediaTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', @@ -572,7 +572,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _timelineThumbnailMediaTypes: EditorSelectOption[] = [ + private _timelineThumbnailMediaTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', @@ -588,7 +588,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _thumbnailEventsMediaTypes: EditorSelectOption[] = [ + private _thumbnailEventsMediaTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'all', @@ -604,7 +604,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _cameraMediaReviewedOptions: EditorSelectOption[] = [ + private _cameraMediaReviewedOptions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'unreviewed', @@ -620,13 +620,13 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _transitionEffects: EditorSelectOption[] = [ + private _transitionEffects: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'none', label: localize('config.media_viewer.transition_effects.none') }, { value: 'slide', label: localize('config.media_viewer.transition_effects.slide') }, ]; - protected _imageModes: EditorSelectOption[] = [ + private _imageModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'camera', label: localize('config.common.image.modes.camera') }, { value: 'entity', label: localize('config.common.image.modes.entity') }, @@ -634,7 +634,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'url', label: localize('config.common.image.modes.url') }, ]; - protected _timelineEventsMediaTypes: EditorSelectOption[] = [ + private _timelineEventsMediaTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'all', label: localize('config.common.events_media_types.all') }, { @@ -647,13 +647,13 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _timelineStyleTypes: EditorSelectOption[] = [ + private _timelineStyleTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'ribbon', label: localize('config.common.timeline.styles.ribbon') }, { value: 'stack', label: localize('config.common.timeline.styles.stack') }, ]; - protected _mediaActionNegativeConditions: EditorSelectOption[] = [ + private _mediaActionNegativeConditions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'unselected', @@ -662,7 +662,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'hidden', label: localize('config.common.media_action_conditions.hidden') }, ]; - protected _mediaActionPositiveConditions: EditorSelectOption[] = [ + private _mediaActionPositiveConditions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'selected', @@ -674,7 +674,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _mediaLiveUnmuteConditions: EditorSelectOption[] = [ + private _mediaLiveUnmuteConditions: EditorSelectOption[] = [ ...this._mediaActionPositiveConditions, { value: 'microphone', @@ -682,7 +682,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _mediaLiveMuteConditions: EditorSelectOption[] = [ + private _mediaLiveMuteConditions: EditorSelectOption[] = [ ...this._mediaActionNegativeConditions, { value: 'microphone', @@ -690,7 +690,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _layoutFits: EditorSelectOption[] = [ + private _layoutFits: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'contain', @@ -700,21 +700,21 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'fill', label: localize('config.cameras.dimensions.layout.fits.fill') }, ]; - protected _miniTimelineModes: EditorSelectOption[] = [ + private _miniTimelineModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'none', label: localize('config.common.controls.timeline.modes.none') }, { value: 'above', label: localize('config.common.controls.timeline.modes.above') }, { value: 'below', label: localize('config.common.controls.timeline.modes.below') }, ]; - protected _profiles: EditorSelectOption[] = [ + private _profiles: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'casting', label: localize('config.profiles.casting') }, { value: 'low-performance', label: localize('config.profiles.low-performance') }, { value: 'scrubbing', label: localize('config.profiles.scrubbing') }, ]; - protected _go2rtcModes: EditorSelectOption[] = [ + private _go2rtcModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'mse', label: localize('config.cameras.go2rtc.modes.mse') }, { value: 'webrtc', label: localize('config.cameras.go2rtc.modes.webrtc') }, @@ -722,19 +722,19 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'mjpeg', label: localize('config.cameras.go2rtc.modes.mjpeg') }, ]; - protected _microphoneButtonTypes: EditorSelectOption[] = [ + private _microphoneButtonTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'momentary', label: localize('config.menu.buttons.types.momentary') }, { value: 'toggle', label: localize('config.menu.buttons.types.toggle') }, ]; - protected _displayModes: EditorSelectOption[] = [ + private _displayModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'single', label: localize('display_modes.single') }, { value: 'grid', label: localize('display_modes.grid') }, ]; - protected _gridSelectPositions: EditorSelectOption[] = [ + private _gridSelectPositions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'default', @@ -750,13 +750,13 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _castMethods: EditorSelectOption[] = [ + private _castMethods: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'standard', label: localize('config.cameras.cast.methods.standard') }, { value: 'dashboard', label: localize('config.cameras.cast.methods.dashboard') }, ]; - protected _cameraMediaTypes: EditorSelectOption[] = [ + private _cameraMediaTypes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', label: localize('config.common.media_types.auto') }, { value: 'events', label: localize('config.common.media_types.events') }, @@ -765,13 +765,13 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'folder', label: localize('config.common.media_types.folder') }, ]; - protected _ptzModes: EditorSelectOption[] = [ + private _ptzModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'on', label: localize('config.live.controls.ptz.modes.on') }, { value: 'off', label: localize('config.live.controls.ptz.modes.off') }, ]; - protected _ptzOrientations: EditorSelectOption[] = [ + private _ptzOrientations: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'vertical', @@ -783,7 +783,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _ptzPositions: EditorSelectOption[] = [ + private _ptzPositions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'top-left', @@ -803,7 +803,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _triggersActionsInteractionModes: EditorSelectOption[] = [ + private _triggersActionsInteractionModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'all', @@ -819,7 +819,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _triggersActionsTrigger: EditorSelectOption[] = [ + private _triggersActionsTrigger: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'default', @@ -839,7 +839,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _triggersActionsUntrigger: EditorSelectOption[] = [ + private _triggersActionsUntrigger: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'default', @@ -851,7 +851,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _triggersEvents: EditorSelectOption[] = [ + private _triggersEvents: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'events', @@ -867,7 +867,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _severities: EditorSelectOption[] = [ + private _severities: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'high', @@ -883,7 +883,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _timelinePanModes: EditorSelectOption[] = [ + private _timelinePanModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'pan', @@ -903,7 +903,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _capabilities: EditorSelectOption[] = [ + private _capabilities: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'live', @@ -947,7 +947,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _forceableCapabilities: EditorSelectOption[] = [ + private _forceableCapabilities: EditorSelectOption[] = [ { value: '', label: '' }, { value: '2-way-audio', @@ -955,7 +955,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _defaultResetInteractionModes: EditorSelectOption[] = [ + private _defaultResetInteractionModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'all', @@ -971,7 +971,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _proxyModes: EditorSelectOption[] = [ + private _proxyModes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', @@ -987,7 +987,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _proxySSLCiphers: EditorSelectOption[] = [ + private _proxySSLCiphers: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', @@ -1011,7 +1011,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _proxySSLVerification: EditorSelectOption[] = [ + private _proxySSLVerification: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'auto', @@ -1027,7 +1027,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _reolinkMediaResolution: EditorSelectOption[] = [ + private _reolinkMediaResolution: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'high', @@ -1039,7 +1039,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard }, ]; - protected _statusBarStyles: EditorSelectOption[] = [ + private _statusBarStyles: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'hover', label: localize('config.status_bar.styles.hover') }, { value: 'hover-card', label: localize('config.status_bar.styles.hover-card') }, @@ -1049,13 +1049,13 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'popup', label: localize('config.status_bar.styles.popup') }, ]; - protected _statusBarPositions: EditorSelectOption[] = [ + private _statusBarPositions: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'top', label: localize('config.status_bar.positions.top') }, { value: 'bottom', label: localize('config.status_bar.positions.bottom') }, ]; - protected _themes: EditorSelectOption[] = [ + private _themes: EditorSelectOption[] = [ { value: '', label: '' }, { value: 'ha', label: localize('config.view.theme.themes.ha') }, { value: 'dark', label: localize('config.view.theme.themes.dark') }, @@ -1063,7 +1063,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard { value: 'traditional', label: localize('config.view.theme.themes.traditional') }, ]; - protected _rotations: EditorSelectOption[] = [ + private _rotations: EditorSelectOption[] = [ { value: '', label: '' }, { value: 0, label: localize('config.cameras.dimensions.rotations.0') }, { value: 90, label: localize('config.cameras.dimensions.rotations.90') }, @@ -1105,7 +1105,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param optionSetName The name of the EditorOptionsSet. * @returns A rendered template. */ - protected _renderOptionSetHeader( + private _renderOptionSetHeader( optionSetName: string, titleClass?: string, ): TemplateResult { @@ -1134,7 +1134,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPath The config path. * @returns A localized label. */ - protected _getLabel(configPath: string): string { + private _getLabel(configPath: string): string { // Strip out array indices from the path. const path = configPath .split('.') @@ -1149,7 +1149,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param domain Only entities from this domain will be shown. * @returns A rendered template. */ - protected _renderEntitySelector( + private _renderEntitySelector( configPath: string, domain: string, ): TemplateResult | void { @@ -1177,7 +1177,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param params Option parameters to control the selector. * @returns A rendered template. */ - protected _renderOptionSelector( + private _renderOptionSelector( configPath: string, options: string[] | { value: unknown; label: string }[] = [], params?: { @@ -1215,7 +1215,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param params Optional parameters to control the selector. * @returns A rendered template. */ - protected _renderIconSelector( + private _renderIconSelector( configPath: string, params?: { label?: string; @@ -1246,7 +1246,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param params Optional parameters to control the selector. * @returns A rendered template. */ - protected _renderNumberInput( + private _renderNumberInput( configPath: string, params?: { min?: number; @@ -1287,7 +1287,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param info The string to display. * @returns A rendered template. */ - protected _renderInfo(info: string): TemplateResult { + private _renderInfo(info: string): TemplateResult { return html` ${info}`; } @@ -1297,7 +1297,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param cameraConfig The raw camera configuration object. * @returns A string title. */ - protected _getEditorCameraTitle( + private _getEditorCameraTitle( cameraIndex: number, cameraConfig: RawAdvancedCameraCardConfig, ): string { @@ -1334,7 +1334,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param cameraConfig The raw camera configuration object. * @returns A string title. */ - protected _getEditorFolderTitle( + private _getEditorFolderTitle( folderIndex: number, folderConfig: RawAdvancedCameraCardConfig, ): string { @@ -1349,7 +1349,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard ); } - protected _renderViewDefaultResetMenu(): TemplateResult { + private _renderViewDefaultResetMenu(): TemplateResult { return this._putInSubmenu( MENU_VIEW_DEFAULT_RESET, true, @@ -1379,7 +1379,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard ); } - protected _renderViewTriggersMenu(): TemplateResult { + private _renderViewTriggersMenu(): TemplateResult { return this._putInSubmenu( MENU_VIEW_TRIGGERS, true, @@ -1437,7 +1437,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard ); } - protected _renderKeyAssigner( + private _renderKeyAssigner( configPath: string, defaultValue: KeyboardShortcut, ): TemplateResult { @@ -1450,7 +1450,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard >`; } - protected _renderViewKeyboardShortcutMenu(): TemplateResult { + private _renderViewKeyboardShortcutMenu(): TemplateResult { return this._putInSubmenu( MENU_VIEW_KEYBOARD_SHORTCUTS, true, @@ -1496,7 +1496,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard ); } - protected _renderStatusBarItem(item: string): TemplateResult { + private _renderStatusBarItem(item: string): TemplateResult { return html` ${this._putInSubmenu( MENU_STATUS_BAR_ITEMS, item, @@ -1519,7 +1519,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard )}`; } - protected _renderMenuButton( + private _renderMenuButton( button: string, additionalOptions?: TemplateResult, ): TemplateResult { @@ -1578,7 +1578,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param template The template to put in the submenu. * @returns */ - protected _putInSubmenu( + private _putInSubmenu( domain: string, key: unknown, labelPath: string, @@ -1614,7 +1614,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPathPositionY The path to the position.y config. * @returns A rendered template. */ - protected _renderMediaLayout( + private _renderMediaLayout( domain: string, labelPath: string, configPathFit: string, @@ -1710,7 +1710,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param defaultShowRecordings Default value of show_recordings. * @returns A rendered template. */ - protected _renderTimelineCoreControls( + private _renderTimelineCoreControls( domain: string, configPathStyle: string, configPathWindowSeconds: string, @@ -1762,7 +1762,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPathShowRecordings Show recordings config path. * @returns A rendered template. */ - protected _renderMiniTimeline( + private _renderMiniTimeline( domain: string, configPathMode: string, configPathStyle: string, @@ -1804,7 +1804,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPathSize Next previous size config path. * @returns A rendered template. */ - protected _renderViewDisplay( + private _renderViewDisplay( domain: string, configPathMode: string, configPathSelectedPosition: string, @@ -1851,7 +1851,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPathSize Next previous size config path. * @returns A rendered template. */ - protected _renderNextPreviousControls( + private _renderNextPreviousControls( domain: string, configPathStyle: string, configPathSize: string, @@ -1896,7 +1896,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param options An optional config path to media selection and mini-timeline mode. * @returns A rendered template. */ - protected _renderThumbnailsControls( + private _renderThumbnailsControls( domain: string, configPathSize: string, configPathShowDetails: string, @@ -1977,7 +1977,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param configPathMode Filter mode config path. * @returns A rendered template. */ - protected _renderFilterControls( + private _renderFilterControls( domain: string, configPathMode: string, ): TemplateResult | void { @@ -1996,7 +1996,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard ); } - protected _renderImageOptions( + private _renderImageOptions( configPathMode: string, configPathUrl: string, configPathEntity: string, @@ -2026,7 +2026,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard `; } - protected _modifyConfig(func: (config: RawAdvancedCameraCardConfig) => boolean): void { + private _modifyConfig(func: (config: RawAdvancedCameraCardConfig) => boolean): void { if (this._config) { const newConfig = copyConfig(this._config); if (func(newConfig)) { @@ -2035,7 +2035,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard } } - protected _renderArrayManagementControls( + private _renderArrayManagementControls( configPathArray: string, index: number, menu: string, @@ -2109,7 +2109,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard `; } - protected _renderFolder( + private _renderFolder( folders: RawAdvancedCameraCardConfigArray, folderIndex: number, addNewFolder?: boolean, @@ -2200,7 +2200,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param addNewCamera Whether or not this is a section to add a new non-existent camera. * @returns A rendered template. */ - protected _renderCamera( + private _renderCamera( cameras: RawAdvancedCameraCardConfigArray, cameraIndex: number, entities: string[], @@ -2784,7 +2784,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param type The allowable input * @returns A rendered template. */ - protected _renderStringInput( + private _renderStringInput( configPath: string, params?: { label?: string; @@ -2828,7 +2828,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param params Optional parameters to control the selector. * @returns A rendered template. */ - protected _renderSwitch( + private _renderSwitch( configPath: string, valueDefault: boolean, params?: { @@ -2852,7 +2852,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard `; } - protected _updateConfig(config: RawAdvancedCameraCardConfig): void { + private _updateConfig(config: RawAdvancedCameraCardConfig): void { this._config = config; fireHASSEvent(this, 'config-changed', { config: this._config }); } @@ -3471,7 +3471,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * Close the editor menu with the given domain. * @param targetDomain The menu domain to close. */ - protected _closeMenu(targetDomain: string) { + private _closeMenu(targetDomain: string) { delete this._expandedMenus[targetDomain]; this.requestUpdate(); } @@ -3481,7 +3481,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * @param targetDomain The menu domain to open. * @param key The menu object key to open. */ - protected _openMenu(targetDomain: string, key: number | string) { + private _openMenu(targetDomain: string, key: number | string) { this._expandedMenus[targetDomain] = key; this.requestUpdate(); } @@ -3490,7 +3490,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * Toggle an editor menu. * @param ev An event. */ - protected _toggleMenu(ev: { target: EditorMenuTarget | null }): void { + private _toggleMenu(ev: { target: EditorMenuTarget | null }): void { if (ev && ev.target) { const domain = ev.target.domain; const key = ev.target.key; @@ -3507,10 +3507,7 @@ export class AdvancedCameraCardEditor extends LitElement implements LovelaceCard * Handle a changed option value. * @param ev Event triggering the change. */ - protected _valueChangedHandler( - key: string, - ev: CustomEvent<{ value: unknown }>, - ): void { + private _valueChangedHandler(key: string, ev: CustomEvent<{ value: unknown }>): void { if (!this._config || !this.hass) { return; } diff --git a/src/ha/browse-media/item.ts b/src/ha/browse-media/item.ts index c003b8d3..cf3e15d7 100644 --- a/src/ha/browse-media/item.ts +++ b/src/ha/browse-media/item.ts @@ -45,9 +45,9 @@ const getIcon = (mediaClass: string): string | null => { }; export class BrowseMediaEventViewMedia extends ViewMedia implements EventViewMedia { - protected _browseMedia: RichBrowseMedia; - protected _id: string; - protected _icon: string | null; + private _browseMedia: RichBrowseMedia; + private _id: string; + private _icon: string | null; constructor( mediaType: ViewMediaType, diff --git a/src/ha/browse-media/walker.ts b/src/ha/browse-media/walker.ts index 62d9cf4b..e38fad97 100644 --- a/src/ha/browse-media/walker.ts +++ b/src/ha/browse-media/walker.ts @@ -68,7 +68,7 @@ export class BrowseMediaWalker { ).flat(); } - protected async _walkBrowseMedia( + private async _walkBrowseMedia( hass: HomeAssistant, step: BrowseMediaStep, options?: { @@ -111,7 +111,7 @@ export class BrowseMediaWalker { return await this.walk(hass, nextSteps, options); } - protected async _browseMedia( + private async _browseMedia( hass: HomeAssistant, target: string | RichBrowseMedia, options?: { diff --git a/src/ha/registry/device/index.ts b/src/ha/registry/device/index.ts index c5f1ffb9..5d9fe5b6 100644 --- a/src/ha/registry/device/index.ts +++ b/src/ha/registry/device/index.ts @@ -4,8 +4,8 @@ import { homeAssistantWSRequest } from '../../ws-request'; import { Device, DeviceCache, DeviceList, deviceListSchema } from './types'; export class DeviceRegistryManager { - protected _cache: DeviceCache; - protected _fetchedDeviceList = false; + private _cache: DeviceCache; + private _fetchedDeviceList = false; constructor(cache: DeviceCache) { this._cache = cache; @@ -29,7 +29,7 @@ export class DeviceRegistryManager { return this._cache.getMatches(func); } - protected async _fetchDeviceList(hass: HomeAssistant): Promise { + private async _fetchDeviceList(hass: HomeAssistant): Promise { if (this._fetchedDeviceList) { return; } diff --git a/src/ha/registry/entity/index.ts b/src/ha/registry/entity/index.ts index 71aaa536..cef8e72e 100644 --- a/src/ha/registry/entity/index.ts +++ b/src/ha/registry/entity/index.ts @@ -15,8 +15,8 @@ import { // non-trivial in size (after which they are cached forever). export class EntityRegistryManagerLive implements EntityRegistryManager { - protected _cache: EntityCache; - protected _fetchedEntityList = false; + private _cache: EntityCache; + private _fetchedEntityList = false; constructor(cache: EntityCache) { this._cache = cache; diff --git a/src/patches/ha-camera-stream.ts b/src/patches/ha-camera-stream.ts index 8161ca87..089f364a 100644 --- a/src/patches/ha-camera-stream.ts +++ b/src/patches/ha-camera-stream.ts @@ -45,8 +45,8 @@ customElements.whenDefined('ha-camera-stream').then(() => { @query('.player:not(.hidden)') protected _player: MediaPlayer; - protected _mediaLoadedInfoPerStream: Record = {}; - protected _mediaLoadedInfoDispatched: MediaLoadedInfo | null = null; + private _mediaLoadedInfoPerStream: Record = {}; + private _mediaLoadedInfoDispatched: MediaLoadedInfo | null = null; // ======================================================================================== // Minor modifications from: @@ -58,7 +58,7 @@ customElements.whenDefined('ha-camera-stream').then(() => { return (await this._player?.getMediaPlayerController()) ?? null; } - protected _storeMediaLoadedInfoHandler( + private _storeMediaLoadedInfoHandler( stream: StreamType, ev: CustomEvent, ) { @@ -66,10 +66,7 @@ customElements.whenDefined('ha-camera-stream').then(() => { ev.stopPropagation(); } - protected _storeMediaLoadedInfo( - stream: StreamType, - mediaLoadedInfo: MediaLoadedInfo, - ) { + private _storeMediaLoadedInfo(stream: StreamType, mediaLoadedInfo: MediaLoadedInfo) { this._mediaLoadedInfoPerStream[stream] = mediaLoadedInfo; this.requestUpdate(); } diff --git a/src/patches/ha-hls-player.ts b/src/patches/ha-hls-player.ts index 6f0bbf19..6a688e06 100644 --- a/src/patches/ha-hls-player.ts +++ b/src/patches/ha-hls-player.ts @@ -42,7 +42,7 @@ customElements.whenDefined('ha-hls-player').then(() => { @query('#video') protected _video: HTMLVideoElement; - protected _mediaPlayerController = new VideoMediaPlayerController( + private _mediaPlayerController = new VideoMediaPlayerController( this, () => this._video, () => this.controls, diff --git a/src/patches/ha-web-rtc-player.ts b/src/patches/ha-web-rtc-player.ts index a5032fbd..7c2bd487 100644 --- a/src/patches/ha-web-rtc-player.ts +++ b/src/patches/ha-web-rtc-player.ts @@ -42,7 +42,7 @@ customElements.whenDefined('ha-web-rtc-player').then(() => { @customElement('advanced-camera-card-ha-web-rtc-player') // eslint-disable-next-line @typescript-eslint/no-unused-vars class AdvancedCameraCardHaWebRtcPlayer extends HaWebRtcPlayer implements MediaPlayer { - protected _mediaPlayerController = new VideoMediaPlayerController( + private _mediaPlayerController = new VideoMediaPlayerController( this, () => this._videoEl, () => this.controls, diff --git a/src/utils/embla/carousel-controller.ts b/src/utils/embla/carousel-controller.ts index 3a2de016..80de6969 100644 --- a/src/utils/embla/carousel-controller.ts +++ b/src/utils/embla/carousel-controller.ts @@ -17,21 +17,21 @@ type EmblaCarouselPlugins = CreatePluginType this._refreshCarouselContents(), @@ -121,7 +121,7 @@ export class CarouselController { } } - protected _refreshCarouselContents = (): void => { + private _refreshCarouselContents = (): void => { const slides = getChildrenFromElement(this._parent); const slidesChanged = !isEqual(this._carousel.slideNodes(), slides); if (slidesChanged) { @@ -129,7 +129,7 @@ export class CarouselController { } }; - protected _createCarousel(slides: HTMLElement[]): EmblaCarouselType { + private _createCarousel(slides: HTMLElement[]): EmblaCarouselType { const carousel = EmblaCarousel( this._root, { diff --git a/src/utils/initializer/initializer.ts b/src/utils/initializer/initializer.ts index 2a44a5df..34112187 100644 --- a/src/utils/initializer/initializer.ts +++ b/src/utils/initializer/initializer.ts @@ -8,7 +8,7 @@ type InitializationCallback = () => Promise; * applied to the usage of this class. */ export class Initializer { - protected _initialized: Set = new Set(); + private _initialized: Set = new Set(); public async initializeMultipleIfNecessary( aspects: Record, diff --git a/src/utils/timer.ts b/src/utils/timer.ts index 358d3808..9e988828 100644 --- a/src/utils/timer.ts +++ b/src/utils/timer.ts @@ -1,6 +1,6 @@ export class Timer { - protected _timer: number | null = null; - protected _repeated = false; + private _timer: number | null = null; + private _repeated = false; public stop(): void { if (this._timer) { diff --git a/src/view/query-results.ts b/src/view/query-results.ts index d5959520..ccc87ca5 100644 --- a/src/view/query-results.ts +++ b/src/view/query-results.ts @@ -12,15 +12,15 @@ interface ResultSliceOptions { } class ResultSlice { - protected _results: ViewItem[]; - protected _selectedIndex: number | null; + private _results: ViewItem[]; + private _selectedIndex: number | null; constructor(options?: ResultSliceOptions) { this._results = options?.results ?? []; this._selectedIndex = this._getInitialSelectedIndex(options); } - protected _getInitialSelectedIndex(options?: ResultSliceOptions): number | null { + private _getInitialSelectedIndex(options?: ResultSliceOptions): number | null { if (options?.selectedIndex !== undefined && options?.selectedIndex !== null) { return options.selectedIndex; } @@ -146,9 +146,9 @@ interface ResultSliceSelectionCriteria { } export class QueryResults { - protected _resultsTimestamp: Date | null = null; - protected _main: ResultSlice; - protected _cameras: CameraResultSlices = new Map(); + private _resultsTimestamp: Date | null = null; + private _main: ResultSlice; + private _cameras: CameraResultSlices = new Map(); constructor(options?: ResultSliceOptions) { this._resultsTimestamp = new Date(); @@ -156,7 +156,7 @@ export class QueryResults { this._buildByCameraSlices(options?.selectApproach); } - protected _buildByCameraSlices(selectApproach?: SelectApproach): void { + private _buildByCameraSlices(selectApproach?: SelectApproach): void { const cameraMap: Map = new Map(); for (const result of this._main.getResults()) { const cameraID = ViewItemClassifier.isMedia(result) ? result.getCameraID() : null; @@ -335,7 +335,7 @@ export class QueryResults { return this; } - protected _getCameraIDsFromCriteria( + private _getCameraIDsFromCriteria( criteria?: ResultSliceSelectionCriteria, ): Set | null { return criteria?.allCameras diff --git a/tests/ha/registry/entity/mock.ts b/tests/ha/registry/entity/mock.ts index ddeb06dd..02cbc30c 100644 --- a/tests/ha/registry/entity/mock.ts +++ b/tests/ha/registry/entity/mock.ts @@ -6,8 +6,8 @@ import { import { HomeAssistant } from '../../../../src/ha/types'; export class EntityRegistryManagerMock implements EntityRegistryManager { - protected _cache = new EntityCache(); - protected _fetchedEntityList = false; + private _cache = new EntityCache(); + private _fetchedEntityList = false; constructor(data?: Entity[]) { data?.forEach((entity) => { diff --git a/tests/test-utils.ts b/tests/test-utils.ts index ddffa092..a4d8f391 100644 --- a/tests/test-utils.ts +++ b/tests/test-utils.ts @@ -357,22 +357,22 @@ export const generateViewMediaArray = (options?: { // ViewMedia itself has no native way to set startTime and ID that aren't linked // to an engine. export class TestViewMedia extends ViewMedia implements EventViewMedia, ReviewViewMedia { - protected _icon: string | null = null; - protected _id: string | null; - protected _startTime: Date | null; - protected _endTime: Date | null; - protected _inProgress: boolean | null; - protected _contentID: string | null; - protected _title: string | null; - protected _thumbnail: string | null; - protected _what: string[] | null = null; - protected _score: number | null = null; - protected _tags: string[] | null = null; - protected _where: string[] | null = null; - protected _severity: Severity | null = null; - protected _reviewed: boolean | null = null; - protected _description: string | null = null; - protected _favorite: boolean | null = null; + private _icon: string | null = null; + private _id: string | null; + private _startTime: Date | null; + private _endTime: Date | null; + private _inProgress: boolean | null; + private _contentID: string | null; + private _title: string | null; + private _thumbnail: string | null; + private _what: string[] | null = null; + private _score: number | null = null; + private _tags: string[] | null = null; + private _where: string[] | null = null; + private _severity: Severity | null = null; + private _reviewed: boolean | null = null; + private _description: string | null = null; + private _favorite: boolean | null = null; constructor(options?: { id?: string | null;