This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm start— Vite dev server on port 8000, opens/demo/, runsvite build --watchin parallel.npm run build— Production build via Vite library mode →dist/widget-value.js(ES only).npm run watch— Rebuild on changes without dev server.npm run types— Regeneratesrc/definition-schema.d.tsfromsrc/definition-schema.jsonusingjson2ts. Run this after editing the JSON schema.npm run analyze— Generate custom-elements manifest (LitElement).npm run release—build→types→npm version patch(novprefix) → push tags. The pushed tag triggers.github/workflows/build-publish.yml, which publishes to npm.npm run link/npm run unlink— Symlink the built package into a sibling../RESWARM/frontendcheckout for local integration testing.
No test runner or lint script is wired into npm scripts (eslint/prettier are devDependencies; no test script exists).
Node >=24.9.0, npm >=10.0.2 (per engines).
This is a single-file LitElement web component published as @record-evolution/widget-value, designed to be embedded in IronFlock/RESWARM dashboards.
Entry point: src/widget-value.ts defines <widget-value-versionplaceholder>. The literal string versionplaceholder is rewritten at build time by @rollup/plugin-replace (configured in vite.config.ts) to the current package.json version, so each published version registers a uniquely versioned custom-element tag (e.g. widget-value-1.1.25). Consumers pick a version by importing it and using the matching tag — multiple versions can coexist on one page. The demo/index.html builds the tag dynamically via unsafeStatic from package.json.
Platform integration: the host platform passes two reactive @property({ type: Object }) inputs:
inputData: InputData— shape declared insrc/definition-schema.jsonand code-generated tosrc/definition-schema.d.tsvianpm run types. The JSON schema is the source of truth; descriptions inside it drive the platform's config UI and AI agent tooling.dataDrivenDisabledandconditionkeys in the schema control which fields the platform exposes for data-binding vs static config.theme: { theme_name, theme_object }— sample themes indemo/themes/. The component also reads CSS custom properties--re-text-colorand--re-tile-background-colorfrom its host context (these win overtheme_object). SeeregisterTheme().
Data flow inside the widget:
update()callstransformData()wheneverinputDatachanges, buildingthis.dataSets: Map<label, Dataseries>.- When
multiChartis true, a series is split into one entry per distinctpivotvalue indata[]; otherwise a single entry uses the staticvalue.needleValueis the average of the most recentadvanced.averageLatestrows; if the newest row'stspis older thanadvanced.maxLatencyseconds,needleValuebecomesundefined(stale data hidden). updated()then runssizingSetup()+applyData(). The component renders an offscreen.sizing-containerto measure natural box dimensions, then computes a grid layout and uniform scale (modifier) that maximises occupied area in.value-containerfor the current host size. AResizeObserverre-runsapplyData()on resize. Font sizes for label / value / unit are set inline based onmodifier.
Build pipeline: Vite library build (build.lib) emits a single ES module with sourcemaps and a copyright banner. tslib is aliased to its ES6 entry; process.env.NODE_ENV is hard-defined to production. There is no bundler-level externalisation — lit is bundled in.
When changing widget configuration: edit src/definition-schema.json, run npm run types, and update consumers in widget-value.ts. Descriptions in the JSON schema are user/agent-facing and intentionally verbose — preserve that style.