refactor: Convert protected methods to private (#2358)

This commit is contained in:
Dermot Duffy
2026-02-19 20:47:59 -08:00
committed by GitHub
parent 529500ed94
commit 0a67df9a25
122 changed files with 815 additions and 829 deletions
+4 -4
View File
@@ -25,11 +25,11 @@ interface AdvancedCameraCardActionHandlerOptions extends ActionHandlerOptions {
class ActionHandler extends HTMLElement implements ActionHandlerInterface {
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 {
[
+5 -5
View File
@@ -3,10 +3,10 @@ import { DateRange, MemoryRangeSet } from './range';
import { RecordingSegment } from './types';
class MemoryRangedCache<Data> {
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<Data> {
}
export class RecordingSegmentsCache {
protected _segments: Map<string, MemoryRangedCache<RecordingSegment>> = new Map();
private _segments: Map<string, MemoryRangedCache<RecordingSegment>> = new Map();
public add(cameraID: string, range: DateRange, segments: RecordingSegment[]) {
let cameraSegmentCache: MemoryRangedCache<RecordingSegment> | undefined =
+1 -1
View File
@@ -28,7 +28,7 @@ export class Capabilities {
}
}
protected _disable(capability: CapabilityKey): void {
private _disable(capability: CapabilityKey): void {
delete this._capabilities[capability];
}
+2 -2
View File
@@ -19,8 +19,8 @@ interface CameraManagerEngineFactoryOptions {
}
export class CameraManagerEngineFactory {
protected _entityRegistryManager: EntityRegistryManager;
protected _deviceRegistryManager: DeviceRegistryManager;
private _entityRegistryManager: EntityRegistryManager;
private _deviceRegistryManager: DeviceRegistryManager;
constructor(
entityRegistryManager: EntityRegistryManager,
+10 -10
View File
@@ -106,7 +106,7 @@ export class FrigateCamera extends Camera {
return true;
}
protected async _initializeConfig(
private async _initializeConfig(
hass: HomeAssistant,
entityRegistryManager: EntityRegistryManager,
): Promise<void> {
@@ -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<PTZCapabilities | null> {
@@ -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<FrigateEventChange>,
): Promise<void> {
@@ -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<FrigateReviewChange>,
): Promise<void> {
@@ -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;
+16 -16
View File
@@ -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<string>,
query: PartialEventQuery & { type: QueryType.Event },
): EventQuery[] | null;
protected _generateBatchableQuery(
private _generateBatchableQuery(
store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>,
query: PartialReviewQuery & { type: QueryType.Review },
): ReviewQuery[] | null;
protected _generateBatchableQuery(
private _generateBatchableQuery(
store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>,
query: (PartialEventQuery | PartialReviewQuery) & {
@@ -368,7 +368,7 @@ export class FrigateCameraManagerEngine
);
}
protected _buildInstanceToCameraIDMapFromQuery(
private _buildInstanceToCameraIDMapFromQuery(
store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>,
): Map<string, Set<string>> {
@@ -386,7 +386,7 @@ export class FrigateCameraManagerEngine
return output;
}
protected _getFrigateCameraNamesForCameraIDs(
private _getFrigateCameraNamesForCameraIDs(
store: CameraManagerReadOnlyConfigStore,
cameraIDs: Set<string>,
): Set<string> {
@@ -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<void> {
@@ -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[],
+12 -12
View File
@@ -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,
+10 -10
View File
@@ -129,10 +129,10 @@ interface ExtendedMediaQueryResult<T extends MediaQuery> {
}
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<Map<CameraConfig, CameraManagerEngine>> {
const output: Map<CameraConfig, CameraManagerEngine> = new Map();
@@ -228,7 +228,7 @@ export class CameraManager {
return output;
}
protected async _initializeCameras(camerasConfig: CameraConfig[]): Promise<void> {
private async _initializeCameras(camerasConfig: CameraConfig[]): Promise<void> {
const initializationStartTime = new Date();
const hass = this._api.getHASSManager().getHASS();
@@ -364,7 +364,7 @@ export class CameraManager {
});
}
protected _generateDefaultQueries<PQT extends PartialCameraQuery>(
private _generateDefaultQueries<PQT extends PartialCameraQuery>(
cameraIDs: string | Set<string>,
partialQuery: PQT,
): PartialQueryConcreteType<PQT>[] | 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<T extends CameraQuery>(queries: T[]): T[] {
private _mergeCompatibleQueries<T extends CameraQuery>(queries: T[]): T[] {
if (queries.length <= 1) {
return queries;
}
@@ -720,7 +720,7 @@ export class CameraManager {
);
}
protected async _handleQuery<QT extends CameraQuery>(
private async _handleQuery<QT extends CameraQuery>(
query: QT | QT[],
engineOptions?: EngineOptions,
): Promise<Map<QT, QueryReturnType<QT>>> {
@@ -821,7 +821,7 @@ export class CameraManager {
return results;
}
protected _convertQueryResultsToMedia<QT extends CameraQuery>(
private _convertQueryResultsToMedia<QT extends CameraQuery>(
results: ResultsMap<QT>,
): ViewMedia[] {
const mediaArray: ViewMedia[] = [];
@@ -60,8 +60,8 @@ const MOTIONEYE_REPL_SUBSTITUTIONS: Record<string, string> = {
const MOTIONEYE_REPL_REGEXP = new RegExp(/(%Y|%m|%d|%H|%M|%S)/g);
export class MotionEyeCameraManagerEngine extends BrowseMediaCameraManagerEngine {
protected _directoryCache = new BrowseMediaCache<BrowseMediaMetadata>();
protected _fileCache = new BrowseMediaCache<BrowseMediaMetadata>();
private _directoryCache = new BrowseMediaCache<BrowseMediaMetadata>();
private _fileCache = new BrowseMediaCache<BrowseMediaMetadata>();
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,
+3 -3
View File
@@ -15,7 +15,7 @@ interface MemoryRangeSetInterface<T> {
}
export class MemoryRangeSet implements MemoryRangeSetInterface<DateRange> {
protected _ranges: DateRange[];
private _ranges: DateRange[];
constructor(ranges?: DateRange[]) {
this._ranges = ranges ?? [];
@@ -44,7 +44,7 @@ export interface ExpiringRange<T extends Date | number> extends Range<T> {
export class ExpiringMemoryRangeSet
implements MemoryRangeSetInterface<ExpiringRange<Date>>
{
protected _ranges: ExpiringRange<Date>[];
private _ranges: ExpiringRange<Date>[];
constructor(ranges?: ExpiringRange<Date>[]) {
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);
}
+9 -9
View File
@@ -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<number | null> {
@@ -84,7 +84,7 @@ export class ReolinkCamera extends EntityCamera {
}
}
protected async _initializeChannel(
private async _initializeChannel(
hass: HomeAssistant,
deviceRegistryManager: DeviceRegistryManager,
): Promise<void> {
@@ -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<PTZEntities | null> {
@@ -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}_`;
}
+7 -7
View File
@@ -53,9 +53,9 @@ export class ReolinkQueryResultsClassifier {
}
export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
protected _camerasCache = new BrowseMediaCache<BrowseMediaReolinkCameraMetadata>();
protected _cache = new BrowseMediaCache<BrowseMediaMetadata>();
protected _deviceRegistryManager: DeviceRegistryManager;
private _camerasCache = new BrowseMediaCache<BrowseMediaReolinkCameraMetadata>();
private _cache = new BrowseMediaCache<BrowseMediaMetadata>();
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<BrowseMediaMetadata>,
@@ -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?: {
+2 -2
View File
@@ -38,8 +38,8 @@ export interface CameraManagerReadOnlyConfigStore {
}
export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
protected _cameras: Map<string, Camera> = new Map();
protected _enginesByType: Map<Engine, CameraManagerEngine> = new Map();
private _cameras: Map<string, Camera> = new Map();
private _enginesByType: Map<Engine, CameraManagerEngine> = new Map();
public addCamera(camera: Camera): void {
this._cameras.set(camera.getID(), camera);
+3 -3
View File
@@ -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<PTZEntities | null> {
@@ -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[]) {
+1 -1
View File
@@ -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,
@@ -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;
@@ -29,9 +29,9 @@ declare module 'action' {
}
export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialActionConfig> {
protected _timer = new Timer();
private _timer = new Timer();
protected async _stepChange(api: CardActionsAPI, targetID: string): Promise<void> {
private async _stepChange(api: CardActionsAPI, targetID: string): Promise<void> {
api.getViewManager().setViewWithMergedContext(
generateViewContextForZoom(targetID, {
requested: this._convertActionToZoomSettings(
@@ -80,9 +80,7 @@ export class PTZDigitalAction extends AdvancedCameraCardAction<PTZDigitialAction
}
}
protected _convertActionToZoomSettings(
base?: PartialZoomSettings,
): PartialZoomSettings {
private _convertActionToZoomSettings(base?: PartialZoomSettings): PartialZoomSettings {
if (!this._action.absolute && !this._action.ptz_action) {
// If neither an absolute position nor an action are specified, the request
// is assumed to be to return to default.
@@ -33,7 +33,7 @@ export class PTZMultiAction extends AdvancedCameraCardAction<PTZMultiActionConfi
).execute(api);
}
protected _toPTZAction(targetID: string): PTZAction {
private _toPTZAction(targetID: string): PTZAction {
return new PTZAction(
this._context,
createPTZAction({
@@ -47,7 +47,7 @@ export class PTZMultiAction extends AdvancedCameraCardAction<PTZMultiActionConfi
);
}
protected _toPTZDigitalAction(targetID: string): PTZDigitalAction {
private _toPTZDigitalAction(targetID: string): PTZDigitalAction {
return new PTZDigitalAction(
this._context,
createPTZDigitalAction({
+2 -2
View File
@@ -22,8 +22,8 @@ declare module 'action' {
}
export class PTZAction extends AdvancedCameraCardAction<PTZActionConfig> {
protected _timer = new Timer();
protected _stopped = false;
private _timer = new Timer();
private _stopped = false;
public async stop(): Promise<void> {
this._stopped = true;
+4 -4
View File
@@ -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,
+4 -4
View File
@@ -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<TaggedAutomation, ConditionsManager>();
private _automations = new Map<TaggedAutomation, ConditionsManager>();
// 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
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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<ViewItem>): void => {
private _handleMediaReviewed = (ev: CustomEvent<ViewItem>): void => {
// If the selected media item has a change of review status, update the card
// (e.g. for the menu).
if (
+9 -11
View File
@@ -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<void> {
await this._api.getDefaultManager().initializeIfNecessary(previousConfig);
+30 -30
View File
@@ -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,
+5 -5
View File
@@ -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 (
@@ -47,7 +47,7 @@ export class EffectsManager implements EffectsManagerInterface {
// effects can be started).
private _pendingEffects: Map<EffectName, EffectOptions | undefined> = new Map();
private _activeEffects: Map<EffectName, EffectComponent | null> = new Map();
protected _container: EffectsContainer | null = null;
private _container: EffectsContainer | null = null;
constructor(importer: EffectModuleImporter = defaultImportEffectModule) {
this._importer = importer;
+3 -3
View File
@@ -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,
});
@@ -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<void> {
if (this._anyDateParser) {
@@ -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(),
});
@@ -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<WebkitHTMLVideoElement>)
| 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
+3 -3
View File
@@ -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;
+1 -1
View File
@@ -9,7 +9,7 @@ export interface StateWatcherSubscriptionInterface {
}
export class StateWatcher implements StateWatcherSubscriptionInterface {
protected _watcherCallbacks = new Map<StateWatcherCallback, string[]>();
private _watcherCallbacks = new Map<StateWatcherCallback, string[]>();
public setHASS(oldHass: HomeAssistant | null, hass: HomeAssistant): void {
if (!oldHass) {
@@ -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<void> {
private async _initializeMandatory(): Promise<void> {
const hass = this._api.getHASSManager().getHASS();
if (!hass || this.isInitializedMandatory()) {
return;
+5 -5
View File
@@ -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);
@@ -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 });
}
}
+3 -3
View File
@@ -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;
+4 -4
View File
@@ -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<void> {
+2 -2
View File
@@ -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;
+8 -8
View File
@@ -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(),
@@ -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;
+7 -7
View File
@@ -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<void> {
private async _executeViewRelated(intent: QueryStringViewIntent): Promise<void> {
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<void> {
private async _executeNonViewRelated(intent: QueryStringViewIntent): Promise<void> {
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) {
@@ -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';
+6 -6
View File
@@ -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 {
+2 -2
View File
@@ -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,
+21 -21
View File
@@ -27,10 +27,10 @@ interface CameraTriggerState {
}
export class TriggersManager {
protected _api: CardTriggersAPI;
protected _states: Map<string, CameraTriggerState> = new Map();
private _api: CardTriggersAPI;
private _states: Map<string, CameraTriggerState> = new Map();
protected _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, {
private _throttledTriggerAction = throttle(this._triggerAction.bind(this), 1000, {
trailing: true,
});
@@ -149,7 +149,7 @@ export class TriggersManager {
return true;
}
protected async _handleEndEvent(ev: CameraEvent): Promise<boolean> {
private async _handleEndEvent(ev: CameraEvent): Promise<boolean> {
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<void> {
private async _triggerAction(ev: CameraEvent): Promise<void> {
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<boolean> {
private async _executeUntriggerAction(): Promise<boolean> {
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<void> {
private async _untriggerAction(cameraID: string): Promise<void> {
this._deleteUntriggerDelayTimer(cameraID);
this._deleteForceUntriggerTimer(cameraID);
@@ -282,7 +282,7 @@ export class TriggersManager {
this._api.getCardElementManager().update();
}
protected async _startUntrigger(cameraID: string): Promise<void> {
private async _startUntrigger(cameraID: string): Promise<void> {
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<void> {
@@ -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);
}
}
+10 -10
View File
@@ -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 {
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -8,7 +8,7 @@ interface SubstreamOnViewModifierAPI {
}
export class SubstreamOnViewModifier implements ViewModifier {
protected _api: SubstreamOnViewModifierAPI;
private _api: SubstreamOnViewModifierAPI;
constructor(api: SubstreamOnViewModifierAPI) {
this._api = api;
@@ -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;
+14 -14
View File
@@ -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<View> | null): void {
private _setView(view: Readonly<View> | null): void {
const oldView = this._view;
log(
@@ -2,13 +2,13 @@ import { ReactiveController, ReactiveControllerHost } from 'lit';
import { Timer } from '../utils/timer';
export class CachedValueController<T> 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,
@@ -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;
+6 -6
View File
@@ -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<MediaLoadedInfo>): void => {
private _handleMediaLoaded = (ev: CustomEvent<MediaLoadedInfo>): 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);
+27 -29
View File
@@ -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<HTMLElement, () => 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<HTMLElement, () => 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<void> {
private async _playTargetIfConfigured(condition: AutoPlayCondition): Promise<void> {
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<void> {
private async _play(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.play();
}
protected async _unmuteTargetIfConfigured(
private async _unmuteTargetIfConfigured(
condition: AutoUnmuteCondition,
): Promise<void> {
if (
@@ -131,20 +131,18 @@ export class MediaActionsController {
await this._unmute(this._target.index);
}
}
protected async _unmute(index: number): Promise<void> {
private async _unmute(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.unmute();
}
protected async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise<void> {
private async _pauseAllIfConfigured(condition: AutoPauseCondition): Promise<void> {
if (this._options?.autoPauseConditions?.includes(condition)) {
for (const index of this._children.keys()) {
await this._pause(index);
}
}
}
protected async _pauseTargetIfConfigured(
condition: AutoPauseCondition,
): Promise<void> {
private async _pauseTargetIfConfigured(condition: AutoPauseCondition): Promise<void> {
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<void> {
private async _pause(index: number): Promise<void> {
await (await this._children[index]?.getMediaPlayerController())?.pause();
}
protected async _muteAllIfConfigured(condition: AutoMuteCondition): Promise<void> {
private async _muteAllIfConfigured(condition: AutoMuteCondition): Promise<void> {
if (this._options?.autoMuteConditions?.includes(condition)) {
for (const index of this._children.keys()) {
await this._mute(index);
}
}
}
protected async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise<void> {
private async _muteTargetIfConfigured(condition: AutoMuteCondition): Promise<void> {
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<void> {
private async _mute(index: number): Promise<void> {
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<void> => {
private _mediaLoadedHandler = async (index: number): Promise<void> => {
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<void> {
const wasIntersecting = this._viewportIntersecting;
@@ -248,11 +246,11 @@ export class MediaActionsController {
}
}
protected _visibilityHandler = async (): Promise<void> => {
private _visibilityHandler = async (): Promise<void> => {
await this._changeVisibility(document.visibilityState === 'visible');
};
protected _changeVisibility = async (visible: boolean): Promise<void> => {
private _changeVisibility = async (visible: boolean): Promise<void> => {
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<void> {
+19 -19
View File
@@ -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<unknown> | undefined)[]): boolean {
private _hasSingleUniqueValue(sets: (Set<unknown> | undefined)[]): boolean {
if (sets.length === 0) {
return false;
}
+29 -29
View File
@@ -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<GridID, MediaLoadedInfo> = 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<GridID, MediaLoadedInfo> = 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<MediaLoadedInfo>): void => {
private _handleMediaLoadedInfoEvent = (ev: CustomEvent<MediaLoadedInfo>): 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`,
@@ -219,7 +219,7 @@ export class MediaDetailsController {
};
}
protected _getControls(context: OverlayControlsContext): OverlayMessageControl[] {
private _getControls(context: OverlayControlsContext): OverlayMessageControl[] {
const controls: OverlayMessageControl[] = [];
const item = this._item;
+29 -29
View File
@@ -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,
+7 -7
View File
@@ -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'
+8 -8
View File
@@ -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');
}
}
+28 -28
View File
@@ -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 = (<CustomEvent<PanzoomEventDetail>>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';
}
}
+4 -4
View File
@@ -48,12 +48,12 @@ export class AdvancedCameraCardCarousel extends LitElement {
@property({ attribute: false })
public selected = 0;
protected _refParent: Ref<HTMLSlotElement> = createRef();
protected _refRoot: Ref<HTMLElement> = createRef();
protected _carousel: CarouselController | null = null;
private _refParent: Ref<HTMLSlotElement> = createRef();
private _refRoot: Ref<HTMLElement> = 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();
+1 -1
View File
@@ -16,7 +16,7 @@ export class AdvancedCameraCardDatePicker extends LitElement {
@property({ attribute: false })
public icon?: string;
protected _refInput: Ref<HTMLInputElement> = createRef();
private _refInput: Ref<HTMLInputElement> = createRef();
get value(): Date | null {
return this._refInput.value?.value ? new Date(this._refInput.value.value) : null;
+1 -1
View File
@@ -20,7 +20,7 @@ export class AdvancedCameraCardDiagnostics extends LitElement {
@property({ attribute: false })
public rawConfig?: RawAdvancedCameraCardConfig;
protected async _renderDiagnostics(): Promise<TemplateResult> {
private async _renderDiagnostics(): Promise<TemplateResult> {
const diagnostics = await getDiagnostics(
this.hass,
this.deviceRegistryManager,
+6 -6
View File
@@ -42,12 +42,12 @@ export class AdvancedCameraCardDrawer extends LitElement {
@property({ type: Boolean, reflect: true, attribute: true })
public empty = true;
protected _refDrawer: Ref<HTMLElement & { open: boolean }> = createRef();
protected _refSlot: Ref<HTMLSlotElement> = createRef();
private _refDrawer: Ref<HTMLElement & { open: boolean }> = createRef();
private _refSlot: Ref<HTMLSlotElement> = createRef();
protected _resizeObserver = new ResizeObserver(() => this._hideDrawerIfNecessary());
private _resizeObserver = new ResizeObserver(() => this._hideDrawerIfNecessary());
protected readonly _isHoverableDevice = isHoverableDevice();
private readonly _isHoverableDevice = isHoverableDevice();
/**
* Called on the first update.
@@ -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;
}
+9 -9
View File
@@ -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<MenuItem>(
@@ -221,7 +221,7 @@ export class AdvancedCameraCardElements extends LitElement {
);
};
protected _statusBarRemoveHandler = (ev: Event): void => {
private _statusBarRemoveHandler = (ev: Event): void => {
// Re-dispatch event from this element (instead of the disconnected one, as
// there is no parent of the disconnected element).
fireAdvancedCameraCardEvent<StatusBarItem>(
@@ -231,7 +231,7 @@ export class AdvancedCameraCardElements extends LitElement {
);
};
protected _menuAddHandler = (ev: Event): void => {
private _menuAddHandler = (ev: Event): void => {
ev = ev as CustomEvent<MenuItem>;
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<MenuItem>;
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;
+8 -8
View File
@@ -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 {
</advanced-camera-card-thumbnail>`;
}
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<GalleryExtendEvent>,
direction: 'earlier' | 'later',
useCache = true,
+2 -2
View File
@@ -23,8 +23,8 @@ export class AdvancedCameraCardImagePlayer extends LitElement implements MediaPl
@property()
public technology?: MediaTechnology;
protected _refImage: Ref<MediaPlayerElement<HTMLImageElement>> = createRef();
protected _mediaPlayerController = new ImageMediaPlayerController(
private _refImage: Ref<MediaPlayerElement<HTMLImageElement>> = createRef();
private _mediaPlayerController = new ImageMediaPlayerController(
this,
() => this._refImage.value ?? null,
);
+13 -13
View File
@@ -89,16 +89,16 @@ export class AdvancedCameraCardImageUpdatingPlayer
public imageConfig?: ImageBaseConfig;
@state()
protected _message: Message | null = null;
private _message: Message | null = null;
protected _refImage: Ref<HTMLImageElement> = createRef();
private _refImage: Ref<HTMLImageElement> = createRef();
protected _cachedValueController?: CachedValueController<string>;
protected _boundVisibilityHandler = this._visibilityHandler.bind(this);
private _cachedValueController?: CachedValueController<string>;
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<ImageMode, 'auto'>): string | null {
private _getRelevantEntityForMode(mode: Exclude<ImageMode, 'auto'>): 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;
+2 -2
View File
@@ -36,14 +36,14 @@ export class AdvancedCameraCardImage extends LitElement implements MediaPlayer {
@property({ attribute: false })
public imageConfig?: ImageViewConfig;
protected _refImage: Ref<MediaPlayerElement> = createRef();
private _refImage: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
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({
+1 -1
View File
@@ -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')) {
+18 -18
View File
@@ -71,15 +71,15 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
public viewFilterCameraID?: string;
// Index between camera name and slide number.
protected _cameraToSlide: Record<string, number> = {};
protected _refPTZControl: Ref<AdvancedCameraCardPTZ> = createRef();
protected _refCarousel: Ref<HTMLElement> = createRef();
private _cameraToSlide: Record<string, number> = {};
private _refPTZControl: Ref<AdvancedCameraCardPTZ> = createRef();
private _refCarousel: Ref<HTMLElement> = 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<string, number>] {
private _getSlides(): [TemplateResult[], Record<string, number>] {
if (!this.cameraManager) {
return [[], {}];
}
@@ -179,14 +179,14 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
return [slides, cameraToSlide];
}
protected _setViewHandler(ev: CustomEvent<CarouselSelected>): void {
private _setViewHandler(ev: CustomEvent<CarouselSelected>): 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();
+3 -3
View File
@@ -41,7 +41,7 @@ export class AdvancedCameraCardLiveGrid extends LitElement {
@property({ attribute: false })
public triggeredCameraIDs?: Set<string>;
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 (
+1 -1
View File
@@ -33,7 +33,7 @@ export class AdvancedCameraCardLive extends LitElement {
@property({ attribute: false })
public triggeredCameraIDs?: Set<string>;
protected _controller = new LiveController(this);
private _controller = new LiveController(this);
protected render(): TemplateResult | void {
if (!this.hass || !this.cameraManager) {
+10 -10
View File
@@ -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<MediaPlayerElement> = createRef();
private _refProvider: Ref<MediaPlayerElement> = 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 <advanced-camera-card-live> element first renders in
// the background. These calls fail without waiting for loading here.
protected _importPromises: Promise<unknown>[] = [];
private _importPromises: Promise<unknown>[] = [];
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` <advanced-camera-card-media-dimensions-container
.dimensionsConfig=${config?.dimensions}
@@ -53,11 +53,11 @@ export class AdvancedCameraCardGo2RTC extends LitElement implements MediaPlayer
public controls = false;
@state()
protected _message: Message | null = null;
private _message: Message | null = null;
protected _player?: VideoRTC;
private _player?: VideoRTC;
protected _mediaPlayerController = new VideoMediaPlayerController(
private _mediaPlayerController = new VideoMediaPlayerController(
this,
() => this._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<string | null> {
private async _getPlayerSource(): Promise<string | null> {
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<void> {
private async _createPlayer(): Promise<void> {
const src = await this._getPlayerSource();
if (!src) {
return;
+1 -1
View File
@@ -24,7 +24,7 @@ export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer
@property({ attribute: true, type: Boolean })
public controls = false;
protected _playerRef: Ref<MediaPlayerElement> = createRef();
private _playerRef: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete;
+1 -1
View File
@@ -19,7 +19,7 @@ export class AdvancedCameraCardLiveImage extends LitElement implements MediaPlay
@property({ attribute: false })
public cameraConfig?: CameraConfig;
protected _refImage: Ref<MediaPlayerElement> = createRef();
private _refImage: Ref<MediaPlayerElement> = createRef();
public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete;
+9 -9
View File
@@ -39,7 +39,7 @@ const JSMPEG_URL_SIGN_REFRESH_THRESHOLD_SECONDS = 1 * 60 * 60;
@customElement('advanced-camera-card-live-jsmpeg')
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<JSMpeg.VideoElement> {
private async _createJSMPEGPlayer(url: string): Promise<JSMpeg.VideoElement> {
this._jsmpegVideoPlayer = await new Promise<JSMpeg.VideoElement>((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<void> {
private async _refreshPlayer(): Promise<void> {
if (!this.hass) {
return;
}
+8 -10
View File
@@ -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<CustomElementConstructor | undefined> {
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 & {
+3 -3
View File
@@ -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<HTMLElement> = createRef();
protected _refOuterContainer: Ref<HTMLElement> = createRef();
private _refInnerContainer: Ref<HTMLElement> = createRef();
private _refOuterContainer: Ref<HTMLElement> = createRef();
protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('dimensionsConfig')) {
+12 -12
View File
@@ -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<AdvancedCameraCardSelect> = createRef();
protected _refCamera: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhen: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhenFrom: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refWhenTo: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refWhat: Ref<AdvancedCameraCardSelect> = createRef();
protected _refWhere: Ref<AdvancedCameraCardSelect> = createRef();
protected _refFavorite: Ref<AdvancedCameraCardSelect> = createRef();
protected _refReviewed: Ref<AdvancedCameraCardSelect> = createRef();
protected _refSeverity: Ref<AdvancedCameraCardSelect> = createRef();
protected _refTags: Ref<AdvancedCameraCardSelect> = createRef();
private _refMediaType: Ref<AdvancedCameraCardSelect> = createRef();
private _refCamera: Ref<AdvancedCameraCardSelect> = createRef();
private _refWhen: Ref<AdvancedCameraCardSelect> = createRef();
private _refWhenFrom: Ref<AdvancedCameraCardDatePicker> = createRef();
private _refWhenTo: Ref<AdvancedCameraCardDatePicker> = createRef();
private _refWhat: Ref<AdvancedCameraCardSelect> = createRef();
private _refWhere: Ref<AdvancedCameraCardSelect> = createRef();
private _refFavorite: Ref<AdvancedCameraCardSelect> = createRef();
private _refReviewed: Ref<AdvancedCameraCardSelect> = createRef();
private _refSeverity: Ref<AdvancedCameraCardSelect> = createRef();
private _refTags: Ref<AdvancedCameraCardSelect> = createRef();
protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('viewManagerEpoch')) {
+2 -2
View File
@@ -20,8 +20,8 @@ export class AdvancedCameraCardMediaGrid extends LitElement {
@property({ attribute: false })
public displayConfig?: ViewDisplayConfig;
protected _controller: MediaGridController | null = null;
protected _refSlot: Ref<HTMLSlotElement> = createRef();
private _controller: MediaGridController | null = null;
private _refSlot: Ref<HTMLSlotElement> = createRef();
connectedCallback(): void {
super.connectedCallback();
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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,
+8 -8
View File
@@ -12,7 +12,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
@property({ attribute: false })
public message: OverlayMessage | null = null;
protected _refMessage: Ref<HTMLElement> = createRef();
private _refMessage: Ref<HTMLElement> = 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`
<div
@@ -81,7 +81,7 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
`;
}
protected async _handleControlClick(control: OverlayMessageControl): Promise<void> {
private async _handleControlClick(control: OverlayMessageControl): Promise<void> {
const result = await control.callback();
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();
+2 -2
View File
@@ -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')) {
+3 -3
View File
@@ -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<SelectElement> = createRef();
private _previouslyReportedValue?: SelectValues;
private _refSelect: Ref<SelectElement> = 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
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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;
}
+4 -4
View File
@@ -34,10 +34,10 @@ export class AdvancedCameraCardSubmenuSelectButton extends LitElement {
public entityRegistryManager?: EntityRegistryManager;
@state()
protected _optionTitles?: Record<string, string>;
private _optionTitles?: Record<string, string>;
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<void> {
private async _refreshOptionTitles(): Promise<void> {
if (!this.hass || !this.submenuSelect) {
return;
}
+4 -4
View File
@@ -19,9 +19,9 @@ export class AdvancedCameraCardSurroundBasic extends LitElement {
right?: DrawerIcons;
};
protected _refDrawerLeft: Ref<AdvancedCameraCardDrawer> = createRef();
protected _refDrawerRight: Ref<AdvancedCameraCardDrawer> = createRef();
protected _boundDrawerHandler = this._drawerHandler.bind(this);
private _refDrawerLeft: Ref<AdvancedCameraCardDrawer> = createRef();
private _refDrawerRight: Ref<AdvancedCameraCardDrawer> = 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<AdvancedCameraCardDrawerOpen>).detail.drawer;
const open = ev.type.endsWith(':open');
if (drawer === 'left' && this._refDrawerLeft.value) {
+1 -1
View File
@@ -54,7 +54,7 @@ export class AdvancedCameraCardSurround extends LitElement {
/**
* Determine if a drawer is being used.
*/
protected _hasDrawer(): boolean {
private _hasDrawer(): boolean {
return (
!!this.thumbnailConfig && ['left', 'right'].includes(this.thumbnailConfig.mode)
);
+9 -9
View File
@@ -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<ThumbnailMediaSelect>(
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 {
</advanced-camera-card-thumbnail>`;
}
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') {
@@ -25,10 +25,10 @@ export class AdvancedCameraCardThumbnailFeatureThumbnail extends LitElement {
@property({ attribute: false })
public hass?: HomeAssistant;
protected _embedThumbnailTask?: Task<FetchThumbnailTaskArgs, string | null>;
private _embedThumbnailTask?: Task<FetchThumbnailTaskArgs, string | null>;
// Only load thumbnails on view in case there is a very large number of them.
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)
+3 -3
View File
@@ -137,9 +137,9 @@ export class AdvancedCameraCardTimelineCore extends LitElement {
@property({ attribute: false })
public itemClickAction?: TimelineItemClickAction;
protected _refDatePicker: Ref<AdvancedCameraCardDatePicker> = createRef();
protected _refTimeline: Ref<HTMLElement> = createRef();
protected _controller: TimelineController = new TimelineController(this);
private _refDatePicker: Ref<AdvancedCameraCardDatePicker> = createRef();
private _refTimeline: Ref<HTMLElement> = createRef();
private _controller: TimelineController = new TimelineController(this);
protected render(): TemplateResult | void {
if (!this.hass || !this.timelineConfig) {

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