Remove js-yaml resource proxy (#18369)

This commit is contained in:
Steve Repsher 2023-10-24 08:17:25 -04:00 committed by GitHub
parent 18827db9ba
commit 32edbd7b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 11 deletions

View File

@ -1,4 +1,5 @@
import { mdiClose } from "@mdi/js"; import { mdiClose } from "@mdi/js";
import { dump } from "js-yaml";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
@ -9,7 +10,6 @@ import "../../../../src/components/ha-expansion-panel";
import "../../../../src/components/ha-icon-button"; import "../../../../src/components/ha-icon-button";
import "../../../../src/components/search-input"; import "../../../../src/components/search-input";
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware"; import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
import { dump } from "../../../../src/resources/js-yaml-dump";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles"; import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import { HomeAssistant } from "../../../../src/types"; import { HomeAssistant } from "../../../../src/types";
import { HassioHardwareDialogParams } from "./show-dialog-hassio-hardware"; import { HassioHardwareDialogParams } from "./show-dialog-hassio-hardware";

View File

@ -2,10 +2,8 @@ import { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { until } from "lit/directives/until"; import { until } from "lit/directives/until";
import { HomeAssistant } from "../types";
import { formatNumber } from "../common/number/format_number"; import { formatNumber } from "../common/number/format_number";
import { HomeAssistant } from "../types";
let jsYamlPromise: Promise<typeof import("../resources/js-yaml-dump")>;
@customElement("ha-attribute-value") @customElement("ha-attribute-value")
class HaAttributeValue extends LitElement { class HaAttributeValue extends LitElement {
@ -44,7 +42,7 @@ class HaAttributeValue extends LitElement {
${attributeValue} ${attributeValue}
</a> </a>
`; `;
} catch (_) { } catch {
// Nothing to do here // Nothing to do here
} }
} }
@ -55,10 +53,7 @@ class HaAttributeValue extends LitElement {
attributeValue.some((val) => val instanceof Object)) || attributeValue.some((val) => val instanceof Object)) ||
(!Array.isArray(attributeValue) && attributeValue instanceof Object) (!Array.isArray(attributeValue) && attributeValue instanceof Object)
) { ) {
if (!jsYamlPromise) { const yaml = import("js-yaml").then(({ dump }) => dump(attributeValue));
jsYamlPromise = import("../resources/js-yaml-dump");
}
const yaml = jsYamlPromise.then((jsYaml) => jsYaml.dump(attributeValue));
return html`<pre>${until(yaml, "")}</pre>`; return html`<pre>${until(yaml, "")}</pre>`;
} }

View File

@ -1,4 +1,5 @@
import { mdiClose } from "@mdi/js"; import { mdiClose } from "@mdi/js";
import { dump } from "js-yaml";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
@ -15,7 +16,6 @@ import {
} from "../../../data/hassio/hardware"; } from "../../../data/hassio/hardware";
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import type { HassDialog } from "../../../dialogs/make-dialog-manager"; import type { HassDialog } from "../../../dialogs/make-dialog-manager";
import { dump } from "../../../resources/js-yaml-dump";
import { haStyle, haStyleDialog } from "../../../resources/styles"; import { haStyle, haStyleDialog } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";

View File

@ -1 +0,0 @@
export { dump } from "js-yaml";