Skip to content

Fix/lit migration#6

Merged
cayossarian merged 4 commits into
mainfrom
fix/lit_migration
Apr 14, 2026
Merged

Fix/lit migration#6
cayossarian merged 4 commits into
mainfrom
fix/lit_migration

Conversation

@cayossarian
Copy link
Copy Markdown
Member

Migrate to the LitElement framework for HA compatibility

Add lit ^3.3.2 as a dependency and @rollup/plugin-node-resolve ^16.0.3
as a dev dependency. Switch rollup output format from iife to esm and
add the resolve plugin so lit can be bundled from node_modules. Enable
experimentalDecorators in tsconfig for LitElement decorator support.
Convert SpanPanelElement from vanilla HTMLElement to LitElement:
- Use reactive properties (@Property, @State) and declarative templates
- Replace innerHTML-based rendering with lit-html template
- Remove all recovery workarounds (health check interval, renderWithRecovery,
  recoverIfNeeded, renderTabWithTimeout) — LitElement survives HA's
  WebSocket reconnection lifecycle natively
- Remove module-level recovery code from panel/index.ts
- Use @CustomElement decorator for registration instead of manual define
- Use declarative event delegation on tab-content container
- Schedule imperative tab renders via updateComplete
Convert SpanPanelCard from vanilla HTMLElement to LitElement with
@CustomElement decorator, @property/@State decorators, and lit html
templates for the outer shell. Inner card content remains imperatively
rendered via innerHTML (hybrid approach) since renderers return HTML
strings. Simplify index.ts to use decorator-based registration for the
card while keeping manual registration for the editor.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the SPAN panel and card implementation to Lit/LitElement to improve Home Assistant frontend compatibility (notably around lifecycle behavior during reconnect/backgrounding).

Changes:

  • Migrate span-panel and span-panel-card from vanilla HTMLElement rendering to LitElement with decorators and reactive state.
  • Switch Rollup output format from IIFE to ESM and add module resolution for bundling Lit.
  • Bump version to 0.9.1 and document the migration/build changes in the changelog.

Reviewed changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.json Enables experimentalDecorators for Lit decorators.
src/panel/span-panel.ts Rewrites the HA panel as a LitElement and converts imperative event wiring/rendering to Lit templates + lifecycle hooks.
src/panel/index.ts Switches to side-effect import to register the panel element.
src/index.ts Switches to side-effect import to register the card element.
src/constants.ts Bumps CARD_VERSION to 0.9.1.
src/card/span-panel-card.ts Rewrites the Lovelace card as a LitElement and reworks discovery/render lifecycle.
rollup.config.mjs Adds node-resolve and changes outputs to ESM.
package.json Bumps package version and adds lit + node-resolve dependency.
package-lock.json Lockfile updates for new deps/version bump.
dist/span-panel-card.js Updated bundled distribution artifact.
CHANGELOG.md Adds 0.9.1 entry describing the migration and build changes.

Comment thread src/panel/span-panel.ts
@cayossarian cayossarian merged commit 7ca1b3a into main Apr 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants