diff --git a/src/components/ha-code-editor.ts b/src/components/ha-code-editor.ts index a17416856948..8b29c7802a86 100644 --- a/src/components/ha-code-editor.ts +++ b/src/components/ha-code-editor.ts @@ -12,7 +12,6 @@ import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../common/dom/fire_event"; import { stopPropagation } from "../common/dom/stop_propagation"; -import { CodeMirror, loadCodeMirror } from "../resources/codemirror.ondemand"; import { HomeAssistant } from "../types"; import "./ha-icon"; @@ -58,7 +57,7 @@ export class HaCodeEditor extends ReactiveElement { @state() private _value = ""; - private _loadedCodeMirror?: CodeMirror; + private _loadedCodeMirror?: typeof import("../resources/codemirror"); private _iconList?: Completion[]; @@ -110,7 +109,7 @@ export class HaCodeEditor extends ReactiveElement { // Ensure CodeMirror module is loaded before any update protected override async scheduleUpdate() { - this._loadedCodeMirror ??= await loadCodeMirror(); + this._loadedCodeMirror ??= await import("../resources/codemirror"); super.scheduleUpdate(); } diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index be3c2b6227b9..d8d4209f5bb9 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -50,7 +50,7 @@ import { subscribeRepairsIssueRegistry } from "../data/repairs"; import { UpdateEntity, updateCanInstall } from "../data/update"; import { SubscribeMixin } from "../mixins/subscribe-mixin"; import { actionHandler } from "../panels/lovelace/common/directives/action-handler-directive"; -import { SortableInstance, loadSortable } from "../resources/sortable.ondemand"; +import type { SortableInstance } from "../resources/sortable"; import { haStyleScrollbar } from "../resources/styles"; import type { HomeAssistant, PanelInfo, Route } from "../types"; import "./ha-icon"; @@ -689,7 +689,7 @@ class HaSidebar extends SubscribeMixin(LitElement) { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.getElementById("sortable")!, { diff --git a/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts b/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts index 1de238a81d55..9a2cbd6caf31 100644 --- a/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts +++ b/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts @@ -24,10 +24,7 @@ import { computeDefaultFavoriteColors, } from "../../../../data/light"; import { actionHandler } from "../../../../panels/lovelace/common/directives/action-handler-directive"; -import { - SortableInstance, - loadSortable, -} from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; import { HomeAssistant } from "../../../../types"; import { showConfirmationDialog } from "../../../generic/show-dialog-box"; import "./ha-favorite-color-button"; @@ -73,7 +70,7 @@ export class HaMoreInfoLightFavoriteColors extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".container")!, { diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index dfdceb700dcc..5c85b509c137 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -32,10 +32,7 @@ import { ACTION_TYPES } from "../../../../data/action"; import { AutomationClipboard } from "../../../../data/automation"; import { Action } from "../../../../data/script"; import { sortableStyles } from "../../../../resources/ha-sortable-style"; -import { - SortableInstance, - loadSortable, -} from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; import { Entries, HomeAssistant } from "../../../../types"; import type HaAutomationActionRow from "./ha-automation-action-row"; import { getType } from "./ha-automation-action-row"; @@ -227,7 +224,7 @@ export default class HaAutomationAction extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable(this.shadowRoot!.querySelector(".actions")!, { animation: 150, fallbackClass: "sortable-fallback", diff --git a/src/panels/config/automation/action/types/ha-automation-action-choose.ts b/src/panels/config/automation/action/types/ha-automation-action-choose.ts index 514376bf46ed..90fa1a22f6ff 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-choose.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-choose.ts @@ -16,10 +16,7 @@ import { CSSResultGroup, LitElement, PropertyValues, css, html } from "lit"; import { customElement, property, state } from "lit/decorators"; import { repeat } from "lit/directives/repeat"; import type { ActionDetail } from "@material/mwc-list"; -import { - loadSortable, - SortableInstance, -} from "../../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../../resources/sortable"; import { ensureArray } from "../../../../../common/array/ensure-array"; import { fireEvent } from "../../../../../common/dom/fire_event"; import { capitalizeFirstLetter } from "../../../../../common/string/capitalize-first-letter"; @@ -481,7 +478,8 @@ export class HaChooseAction extends LitElement implements ActionElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../../resources/sortable")) + .default; this._sortable = new Sortable(this.shadowRoot!.querySelector(".options")!, { animation: 150, fallbackClass: "sortable-fallback", diff --git a/src/panels/config/automation/condition/ha-automation-condition.ts b/src/panels/config/automation/condition/ha-automation-condition.ts index 592039b61879..36cb5fb485ec 100644 --- a/src/panels/config/automation/condition/ha-automation-condition.ts +++ b/src/panels/config/automation/condition/ha-automation-condition.ts @@ -40,10 +40,7 @@ import type { LocalizeFunc } from "../../../../common/translations/localize"; import type { HaSelect } from "../../../../components/ha-select"; import { CONDITION_TYPES } from "../../../../data/condition"; import { sortableStyles } from "../../../../resources/ha-sortable-style"; -import { - loadSortable, - SortableInstance, -} from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; import "./types/ha-automation-condition-and"; import "./types/ha-automation-condition-device"; import "./types/ha-automation-condition-numeric_state"; @@ -248,7 +245,7 @@ export default class HaAutomationCondition extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".conditions")!, { diff --git a/src/panels/config/automation/trigger/ha-automation-trigger.ts b/src/panels/config/automation/trigger/ha-automation-trigger.ts index cf8ea19541e2..3be0e591619e 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger.ts @@ -31,8 +31,7 @@ import "../../../../components/ha-svg-icon"; import { AutomationClipboard, Trigger } from "../../../../data/automation"; import { TRIGGER_TYPES } from "../../../../data/trigger"; import { sortableStyles } from "../../../../resources/ha-sortable-style"; -import { SortableInstance } from "../../../../resources/sortable"; -import { loadSortable } from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; import { Entries, HomeAssistant } from "../../../../types"; import "./ha-automation-trigger-row"; import type HaAutomationTriggerRow from "./ha-automation-trigger-row"; @@ -225,7 +224,7 @@ export default class HaAutomationTrigger extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".triggers")!, { diff --git a/src/panels/config/helpers/forms/ha-input_select-form.ts b/src/panels/config/helpers/forms/ha-input_select-form.ts index d314bbfa9934..e65f951e4bb2 100644 --- a/src/panels/config/helpers/forms/ha-input_select-form.ts +++ b/src/panels/config/helpers/forms/ha-input_select-form.ts @@ -16,10 +16,7 @@ import type { InputSelect } from "../../../../data/input_select"; import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; -import { - loadSortable, - SortableInstance, -} from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; @customElement("ha-input_select-form") class HaInputSelectForm extends LitElement { @@ -50,7 +47,7 @@ class HaInputSelectForm extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable(this.shadowRoot!.querySelector(".options")!, { animation: 150, fallbackClass: "sortable-fallback", diff --git a/src/panels/lovelace/cards/hui-shopping-list-card.ts b/src/panels/lovelace/cards/hui-shopping-list-card.ts index 1b7dc10a5651..6c7243b7c50c 100644 --- a/src/panels/lovelace/cards/hui-shopping-list-card.ts +++ b/src/panels/lovelace/cards/hui-shopping-list-card.ts @@ -28,10 +28,7 @@ import { updateItem, } from "../../../data/shopping-list"; import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; -import { - loadSortable, - SortableInstance, -} from "../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../resources/sortable"; import { HomeAssistant } from "../../../types"; import { LovelaceCard, LovelaceCardEditor } from "../types"; import { SensorCardConfig, ShoppingListCardConfig } from "./types"; @@ -318,7 +315,7 @@ class HuiShoppingListCard } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../resources/sortable")).default; const sortableEl = this._sortableEl; this._sortable = new Sortable(sortableEl!, { animation: 150, diff --git a/src/panels/lovelace/components/hui-entity-editor.ts b/src/panels/lovelace/components/hui-entity-editor.ts index 870058d3493f..42aed25312af 100644 --- a/src/panels/lovelace/components/hui-entity-editor.ts +++ b/src/panels/lovelace/components/hui-entity-editor.ts @@ -11,10 +11,7 @@ import type { } from "../../../components/entity/ha-entity-picker"; import "../../../components/ha-icon-button"; import { sortableStyles } from "../../../resources/ha-sortable-style"; -import { - loadSortable, - SortableInstance, -} from "../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../resources/sortable"; import { HomeAssistant } from "../../../types"; import { EntityConfig } from "../entity-rows/types"; @@ -93,7 +90,7 @@ export class HuiEntityEditor extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".entities")!, { diff --git a/src/panels/lovelace/editor/config-elements/hui-tile-card-features-editor.ts b/src/panels/lovelace/editor/config-elements/hui-tile-card-features-editor.ts index f35b32893ffc..a4b3ea2ad26a 100644 --- a/src/panels/lovelace/editor/config-elements/hui-tile-card-features-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-tile-card-features-editor.ts @@ -19,10 +19,7 @@ import { stripCustomPrefix, } from "../../../../data/lovelace_custom_cards"; import { sortableStyles } from "../../../../resources/ha-sortable-style"; -import { - SortableInstance, - loadSortable, -} from "../../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../../resources/sortable"; import { HomeAssistant } from "../../../../types"; import { getTileFeatureElementClass } from "../../create-element/create-tile-feature-element"; import { supportsAlarmModesTileFeature } from "../../tile-features/hui-alarm-modes-tile-feature"; @@ -321,7 +318,7 @@ export class HuiTileCardFeaturesEditor extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".features")!, { diff --git a/src/panels/lovelace/editor/hui-entities-card-row-editor.ts b/src/panels/lovelace/editor/hui-entities-card-row-editor.ts index 950ce84d4137..8e06e231af7b 100644 --- a/src/panels/lovelace/editor/hui-entities-card-row-editor.ts +++ b/src/panels/lovelace/editor/hui-entities-card-row-editor.ts @@ -9,10 +9,7 @@ import type { HaEntityPicker } from "../../../components/entity/ha-entity-picker import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; import { sortableStyles } from "../../../resources/ha-sortable-style"; -import { - loadSortable, - SortableInstance, -} from "../../../resources/sortable.ondemand"; +import type { SortableInstance } from "../../../resources/sortable"; import { HomeAssistant } from "../../../types"; import { EntityConfig, LovelaceRowConfig } from "../entity-rows/types"; @@ -134,7 +131,7 @@ export class HuiEntitiesCardRowEditor extends LitElement { } private async _createSortable() { - const Sortable = await loadSortable(); + const Sortable = (await import("../../../resources/sortable")).default; this._sortable = new Sortable( this.shadowRoot!.querySelector(".entities")!, { diff --git a/src/resources/codemirror.ondemand.ts b/src/resources/codemirror.ondemand.ts deleted file mode 100644 index 0f62748cfa49..000000000000 --- a/src/resources/codemirror.ondemand.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type CodeMirror = typeof import("./codemirror"); - -let loaded: CodeMirror; - -export const loadCodeMirror = async () => { - loaded ??= await import("./codemirror"); - return loaded; -}; diff --git a/src/resources/sortable.ondemand.ts b/src/resources/sortable.ondemand.ts deleted file mode 100644 index a33f39d23353..000000000000 --- a/src/resources/sortable.ondemand.ts +++ /dev/null @@ -1,11 +0,0 @@ -let loaded: typeof import("./sortable").default; - -export type { SortableInstance } from "./sortable"; -export const loadSortable = async (): Promise< - typeof import("./sortable").default -> => { - if (!loaded) { - loaded = (await import("./sortable")).default; - } - return loaded; -};