chore: Standardize code, comments and docs on US-English spelling (#2707)
This commit is contained in:
@@ -96,7 +96,7 @@ export class ActionsManager implements ActionsExecutor {
|
||||
ev: Event | CustomEvent<ActionConfig>,
|
||||
): Promise<void> => {
|
||||
if (!('detail' in ev)) {
|
||||
// The event may or may not be a CustomEvent object. For example, whilst
|
||||
// The event may or may not be a CustomEvent object. For example, while
|
||||
// this card doesn't use custom-card-helpers, embedded elements may:
|
||||
// https://github.com/custom-cards/custom-card-helpers/blob/master/src/fire-event.ts#L70
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { AdvancedCameraCardConfig } from '../../config/schema/types';
|
||||
|
||||
// The card state exposed via the `acc` namespace AND as the
|
||||
// `trigger.from_acc`/`to_acc` before/after snapshots (the card analogue of HA's
|
||||
// `trigger.from_acc`/`to_acc` before/after snapshots (the card analog of HA's
|
||||
// full `trigger.from_state`/`to_state`).
|
||||
export interface TemplateAdvancedCameraCardState {
|
||||
camera?: string;
|
||||
|
||||
@@ -25,7 +25,7 @@ export class SubstreamViewModifier implements ViewModifier {
|
||||
return;
|
||||
}
|
||||
// A stream equal to the camera itself is semantically "no substream";
|
||||
// normalise it to a cleared override so the map doesn't carry self-
|
||||
// normalize it to a cleared override so the map doesn't carry self-
|
||||
// referential entries.
|
||||
if (!this._options.stream || this._options.stream === cameraID) {
|
||||
view.context?.live?.overrides?.delete(cameraID);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const getLocalizationKeyForPath = (path: ConfigPath): string =>
|
||||
* Compute the label for a form field. Intended for use as an `ha-form`
|
||||
* `computeLabel` callback. A field is named for the setting it edits, which for
|
||||
* a bound field is wherever that setting is stored rather than where the field
|
||||
* sits in the form. Container nodes are labelled by their explicit title, never
|
||||
* sits in the form. Container nodes are labeled by their explicit title, never
|
||||
* by configuration path (their headers already render the title).
|
||||
* @param form The form the field belongs to.
|
||||
* @param schema The field's schema.
|
||||
@@ -37,7 +37,7 @@ export const computeFormLabel = (
|
||||
return schema.label;
|
||||
}
|
||||
if (!isFormFieldSchema(schema)) {
|
||||
// Only an expandable has a title: a grid lays out fields that are labelled
|
||||
// Only an expandable has a title: a grid lays out fields that are labeled
|
||||
// individually, and shows nothing of its own.
|
||||
return (schema.type === 'expandable' ? schema.title : null) ?? schema.name ?? '';
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const getShownPaths = (forms: EditorForm[]): Set<string> =>
|
||||
|
||||
// What the full editor shows and the simple editor does not. Configuration
|
||||
// outside this is either something the simple editor shows too, or something
|
||||
// neither shows (`elements`, `debug`, anything the card does not recognise at
|
||||
// neither shows (`elements`, `debug`, anything the card does not recognize at
|
||||
// all), which the full editor would be no better at showing.
|
||||
const getFullOnlyPaths = (): Set<string> => {
|
||||
const simplePaths = getShownPaths([
|
||||
|
||||
@@ -34,7 +34,7 @@ import { isWebKitUserAgent } from '../utils/user-agent';
|
||||
// MSE Tuning
|
||||
// ===========================================================================
|
||||
|
||||
// These are judgement-based budgets (time, buffered seconds, staged bytes)
|
||||
// These are judgment-based budgets (time, buffered seconds, staged bytes)
|
||||
// balancing latency and resilience, not derived values. The retained-buffer
|
||||
// window and the staged-bytes cap follow go2rtc's reference web client; the
|
||||
// negotiation timeout has no counterpart there and is added by this
|
||||
|
||||
@@ -89,7 +89,7 @@ export class MediaDimensionsContainerController implements ReactiveController {
|
||||
private _mediaLoadedHandler = (ev: CustomEvent<MediaLoadedInfoEventDetail>): void => {
|
||||
const info = ev.detail.info;
|
||||
// Only resize if the media dimensions have changed (otherwise the loading
|
||||
// image whilst waiting for the stream, will trigger aresize every second).
|
||||
// image while waiting for the stream, will trigger aresize every second).
|
||||
if (
|
||||
this._mediaDimensions?.width === info.width &&
|
||||
this._mediaDimensions.height === info.height
|
||||
|
||||
@@ -186,7 +186,7 @@ export class AdvancedCameraCardImageUpdatingPlayer
|
||||
livenessOptions: {
|
||||
// Frames are only due while the refresh timer runs. A snapshot with
|
||||
// refreshing switched off shows one picture forever, which is the
|
||||
// configured behaviour and never a stall.
|
||||
// configured behavior and never a stall.
|
||||
isFrameExpected: () => this._cachedValueController.hasTimer(),
|
||||
|
||||
// Allow a whole refresh interval to pass, plus the standard window, so
|
||||
|
||||
@@ -154,7 +154,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
|
||||
|
||||
/**
|
||||
* Determine if a camera image should be shown in lieu of the real stream
|
||||
* whilst loading.
|
||||
* while loading.
|
||||
* @returns`true` if an image should be shown.
|
||||
*/
|
||||
private _shouldShowImageDuringLoading(): boolean {
|
||||
@@ -287,7 +287,7 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
|
||||
private _getNotification(failure: StreamFailure | null): TemplateResult | null {
|
||||
// If a card *re*-initializes (e.g. was already initialized and then there's
|
||||
// a use of the editor to change the config), cameras will re-initialize in
|
||||
// place, which means they might be asked to render (here) whilst not yet
|
||||
// place, which means they might be asked to render (here) while not yet
|
||||
// being initialized. This can cause spurious errors (e.g. lack of resolved
|
||||
// endpoints). Instead, simply never render uninitialized cameras.
|
||||
if (!this.camera?.isInitialized()) {
|
||||
|
||||
@@ -5,9 +5,10 @@ import type { ConditionsEvaluationResult, ConditionState } from '../types';
|
||||
import type { ConditionEvaluator, ConditionOfType, EvaluatorContext } from './types';
|
||||
|
||||
// Home Assistant resolves an expected value that names an `input_*` helper to
|
||||
// that helper's current state (its Lovelace state-condition behaviour), on both
|
||||
// that helper's current state (its Lovelace state-condition behavior), on both
|
||||
// the state and the attribute path; only these helper domains are resolved.
|
||||
// Regexp directly from: https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/condition.py
|
||||
// Regexp directly from:
|
||||
// https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/condition.py
|
||||
const INPUT_ENTITY_ID =
|
||||
/^input_(?:select|text|number|boolean|datetime)\.(?!.+__)(?!_)[\da-z_]+(?<!_)$/;
|
||||
|
||||
|
||||
@@ -587,7 +587,7 @@ const dropTriggerOnlyConditions = (conditions: unknown[]): unknown[] => {
|
||||
// composite the user wrote empty is kept; only one the recursion emptied
|
||||
// is dropped.
|
||||
if (inner.length || !children.length) {
|
||||
// `arrayify` has already normalised `children`, so rebuilding a
|
||||
// `arrayify` has already normalized `children`, so rebuilding a
|
||||
// composite the recursion left alone would rewrite Home Assistant's
|
||||
// single-condition spelling (`or: <condition>`) into a list the user
|
||||
// never wrote.
|
||||
@@ -672,7 +672,7 @@ const getAutomationList = (
|
||||
plural: string,
|
||||
singular: string,
|
||||
): { key: string; items: unknown[] } => {
|
||||
// Mirroring the schema's rename, the singular key is honoured only when the
|
||||
// Mirroring the schema's rename, the singular key is honored only when the
|
||||
// plural is absent; an automation with neither is written under the plural.
|
||||
const key = singular in automation && !(plural in automation) ? singular : plural;
|
||||
return { key, items: arrayify(automation[key]) };
|
||||
|
||||
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
||||
|
||||
import { arrayify } from '../../../utils/basic';
|
||||
|
||||
// Normalise a single item to an array like Home Assistant's `cv.ensure_list` (a
|
||||
// Normalize a single item to an array like Home Assistant's `cv.ensure_list` (a
|
||||
// key written with no value is a list of nothing). The schema output is always
|
||||
// the list, so the rest of the code only ever sees the canonical form. An
|
||||
// absent value is passed through so that an optional field stays absent rather
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface SubscriptionFailure<K> {
|
||||
failureCount?: number;
|
||||
}
|
||||
|
||||
// Recoverable health of a set of keyed subscriptions. A named specialisation
|
||||
// Recoverable health of a set of keyed subscriptions. A named specialization
|
||||
// for readability and the extension point for any subscription-specific health
|
||||
// surface later.
|
||||
export type SubscriptionHealthInterface<K> = RecoverableHealthInterface<
|
||||
|
||||
@@ -88,7 +88,7 @@ const matchesSchemaValue = (expected: unknown, actual: unknown): boolean => {
|
||||
// HA-faithful match for the event `context` object: every defined filter field
|
||||
// must match the event's corresponding field by equality (scalar filter) or
|
||||
// list-membership (array filter). A null event-side field never satisfies an
|
||||
// explicit filter, mirroring HA's behaviour.
|
||||
// explicit filter, mirroring HA's behavior.
|
||||
// https://www.home-assistant.io/docs/automation/trigger/#event-trigger
|
||||
export const matchesEventContext = (
|
||||
filter: HAEventContextFilter,
|
||||
|
||||
@@ -55,11 +55,11 @@
|
||||
}
|
||||
|
||||
// Each top-level section is an HA expansion panel. An open section draws its
|
||||
// own outline, which would otherwise sit directly against the neighbouring
|
||||
// own outline, which would otherwise sit directly against the neighboring
|
||||
// sections, so every section is spaced whether it is open or not: a gap that
|
||||
// appeared only on opening would move the sections below as the panel grew.
|
||||
// The margins of two adjacent sections collapse together, so the gap is the
|
||||
// same wherever it falls.
|
||||
// appeared only on opening would move the sections below as the panel grew. The
|
||||
// margins of two adjacent sections collapse together, so the gap is the same
|
||||
// wherever it falls.
|
||||
.section {
|
||||
display: block;
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
|
||||
// Triggered and transmitting cameras are highlighted with a soft inset glow,
|
||||
// drawn by an overlay stacked above the camera feed. The overlays come before
|
||||
// the carousel controls in source order, so they stack above the feed but
|
||||
// below the controls; `pointer-events: none` keeps them inert. The glow is an
|
||||
// the carousel controls in source order, so they stack above the feed but below
|
||||
// the controls; `pointer-events: none` keeps them inert. The glow is an
|
||||
// interior effect, so it coexists with the grid selection border (see
|
||||
// media-grid.scss) without competing for the `border` property.
|
||||
//
|
||||
// The two states differ by colour and rhythm: triggered is an amber glow that
|
||||
// The two states differ by color and rhythm: triggered is an amber glow that
|
||||
// pulses fully out and back (a "something happened" beacon), transmitting is a
|
||||
// red glow that breathes gently without ever fully fading ("you are live").
|
||||
// Transmitting wins: while it is active the trigger overlay is faded out.
|
||||
@@ -82,7 +82,7 @@
|
||||
// Hidden by default; activation/deactivation is a plain opacity fade. Each
|
||||
// overlay carries its own static box-shadow (not scoped to the
|
||||
// `[triggered]`/`[transmitting]` selectors) so the glow stays painted in its
|
||||
// own colour throughout the fade-out, after its animation has been removed.
|
||||
// own color throughout the fade-out, after its animation has been removed.
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ img {
|
||||
border-radius: var(--advanced-camera-card-border-radius-final);
|
||||
|
||||
// Not 'contain' as some thumbnails may vary in aspect-ratio slightly and
|
||||
// should be clipped to fill the thumbnail div whilst maintaining
|
||||
// aspect-ratio.
|
||||
// should be clipped to fill the thumbnail div while maintaining aspect-ratio.
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import { errorToConsole } from './basic';
|
||||
* @param host The host object.
|
||||
* @param task The Lit task.
|
||||
* @param completeFunc The function to call with the result.
|
||||
* @param inProgressFunc The function to call whilst in progress.
|
||||
* @param inProgressFunc The function to call while in progress.
|
||||
* @returns A template.
|
||||
*/
|
||||
export const renderTask = <R>(
|
||||
|
||||
Reference in New Issue
Block a user