Results of running ts-prune.
This commit is contained in:
+3
-1
@@ -70,12 +70,14 @@
|
||||
"rollup-plugin-typescript2": "^0.33.0",
|
||||
"rollup-plugin-visualizer": "^5.8.2",
|
||||
"sass": "^1.54.9",
|
||||
"ts-prune": "^0.10.3",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "rollup -c --watch",
|
||||
"build": "yarn run lint && yarn run rollup",
|
||||
"lint": "eslint 'src/**/*.ts'",
|
||||
"rollup": "rollup -c"
|
||||
"rollup": "rollup -c",
|
||||
"prune": "ts-prune"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ const getActionHandler = (): ActionHandler => {
|
||||
return actionhandler as ActionHandler;
|
||||
};
|
||||
|
||||
export const actionHandlerBind = (
|
||||
const actionHandlerBind = (
|
||||
element: ActionHandlerElement,
|
||||
options?: FrigateCardActionHandlerOptions,
|
||||
): void => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import isEqual from 'lodash-es/isEqual';
|
||||
import orderBy from 'lodash-es/orderBy';
|
||||
import sortedUniqBy from 'lodash-es/sortedUniqBy';
|
||||
import { RecordingSegment } from '../types';
|
||||
import { DateRange, MemoryRangeSet } from './range';
|
||||
import { DataQuery, QueryResults } from './types';
|
||||
import { DataQuery, QueryResults, RecordingSegment } from './types';
|
||||
|
||||
interface RequestCacheItem<Request, Response> {
|
||||
request: Request;
|
||||
@@ -17,7 +16,7 @@ interface CameraManagerCache<Request, Response> {
|
||||
set(request: Request, response: Response, expiry?: Date): void;
|
||||
}
|
||||
|
||||
export class MemoryRequestCache<Request, Response>
|
||||
class MemoryRequestCache<Request, Response>
|
||||
implements CameraManagerCache<Request, Response>
|
||||
{
|
||||
protected _data: RequestCacheItem<Request, Response>[] = [];
|
||||
@@ -62,7 +61,7 @@ export class MemoryRequestCache<Request, Response>
|
||||
|
||||
export class RequestCache extends MemoryRequestCache<DataQuery, QueryResults> {}
|
||||
|
||||
export class MemoryRangedCache<Data> {
|
||||
class MemoryRangedCache<Data> {
|
||||
protected _ranges: MemoryRangeSet = new MemoryRangeSet();
|
||||
protected _data: Data[] = [];
|
||||
protected _timeFunc: (data: Data) => number;
|
||||
|
||||
@@ -5,7 +5,7 @@ const dayStringToDate = (arg: unknown): Date | unknown => {
|
||||
return typeof arg === 'string' ? dayToDate(arg) : arg;
|
||||
};
|
||||
|
||||
export const eventSchema = z.object({
|
||||
const eventSchema = z.object({
|
||||
camera: z.string(),
|
||||
end_time: z.number().nullable(),
|
||||
false_positive: z.boolean().nullable(),
|
||||
|
||||
@@ -37,7 +37,7 @@ import sum from 'lodash-es/sum';
|
||||
import add from 'date-fns/add';
|
||||
import { log } from '../utils/debug.js';
|
||||
|
||||
export class QueryClassifier {
|
||||
class QueryClassifier {
|
||||
public static isEventQuery(query: DataQuery | PartialDataQuery): query is EventQuery {
|
||||
return query.type === QueryType.Event;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ export class QueryClassifier {
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryResultClassifier {
|
||||
class QueryResultClassifier {
|
||||
public static isEventQueryResult(
|
||||
queryResults: QueryResults,
|
||||
): queryResults is EventQueryResults {
|
||||
|
||||
@@ -26,12 +26,12 @@ export interface DataQuery {
|
||||
}
|
||||
export type PartialDataQuery = Partial<DataQuery>;
|
||||
|
||||
export interface TimeBasedDataQuery {
|
||||
interface TimeBasedDataQuery {
|
||||
start: Date;
|
||||
end: Date;
|
||||
}
|
||||
|
||||
export interface LimitedDataQuery {
|
||||
interface LimitedDataQuery {
|
||||
limit: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class ConditionStateRequestEvent extends Event {
|
||||
public conditionState?: ConditionState;
|
||||
}
|
||||
|
||||
export function evaluateCondition(
|
||||
function evaluateCondition(
|
||||
condition?: Readonly<FrigateCardCondition>,
|
||||
state?: Readonly<ConditionState>,
|
||||
): boolean {
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ type InitializedType = 'initialized' | 'initializing';
|
||||
* Main FrigateCard class.
|
||||
*/
|
||||
@customElement('frigate-card')
|
||||
export class FrigateCard extends LitElement {
|
||||
class FrigateCard extends LitElement {
|
||||
@state()
|
||||
protected _hass?: ExtendedHomeAssistant;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const defaultOptions: OptionsType = {
|
||||
breakpoints: {},
|
||||
};
|
||||
|
||||
export type AutoMediaOptionsType = Partial<OptionsType>
|
||||
type AutoMediaOptionsType = Partial<OptionsType>
|
||||
|
||||
export type AutoMediaType = CreatePluginType<
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreatePluginType } from 'embla-carousel/components/Plugins';
|
||||
import EmblaCarousel, { EmblaCarouselType, EmblaEventType } from 'embla-carousel';
|
||||
import { LazyUnloadCondition } from '../../types';
|
||||
|
||||
export type OptionsType = CreateOptionsType<{
|
||||
type OptionsType = CreateOptionsType<{
|
||||
// Number of slides to lazyload left/right of selected (0 == only selected
|
||||
// slide).
|
||||
lazyLoadCount?: number;
|
||||
@@ -13,15 +13,15 @@ export type OptionsType = CreateOptionsType<{
|
||||
lazyUnloadCallback?: (index: number, slide: HTMLElement) => void;
|
||||
}>;
|
||||
|
||||
export const defaultOptions: OptionsType = {
|
||||
const defaultOptions: OptionsType = {
|
||||
active: true,
|
||||
breakpoints: {},
|
||||
lazyLoadCount: 0,
|
||||
};
|
||||
|
||||
export type LazyloadOptionsType = Partial<OptionsType>;
|
||||
type LazyloadOptionsType = Partial<OptionsType>;
|
||||
|
||||
export type LazyloadType = CreatePluginType<
|
||||
type LazyloadType = CreatePluginType<
|
||||
{
|
||||
hasLazyloaded(index: number): boolean;
|
||||
},
|
||||
|
||||
@@ -28,12 +28,12 @@ const getEmptyImageSrc = (width: number, height: number) =>
|
||||
`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}"%3E%3C/svg%3E`;
|
||||
export const IMG_EMPTY = getEmptyImageSrc(16, 9);
|
||||
|
||||
export interface CarouselMediaLoadedInfo {
|
||||
interface CarouselMediaLoadedInfo {
|
||||
slide: number;
|
||||
mediaLoadedInfo: MediaLoadedInfo;
|
||||
}
|
||||
|
||||
export interface CarouselMediaUnloadedInfo {
|
||||
interface CarouselMediaUnloadedInfo {
|
||||
slide: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export type MediaFilterControls = {
|
||||
};
|
||||
|
||||
@customElement('frigate-card-media-filter-core')
|
||||
export class FrigateCardMediaFilterCore extends LitElement {
|
||||
class FrigateCardMediaFilterCore extends LitElement {
|
||||
@property({ attribute: false })
|
||||
public hass?: ExtendedHomeAssistant;
|
||||
|
||||
|
||||
+2
-2
@@ -117,7 +117,7 @@ export const isConfigUpgradeable = function (obj: RawFrigateCardConfig): boolean
|
||||
* @param obj Configuration object.
|
||||
* @returns `true` if the configuration was modified.
|
||||
*/
|
||||
export const trimConfig = function (obj: RawFrigateCardConfig): boolean {
|
||||
const trimConfig = function (obj: RawFrigateCardConfig): boolean {
|
||||
const keys = Object.keys(obj);
|
||||
let modified = false;
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
@@ -221,7 +221,7 @@ const deleteProperty = function (_value: unknown): number | null | undefined {
|
||||
* @param transform An optional transform for the value.
|
||||
* @returns `true` if the configuration was modified.
|
||||
*/
|
||||
export const moveConfigValue = (
|
||||
const moveConfigValue = (
|
||||
obj: RawFrigateCardConfig,
|
||||
oldPath: string,
|
||||
newPath: string,
|
||||
|
||||
+7
-8
@@ -35,7 +35,7 @@ export const CONF_CAMERAS_ARRAY_TRIGGERS_ENTITIES =
|
||||
|
||||
export const CONF_ELEMENTS = 'elements' as const;
|
||||
|
||||
export const CONF_VIEW = 'view' as const;
|
||||
const CONF_VIEW = 'view' as const;
|
||||
export const CONF_VIEW_CAMERA_SELECT = `${CONF_VIEW}.camera_select` as const;
|
||||
export const CONF_VIEW_DARK_MODE = `${CONF_VIEW}.dark_mode` as const;
|
||||
export const CONF_VIEW_DEFAULT = `${CONF_VIEW}.default` as const;
|
||||
@@ -53,7 +53,7 @@ export const CONF_VIEW_SCAN_UNTRIGGER_RESET =
|
||||
export const CONF_VIEW_SCAN_UNTRIGGER_SECONDS =
|
||||
`${CONF_VIEW_SCAN}.untrigger_seconds` as const;
|
||||
|
||||
export const CONF_EVENT_GALLERY = 'event_gallery' as const;
|
||||
const CONF_EVENT_GALLERY = 'event_gallery' as const;
|
||||
export const CONF_EVENT_GALLERY_CONTROLS_FILTER_MODE =
|
||||
`${CONF_EVENT_GALLERY}.controls.filter.mode` as const;
|
||||
export const CONF_EVENT_GALLERY_CONTROLS_THUMBNAILS_SHOW_DETAILS =
|
||||
@@ -111,7 +111,7 @@ export const CONF_MEDIA_VIEWER_LAYOUT_POSITION_X =
|
||||
export const CONF_MEDIA_VIEWER_LAYOUT_POSITION_Y =
|
||||
`${CONF_MEDIA_VIEWER}.layout.position.y` as const;
|
||||
|
||||
export const CONF_LIVE = 'live' as const;
|
||||
const CONF_LIVE = 'live' as const;
|
||||
export const CONF_LIVE_AUTO_PLAY = `${CONF_LIVE}.auto_play` as const;
|
||||
export const CONF_LIVE_AUTO_PAUSE = `${CONF_LIVE}.auto_pause` as const;
|
||||
export const CONF_LIVE_AUTO_MUTE = `${CONF_LIVE}.auto_mute` as const;
|
||||
@@ -151,7 +151,6 @@ export const CONF_LIVE_LAYOUT_FIT = `${CONF_LIVE}.layout.fit` as const;
|
||||
export const CONF_LIVE_LAYOUT_POSITION_X = `${CONF_LIVE}.layout.position.x` as const;
|
||||
export const CONF_LIVE_LAYOUT_POSITION_Y = `${CONF_LIVE}.layout.position.y` as const;
|
||||
export const CONF_LIVE_DRAGGABLE = `${CONF_LIVE}.draggable` as const;
|
||||
export const CONF_LIVE_JSMPEG = `${CONF_LIVE}.jsmpeg` as const;
|
||||
export const CONF_LIVE_LAZY_LOAD = `${CONF_LIVE}.lazy_load` as const;
|
||||
export const CONF_LIVE_LAZY_UNLOAD = `${CONF_LIVE}.lazy_unload` as const;
|
||||
export const CONF_LIVE_PRELOAD = `${CONF_LIVE}.preload` as const;
|
||||
@@ -160,7 +159,7 @@ export const CONF_LIVE_SHOW_IMAGE_DURING_LOAD =
|
||||
`${CONF_LIVE}.show_image_during_load` as const;
|
||||
export const CONF_LIVE_WEBRTC_CARD = `${CONF_LIVE}.webrtc_card` as const;
|
||||
|
||||
export const CONF_IMAGE = 'image' as const;
|
||||
const CONF_IMAGE = 'image' as const;
|
||||
export const CONF_IMAGE_LAYOUT_FIT = `${CONF_IMAGE}.layout.fit` as const;
|
||||
export const CONF_IMAGE_LAYOUT_POSITION_X = `${CONF_IMAGE}.layout.position.x` as const;
|
||||
export const CONF_IMAGE_LAYOUT_POSITION_Y = `${CONF_IMAGE}.layout.position.y` as const;
|
||||
@@ -168,7 +167,7 @@ export const CONF_IMAGE_MODE = `${CONF_IMAGE}.mode` as const;
|
||||
export const CONF_IMAGE_REFRESH_SECONDS = `${CONF_IMAGE}.refresh_seconds` as const;
|
||||
export const CONF_IMAGE_URL = `${CONF_IMAGE}.url` as const;
|
||||
|
||||
export const CONF_TIMELINE = 'timeline' as const;
|
||||
const CONF_TIMELINE = 'timeline' as const;
|
||||
export const CONF_TIMELINE_WINDOW_SECONDS = `${CONF_TIMELINE}.window_seconds` as const;
|
||||
export const CONF_TIMELINE_CLUSTERING_THRESHOLD =
|
||||
`${CONF_TIMELINE}.clustering_threshold` as const;
|
||||
@@ -205,14 +204,14 @@ export const CONF_MENU_BUTTONS_MEDIA_PLAYER =
|
||||
export const CONF_MENU_BUTTONS_SNAPSHOTS = `${CONF_MENU}.buttons.snapshots` as const;
|
||||
export const CONF_MENU_BUTTONS_TIMELINE = `${CONF_MENU}.buttons.timeline` as const;
|
||||
|
||||
export const CONF_DIMENSIONS = 'dimensions' as const;
|
||||
const CONF_DIMENSIONS = 'dimensions' as const;
|
||||
export const CONF_DIMENSIONS_ASPECT_RATIO = `${CONF_DIMENSIONS}.aspect_ratio` as const;
|
||||
export const CONF_DIMENSIONS_ASPECT_RATIO_MODE =
|
||||
`${CONF_DIMENSIONS}.aspect_ratio_mode` as const;
|
||||
|
||||
export const CONF_OVERRIDES = 'overrides' as const;
|
||||
|
||||
export const CONF_PERFORMANCE = 'performance' as const;
|
||||
const CONF_PERFORMANCE = 'performance' as const;
|
||||
export const CONF_PERFORMANCE_FEATURES_ANIMATED_PROGRESS_INDICATOR = `${CONF_PERFORMANCE}.features.animated_progress_indicator`;
|
||||
export const CONF_PERFORMANCE_PROFILE = `${CONF_PERFORMANCE}.profile`;
|
||||
export const CONF_PERFORMANCE_STYLE_BOX_SHADOW = `${CONF_PERFORMANCE}.style.box_shadow`;
|
||||
|
||||
+8
-70
@@ -64,7 +64,7 @@ const FRIGATE_MENU_STYLES = [
|
||||
const FRIGATE_MENU_POSITIONS = ['left', 'right', 'top', 'bottom'] as const;
|
||||
const FRIGATE_MENU_ALIGNMENTS = FRIGATE_MENU_POSITIONS;
|
||||
|
||||
export const FRIGATE_MENU_PRIORITY_DEFAULT = 50;
|
||||
const FRIGATE_MENU_PRIORITY_DEFAULT = 50;
|
||||
export const FRIGATE_MENU_PRIORITY_MAX = 100;
|
||||
|
||||
const LIVE_PROVIDERS = ['auto', 'image', 'ha', 'frigate-jsmpeg', 'webrtc-card'] as const;
|
||||
@@ -131,7 +131,7 @@ const actionBaseSchema = z.object({
|
||||
// HA accepts either a boolean or a ConfirmationRestrictionConfig object.
|
||||
// `custom-card-helpers` currently only supports the latter. For maximum
|
||||
// compatibility, this card supports what HA supports.
|
||||
export interface ExtendedConfirmationRestrictionConfig {
|
||||
interface ExtendedConfirmationRestrictionConfig {
|
||||
confirmation?: boolean | ConfirmationRestrictionConfig;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ const customSchema = z
|
||||
/**
|
||||
* Camera configuration section
|
||||
*/
|
||||
export const cameraConfigDefault = {
|
||||
const cameraConfigDefault = {
|
||||
live_provider: 'auto' as const,
|
||||
frigate: {
|
||||
client_id: 'frigate' as const,
|
||||
@@ -460,12 +460,12 @@ const menuBaseSchema = z.object({
|
||||
icon: z.string().optional(),
|
||||
});
|
||||
|
||||
export const menuIconSchema = menuBaseSchema.merge(iconSchema).extend({
|
||||
const menuIconSchema = menuBaseSchema.merge(iconSchema).extend({
|
||||
type: z.literal('custom:frigate-card-menu-icon'),
|
||||
});
|
||||
export type MenuIcon = z.infer<typeof menuIconSchema>;
|
||||
|
||||
export const menuStateIconSchema = menuBaseSchema
|
||||
const menuStateIconSchema = menuBaseSchema
|
||||
.merge(stateIconSchema)
|
||||
.extend({
|
||||
type: z.literal('custom:frigate-card-menu-state-icon'),
|
||||
@@ -573,7 +573,6 @@ const pictureElementSchema = z.union([
|
||||
conditionalSchema,
|
||||
customSchema,
|
||||
]);
|
||||
export type PictureElement = z.infer<typeof pictureElementSchema>;
|
||||
|
||||
const pictureElementsSchema = pictureElementSchema.array().optional();
|
||||
export type PictureElements = z.infer<typeof pictureElementsSchema>;
|
||||
@@ -643,7 +642,7 @@ const viewConfigSchema = z
|
||||
* Image view configuration section.
|
||||
*/
|
||||
|
||||
export const IMAGE_MODES = ['screensaver', 'camera', 'url'] as const;
|
||||
const IMAGE_MODES = ['screensaver', 'camera', 'url'] as const;
|
||||
const imageConfigDefault = {
|
||||
mode: 'url' as const,
|
||||
refresh_seconds: 0,
|
||||
@@ -701,8 +700,6 @@ const timelineCoreConfigDefault = {
|
||||
};
|
||||
|
||||
const timelineMediaSchema = z.enum(['all', 'clips', 'snapshots']);
|
||||
export type TimelineMedia = z.infer<typeof timelineMediaSchema>;
|
||||
|
||||
const timelineCoreConfigSchema = z.object({
|
||||
clustering_threshold: z
|
||||
.number()
|
||||
@@ -1011,9 +1008,6 @@ const viewerNextPreviousControlConfigSchema = nextPreviousControlConfigSchema.ex
|
||||
viewerConfigDefault.controls.next_previous.size,
|
||||
),
|
||||
});
|
||||
export type ViewerNextPreviousControlConfig = z.infer<
|
||||
typeof viewerNextPreviousControlConfigSchema
|
||||
>;
|
||||
|
||||
const viewerConfigSchema = z
|
||||
.object({
|
||||
@@ -1228,7 +1222,7 @@ const debugConfigSchema = z
|
||||
logging: z.boolean().default(debugConfigDefault.logging),
|
||||
})
|
||||
.default(debugConfigDefault);
|
||||
export type DebugConfig = z.infer<typeof debugConfigSchema>;
|
||||
type DebugConfig = z.infer<typeof debugConfigSchema>;
|
||||
|
||||
export interface CardWideConfig {
|
||||
performance?: PerformanceConfig;
|
||||
@@ -1294,40 +1288,6 @@ export interface ExtendedHomeAssistant extends HomeAssistant {
|
||||
};
|
||||
}
|
||||
|
||||
export interface BrowseMediaQueryParameters {
|
||||
// ========================================
|
||||
// Parameters used to construct media query
|
||||
// ========================================
|
||||
mediaType?: 'clips' | 'snapshots';
|
||||
clientId: string;
|
||||
cameraName: string;
|
||||
label?: string;
|
||||
zone?: string;
|
||||
before?: number;
|
||||
after?: number;
|
||||
unlimited?: boolean;
|
||||
|
||||
// ========================================
|
||||
// Parameters used to differentiate results
|
||||
// ========================================
|
||||
// Optional title to be used for separating results when merging multiple
|
||||
// sets of results. See `mergeFrigateBrowseMediaSources()` .
|
||||
title?: string;
|
||||
|
||||
// Optional camera-id to which this query is associated. May be used to map
|
||||
// results to a particular camera within the card.
|
||||
cameraID?: string;
|
||||
}
|
||||
|
||||
export interface BrowseRecordingQueryParameters {
|
||||
clientId: string;
|
||||
cameraName: string;
|
||||
year: number;
|
||||
month: number;
|
||||
day: number;
|
||||
hour: number;
|
||||
}
|
||||
|
||||
export interface MediaLoadedInfo {
|
||||
width: number;
|
||||
height: number;
|
||||
@@ -1380,28 +1340,6 @@ export interface CardHelpers {
|
||||
* Home Assistant API types.
|
||||
*/
|
||||
|
||||
export const MEDIA_CLASS_PLAYLIST = 'playlist' as const;
|
||||
export const MEDIA_CLASS_VIDEO = 'video' as const;
|
||||
export const MEDIA_TYPE_PLAYLIST = 'playlist' as const;
|
||||
export const MEDIA_TYPE_IMAGE = 'image' as const;
|
||||
export const MEDIA_TYPE_VIDEO = 'video' as const;
|
||||
|
||||
// Recursive type, cannot use type interference:
|
||||
// See: https://github.com/colinhacks/zod#recursive-types
|
||||
//
|
||||
// Server side data-type defined here: https://github.com/home-assistant/core/blob/dev/homeassistant/components/media_player/browse_media.py#L46
|
||||
export interface BrowseMediaSource {
|
||||
title: string;
|
||||
media_class: string;
|
||||
media_content_type: string;
|
||||
media_content_id: string;
|
||||
can_play: boolean;
|
||||
can_expand: boolean;
|
||||
children_media_class?: string | null;
|
||||
thumbnail: string | null;
|
||||
children?: BrowseMediaSource[] | null;
|
||||
}
|
||||
|
||||
// Server side data-type defined here: https://github.com/home-assistant/core/blob/dev/homeassistant/components/media_source/models.py
|
||||
export const resolvedMediaSchema = z.object({
|
||||
url: z.string(),
|
||||
@@ -1414,7 +1352,7 @@ export const signedPathSchema = z.object({
|
||||
});
|
||||
export type SignedPath = z.infer<typeof signedPathSchema>;
|
||||
|
||||
export const entitySchema = z.object({
|
||||
const entitySchema = z.object({
|
||||
config_entry_id: z.string().nullable(),
|
||||
disabled_by: z.string().nullable(),
|
||||
entity_id: z.string(),
|
||||
|
||||
@@ -10,6 +10,7 @@ export const log = (cardWideConfig?: CardWideConfig, ...args: unknown[]) => {
|
||||
* For debug purposes only.
|
||||
* @param seconds
|
||||
*/
|
||||
// ts-prune-ignore-next
|
||||
export const sleep = async (seconds: number) => {
|
||||
await new Promise((r) => setTimeout(r, seconds * 1000));
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ const deviceSchema = z.object({
|
||||
config_entries: z.string().array(),
|
||||
manufacturer: z.string().nullable(),
|
||||
})
|
||||
export const deviceListSchema = deviceSchema.array();
|
||||
const deviceListSchema = deviceSchema.array();
|
||||
export type DeviceList = z.infer<typeof deviceListSchema>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -205,7 +205,7 @@ function computeStyle(state: HassEntity): StyleInfo {
|
||||
* @param stateObj The HassEntity object from `hass.states`.
|
||||
* @returns A string state, e.g. 'on'.
|
||||
*/
|
||||
export const computeActiveState = (stateObj: HassEntity): string => {
|
||||
const computeActiveState = (stateObj: HassEntity): string => {
|
||||
const domain = stateObj.entity_id.split('.')[0];
|
||||
let state = stateObj.state;
|
||||
|
||||
|
||||
@@ -4,11 +4,7 @@ import {
|
||||
HassEntityBase
|
||||
} from 'home-assistant-js-websocket';
|
||||
|
||||
export const UPDATE_SUPPORT_INSTALL = 1;
|
||||
export const UPDATE_SUPPORT_SPECIFIC_VERSION = 2;
|
||||
export const UPDATE_SUPPORT_PROGRESS = 4;
|
||||
export const UPDATE_SUPPORT_BACKUP = 8;
|
||||
export const UPDATE_SUPPORT_RELEASE_NOTES = 16;
|
||||
const UPDATE_SUPPORT_PROGRESS = 4;
|
||||
|
||||
interface UpdateEntityAttributes extends HassEntityAttributeBase {
|
||||
auto_update: boolean | null;
|
||||
@@ -28,7 +24,7 @@ export interface UpdateEntity extends HassEntityBase {
|
||||
export const supportsFeature = (stateObj: HassEntity, feature: number): boolean =>
|
||||
((stateObj.attributes.supported_features ?? 0) & feature) !== 0;
|
||||
|
||||
export const updateUsesProgress = (entity: UpdateEntity): boolean =>
|
||||
const updateUsesProgress = (entity: UpdateEntity): boolean =>
|
||||
supportsFeature(entity, UPDATE_SUPPORT_PROGRESS) &&
|
||||
typeof entity.attributes.in_progress === 'number';
|
||||
|
||||
|
||||
@@ -21,22 +21,3 @@ export const alarmPanelIcon = (state?: string) => {
|
||||
return 'mdi:shield';
|
||||
}
|
||||
};
|
||||
|
||||
export const alarmPanelIconAction = (state?: string) => {
|
||||
switch (state) {
|
||||
case 'armed_away':
|
||||
return 'mdi:shield-lock-outline';
|
||||
case 'armed_vacation':
|
||||
return 'mdi:shield-airplane-outline';
|
||||
case 'armed_home':
|
||||
return 'mdi:shield-home-outline';
|
||||
case 'armed_night':
|
||||
return 'mdi:shield-moon-outline';
|
||||
case 'armed_custom_bypass':
|
||||
return 'mdi:shield-half-full';
|
||||
case 'disarmed':
|
||||
return 'mdi:shield-off-outline';
|
||||
default:
|
||||
return 'mdi:shield-outline';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,27 +87,3 @@ export const coverIcon = (state?: string, entity?: HassEntity): string => {
|
||||
return 'mdi:window-open';
|
||||
}
|
||||
};
|
||||
|
||||
export const computeOpenIcon = (stateObj: HassEntity): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case 'awning':
|
||||
case 'curtain':
|
||||
case 'door':
|
||||
case 'gate':
|
||||
return 'mdi:arrow-expand-horizontal';
|
||||
default:
|
||||
return 'mdi:arrow-up';
|
||||
}
|
||||
};
|
||||
|
||||
export const computeCloseIcon = (stateObj: HassEntity): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case 'awning':
|
||||
case 'curtain':
|
||||
case 'door':
|
||||
case 'gate':
|
||||
return 'mdi:arrow-collapse-horizontal';
|
||||
default:
|
||||
return 'mdi:arrow-down';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ const batteryStateIcon = (
|
||||
return batteryIcon(battery, batteryCharging);
|
||||
};
|
||||
|
||||
export const batteryIcon = (
|
||||
const batteryIcon = (
|
||||
batteryState: number | string,
|
||||
batteryCharging?: boolean,
|
||||
) => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// to give a cleaner UI appearance, see:
|
||||
// https://github.com/dermotduffy/frigate-hass-card/issues/856
|
||||
export const MEDIA_LOAD_CONTROLS_HIDE_SECONDS = 2;
|
||||
export const MEDIA_SEEK_CONTROLS_HIDE_SECONDS = 1;
|
||||
const MEDIA_SEEK_CONTROLS_HIDE_SECONDS = 1;
|
||||
|
||||
/**
|
||||
* Temporarily hide media controls.
|
||||
|
||||
@@ -8,7 +8,7 @@ import { HomeAssistant } from 'custom-card-helpers';
|
||||
* @param thumbnailURL The thumbnail URL.
|
||||
* @returns A base64 encoded data URL for the thumbnail.
|
||||
*/
|
||||
export const fetchThumbnail = async (
|
||||
const fetchThumbnail = async (
|
||||
hass: HomeAssistant,
|
||||
thumbnailURL: string,
|
||||
): Promise<string | null> => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { EventQuery, MediaQuery, RecordingQuery } from '../camera-manager/types.
|
||||
|
||||
export type MediaQueries = EventMediaQueries | RecordingMediaQueries;
|
||||
|
||||
export class MediaQueriesBase<T extends MediaQuery> {
|
||||
class MediaQueriesBase<T extends MediaQuery> {
|
||||
protected _queries: T[] | null = null;
|
||||
|
||||
public constructor(queries?: T[]) {
|
||||
|
||||
+2
-4
@@ -1,5 +1,3 @@
|
||||
// Minor / later:
|
||||
// - TODO: ts-prune https://camchenry.com/blog/deleting-dead-code-in-typescript
|
||||
// Gallery:
|
||||
// - TODO: Filter panel expands from right can occasionally 'stick' open.
|
||||
|
||||
@@ -14,7 +12,7 @@ import { dispatchFrigateCardEvent } from '../utils/basic.js';
|
||||
import { MediaQueries } from './media-queries';
|
||||
import { MediaQueriesResults } from './media-queries-results';
|
||||
|
||||
export interface ViewEvolveParameters {
|
||||
interface ViewEvolveParameters {
|
||||
view?: FrigateCardView;
|
||||
camera?: string;
|
||||
query?: MediaQueries | null;
|
||||
@@ -22,7 +20,7 @@ export interface ViewEvolveParameters {
|
||||
context?: ViewContext | null;
|
||||
}
|
||||
|
||||
export interface ViewParameters extends ViewEvolveParameters {
|
||||
interface ViewParameters extends ViewEvolveParameters {
|
||||
view: FrigateCardView;
|
||||
camera: string;
|
||||
}
|
||||
|
||||
@@ -521,6 +521,16 @@
|
||||
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
|
||||
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
|
||||
|
||||
"@ts-morph/common@~0.12.3":
|
||||
version "0.12.3"
|
||||
resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.12.3.tgz#a96e250217cd30e480ab22ec6a0ebbe65fd784ff"
|
||||
integrity sha512-4tUmeLyXJnJWvTFOKtcNJ1yh0a3SsTLi2MUoyj8iUNznFRN1ZquaNe7Oukqrnki2FzZkm0J9adCNLDZxUzvj+w==
|
||||
dependencies:
|
||||
fast-glob "^3.2.7"
|
||||
minimatch "^3.0.4"
|
||||
mkdirp "^1.0.4"
|
||||
path-browserify "^1.0.1"
|
||||
|
||||
"@types/bluebird@^3.5.36":
|
||||
version "3.5.36"
|
||||
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.36.tgz#00d9301d4dc35c2f6465a8aec634bb533674c652"
|
||||
@@ -870,6 +880,11 @@ cliui@^7.0.2:
|
||||
strip-ansi "^6.0.0"
|
||||
wrap-ansi "^7.0.0"
|
||||
|
||||
code-block-writer@^11.0.0:
|
||||
version "11.0.3"
|
||||
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-11.0.3.tgz#9eec2993edfb79bfae845fbc093758c0a0b73b76"
|
||||
integrity sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==
|
||||
|
||||
color-convert@^1.9.0:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
||||
@@ -904,6 +919,11 @@ commander@^2.20.0, commander@^2.20.3:
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
|
||||
|
||||
commander@^6.2.1:
|
||||
version "6.2.1"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
|
||||
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
|
||||
|
||||
commander@^7.2.0:
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
|
||||
@@ -1475,7 +1495,7 @@ fast-diff@^1.1.2:
|
||||
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
|
||||
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==
|
||||
|
||||
fast-glob@^3.2.9:
|
||||
fast-glob@^3.2.7, fast-glob@^3.2.9:
|
||||
version "3.2.12"
|
||||
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80"
|
||||
integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==
|
||||
@@ -2002,6 +2022,11 @@ json5@^1.0.1:
|
||||
dependencies:
|
||||
minimist "^1.2.0"
|
||||
|
||||
json5@^2.1.3:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
||||
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||
|
||||
json5@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
|
||||
@@ -2097,6 +2122,11 @@ lodash.uniq@^4.5.0:
|
||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==
|
||||
|
||||
lodash@^4.17.21:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
||||
lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||
@@ -2175,6 +2205,11 @@ minimist@^1.2.0, minimist@^1.2.6:
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
mkdirp@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||
|
||||
moment@^2.29.4:
|
||||
version "2.29.4"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
||||
@@ -2368,6 +2403,11 @@ parse-json@^5.0.0:
|
||||
json-parse-even-better-errors "^2.3.0"
|
||||
lines-and-columns "^1.1.6"
|
||||
|
||||
path-browserify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
|
||||
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
|
||||
|
||||
path-exists@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
|
||||
@@ -3078,6 +3118,31 @@ to-regex-range@^5.0.1:
|
||||
dependencies:
|
||||
is-number "^7.0.0"
|
||||
|
||||
"true-myth@^4.1.0":
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/true-myth/-/true-myth-4.1.1.tgz#ff4ac9d5130276e34aa338757e2416ec19248ba2"
|
||||
integrity sha512-rqy30BSpxPznbbTcAcci90oZ1YR4DqvKcNXNerG5gQBU2v4jk0cygheiul5J6ExIMrgDVuanv/MkGfqZbKrNNg==
|
||||
|
||||
ts-morph@^13.0.1:
|
||||
version "13.0.3"
|
||||
resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-13.0.3.tgz#c0c51d1273ae2edb46d76f65161eb9d763444c1d"
|
||||
integrity sha512-pSOfUMx8Ld/WUreoSzvMFQG5i9uEiWIsBYjpU9+TTASOeUa89j5HykomeqVULm1oqWtBdleI3KEFRLrlA3zGIw==
|
||||
dependencies:
|
||||
"@ts-morph/common" "~0.12.3"
|
||||
code-block-writer "^11.0.0"
|
||||
|
||||
ts-prune@^0.10.3:
|
||||
version "0.10.3"
|
||||
resolved "https://registry.yarnpkg.com/ts-prune/-/ts-prune-0.10.3.tgz#b6c71a525543b38dcf947a7d3adfb7f9e8b91f38"
|
||||
integrity sha512-iS47YTbdIcvN8Nh/1BFyziyUqmjXz7GVzWu02RaZXqb+e/3Qe1B7IQ4860krOeCGUeJmterAlaM2FRH0Ue0hjw==
|
||||
dependencies:
|
||||
commander "^6.2.1"
|
||||
cosmiconfig "^7.0.1"
|
||||
json5 "^2.1.3"
|
||||
lodash "^4.17.21"
|
||||
"true-myth" "^4.1.0"
|
||||
ts-morph "^13.0.1"
|
||||
|
||||
ts-toolbelt@^9.6.0:
|
||||
version "9.6.0"
|
||||
resolved "https://registry.yarnpkg.com/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz#50a25426cfed500d4a09bd1b3afb6f28879edfd5"
|
||||
|
||||
Reference in New Issue
Block a user