mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Introduce TypeScript (#1773)
This commit is contained in:
parent
e2511c5ed3
commit
97e1aae9c0
@ -3,7 +3,7 @@ module.exports.babelLoaderConfig = ({ latestBuild }) => {
|
||||
throw Error("latestBuild not defined for babel loader config");
|
||||
}
|
||||
return {
|
||||
test: /\.m?js$/,
|
||||
test: /\.m?js$|\.ts$/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
@ -12,6 +12,7 @@ module.exports.babelLoaderConfig = ({ latestBuild }) => {
|
||||
require("@babel/preset-env").default,
|
||||
{ modules: false },
|
||||
],
|
||||
require("@babel/preset-typescript").default,
|
||||
].filter(Boolean),
|
||||
plugins: [
|
||||
// Part of ES2018. Converts {...a, b: 2} to Object.assign({}, a, {b: 2})
|
||||
|
@ -56,6 +56,9 @@ module.exports = {
|
||||
},
|
||||
}),
|
||||
].filter(Boolean),
|
||||
resolve: {
|
||||
extensions: [".ts", ".js", ".json"],
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js",
|
||||
chunkFilename: chunkFilename,
|
||||
|
@ -42,6 +42,9 @@ module.exports = {
|
||||
exclude: [/\.js\.map$/, /\.LICENSE$/, /\.py$/, /\.txt$/],
|
||||
}),
|
||||
].filter(Boolean),
|
||||
resolve: {
|
||||
extensions: [".ts", ".js", ".json"],
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js",
|
||||
chunkFilename,
|
||||
|
@ -8,7 +8,7 @@
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "script/build_frontend",
|
||||
"lint": "eslint src hassio/src gallery/src test-mocha && polymer lint",
|
||||
"lint": "eslint src hassio/src gallery/src test-mocha && tslint -c tslint.json 'src/**/*.ts' 'hassio/src/**/*.ts' 'gallery/src/**/*.ts' 'test-mocha/**/*.ts' && polymer lint",
|
||||
"mocha": "node_modules/.bin/mocha --opts test-mocha/mocha.opts",
|
||||
"test": "npm run lint && npm run mocha",
|
||||
"docker_build": "sh ./script/docker_run.sh build $npm_package_version",
|
||||
@ -91,10 +91,12 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.2",
|
||||
"@babel/plugin-external-helpers": "^7.0.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.0.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
||||
"@babel/plugin-transform-react-jsx": "^7.0.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"@babel/preset-typescript": "7.0.0",
|
||||
"@gfx/zopfli": "^1.0.9",
|
||||
"babel-eslint": "^10",
|
||||
"babel-loader": "^8.0.4",
|
||||
@ -133,6 +135,10 @@
|
||||
"reify": "^0.17.3",
|
||||
"require-dir": "^1.0.0",
|
||||
"sinon": "^6.3.4",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0",
|
||||
"tslint-eslint-rules": "^5.4.0",
|
||||
"typescript": "3.1.3",
|
||||
"wct-browser-legacy": "^1.0.1",
|
||||
"web-component-tester": "^6.8.0",
|
||||
"webpack": "^4.19.1",
|
||||
|
@ -1,52 +0,0 @@
|
||||
import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js";
|
||||
import { LocalizeBaseMixin } from "./localize-base-mixin";
|
||||
|
||||
export const HassLocalizeLitMixin = dedupingMixin(
|
||||
(superClass) =>
|
||||
class extends LocalizeBaseMixin(superClass) {
|
||||
static get properties() {
|
||||
return {
|
||||
hass: {},
|
||||
localize: {},
|
||||
};
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
|
||||
let language;
|
||||
let resources;
|
||||
if (this.hass) {
|
||||
language = this.hass.language;
|
||||
resources = this.hass.resources;
|
||||
}
|
||||
this.localize = this.__computeLocalize(language, resources);
|
||||
}
|
||||
|
||||
updated(changedProperties) {
|
||||
super.updated(changedProperties);
|
||||
|
||||
if (!changedProperties.has("hass")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let oldLanguage;
|
||||
let oldResources;
|
||||
if (changedProperties.hass) {
|
||||
oldLanguage = changedProperties.hass.language;
|
||||
oldResources = changedProperties.hass.resources;
|
||||
}
|
||||
|
||||
let language;
|
||||
let resources;
|
||||
if (this.hass) {
|
||||
language = this.hass.language;
|
||||
resources = this.hass.resources;
|
||||
}
|
||||
|
||||
if (oldLanguage !== language || oldResources !== resources) {
|
||||
this.localize = this.__computeLocalize(language, resources);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
67
src/mixins/lit-localize-mixin.ts
Normal file
67
src/mixins/lit-localize-mixin.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import {
|
||||
Constructor,
|
||||
LitElement,
|
||||
PropertyDeclarations,
|
||||
PropertyValues,
|
||||
} from "@polymer/lit-element";
|
||||
import { HomeAssistant } from "../types";
|
||||
import {
|
||||
LocalizeBaseMixin,
|
||||
LocalizeFunc,
|
||||
LocalizeMixin,
|
||||
} from "./localize-base-mixin";
|
||||
|
||||
export const HassLocalizeLitMixin = (
|
||||
superClass: Constructor<LitElement>
|
||||
): Constructor<LitElement & LocalizeMixin> =>
|
||||
// @ts-ignore
|
||||
class extends LocalizeBaseMixin(superClass) {
|
||||
protected hass: HomeAssistant;
|
||||
protected localize: LocalizeFunc;
|
||||
|
||||
static get properties(): PropertyDeclarations {
|
||||
return {
|
||||
hass: {},
|
||||
localize: {},
|
||||
};
|
||||
}
|
||||
|
||||
public connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
let language;
|
||||
let resources;
|
||||
if (this.hass) {
|
||||
language = this.hass.language;
|
||||
resources = this.hass.resources;
|
||||
}
|
||||
this.localize = this.__computeLocalize(language, resources);
|
||||
}
|
||||
|
||||
public updated(changedProperties: PropertyValues) {
|
||||
super.updated(changedProperties);
|
||||
|
||||
if (!changedProperties.has("hass")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let oldLanguage;
|
||||
let oldResources;
|
||||
const hass = changedProperties.get("hass") as HomeAssistant;
|
||||
if (hass) {
|
||||
oldLanguage = hass.language;
|
||||
oldResources = hass.resources;
|
||||
}
|
||||
|
||||
let language;
|
||||
let resources;
|
||||
if (this.hass) {
|
||||
language = this.hass.language;
|
||||
resources = this.hass.resources;
|
||||
}
|
||||
|
||||
if (oldLanguage !== language || oldResources !== resources) {
|
||||
this.localize = this.__computeLocalize(language, resources);
|
||||
}
|
||||
}
|
||||
};
|
@ -1,82 +0,0 @@
|
||||
import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js";
|
||||
import IntlMessageFormat from "intl-messageformat/src/main.js";
|
||||
|
||||
/**
|
||||
Adapted from Polymer app-localize-behavior.
|
||||
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
export const LocalizeBaseMixin = dedupingMixin(
|
||||
(superClass) =>
|
||||
class extends superClass {
|
||||
/**
|
||||
* Returns a computed `localize` method, based on the current `language`.
|
||||
*/
|
||||
__computeLocalize(language, resources, formats) {
|
||||
const proto = this.constructor.prototype;
|
||||
|
||||
// Check if localCache exist just in case.
|
||||
this.__checkLocalizationCache(proto);
|
||||
|
||||
// Everytime any of the parameters change, invalidate the strings cache.
|
||||
if (!proto.__localizationCache) {
|
||||
proto.__localizationCache = {
|
||||
messages: {},
|
||||
};
|
||||
}
|
||||
proto.__localizationCache.messages = {};
|
||||
|
||||
return (key, ...args) => {
|
||||
if (!key || !resources || !language || !resources[language]) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Cache the key/value pairs for the same language, so that we don't
|
||||
// do extra work if we're just reusing strings across an application.
|
||||
const translatedValue = resources[language][key];
|
||||
|
||||
if (!translatedValue) {
|
||||
return this.useKeyIfMissing ? key : "";
|
||||
}
|
||||
|
||||
const messageKey = key + translatedValue;
|
||||
let translatedMessage =
|
||||
proto.__localizationCache.messages[messageKey];
|
||||
|
||||
if (!translatedMessage) {
|
||||
translatedMessage = new IntlMessageFormat(
|
||||
translatedValue,
|
||||
language,
|
||||
formats
|
||||
);
|
||||
proto.__localizationCache.messages[messageKey] = translatedMessage;
|
||||
}
|
||||
|
||||
const argObject = {};
|
||||
for (let i = 0; i < args.length; i += 2) {
|
||||
argObject[args[i]] = args[i + 1];
|
||||
}
|
||||
|
||||
return translatedMessage.format(argObject);
|
||||
};
|
||||
}
|
||||
|
||||
__checkLocalizationCache(proto) {
|
||||
// do nothing if proto is undefined.
|
||||
if (proto === undefined) return;
|
||||
|
||||
// In the event proto not have __localizationCache object, create it.
|
||||
if (proto.__localizationCache === undefined) {
|
||||
proto.__localizationCache = {
|
||||
messages: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
109
src/mixins/localize-base-mixin.ts
Normal file
109
src/mixins/localize-base-mixin.ts
Normal file
@ -0,0 +1,109 @@
|
||||
import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js";
|
||||
import IntlMessageFormat from "intl-messageformat/src/main.js";
|
||||
|
||||
/**
|
||||
* Adapted from Polymer app-localize-behavior.
|
||||
*
|
||||
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Optional dictionary of user defined formats, as explained here:
|
||||
* http://formatjs.io/guides/message-syntax/#custom-formats
|
||||
*
|
||||
* For example, a valid dictionary of formats would be:
|
||||
* this.formats = {
|
||||
* number: { USD: { style: 'currency', currency: 'USD' } }
|
||||
* }
|
||||
*/
|
||||
interface FormatType {
|
||||
[format: string]: any;
|
||||
}
|
||||
export interface FormatsType {
|
||||
number: FormatType;
|
||||
date: FormatType;
|
||||
time: FormatType;
|
||||
}
|
||||
|
||||
export type LocalizeFunc = (key: string, ...args: any[]) => string;
|
||||
|
||||
export interface LocalizeMixin {
|
||||
localize: LocalizeFunc;
|
||||
}
|
||||
|
||||
export const LocalizeBaseMixin = (superClass) =>
|
||||
class extends superClass {
|
||||
/**
|
||||
* Returns a computed `localize` method, based on the current `language`.
|
||||
*/
|
||||
public __computeLocalize(
|
||||
language: string,
|
||||
resources: string,
|
||||
formats?: FormatsType
|
||||
): LocalizeFunc {
|
||||
const proto = this.constructor.prototype;
|
||||
|
||||
// Check if localCache exist just in case.
|
||||
this.__checkLocalizationCache(proto);
|
||||
|
||||
// Everytime any of the parameters change, invalidate the strings cache.
|
||||
if (!proto.__localizationCache) {
|
||||
proto.__localizationCache = {
|
||||
messages: {},
|
||||
};
|
||||
}
|
||||
proto.__localizationCache.messages = {};
|
||||
|
||||
return (key, ...args) => {
|
||||
if (!key || !resources || !language || !resources[language]) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Cache the key/value pairs for the same language, so that we don't
|
||||
// do extra work if we're just reusing strings across an application.
|
||||
const translatedValue = resources[language][key];
|
||||
|
||||
if (!translatedValue) {
|
||||
return this.useKeyIfMissing ? key : "";
|
||||
}
|
||||
|
||||
const messageKey = key + translatedValue;
|
||||
let translatedMessage = proto.__localizationCache.messages[messageKey];
|
||||
|
||||
if (!translatedMessage) {
|
||||
translatedMessage = new (IntlMessageFormat as any)(
|
||||
translatedValue,
|
||||
language,
|
||||
formats
|
||||
);
|
||||
proto.__localizationCache.messages[messageKey] = translatedMessage;
|
||||
}
|
||||
|
||||
const argObject = {};
|
||||
for (let i = 0; i < args.length; i += 2) {
|
||||
argObject[args[i]] = args[i + 1];
|
||||
}
|
||||
|
||||
return translatedMessage.format(argObject);
|
||||
};
|
||||
}
|
||||
|
||||
public __checkLocalizationCache(proto) {
|
||||
// do nothing if proto is undefined.
|
||||
if (proto === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In the event proto not have __localizationCache object, create it.
|
||||
if (proto.__localizationCache === undefined) {
|
||||
proto.__localizationCache = {
|
||||
messages: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js";
|
||||
import { LocalizeBaseMixin } from "./localize-base-mixin.js";
|
||||
import { LocalizeBaseMixin } from "./localize-base-mixin";
|
||||
/**
|
||||
* Polymer Mixin to enable a localize function powered by language/resources from hass object.
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { LitElement, html } from "@polymer/lit-element";
|
||||
import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
||||
import { classMap } from "lit-html/directives/classMap.js";
|
||||
import { repeat } from "lit-html/directives/repeat";
|
||||
|
||||
@ -12,11 +12,89 @@ import "../../../components/entity/state-badge.js";
|
||||
import "../../../components/ha-card.js";
|
||||
import "../../../components/ha-icon.js";
|
||||
|
||||
import EventsMixin from "../../../mixins/events-mixin.js";
|
||||
import { HassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin.js";
|
||||
import { fireEvent } from "../../../common/dom/fire_event.js";
|
||||
import { HassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||
import { HomeAssistant } from "../../../types.js";
|
||||
import { LovelaceCard, LovelaceConfig } from "../types.js";
|
||||
|
||||
class HuiGlanceCard extends HassLocalizeLitMixin(EventsMixin(LitElement)) {
|
||||
renderStyle() {
|
||||
interface EntityConfig {
|
||||
name: string;
|
||||
icon: string;
|
||||
entity: string;
|
||||
tap_action: "toggle" | "call-service" | "more-info";
|
||||
service?: string;
|
||||
service_data?: object;
|
||||
}
|
||||
|
||||
interface Config extends LovelaceConfig {
|
||||
show_name?: boolean;
|
||||
show_state?: boolean;
|
||||
title?: string;
|
||||
column_width?: string;
|
||||
theming?: "primary";
|
||||
entities: EntityConfig[];
|
||||
}
|
||||
|
||||
class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
|
||||
implements LovelaceCard {
|
||||
static get properties(): PropertyDeclarations {
|
||||
return {
|
||||
hass: {},
|
||||
};
|
||||
}
|
||||
protected hass: HomeAssistant;
|
||||
protected config: Config;
|
||||
protected configEntities: EntityConfig[];
|
||||
|
||||
public getCardSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public setConfig(config: Config) {
|
||||
this.config = config;
|
||||
this.style.setProperty(
|
||||
"--glance-column-width",
|
||||
config.column_width || "20%"
|
||||
);
|
||||
|
||||
if (config.theming) {
|
||||
if (typeof config.theming !== "string") {
|
||||
throw new Error("Incorrect theming config.");
|
||||
}
|
||||
this.classList.add(`theme-${config.theming}`);
|
||||
}
|
||||
|
||||
this.configEntities = processConfigEntities(config.entities);
|
||||
if (this.hass) {
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.config) {
|
||||
return html``;
|
||||
}
|
||||
const { title } = this.config;
|
||||
const states = this.hass.states;
|
||||
const entities = this.configEntities.filter(
|
||||
(conf) => conf.entity in states
|
||||
);
|
||||
|
||||
return html`
|
||||
${this.renderStyle()}
|
||||
<ha-card .header="${title}">
|
||||
<div class="entities ${classMap({ "no-header": !title })}">
|
||||
${repeat<EntityConfig>(
|
||||
entities,
|
||||
(entityConf) => entityConf.entity,
|
||||
(entityConf) => this.renderEntity(entityConf)
|
||||
)}
|
||||
</div>
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
|
||||
private renderStyle() {
|
||||
return html`
|
||||
<style>
|
||||
:host(.theme-primary) {
|
||||
@ -59,17 +137,17 @@ class HuiGlanceCard extends HassLocalizeLitMixin(EventsMixin(LitElement)) {
|
||||
`;
|
||||
}
|
||||
|
||||
renderEntity(entityConf) {
|
||||
private renderEntity(entityConf) {
|
||||
const stateObj = this.hass.states[entityConf.entity];
|
||||
|
||||
return html`
|
||||
<div
|
||||
class="entity"
|
||||
.entityConf="${entityConf}"
|
||||
@click="${this._handleClick}"
|
||||
@click="${this.handleClick}"
|
||||
>
|
||||
${
|
||||
this._config.show_name !== false
|
||||
this.config.show_name !== false
|
||||
? html`<div class="name">${
|
||||
"name" in entityConf
|
||||
? entityConf.name
|
||||
@ -82,7 +160,7 @@ class HuiGlanceCard extends HassLocalizeLitMixin(EventsMixin(LitElement)) {
|
||||
.overrideIcon="${entityConf.icon}"
|
||||
></state-badge>
|
||||
${
|
||||
this._config.show_state !== false
|
||||
this.config.show_state !== false
|
||||
? html`<div>${computeStateDisplay(this.localize, stateObj)}</div>`
|
||||
: ""
|
||||
}
|
||||
@ -90,60 +168,8 @@ class HuiGlanceCard extends HassLocalizeLitMixin(EventsMixin(LitElement)) {
|
||||
`;
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this._config) return html``;
|
||||
const { title } = this._config;
|
||||
const states = this.hass.states;
|
||||
const entities = this._configEntities.filter(
|
||||
(conf) => conf.entity in states
|
||||
);
|
||||
|
||||
return html`
|
||||
${this.renderStyle()}
|
||||
<ha-card .header="${title}">
|
||||
<div class="entities ${classMap({ "no-header": !title })}">
|
||||
${repeat(
|
||||
entities,
|
||||
(entityConf) => entityConf.entity,
|
||||
(entityConf) => this.renderEntity(entityConf)
|
||||
)}
|
||||
</div>
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
return {
|
||||
hass: {},
|
||||
};
|
||||
}
|
||||
|
||||
getCardSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
setConfig(config) {
|
||||
this._config = config;
|
||||
this.style.setProperty(
|
||||
"--glance-column-width",
|
||||
(config && config.column_width) || "20%"
|
||||
);
|
||||
|
||||
if (config && config.theming) {
|
||||
if (typeof config.theming !== "string") {
|
||||
throw new Error("Incorrect theming config.");
|
||||
}
|
||||
this.classList.add(`theme-${config.theming}`);
|
||||
}
|
||||
|
||||
this._configEntities = processConfigEntities(config.entities);
|
||||
if (this.hass) {
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
_handleClick(ev) {
|
||||
const config = ev.currentTarget.entityConf;
|
||||
private handleClick(ev: MouseEvent) {
|
||||
const config = (ev.currentTarget as any).entityConf as EntityConfig;
|
||||
const entityId = config.entity;
|
||||
switch (config.tap_action) {
|
||||
case "toggle":
|
||||
@ -156,9 +182,15 @@ class HuiGlanceCard extends HassLocalizeLitMixin(EventsMixin(LitElement)) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this.fire("hass-more-info", { entityId });
|
||||
fireEvent(this, "hass-more-info", { entityId });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"hui-glance-card": HuiGlanceCard;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("hui-glance-card", HuiGlanceCard);
|
@ -4,7 +4,7 @@ import "../cards/hui-conditional-card.js";
|
||||
import "../cards/hui-entities-card.js";
|
||||
import "../cards/hui-entity-filter-card.js";
|
||||
import "../cards/hui-error-card.js";
|
||||
import "../cards/hui-glance-card";
|
||||
import "../cards/hui-glance-card.ts";
|
||||
import "../cards/hui-history-graph-card.js";
|
||||
import "../cards/hui-horizontal-stack-card.js";
|
||||
import "../cards/hui-iframe-card.js";
|
||||
|
8
src/panels/lovelace/types.ts
Normal file
8
src/panels/lovelace/types.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export interface LovelaceConfig {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface LovelaceCard {
|
||||
getCardSize(): number;
|
||||
setConfig(config: LovelaceConfig): void;
|
||||
}
|
13
src/types.ts
Normal file
13
src/types.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { HassEntities, HassConfig } from "home-assistant-js-websocket";
|
||||
|
||||
export interface HomeAssistant {
|
||||
states: HassEntities;
|
||||
config: HassConfig;
|
||||
language: string;
|
||||
resources: { [key: string]: any };
|
||||
callService: (
|
||||
domain: string,
|
||||
service: string,
|
||||
serviceData: { [key: string]: any }
|
||||
) => Promise<void>;
|
||||
}
|
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["es2017", "dom", "dom.iterable"],
|
||||
"noEmit": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"experimentalDecorators": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false
|
||||
}
|
||||
}
|
8
tslint.json
Normal file
8
tslint.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-eslint-rules", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"interface-name": false,
|
||||
"no-submodule-imports": false,
|
||||
"ordered-imports": false
|
||||
}
|
||||
}
|
@ -222,6 +222,7 @@ function createConfig(isProdBuild, latestBuild) {
|
||||
publicPath,
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".js", ".json"],
|
||||
alias: {
|
||||
react: "preact-compat",
|
||||
"react-dom": "preact-compat",
|
||||
|
133
yarn.lock
133
yarn.lock
@ -214,7 +214,7 @@
|
||||
"@babel/template" "7.0.0-beta.49"
|
||||
"@babel/types" "7.0.0-beta.49"
|
||||
|
||||
"@babel/helper-function-name@^7.1.0":
|
||||
"@babel/helper-function-name@^7.0.0", "@babel/helper-function-name@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53"
|
||||
integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==
|
||||
@ -398,7 +398,7 @@
|
||||
"@babel/traverse" "7.0.0-beta.49"
|
||||
"@babel/types" "7.0.0-beta.49"
|
||||
|
||||
"@babel/helper-replace-supers@^7.1.0":
|
||||
"@babel/helper-replace-supers@^7.0.0", "@babel/helper-replace-supers@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.1.0.tgz#5fc31de522ec0ef0899dc9b3e7cf6a5dd655f362"
|
||||
integrity sha512-BvcDWYZRWVuDeXTYZWxekQNO5D4kO55aArwZOTFXw6rlLQA8ZaDicJR1sO47h+HrnCiDFiww0fSPV0d713KBGQ==
|
||||
@ -542,6 +542,18 @@
|
||||
"@babel/helper-remap-async-to-generator" "^7.1.0"
|
||||
"@babel/plugin-syntax-async-generators" "^7.0.0"
|
||||
|
||||
"@babel/plugin-proposal-class-properties@7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.0.0.tgz#a16b5c076ba6c3d87df64d2480a380e979543731"
|
||||
integrity sha512-mVgsbdySh6kuzv4omXvw0Kuh+3hrUrQ883qTCf75MqfC6zctx2LXrP3Wt+bbJmB5fE5nfhf/Et2pQyrRy4j0Pg==
|
||||
dependencies:
|
||||
"@babel/helper-function-name" "^7.0.0"
|
||||
"@babel/helper-member-expression-to-functions" "^7.0.0"
|
||||
"@babel/helper-optimise-call-expression" "^7.0.0"
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
"@babel/helper-replace-supers" "^7.0.0"
|
||||
"@babel/plugin-syntax-class-properties" "^7.0.0"
|
||||
|
||||
"@babel/plugin-proposal-json-strings@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz#3b4d7b5cf51e1f2e70f52351d28d44fc2970d01e"
|
||||
@ -597,6 +609,13 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-class-properties@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.0.0.tgz#e051af5d300cbfbcec4a7476e37a803489881634"
|
||||
integrity sha512-cR12g0Qzn4sgkjrbrzWy2GE7m9vMl/sFkqZ3gIpAQdrvPDnLM8180i+ANDFIXfjHo9aqp0ccJlQ0QNZcFUbf9w==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-dynamic-import@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.0.0.tgz#6dfb7d8b6c3be14ce952962f658f3b7eb54c33ee"
|
||||
@ -653,6 +672,13 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-typescript@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.0.0.tgz#90f4fe0a741ae9c0dcdc3017717c05a0cbbd5158"
|
||||
integrity sha512-5fxmdqiAQVQTIS+KSvYeZuTt91wKtBTYi6JlIkvbQ6hmO+9fZE81ezxmMiFMIsxE7CdRSgzn7nQ1BChcvK9OpA==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-transform-arrow-functions@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz#a6c14875848c68a3b4b3163a486535ef25c7e749"
|
||||
@ -1037,6 +1063,14 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "7.0.0-beta.49"
|
||||
|
||||
"@babel/plugin-transform-typescript@^7.0.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.1.0.tgz#81e7b4be90e7317cbd04bf1163ebf06b2adee60b"
|
||||
integrity sha512-TOTtVeT+fekAesiCHnPz+PSkYSdOSLyLn42DI45nxg6iCdlQY6LIj/tYqpMB0y+YicoTUiYiXqF8rG6SKfhw6Q==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
"@babel/plugin-syntax-typescript" "^7.0.0"
|
||||
|
||||
"@babel/plugin-transform-unicode-regex@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.0.0.tgz#c6780e5b1863a76fe792d90eded9fcd5b51d68fc"
|
||||
@ -1102,6 +1136,14 @@
|
||||
js-levenshtein "^1.1.3"
|
||||
semver "^5.3.0"
|
||||
|
||||
"@babel/preset-typescript@7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.0.0.tgz#1e65c8b863ff5b290f070d999c810bb48a8e3904"
|
||||
integrity sha512-rFq0bsJjXJo+PyRyBeHDIUGD7+4btHzYcNbL8kgk/7UOxuC9s53ziXxaIL7Ehz4zbsLMREXmUzeamuHwh7BHZg==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
"@babel/plugin-transform-typescript" "^7.0.0"
|
||||
|
||||
"@babel/template@7.0.0-beta.35":
|
||||
version "7.0.0-beta.35"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.35.tgz#459230417f51c29401cf71162aeeff6cef2bcca7"
|
||||
@ -3366,7 +3408,7 @@ aws4@^1.2.1, aws4@^1.6.0:
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289"
|
||||
integrity sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==
|
||||
|
||||
babel-code-frame@^6.26.0:
|
||||
babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
|
||||
integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=
|
||||
@ -4362,7 +4404,7 @@ buffer@^4.3.0:
|
||||
ieee754 "^1.1.4"
|
||||
isarray "^1.0.0"
|
||||
|
||||
builtin-modules@^1.0.0:
|
||||
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
|
||||
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
|
||||
@ -4965,6 +5007,11 @@ commander@2.9.0:
|
||||
dependencies:
|
||||
graceful-readlink ">= 1.0.0"
|
||||
|
||||
commander@^2.12.1:
|
||||
version "2.19.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
|
||||
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
|
||||
|
||||
commander@^2.14.1:
|
||||
version "2.18.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970"
|
||||
@ -5720,7 +5767,7 @@ diff@3.2.0:
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"
|
||||
integrity sha1-yc45Okt8vQsFinJck98pkCeGj/k=
|
||||
|
||||
diff@3.5.0, diff@^3.3.1, diff@^3.5.0:
|
||||
diff@3.5.0, diff@^3.2.0, diff@^3.3.1, diff@^3.5.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
|
||||
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
|
||||
@ -5772,6 +5819,14 @@ dns-txt@^2.0.2:
|
||||
dependencies:
|
||||
buffer-indexof "^1.0.0"
|
||||
|
||||
doctrine@0.7.2:
|
||||
version "0.7.2"
|
||||
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523"
|
||||
integrity sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=
|
||||
dependencies:
|
||||
esutils "^1.1.6"
|
||||
isarray "0.0.1"
|
||||
|
||||
doctrine@1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
|
||||
@ -6372,6 +6427,11 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1:
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
|
||||
integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=
|
||||
|
||||
esutils@^1.1.6:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375"
|
||||
integrity sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=
|
||||
|
||||
esutils@^2.0.0, esutils@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
|
||||
@ -9029,7 +9089,7 @@ js-tokens@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||
|
||||
js-yaml@^3.12.0, js-yaml@^3.9.0:
|
||||
js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
|
||||
version "3.12.0"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
|
||||
integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==
|
||||
@ -14161,11 +14221,67 @@ trim-right@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
|
||||
integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=
|
||||
|
||||
tslib@1.9.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
|
||||
integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==
|
||||
|
||||
tslib@^1.8.0, tslib@^1.8.1:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
|
||||
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
|
||||
|
||||
tslib@^1.9.0:
|
||||
version "1.9.2"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.2.tgz#8be0cc9a1f6dc7727c38deb16c2ebd1a2892988e"
|
||||
integrity sha512-AVP5Xol3WivEr7hnssHDsaM+lVrVXWUvd1cfXTRkTj80b//6g2wIFEH6hZG0muGZRnHGrfttpdzRk3YlBkWjKw==
|
||||
|
||||
tslint-config-prettier@^1.15.0:
|
||||
version "1.15.0"
|
||||
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.15.0.tgz#76b9714399004ab6831fdcf76d89b73691c812cf"
|
||||
integrity sha512-06CgrHJxJmNYVgsmeMoa1KXzQRoOdvfkqnJth6XUkNeOz707qxN0WfxfhYwhL5kXHHbYJRby2bqAPKwThlZPhw==
|
||||
|
||||
tslint-eslint-rules@^5.4.0:
|
||||
version "5.4.0"
|
||||
resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz#e488cc9181bf193fe5cd7bfca213a7695f1737b5"
|
||||
integrity sha512-WlSXE+J2vY/VPgIcqQuijMQiel+UtmXS+4nvK4ZzlDiqBfXse8FAvkNnTcYhnQyOTW5KFM+uRRGXxYhFpuBc6w==
|
||||
dependencies:
|
||||
doctrine "0.7.2"
|
||||
tslib "1.9.0"
|
||||
tsutils "^3.0.0"
|
||||
|
||||
tslint@^5.11.0:
|
||||
version "5.11.0"
|
||||
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.11.0.tgz#98f30c02eae3cde7006201e4c33cb08b48581eed"
|
||||
integrity sha1-mPMMAurjzecAYgHkwzywi0hYHu0=
|
||||
dependencies:
|
||||
babel-code-frame "^6.22.0"
|
||||
builtin-modules "^1.1.1"
|
||||
chalk "^2.3.0"
|
||||
commander "^2.12.1"
|
||||
diff "^3.2.0"
|
||||
glob "^7.1.1"
|
||||
js-yaml "^3.7.0"
|
||||
minimatch "^3.0.4"
|
||||
resolve "^1.3.2"
|
||||
semver "^5.3.0"
|
||||
tslib "^1.8.0"
|
||||
tsutils "^2.27.2"
|
||||
|
||||
tsutils@^2.27.2:
|
||||
version "2.29.0"
|
||||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
|
||||
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tsutils@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.1.0.tgz#9136fdbc347799941db4eb326af4dcb81454820e"
|
||||
integrity sha512-rmGhespW+nZMtdkc4JJefYSjux2uCDZxCTLU+nu8gvm+gM+YT0W5XAygHxaeOwRAHZ+SoPdrovZmAlZ2a0KSlw==
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tty-browserify@0.0.0:
|
||||
version "0.0.0"
|
||||
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
|
||||
@ -14221,6 +14337,11 @@ typedarray@^0.0.6:
|
||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||
|
||||
typescript@3.1.3:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5"
|
||||
integrity sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==
|
||||
|
||||
typical@^2.6.0, typical@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d"
|
||||
|
Loading…
x
Reference in New Issue
Block a user