Bump TypeScript to 3.7 (#4282)

* Bump TypeScript to 3.7

* Update prettier to support ts 3.7

* Prettier

* More prettier

* Even more prettier
This commit is contained in:
Bram Kragten 2019-11-27 22:51:03 +01:00 committed by Paulus Schoutsen
parent b8a026397b
commit 8a39d18323
100 changed files with 1165 additions and 600 deletions

View File

@ -175,9 +175,9 @@ export class HcMain extends HassElement {
} catch (err) {
// Generate a Lovelace config.
this._unsubLovelace = () => undefined;
const {
generateLovelaceConfigFromHass,
} = await import("../../../../src/panels/lovelace/common/generate-lovelace-config");
const { generateLovelaceConfigFromHass } = await import(
"../../../../src/panels/lovelace/common/generate-lovelace-config"
);
this._handleNewLovelaceConfig(
await generateLovelaceConfigFromHass(this.hass!)
);

View File

@ -53,7 +53,7 @@ class CardModder extends LitElement {
for (var k in this._config.style) {
if (window.cardTools.hasTemplate(this._config.style[k]))
this.templated.push(k);
this.card.style.setProperty(k, '');
this.card.style.setProperty(k, "");
target.style.setProperty(
k,
window.cardTools.parseTemplate(this._config.style[k])

View File

@ -12,5 +12,7 @@ import "./resources/hademo-icons";
/* polyfill for paper-dropdown */
setTimeout(() => {
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min");
import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
}, 1000);

View File

@ -65,74 +65,79 @@ const generateHistory = (state, deltas) => {
const incrementalUnits = ["clients", "queries", "ads"];
export const mockHistory = (mockHass: MockHomeAssistant) => {
mockHass.mockAPI(new RegExp("history/period/.+"), (
hass,
// @ts-ignore
method,
path,
// @ts-ignore
parameters
) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(",");
mockHass.mockAPI(
new RegExp("history/period/.+"),
(
hass,
// @ts-ignore
method,
path,
// @ts-ignore
parameters
) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(",");
const results: HassEntity[][] = [];
const results: HassEntity[][] = [];
for (const entityId of entities) {
const state = hass.states[entityId];
for (const entityId of entities) {
const state = hass.states[entityId];
if (!state) {
continue;
}
if (!state) {
continue;
}
if (!state.attributes.unit_of_measurement) {
results.push(generateHistory(state, [state.state]));
continue;
}
if (!state.attributes.unit_of_measurement) {
results.push(generateHistory(state, [state.state]));
continue;
}
const numberState = Number(state.state);
const numberState = Number(state.state);
if (isNaN(numberState)) {
// tslint:disable-next-line
console.log(
"Ignoring state with unparsable state but with a unit",
entityId,
state
if (isNaN(numberState)) {
// tslint:disable-next-line
console.log(
"Ignoring state with unparsable state but with a unit",
entityId,
state
);
continue;
}
const statesToGenerate = 15;
let genFunc;
if (incrementalUnits.includes(state.attributes.unit_of_measurement)) {
let initial = Math.floor(
numberState * 0.4 + numberState * Math.random() * 0.2
);
const diff = Math.max(
1,
Math.floor((numberState - initial) / statesToGenerate)
);
genFunc = () => {
initial += diff;
return Math.min(numberState, initial);
};
} else {
const diff = Math.floor(
numberState * (numberState > 80 ? 0.05 : 0.5)
);
genFunc = () =>
numberState - diff + Math.floor(Math.random() * 2 * diff);
}
results.push(
generateHistory(
{
entity_id: state.entity_id,
attributes: state.attributes,
},
Array.from({ length: statesToGenerate }, genFunc)
)
);
continue;
}
const statesToGenerate = 15;
let genFunc;
if (incrementalUnits.includes(state.attributes.unit_of_measurement)) {
let initial = Math.floor(
numberState * 0.4 + numberState * Math.random() * 0.2
);
const diff = Math.max(
1,
Math.floor((numberState - initial) / statesToGenerate)
);
genFunc = () => {
initial += diff;
return Math.min(numberState, initial);
};
} else {
const diff = Math.floor(numberState * (numberState > 80 ? 0.05 : 0.5));
genFunc = () =>
numberState - diff + Math.floor(Math.random() * 2 * diff);
}
results.push(
generateHistory(
{
entity_id: state.entity_id,
attributes: state.attributes,
},
Array.from({ length: statesToGenerate }, genFunc)
)
);
return results;
}
return results;
});
);
};

View File

@ -12,9 +12,10 @@ export const mockLovelace = (
localizePromise: Promise<LocalizeFunc>
) => {
hass.mockWS("lovelace/config", () =>
Promise.all([selectedDemoConfig, localizePromise]).then(
([config, localize]) => config.lovelace(localize)
)
Promise.all([
selectedDemoConfig,
localizePromise,
]).then(([config, localize]) => config.lovelace(localize))
);
hass.mockWS("lovelace/config/save", () => Promise.resolve());

View File

@ -44,9 +44,7 @@ class HassioAddonAudio extends EventsMixin(PolymerElement) {
selected="{{selectedInput}}"
>
<template is="dom-repeat" items="[[inputDevices]]">
<paper-item device\$="[[item.device]]"
>[[item.name]]</paper-item
>
<paper-item device$="[[item.device]]">[[item.name]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
@ -57,9 +55,7 @@ class HassioAddonAudio extends EventsMixin(PolymerElement) {
selected="{{selectedOutput}}"
>
<template is="dom-repeat" items="[[outputDevices]]">
<paper-item device\$="[[item.device]]"
>[[item.name]]</paper-item
>
<paper-item device$="[[item.device]]">[[item.name]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>

View File

@ -569,7 +569,10 @@ class HassioAddonInfo extends EventsMixin(PolymerElement) {
openChangelog() {
this.hass
.callApi("get", `hassio/addons/${this.addonSlug}/changelog`)
.then((resp) => resp, () => "Error getting changelog")
.then(
(resp) => resp,
() => "Error getting changelog"
)
.then((content) => {
showHassioMarkdownDialog(this, {
title: "Changelog",

View File

@ -74,9 +74,7 @@ export class HassioUpdate extends LitElement {
this.supervisorInfo.version,
this.supervisorInfo.last_version,
"hassio/supervisor/update",
`https://github.com//home-assistant/hassio/releases/tag/${
this.supervisorInfo.last_version
}`
`https://github.com//home-assistant/hassio/releases/tag/${this.supervisorInfo.last_version}`
)}
${this.hassOsInfo
? this._renderUpdateCard(
@ -84,9 +82,7 @@ export class HassioUpdate extends LitElement {
this.hassOsInfo.version,
this.hassOsInfo.version_latest,
"hassio/hassos/update",
`https://github.com//home-assistant/hassos/releases/tag/${
this.hassOsInfo.version_latest
}`
`https://github.com//home-assistant/hassos/releases/tag/${this.hassOsInfo.version_latest}`
)
: ""}
</div>

View File

@ -12,7 +12,9 @@ export const showHassioMarkdownDialog = (
fireEvent(element, "show-dialog", {
dialogTag: "dialog-hassio-markdown",
dialogImport: () =>
import(/* webpackChunkName: "dialog-hassio-markdown" */ "./dialog-hassio-markdown"),
import(
/* webpackChunkName: "dialog-hassio-markdown" */ "./dialog-hassio-markdown"
),
dialogParams,
});
};

View File

@ -12,7 +12,9 @@ export const showHassioSnapshotDialog = (
fireEvent(element, "show-dialog", {
dialogTag: "dialog-hassio-snapshot",
dialogImport: () =>
import(/* webpackChunkName: "dialog-hassio-snapshot" */ "./dialog-hassio-snapshot"),
import(
/* webpackChunkName: "dialog-hassio-snapshot" */ "./dialog-hassio-snapshot"
),
dialogParams,
});
};

View File

@ -56,12 +56,16 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
addon: {
tag: "hassio-addon-view",
load: () =>
import(/* webpackChunkName: "hassio-addon-view" */ "./addon-view/hassio-addon-view"),
import(
/* webpackChunkName: "hassio-addon-view" */ "./addon-view/hassio-addon-view"
),
},
ingress: {
tag: "hassio-ingress-view",
load: () =>
import(/* webpackChunkName: "hassio-ingress-view" */ "./ingress-view/hassio-ingress-view"),
import(
/* webpackChunkName: "hassio-ingress-view" */ "./ingress-view/hassio-ingress-view"
),
},
},
};

View File

@ -105,15 +105,15 @@
"xss": "^1.0.6"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/plugin-external-helpers": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/preset-env": "^7.4.2",
"@babel/preset-typescript": "^7.4.0",
"@babel/core": "^7.7.4",
"@babel/plugin-external-helpers": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/plugin-transform-react-jsx": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/preset-typescript": "^7.7.4",
"@types/chai": "^4.1.7",
"@types/chromecast-caf-receiver": "^3.0.12",
"@types/chromecast-caf-sender": "^1.0.1",
@ -155,18 +155,18 @@
"merge-stream": "^1.0.1",
"mocha": "^6.0.2",
"parse5": "^5.1.0",
"prettier": "^1.16.4",
"prettier": "^1.19.1",
"raw-loader": "^2.0.0",
"reify": "^0.18.1",
"require-dir": "^1.2.0",
"sinon": "^7.3.1",
"terser-webpack-plugin": "^1.2.3",
"ts-mocha": "^6.0.0",
"tslint": "^5.14.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.6.3",
"typescript": "^3.7.2",
"web-component-tester": "^6.9.2",
"webpack": "^4.40.2",
"webpack-cli": "^3.3.9",

View File

@ -98,9 +98,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
<ha-markdown
allowsvg
.content=${this.localize(
`ui.panel.page-authorize.form.providers.${
step.handler[0]
}.abort.${step.reason}`
`ui.panel.page-authorize.form.providers.${step.handler[0]}.abort.${step.reason}`
)}
></ha-markdown>
`;
@ -229,9 +227,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
}
private _computeStepDescription(step: DataEntryFlowStepForm) {
const resourceKey = `ui.panel.page-authorize.form.providers.${
step.handler[0]
}.step.${step.step_id}.description`;
const resourceKey = `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description`;
const args: string[] = [];
const placeholders = step.description_placeholders || {};
Object.keys(placeholders).forEach((key) => {
@ -245,9 +241,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
// Returns a callback for ha-form to calculate labels per schema object
return (schema) =>
this.localize(
`ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${
step.step_id
}.data.${schema.name}`
`ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.data.${schema.name}`
);
}
@ -255,9 +249,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
// Returns a callback for ha-form to calculate error messages
return (error) =>
this.localize(
`ui.panel.page-authorize.form.providers.${
step.handler[0]
}.error.${error}`
`ui.panel.page-authorize.form.providers.${step.handler[0]}.error.${error}`
);
}

View File

@ -11,7 +11,9 @@ import "./ha-auth-flow";
import { AuthProvider, fetchAuthProviders } from "../data/auth";
import { registerServiceWorker } from "../util/register-service-worker";
import(/* webpackChunkName: "pick-auth-provider" */ "../auth/ha-pick-auth-provider");
import(
/* webpackChunkName: "pick-auth-provider" */ "../auth/ha-pick-auth-provider"
);
interface QueryParams {
client_id?: string;

View File

@ -10,11 +10,11 @@ function toLocaleDateStringSupportsOptions() {
return false;
}
export default (toLocaleDateStringSupportsOptions()
export default toLocaleDateStringSupportsOptions()
? (dateObj: Date, locales: string) =>
dateObj.toLocaleDateString(locales, {
year: "numeric",
month: "long",
day: "numeric",
})
: (dateObj: Date) => fecha.format(dateObj, "mediumDate"));
: (dateObj: Date) => fecha.format(dateObj, "mediumDate");

View File

@ -10,7 +10,7 @@ function toLocaleStringSupportsOptions() {
return false;
}
export default (toLocaleStringSupportsOptions()
export default toLocaleStringSupportsOptions()
? (dateObj: Date, locales: string) =>
dateObj.toLocaleString(locales, {
year: "numeric",
@ -19,4 +19,4 @@ export default (toLocaleStringSupportsOptions()
hour: "numeric",
minute: "2-digit",
})
: (dateObj: Date) => fecha.format(dateObj, "haDateTime"));
: (dateObj: Date) => fecha.format(dateObj, "haDateTime");

View File

@ -10,10 +10,10 @@ function toLocaleTimeStringSupportsOptions() {
return false;
}
export default (toLocaleTimeStringSupportsOptions()
export default toLocaleTimeStringSupportsOptions()
? (dateObj: Date, locales: string) =>
dateObj.toLocaleTimeString(locales, {
hour: "numeric",
minute: "2-digit",
})
: (dateObj: Date) => fecha.format(dateObj, "shortTime"));
: (dateObj: Date) => fecha.format(dateObj, "shortTime");

View File

@ -60,7 +60,7 @@ export const applyThemesOnElement = (
element.updateStyles(styles);
} else if (window.ShadyCSS) {
// implement updateStyles() method of Polymer elements
window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ (element), styles);
window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ element, styles);
}
if (!updateMeta) {

View File

@ -11,7 +11,9 @@ export const setupLeafletMap = async (
throw new Error("Cannot setup Leaflet map on disconnected element");
}
// tslint:disable-next-line
const Leaflet = (await import(/* webpackChunkName: "leaflet" */ "leaflet")) as LeafletModuleType;
const Leaflet = (await import(
/* webpackChunkName: "leaflet" */ "leaflet"
)) as LeafletModuleType;
Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/";
const map = Leaflet.map(mapElement);

View File

@ -215,7 +215,9 @@ class HaChartBase extends mixinBehaviors(
}
if (scriptsLoaded === null) {
scriptsLoaded = import(/* webpackChunkName: "load_chart" */ "../../resources/ha-chart-scripts.js");
scriptsLoaded = import(
/* webpackChunkName: "load_chart" */ "../../resources/ha-chart-scripts.js"
);
}
scriptsLoaded.then((ChartModule) => {
this.ChartClass = ChartModule.default;

View File

@ -122,8 +122,9 @@ class HaCameraStream extends LitElement {
private async _startHls(): Promise<void> {
// tslint:disable-next-line
const Hls = ((await import(/* webpackChunkName: "hls.js" */ "hls.js")) as any)
.default as HLSModule;
const Hls = ((await import(
/* webpackChunkName: "hls.js" */ "hls.js"
)) as any).default as HLSModule;
let hlsSupported = Hls.isSupported();
const videoEl = this._videoEl;

View File

@ -72,9 +72,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
computeCurrentStatus(hass, stateObj) {
if (!hass || !stateObj) return null;
if (stateObj.attributes.current_temperature != null) {
return `${stateObj.attributes.current_temperature} ${
hass.config.unit_system.temperature
}`;
return `${stateObj.attributes.current_temperature} ${hass.config.unit_system.temperature}`;
}
if (stateObj.attributes.current_humidity != null) {
return `${stateObj.attributes.current_humidity} %`;
@ -89,22 +87,16 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
stateObj.attributes.target_temp_low != null &&
stateObj.attributes.target_temp_high != null
) {
return `${stateObj.attributes.target_temp_low}-${
stateObj.attributes.target_temp_high
} ${hass.config.unit_system.temperature}`;
return `${stateObj.attributes.target_temp_low}-${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`;
}
if (stateObj.attributes.temperature != null) {
return `${stateObj.attributes.temperature} ${
hass.config.unit_system.temperature
}`;
return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`;
}
if (
stateObj.attributes.target_humidity_low != null &&
stateObj.attributes.target_humidity_high != null
) {
return `${stateObj.attributes.target_humidity_low}-${
stateObj.attributes.target_humidity_high
}%`;
return `${stateObj.attributes.target_humidity_low}-${stateObj.attributes.target_humidity_high}%`;
}
if (stateObj.attributes.humidity != null) {
return `${stateObj.attributes.humidity} %`;
@ -121,9 +113,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
const stateString = localize(`state.climate.${stateObj.state}`);
return stateObj.attributes.hvac_action
? `${localize(
`state_attributes.climate.hvac_action.${
stateObj.attributes.hvac_action
}`
`state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}`
)} (${stateString})`
: stateString;
}

View File

@ -58,14 +58,10 @@ class HaWaterHeaterState extends LocalizeMixin(PolymerElement) {
stateObj.attributes.target_temp_low != null &&
stateObj.attributes.target_temp_high != null
) {
return `${stateObj.attributes.target_temp_low} - ${
stateObj.attributes.target_temp_high
} ${hass.config.unit_system.temperature}`;
return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`;
}
if (stateObj.attributes.temperature != null) {
return `${stateObj.attributes.temperature} ${
hass.config.unit_system.temperature
}`;
return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`;
}
return "";

View File

@ -19,9 +19,7 @@ export interface Stream {
}
export const computeMJPEGStreamUrl = (entity: CameraEntity) =>
`/api/camera_proxy_stream/${entity.entity_id}?token=${
entity.attributes.access_token
}`;
`/api/camera_proxy_stream/${entity.entity_id}?token=${entity.attributes.access_token}`;
export const fetchThumbnailUrlWithCache = (
hass: HomeAssistant,

View File

@ -3,7 +3,7 @@ import { HomeAssistant } from "../types";
interface ProcessResults {
card: { [key: string]: { [key: string]: string } };
speech: {
[SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string }
[SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string };
};
}

View File

@ -107,9 +107,7 @@ export const localizeDeviceAutomationAction = (
state ? computeStateName(state) : "<unknown>",
"subtype",
hass.localize(
`component.${action.domain}.device_automation.action_subtype.${
action.subtype
}`
`component.${action.domain}.device_automation.action_subtype.${action.subtype}`
)
);
};
@ -122,16 +120,12 @@ export const localizeDeviceAutomationCondition = (
? hass.states[condition.entity_id]
: undefined;
return hass.localize(
`component.${condition.domain}.device_automation.condition_type.${
condition.type
}`,
`component.${condition.domain}.device_automation.condition_type.${condition.type}`,
"entity_name",
state ? computeStateName(state) : "<unknown>",
"subtype",
hass.localize(
`component.${condition.domain}.device_automation.condition_subtype.${
condition.subtype
}`
`component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}`
)
);
};
@ -142,16 +136,12 @@ export const localizeDeviceAutomationTrigger = (
) => {
const state = trigger.entity_id ? hass.states[trigger.entity_id] : undefined;
return hass.localize(
`component.${trigger.domain}.device_automation.trigger_type.${
trigger.type
}`,
`component.${trigger.domain}.device_automation.trigger_type.${trigger.type}`,
"entity_name",
state ? computeStateName(state) : "<unknown>",
"subtype",
hass.localize(
`component.${trigger.domain}.device_automation.trigger_subtype.${
trigger.subtype
}`
`component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}`
)
);
};

View File

@ -149,9 +149,7 @@ export const createHassioSession = async (hass: HomeAssistant) => {
"POST",
"hassio/ingress/session"
);
document.cookie = `ingress_session=${
response.data.session
};path=/api/hassio_ingress/`;
document.cookie = `ingress_session=${response.data.session};path=/api/hassio_ingress/`;
};
export const reloadHassioAddons = (hass: HomeAssistant) =>

View File

@ -98,9 +98,7 @@ class DialogConfigEntrySystemOptions extends LitElement {
"ui.dialogs.config_entry_system_options.enable_new_entities_description",
"integration",
this.hass.localize(
`component.${
this._params.entry.domain
}.config.title`
`component.${this._params.entry.domain}.config.title`
) || this._params.entry.domain
)}
</p>

View File

@ -10,7 +10,9 @@ export interface ConfigEntrySystemOptionsDialogParams {
}
export const loadConfigEntrySystemOptionsDialog = () =>
import(/* webpackChunkName: "config-entry-system-options" */ "./dialog-config-entry-system-options");
import(
/* webpackChunkName: "config-entry-system-options" */ "./dialog-config-entry-system-options"
);
export const showConfigEntrySystemOptionsDialog = (
element: HTMLElement,

View File

@ -71,9 +71,7 @@ export const showConfigFlowDialog = (
renderShowFormStepFieldLabel(hass, step, field) {
return hass.localize(
`component.${step.handler}.config.step.${step.step_id}.data.${
field.name
}`
`component.${step.handler}.config.step.${step.step_id}.data.${field.name}`
);
},

View File

@ -79,7 +79,9 @@ export interface DataEntryFlowDialogParams {
}
export const loadDataEntryFlowDialog = () =>
import(/* webpackChunkName: "dialog-config-flow" */ "./dialog-data-entry-flow");
import(
/* webpackChunkName: "dialog-config-flow" */ "./dialog-data-entry-flow"
);
export const showFlowDialog = (
element: HTMLElement,

View File

@ -54,9 +54,7 @@ export const showOptionsFlowDialog = (
renderShowFormStepFieldLabel(hass, step, field) {
return hass.localize(
`component.${configEntry.domain}.options.step.${step.step_id}.data.${
field.name
}`
`component.${configEntry.domain}.options.step.${step.step_id}.data.${field.name}`
);
},

View File

@ -12,7 +12,9 @@ export interface DeviceRegistryDetailDialogParams {
}
export const loadDeviceRegistryDetailDialog = () =>
import(/* webpackChunkName: "device-registry-detail-dialog" */ "./dialog-device-registry-detail");
import(
/* webpackChunkName: "device-registry-detail-dialog" */ "./dialog-device-registry-detail"
);
export const showDeviceRegistryDetailDialog = (
element: HTMLElement,

View File

@ -6,7 +6,9 @@ export interface HaDomainTogglerDialogParams {
}
export const loadDomainTogglerDialog = () =>
import(/* webpackChunkName: "dialog-domain-toggler" */ "./dialog-domain-toggler");
import(
/* webpackChunkName: "dialog-domain-toggler" */ "./dialog-domain-toggler"
);
export const showDomainTogglerDialog = (
element: HTMLElement,

View File

@ -1,7 +1,9 @@
import { fireEvent } from "../../common/dom/fire_event";
const loadVoiceCommandDialog = () =>
import(/* webpackChunkName: "ha-voice-command-dialog" */ "./ha-voice-command-dialog");
import(
/* webpackChunkName: "ha-voice-command-dialog" */ "./ha-voice-command-dialog"
);
export const showVoiceCommandDialog = (element: HTMLElement): void => {
fireEvent(element, "show-dialog", {

View File

@ -5,7 +5,9 @@ export interface ZHADeviceInfoDialogParams {
}
export const loadZHADeviceInfoDialog = () =>
import(/* webpackChunkName: "dialog-zha-device-info" */ "./dialog-zha-device-info");
import(
/* webpackChunkName: "dialog-zha-device-info" */ "./dialog-zha-device-info"
);
export const showZHADeviceInfoDialog = (
element: HTMLElement,

View File

@ -10,6 +10,8 @@ import "../auth/ha-authorize";
/* polyfill for paper-dropdown */
setTimeout(
() =>
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"),
import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
),
2000
);

View File

@ -27,9 +27,9 @@ const isExternal = location.search.includes("external_auth=1");
const authProm = isExternal
? () =>
import(/* webpackChunkName: "external_auth" */ "../external_app/external_auth").then(
({ createExternalAuth }) => createExternalAuth(hassUrl)
)
import(
/* webpackChunkName: "external_auth" */ "../external_app/external_auth"
).then(({ createExternalAuth }) => createExternalAuth(hassUrl))
: () =>
getAuth({
hassUrl,

View File

@ -74,20 +74,23 @@ export const provideHass = (
restResponses.push([path, callback]);
}
mockAPI(new RegExp("states/.+"), (
// @ts-ignore
method,
path,
parameters
) => {
const [domain, objectId] = path.substr(7).split(".", 2);
if (!domain || !objectId) {
return;
mockAPI(
new RegExp("states/.+"),
(
// @ts-ignore
method,
path,
parameters
) => {
const [domain, objectId] = path.substr(7).split(".", 2);
if (!domain || !objectId) {
return;
}
addEntities(
getEntity(domain, objectId, parameters.state, parameters.attributes)
);
}
addEntities(
getEntity(domain, objectId, parameters.state, parameters.attributes)
);
});
);
const localLanguage = getLocalLanguage();
@ -117,9 +120,7 @@ export const provideHass = (
? callback(msg)
: Promise.reject({
code: "command_not_mocked",
message: `WS Command ${
msg.type
} is not implemented in provide_hass.`,
message: `WS Command ${msg.type} is not implemented in provide_hass.`,
});
},
subscribeMessage: async (onChange, msg) => {
@ -128,9 +129,7 @@ export const provideHass = (
? callback(msg, onChange)
: Promise.reject({
code: "command_not_mocked",
message: `WS Command ${
msg.type
} is not implemented in provide_hass.`,
message: `WS Command ${msg.type} is not implemented in provide_hass.`,
});
},
subscribeEvents: async (

View File

@ -45,7 +45,9 @@ export class HomeAssistantAppEl extends HassElement {
this._initialize();
setTimeout(registerServiceWorker, 1000);
/* polyfill for paper-dropdown */
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min");
import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
}
protected updated(changedProps: PropertyValues): void {
@ -55,9 +57,10 @@ export class HomeAssistantAppEl extends HassElement {
this._updateHass({ panelUrl: this._panelUrl });
}
if (changedProps.has("hass")) {
this.hassChanged(this.hass!, changedProps.get("hass") as
| HomeAssistant
| undefined);
this.hassChanged(
this.hass!,
changedProps.get("hass") as HomeAssistant | undefined
);
}
}

View File

@ -12,33 +12,59 @@ import { removeInitSkeleton } from "../util/init-skeleton";
const CACHE_COMPONENTS = ["lovelace", "states", "developer-tools"];
const COMPONENTS = {
calendar: () =>
import(/* webpackChunkName: "panel-calendar" */ "../panels/calendar/ha-panel-calendar"),
import(
/* webpackChunkName: "panel-calendar" */ "../panels/calendar/ha-panel-calendar"
),
config: () =>
import(/* webpackChunkName: "panel-config" */ "../panels/config/ha-panel-config"),
import(
/* webpackChunkName: "panel-config" */ "../panels/config/ha-panel-config"
),
custom: () =>
import(/* webpackChunkName: "panel-custom" */ "../panels/custom/ha-panel-custom"),
import(
/* webpackChunkName: "panel-custom" */ "../panels/custom/ha-panel-custom"
),
"developer-tools": () =>
import(/* webpackChunkName: "panel-developer-tools" */ "../panels/developer-tools/ha-panel-developer-tools"),
import(
/* webpackChunkName: "panel-developer-tools" */ "../panels/developer-tools/ha-panel-developer-tools"
),
lovelace: () =>
import(/* webpackChunkName: "panel-lovelace" */ "../panels/lovelace/ha-panel-lovelace"),
import(
/* webpackChunkName: "panel-lovelace" */ "../panels/lovelace/ha-panel-lovelace"
),
states: () =>
import(/* webpackChunkName: "panel-states" */ "../panels/states/ha-panel-states"),
import(
/* webpackChunkName: "panel-states" */ "../panels/states/ha-panel-states"
),
history: () =>
import(/* webpackChunkName: "panel-history" */ "../panels/history/ha-panel-history"),
import(
/* webpackChunkName: "panel-history" */ "../panels/history/ha-panel-history"
),
iframe: () =>
import(/* webpackChunkName: "panel-iframe" */ "../panels/iframe/ha-panel-iframe"),
import(
/* webpackChunkName: "panel-iframe" */ "../panels/iframe/ha-panel-iframe"
),
kiosk: () =>
import(/* webpackChunkName: "panel-kiosk" */ "../panels/kiosk/ha-panel-kiosk"),
import(
/* webpackChunkName: "panel-kiosk" */ "../panels/kiosk/ha-panel-kiosk"
),
logbook: () =>
import(/* webpackChunkName: "panel-logbook" */ "../panels/logbook/ha-panel-logbook"),
import(
/* webpackChunkName: "panel-logbook" */ "../panels/logbook/ha-panel-logbook"
),
mailbox: () =>
import(/* webpackChunkName: "panel-mailbox" */ "../panels/mailbox/ha-panel-mailbox"),
import(
/* webpackChunkName: "panel-mailbox" */ "../panels/mailbox/ha-panel-mailbox"
),
map: () =>
import(/* webpackChunkName: "panel-map" */ "../panels/map/ha-panel-map"),
profile: () =>
import(/* webpackChunkName: "panel-profile" */ "../panels/profile/ha-panel-profile"),
import(
/* webpackChunkName: "panel-profile" */ "../panels/profile/ha-panel-profile"
),
"shopping-list": () =>
import(/* webpackChunkName: "panel-shopping-list" */ "../panels/shopping-list/ha-panel-shopping-list"),
import(
/* webpackChunkName: "panel-shopping-list" */ "../panels/shopping-list/ha-panel-shopping-list"
),
};
const getRoutes = (panels: Panels): RouterOptions => {

View File

@ -84,8 +84,12 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
this._fetchOnboardingSteps();
import(/* webpackChunkName: "onboarding-integrations" */ "./onboarding-integrations");
import(/* webpackChunkName: "onboarding-core-config" */ "./onboarding-core-config");
import(
/* webpackChunkName: "onboarding-integrations" */ "./onboarding-integrations"
);
import(
/* webpackChunkName: "onboarding-core-config" */ "./onboarding-core-config"
);
registerServiceWorker(false);
this.addEventListener("onboarding-step", (ev) => this._handleStepDone(ev));
}

View File

@ -124,7 +124,9 @@ class OnboardingIntegrations extends LitElement {
loadConfigFlowDialog();
this._loadConfigEntries();
/* polyfill for paper-dropdown */
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min");
import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
}
private _createFlow() {

View File

@ -14,7 +14,9 @@ export interface AreaRegistryDetailDialogParams {
}
export const loadAreaRegistryDetailDialog = () =>
import(/* webpackChunkName: "area-registry-detail-dialog" */ "./dialog-area-registry-detail");
import(
/* webpackChunkName: "area-registry-detail-dialog" */ "./dialog-area-registry-detail"
);
export const showAreaRegistryDetailDialog = (
element: HTMLElement,

View File

@ -115,9 +115,7 @@ class HaAutomationPicker extends LitElement {
<a
href=${ifDefined(
automation.attributes.id
? `/config/automation/edit/${
automation.attributes.id
}`
? `/config/automation/edit/${automation.attributes.id}`
: undefined
)}
>

View File

@ -6,7 +6,9 @@ export interface ThingtalkDialogParams {
}
export const loadThingtalkDialog = () =>
import(/* webpackChunkName: "thingtalk-dialog" */ "./thingtalk/dialog-thingtalk");
import(
/* webpackChunkName: "thingtalk-dialog" */ "./thingtalk/dialog-thingtalk"
);
export const showThingtalkDialog = (
element: HTMLElement,

View File

@ -12,7 +12,9 @@ export const showCloudCertificateDialog = (
fireEvent(element, "show-dialog", {
dialogTag: "dialog-cloud-certificate",
dialogImport: () =>
import(/* webpackChunkName: "dialog-cloud-certificate" */ "./dialog-cloud-certificate"),
import(
/* webpackChunkName: "dialog-cloud-certificate" */ "./dialog-cloud-certificate"
),
dialogParams: webhookDialogParams,
});
};

View File

@ -15,7 +15,9 @@ export const showManageCloudhookDialog = (
fireEvent(element, "show-dialog", {
dialogTag: "dialog-manage-cloudhook",
dialogImport: () =>
import(/* webpackChunkName: "cloud-webhook-manage-dialog" */ "./dialog-manage-cloudhook"),
import(
/* webpackChunkName: "cloud-webhook-manage-dialog" */ "./dialog-manage-cloudhook"
),
dialogParams: webhookDialogParams,
});
};

View File

@ -46,12 +46,16 @@ class HaConfigCloud extends HassRouterPage {
register: {
tag: "cloud-register",
load: () =>
import(/* webpackChunkName: "cloud-register" */ "./register/cloud-register"),
import(
/* webpackChunkName: "cloud-register" */ "./register/cloud-register"
),
},
"forgot-password": {
tag: "cloud-forgot-password",
load: () =>
import(/* webpackChunkName: "cloud-forgot-password" */ "./forgot-password/cloud-forgot-password"),
import(
/* webpackChunkName: "cloud-forgot-password" */ "./forgot-password/cloud-forgot-password"
),
},
account: {
tag: "cloud-account",
@ -59,7 +63,9 @@ class HaConfigCloud extends HassRouterPage {
"google-assistant": {
tag: "cloud-google-assistant",
load: () =>
import(/* webpackChunkName: "cloud-google-assistant" */ "./google-assistant/cloud-google-assistant"),
import(
/* webpackChunkName: "cloud-google-assistant" */ "./google-assistant/cloud-google-assistant"
),
},
alexa: {
tag: "cloud-alexa",

View File

@ -6,7 +6,9 @@ export interface EntityRegistryDetailDialogParams {
}
export const loadEntityRegistryDetailDialog = () =>
import(/* webpackChunkName: "entity-registry-detail-dialog" */ "./dialog-entity-registry-detail");
import(
/* webpackChunkName: "entity-registry-detail-dialog" */ "./dialog-entity-registry-detail"
);
export const showEntityRegistryDetailDialog = (
element: HTMLElement,

View File

@ -31,82 +31,114 @@ class HaPanelConfig extends HassRouterPage {
area_registry: {
tag: "ha-config-area-registry",
load: () =>
import(/* webpackChunkName: "panel-config-area-registry" */ "./area_registry/ha-config-area-registry"),
import(
/* webpackChunkName: "panel-config-area-registry" */ "./area_registry/ha-config-area-registry"
),
},
automation: {
tag: "ha-config-automation",
load: () =>
import(/* webpackChunkName: "panel-config-automation" */ "./automation/ha-config-automation"),
import(
/* webpackChunkName: "panel-config-automation" */ "./automation/ha-config-automation"
),
},
cloud: {
tag: "ha-config-cloud",
load: () =>
import(/* webpackChunkName: "panel-config-cloud" */ "./cloud/ha-config-cloud"),
import(
/* webpackChunkName: "panel-config-cloud" */ "./cloud/ha-config-cloud"
),
},
core: {
tag: "ha-config-core",
load: () =>
import(/* webpackChunkName: "panel-config-core" */ "./core/ha-config-core"),
import(
/* webpackChunkName: "panel-config-core" */ "./core/ha-config-core"
),
},
devices: {
tag: "ha-config-devices",
load: () =>
import(/* webpackChunkName: "panel-config-devices" */ "./devices/ha-config-devices"),
import(
/* webpackChunkName: "panel-config-devices" */ "./devices/ha-config-devices"
),
},
server_control: {
tag: "ha-config-server-control",
load: () =>
import(/* webpackChunkName: "panel-config-server-control" */ "./server_control/ha-config-server-control"),
import(
/* webpackChunkName: "panel-config-server-control" */ "./server_control/ha-config-server-control"
),
},
customize: {
tag: "ha-config-customize",
load: () =>
import(/* webpackChunkName: "panel-config-customize" */ "./customize/ha-config-customize"),
import(
/* webpackChunkName: "panel-config-customize" */ "./customize/ha-config-customize"
),
},
dashboard: {
tag: "ha-config-dashboard",
load: () =>
import(/* webpackChunkName: "panel-config-dashboard" */ "./dashboard/ha-config-dashboard"),
import(
/* webpackChunkName: "panel-config-dashboard" */ "./dashboard/ha-config-dashboard"
),
},
entity_registry: {
tag: "ha-config-entity-registry",
load: () =>
import(/* webpackChunkName: "panel-config-entity-registry" */ "./entity_registry/ha-config-entity-registry"),
import(
/* webpackChunkName: "panel-config-entity-registry" */ "./entity_registry/ha-config-entity-registry"
),
},
integrations: {
tag: "ha-config-integrations",
load: () =>
import(/* webpackChunkName: "panel-config-integrations" */ "./integrations/ha-config-integrations"),
import(
/* webpackChunkName: "panel-config-integrations" */ "./integrations/ha-config-integrations"
),
},
person: {
tag: "ha-config-person",
load: () =>
import(/* webpackChunkName: "panel-config-person" */ "./person/ha-config-person"),
import(
/* webpackChunkName: "panel-config-person" */ "./person/ha-config-person"
),
},
script: {
tag: "ha-config-script",
load: () =>
import(/* webpackChunkName: "panel-config-script" */ "./script/ha-config-script"),
import(
/* webpackChunkName: "panel-config-script" */ "./script/ha-config-script"
),
},
scene: {
tag: "ha-config-scene",
load: () =>
import(/* webpackChunkName: "panel-config-scene" */ "./scene/ha-config-scene"),
import(
/* webpackChunkName: "panel-config-scene" */ "./scene/ha-config-scene"
),
},
users: {
tag: "ha-config-users",
load: () =>
import(/* webpackChunkName: "panel-config-users" */ "./users/ha-config-users"),
import(
/* webpackChunkName: "panel-config-users" */ "./users/ha-config-users"
),
},
zha: {
tag: "zha-config-panel",
load: () =>
import(/* webpackChunkName: "panel-config-zha" */ "./zha/zha-config-panel"),
import(
/* webpackChunkName: "panel-config-zha" */ "./zha/zha-config-panel"
),
},
zwave: {
tag: "ha-config-zwave",
load: () =>
import(/* webpackChunkName: "panel-config-zwave" */ "./zwave/ha-config-zwave"),
import(
/* webpackChunkName: "panel-config-zwave" */ "./zwave/ha-config-zwave"
),
},
},
};

View File

@ -108,9 +108,7 @@ export default class DeviceCondition extends Component<any, any> {
// Returns a callback for ha-form to calculate labels per schema object
return (schema) =>
localize(
`ui.panel.config.automation.editor.condition.type.device.extra_fields.${
schema.name
}`
`ui.panel.config.automation.editor.condition.type.device.extra_fields.${schema.name}`
) || schema.name;
}
}

View File

@ -127,9 +127,7 @@ export default class DeviceActionEditor extends Component<
// Returns a callback for ha-form to calculate labels per schema object
return (schema) =>
localize(
`ui.panel.config.automation.editor.actions.type.device_id.extra_fields.${
schema.name
}`
`ui.panel.config.automation.editor.actions.type.device_id.extra_fields.${schema.name}`
) || schema.name;
}
}

View File

@ -109,9 +109,7 @@ export default class DeviceTrigger extends Component<any, any> {
// Returns a callback for ha-form to calculate labels per schema object
return (schema) =>
localize(
`ui.panel.config.automation.editor.triggers.type.device.extra_fields.${
schema.name
}`
`ui.panel.config.automation.editor.triggers.type.device.extra_fields.${schema.name}`
) || schema.name;
}
}

View File

@ -167,9 +167,9 @@ class HaConfigPerson extends LitElement {
users: this._allowedUsers(users, entry),
createEntry: async (values) => {
const created = await createPerson(this.hass!, values);
this._storageItems = this._storageItems!.concat(created).sort(
(ent1, ent2) => compare(ent1.name, ent2.name)
);
this._storageItems = this._storageItems!.concat(
created
).sort((ent1, ent2) => compare(ent1.name, ent2.name));
},
updateEntry: async (values) => {
const updated = await updatePerson(this.hass!, entry!.id, values);

View File

@ -11,7 +11,9 @@ export interface PersonDetailDialogParams {
}
export const loadPersonDetailDialog = () =>
import(/* webpackChunkName: "person-detail-dialog" */ "./dialog-person-detail");
import(
/* webpackChunkName: "person-detail-dialog" */ "./dialog-person-detail"
);
export const showPersonDetailDialog = (
element: HTMLElement,

View File

@ -112,7 +112,9 @@ class HaUserPicker extends EventsMixin(
dialogShowEvent: "show-add-user",
dialogTag: "ha-dialog-add-user",
dialogImport: () =>
import(/* webpackChunkName: "ha-dialog-add-user" */ "./ha-dialog-add-user"),
import(
/* webpackChunkName: "ha-dialog-add-user" */ "./ha-dialog-add-user"
),
});
}
}

View File

@ -97,10 +97,9 @@ export class HaConfigZha extends LitElement {
private async _fetchBindableDevices(): Promise<void> {
if (this._selectedDevice && this.hass) {
this._bindableDevices = (await fetchBindableDevices(
this.hass,
this._selectedDevice!.ieee
)).sort(sortZHADevices);
this._bindableDevices = (
await fetchBindableDevices(this.hass, this._selectedDevice!.ieee)
).sort(sortZHADevices);
}
}

View File

@ -21,12 +21,16 @@ class ZHAConfigPanel extends HassRouterPage {
configuration: {
tag: "ha-config-zha",
load: () =>
import(/* webpackChunkName: "zha-configuration-page" */ "./ha-config-zha"),
import(
/* webpackChunkName: "zha-configuration-page" */ "./ha-config-zha"
),
},
add: {
tag: "zha-add-devices-page",
load: () =>
import(/* webpackChunkName: "zha-add-devices-page" */ "./zha-add-devices-page"),
import(
/* webpackChunkName: "zha-add-devices-page" */ "./zha-add-devices-page"
),
},
},
};

View File

@ -137,7 +137,9 @@ class OzwLog extends LocalizeMixin(EventsMixin(PolymerElement)) {
dialogShowEvent: "show-ozwlog-dialog",
dialogTag: "zwave-log-dialog",
dialogImport: () =>
import(/* webpackChunkName: "zwave-log-dialog" */ "./zwave-log-dialog"),
import(
/* webpackChunkName: "zwave-log-dialog" */ "./zwave-log-dialog"
),
});
}
}

View File

@ -21,7 +21,9 @@ const registerDialog = (element: HTMLElement) =>
dialogShowEvent,
dialogTag,
dialogImport: () =>
import(/* webpackChunkName: "system-log-detail-dialog" */ "./dialog-system-log-detail"),
import(
/* webpackChunkName: "system-log-detail-dialog" */ "./dialog-system-log-detail"
),
});
export const showSystemLogDetailDialog = (

View File

@ -40,7 +40,9 @@ const BUTTONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", "clear"];
@customElement("hui-alarm-panel-card")
class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
public static async getConfigElement() {
await import(/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor");
await import(
/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor"
);
return document.createElement("hui-alarm-panel-card-editor");
}

View File

@ -23,7 +23,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-entities-card")
class HuiEntitiesCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor");
await import(
/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor"
);
return document.createElement("hui-entities-card-editor");
}

View File

@ -34,7 +34,9 @@ import { ActionHandlerEvent } from "../../../data/lovelace";
@customElement("hui-entity-button-card")
class HuiEntityButtonCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor");
await import(
/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor"
);
return document.createElement("hui-entity-button-card-editor");
}

View File

@ -33,7 +33,9 @@ export const severityMap = {
@customElement("hui-gauge-card")
class HuiGaugeCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-gauge-card-editor" */ "../editor/config-elements/hui-gauge-card-editor");
await import(
/* webpackChunkName: "hui-gauge-card-editor" */ "../editor/config-elements/hui-gauge-card-editor"
);
return document.createElement("hui-gauge-card-editor");
}
public static getStubConfig(): object {

View File

@ -32,7 +32,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-glance-card")
export class HuiGlanceCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor");
await import(
/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor"
);
return document.createElement("hui-glance-card-editor");
}

View File

@ -9,7 +9,9 @@ import { processConfigEntities } from "../common/process-config-entities";
class HuiHistoryGraphCard extends PolymerElement {
static async getConfigElement() {
await import(/* webpackChunkName: "hui-history-graph-card-editor" */ "../editor/config-elements/hui-history-graph-card-editor");
await import(
/* webpackChunkName: "hui-history-graph-card-editor" */ "../editor/config-elements/hui-history-graph-card-editor"
);
return document.createElement("hui-history-graph-card-editor");
}

View File

@ -17,7 +17,9 @@ import { IframeCardConfig } from "./types";
@customElement("hui-iframe-card")
export class HuiIframeCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-iframe-card-editor" */ "../editor/config-elements/hui-iframe-card-editor");
await import(
/* webpackChunkName: "hui-iframe-card-editor" */ "../editor/config-elements/hui-iframe-card-editor"
);
return document.createElement("hui-iframe-card-editor");
}
public static getStubConfig(): object {

View File

@ -33,7 +33,9 @@ import { SUPPORT_BRIGHTNESS } from "../../../data/light";
@customElement("hui-light-card")
export class HuiLightCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor");
await import(
/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor"
);
return document.createElement("hui-light-card-editor");
}
public static getStubConfig(): object {
@ -165,9 +167,9 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
}
private _dragEvent(e: any): void {
this.shadowRoot!.querySelector(".brightness")!.innerHTML = `${
e.detail.value
} %`;
this.shadowRoot!.querySelector(
".brightness"
)!.innerHTML = `${e.detail.value} %`;
this._showBrightness();
this._hideBrightness();
}

View File

@ -34,7 +34,9 @@ import { classMap } from "lit-html/directives/class-map";
@customElement("hui-map-card")
class HuiMapCard extends LitElement implements LovelaceCard {
public static async getConfigElement() {
await import(/* webpackChunkName: "hui-map-card-editor" */ "../editor/config-elements/hui-map-card-editor");
await import(
/* webpackChunkName: "hui-map-card-editor" */ "../editor/config-elements/hui-map-card-editor"
);
return document.createElement("hui-map-card-editor");
}

View File

@ -23,7 +23,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-markdown-card")
export class HuiMarkdownCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-markdown-card-editor" */ "../editor/config-elements/hui-markdown-card-editor");
await import(
/* webpackChunkName: "hui-markdown-card-editor" */ "../editor/config-elements/hui-markdown-card-editor"
);
return document.createElement("hui-markdown-card-editor");
}

View File

@ -4,7 +4,9 @@ import LegacyWrapperCard from "./hui-legacy-wrapper-card";
class HuiMediaControlCard extends LegacyWrapperCard {
static async getConfigElement() {
await import(/* webpackChunkName: "hui-media-control-card-editor" */ "../editor/config-elements/hui-media-control-card-editor");
await import(
/* webpackChunkName: "hui-media-control-card-editor" */ "../editor/config-elements/hui-media-control-card-editor"
);
return document.createElement("hui-media-control-card-editor");
}

View File

@ -24,7 +24,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-picture-card")
export class HuiPictureCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-card-editor" */ "../editor/config-elements/hui-picture-card-editor");
await import(
/* webpackChunkName: "hui-picture-card-editor" */ "../editor/config-elements/hui-picture-card-editor"
);
return document.createElement("hui-picture-card-editor");
}
public static getStubConfig(): object {

View File

@ -32,7 +32,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-picture-entity-card")
class HuiPictureEntityCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-entity-card-editor" */ "../editor/config-elements/hui-picture-entity-card-editor");
await import(
/* webpackChunkName: "hui-picture-entity-card-editor" */ "../editor/config-elements/hui-picture-entity-card-editor"
);
return document.createElement("hui-picture-entity-card-editor");
}
public static getStubConfig(): object {
@ -58,7 +60,9 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
if (
computeDomain(config.entity) !== "camera" &&
(!config.image && !config.state_image && !config.camera_image)
!config.image &&
!config.state_image &&
!config.camera_image
) {
throw new Error("No image source configured.");
}

View File

@ -36,7 +36,9 @@ const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]);
@customElement("hui-picture-glance-card")
class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-glance-card-editor" */ "../editor/config-elements/hui-picture-glance-card-editor");
await import(
/* webpackChunkName: "hui-picture-glance-card-editor" */ "../editor/config-elements/hui-picture-glance-card-editor"
);
return document.createElement("hui-picture-glance-card-editor");
}
public static getStubConfig(): object {

View File

@ -33,7 +33,9 @@ const SENSORS = {
@customElement("hui-plant-status-card")
class HuiPlantStatusCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-plant-status-card-editor" */ "../editor/config-elements/hui-plant-status-card-editor");
await import(
/* webpackChunkName: "hui-plant-status-card-editor" */ "../editor/config-elements/hui-plant-status-card-editor"
);
return document.createElement("hui-plant-status-card-editor");
}

View File

@ -108,8 +108,14 @@ const coordinates = (
history.forEach((item) => (item.state = Number(item.state)));
history = history.filter((item) => !Number.isNaN(item.state));
const min = Math.min.apply(Math, history.map((item) => item.state));
const max = Math.max.apply(Math, history.map((item) => item.state));
const min = Math.min.apply(
Math,
history.map((item) => item.state)
);
const max = Math.max.apply(
Math,
history.map((item) => item.state)
);
const now = new Date().getTime();
const reduce = (res, item, point) => {
@ -141,7 +147,9 @@ const coordinates = (
@customElement("hui-sensor-card")
class HuiSensorCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-sensor-card-editor" */ "../editor/config-elements/hui-sensor-card-editor");
await import(
/* webpackChunkName: "hui-sensor-card-editor" */ "../editor/config-elements/hui-sensor-card-editor"
);
return document.createElement("hui-sensor-card-editor");
}

View File

@ -30,7 +30,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-shopping-list-card")
class HuiShoppingListCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor");
await import(
/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor"
);
return document.createElement("hui-shopping-list-card-editor");
}

View File

@ -47,7 +47,9 @@ const modeIcons: { [mode in HvacMode]: string } = {
@customElement("hui-thermostat-card")
export class HuiThermostatCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor");
await import(
/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor"
);
return document.createElement("hui-thermostat-card-editor");
}
@ -179,9 +181,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
${
stateObj.attributes.hvac_action
? this.hass!.localize(
`state_attributes.climate.hvac_action.${
stateObj.attributes.hvac_action
}`
`state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}`
)
: this.hass!.localize(`state.climate.${stateObj.state}`)
}
@ -191,9 +191,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
? html`
-
${this.hass!.localize(
`state_attributes.climate.preset_mode.${
stateObj.attributes.preset_mode
}`
`state_attributes.climate.preset_mode.${stateObj.attributes.preset_mode}`
) || stateObj.attributes.preset_mode}
`
: ""

View File

@ -65,7 +65,9 @@ const weatherIcons = {
@customElement("hui-weather-forecast-card")
class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-weather-forecast-card-editor" */ "../editor/config-elements/hui-weather-forecast-card-editor");
await import(
/* webpackChunkName: "hui-weather-forecast-card-editor" */ "../editor/config-elements/hui-weather-forecast-card-editor"
);
return document.createElement("hui-weather-forecast-card-editor");
}
public static getStubConfig(): object {
@ -218,7 +220,9 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
? html`
${new Date(item.datetime).toLocaleTimeString(
this.hass!.language,
{ hour: "numeric" }
{
hour: "numeric",
}
)}
`
: ""}

View File

@ -287,9 +287,10 @@ const generateViewConfig = (
splitted.groups.forEach((groupEntity) => {
cards = cards.concat(
computeCards(
groupEntity.attributes.entity_id.map(
(entityId): [string, HassEntity] => [entityId, entities[entityId]]
),
groupEntity.attributes.entity_id.map((entityId): [
string,
HassEntity
] => [entityId, entities[entityId]]),
{
title: computeStateName(groupEntity),
show_header_toggle: groupEntity.attributes.control !== "hidden",
@ -303,9 +304,10 @@ const generateViewConfig = (
.forEach((domain) => {
cards = cards.concat(
computeCards(
ungroupedEntitites[domain].map(
(entityId): [string, HassEntity] => [entityId, entities[entityId]]
),
ungroupedEntitites[domain].map((entityId): [string, HassEntity] => [
entityId,
entities[entityId],
]),
{
title: localize(`domain.${domain}`),
}
@ -418,7 +420,9 @@ export const generateLovelaceConfigFromData = async (
// User has no entities
if (views.length === 1 && views[0].cards!.length === 0) {
import(/* webpackChunkName: "hui-empty-state-card" */ "../cards/hui-empty-state-card");
import(
/* webpackChunkName: "hui-empty-state-card" */ "../cards/hui-empty-state-card"
);
views[0].cards!.push({
type: "custom:hui-empty-state-card",
});

View File

@ -32,9 +32,9 @@ export const loadLovelaceResources = (
break;
case "html":
import(/* webpackChunkName: "import-href-polyfill" */ "../../../resources/html-import/import-href").then(
({ importHref }) => importHref(normalizedUrl)
);
import(
/* webpackChunkName: "import-href-polyfill" */ "../../../resources/html-import/import-href"
).then(({ importHref }) => importHref(normalizedUrl));
break;
default:

View File

@ -23,7 +23,9 @@ const registerEditCardDialog = (element: HTMLElement): Event =>
dialogShowEvent,
dialogTag,
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-card" */ "./hui-dialog-edit-card"),
import(
/* webpackChunkName: "hui-dialog-edit-card" */ "./hui-dialog-edit-card"
),
});
export const showEditCardDialog = (

View File

@ -20,7 +20,9 @@ const registerEditCardDialog = (element: HTMLElement): Event =>
dialogShowEvent: "show-move-card-view",
dialogTag: "hui-dialog-move-card-view",
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-move-card-view" */ "./hui-dialog-move-card-view"),
import(
/* webpackChunkName: "hui-dialog-move-card-view" */ "./hui-dialog-move-card-view"
),
});
export const showMoveCardViewDialog = (

View File

@ -17,7 +17,9 @@ const registerEditLovelaceDialog = (element: HTMLElement): Event =>
dialogShowEvent,
dialogTag,
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-lovelace" */ "./hui-dialog-edit-lovelace"),
import(
/* webpackChunkName: "hui-dialog-edit-lovelace" */ "./hui-dialog-edit-lovelace"
),
});
export const showEditLovelaceDialog = (

View File

@ -13,7 +13,9 @@ export const showSelectViewDialog = (
fireEvent(element, "show-dialog", {
dialogTag: "hui-dialog-select-view",
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-select-view" */ "./hui-dialog-select-view"),
import(
/* webpackChunkName: "hui-dialog-select-view" */ "./hui-dialog-select-view"
),
dialogParams: selectViewDialogParams,
});
};

View File

@ -27,7 +27,9 @@ export const showSaveDialog = (
dialogShowEvent,
dialogTag,
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-save-config" */ "./hui-dialog-save-config"),
import(
/* webpackChunkName: "hui-dialog-save-config" */ "./hui-dialog-save-config"
),
});
}
fireEvent(element, dialogShowEvent, saveDialogParams);

View File

@ -27,7 +27,9 @@ const registerEditViewDialog = (element: HTMLElement): Event =>
dialogShowEvent,
dialogTag,
dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-view" */ "./hui-dialog-edit-view"),
import(
/* webpackChunkName: "hui-dialog-edit-view" */ "./hui-dialog-edit-view"
),
});
export const showEditViewDialog = (

View File

@ -650,13 +650,13 @@ class HUIRoot extends LitElement {
if (viewIndex === "hass-unused-entities") {
const unusedEntities = document.createElement("hui-unused-entities");
// Wait for promise to resolve so that the element has been upgraded.
import(/* webpackChunkName: "hui-unused-entities" */ "./editor/unused-entities/hui-unused-entities").then(
() => {
unusedEntities.hass = this.hass!;
unusedEntities.lovelace = this.lovelace!;
unusedEntities.narrow = this.narrow;
}
);
import(
/* webpackChunkName: "hui-unused-entities" */ "./editor/unused-entities/hui-unused-entities"
).then(() => {
unusedEntities.hass = this.hass!;
unusedEntities.lovelace = this.lovelace!;
unusedEntities.narrow = this.narrow;
});
if (this.config.background) {
unusedEntities.style.setProperty(
"--lovelace-background",

View File

@ -157,7 +157,9 @@ class HaPanelMailbox extends EventsMixin(LocalizeMixin(PolymerElement)) {
dialogShowEvent: "show-audio-message-dialog",
dialogTag: "ha-dialog-show-audio-message",
dialogImport: () =>
import(/* webpackChunkName: "ha-dialog-show-audio-message" */ "./ha-dialog-show-audio-message"),
import(
/* webpackChunkName: "ha-dialog-show-audio-message" */ "./ha-dialog-show-audio-message"
),
});
}
this.hassChanged = this.hassChanged.bind(this);

View File

@ -34,9 +34,7 @@ class HaEntityMarker extends EventsMixin(PolymerElement) {
</style>
<div class="marker">
<template is="dom-if" if="[[entityName]]"
>[[entityName]]</template
>
<template is="dom-if" if="[[entityName]]">[[entityName]]</template>
<template is="dom-if" if="[[entityPicture]]">
<iron-image
sizing="cover"

View File

@ -288,9 +288,7 @@ class HaMfaModuleSetupFlow extends LocalizeMixin(EventsMixin(PolymerElement)) {
_computeStepDescription(localize, step) {
const args = [
`component.auth.mfa_setup.${step.handler}.step.${
step.step_id
}.description`,
`component.auth.mfa_setup.${step.handler}.step.${step.step_id}.description`,
];
const placeholders = step.description_placeholders || {};
Object.keys(placeholders).forEach((key) => {
@ -304,9 +302,7 @@ class HaMfaModuleSetupFlow extends LocalizeMixin(EventsMixin(PolymerElement)) {
// Returns a callback for ha-form to calculate labels per schema object
return (schema) =>
localize(
`component.auth.mfa_setup.${step.handler}.step.${step.step_id}.data.${
schema.name
}`
`component.auth.mfa_setup.${step.handler}.step.${step.step_id}.data.${schema.name}`
) || schema.name;
}

View File

@ -84,7 +84,9 @@ class HaMfaModulesCard extends EventsMixin(LocalizeMixin(PolymerElement)) {
dialogShowEvent: "show-mfa-module-setup-flow",
dialogTag: "ha-mfa-module-setup-flow",
dialogImport: () =>
import(/* webpackChunkName: "ha-mfa-module-setup-flow" */ "./ha-mfa-module-setup-flow"),
import(
/* webpackChunkName: "ha-mfa-module-setup-flow" */ "./ha-mfa-module-setup-flow"
),
});
}
}

View File

@ -30,7 +30,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
if (askWrite()) {
this.updateComplete
.then(() =>
import(/* webpackChunkName: "ha-store-auth-card" */ "../dialogs/ha-store-auth-card")
import(
/* webpackChunkName: "ha-store-auth-card" */ "../dialogs/ha-store-auth-card"
)
)
.then(() => {
const el = document.createElement("ha-store-auth-card");

View File

@ -7,7 +7,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
// Need to load in advance because when disconnected, can't dynamically load code.
import(/* webpackChunkName: "notification-manager" */ "../managers/notification-manager");
import(
/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"
);
}
protected hassReconnected() {

View File

@ -19,7 +19,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
this.addEventListener("hass-more-info", (e) => this._handleMoreInfo(e));
// Load it once we are having the initial rendering done.
import(/* webpackChunkName: "more-info-dialog" */ "../dialogs/ha-more-info-dialog");
import(
/* webpackChunkName: "more-info-dialog" */ "../dialogs/ha-more-info-dialog"
);
}
private async _handleMoreInfo(ev) {

View File

@ -10,7 +10,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
dialogShowEvent: "hass-notification",
dialogTag: "notification-manager",
dialogImport: () =>
import(/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"),
import(
/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"
),
});
}
};

View File

@ -6,7 +6,9 @@ const JS_CACHE = {};
export const loadCustomPanel = (panelConfig): Promise<unknown> => {
if (panelConfig.html_url) {
const toLoad = [
import(/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href"),
import(
/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href"
),
];
if (!panelConfig.embed_iframe) {

View File

@ -105,9 +105,7 @@ async function fetchTranslation(fingerprint) {
});
if (!response.ok) {
throw new Error(
`Fail to fetch translation ${fingerprint}: HTTP response status is ${
response.status
}`
`Fail to fetch translation ${fingerprint}: HTTP response status is ${response.status}`
);
}
return response.json();

932
yarn.lock

File diff suppressed because it is too large Load Diff