Files
alexei.dolgolyov 997ff2fd70 Migrate frontend from JavaScript to TypeScript
- Rename all 54 .js files to .ts, update esbuild entry point
- Add tsconfig.json, TypeScript devDependency, typecheck script
- Create types.ts with 25+ interfaces matching backend Pydantic schemas
  (Device, OutputTarget, ColorStripSource, PatternTemplate, ValueSource,
  AudioSource, PictureSource, ScenePreset, SyncClock, Automation, etc.)
- Make DataCache generic (DataCache<T>) with typed state instances
- Type all state variables in state.ts with proper entity types
- Type all create*Card functions with proper entity interfaces
- Type all function parameters and return types across all 54 files
- Type core component constructors (CardSection, IconSelect, EntitySelect,
  FilterList, TagInput, TreeNav, Modal) with exported option interfaces
- Add comprehensive global.d.ts for window function declarations
- Type fetchWithAuth with FetchAuthOpts interface
- Remove all (window as any) casts in favor of global.d.ts declarations
- Zero tsc errors, esbuild bundle unchanged

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 13:08:23 +03:00

44 lines
1.0 KiB
JavaScript

import * as esbuild from 'esbuild';
const srcDir = 'src/wled_controller/static';
const outDir = `${srcDir}/dist`;
const watch = process.argv.includes('--watch');
/** @type {esbuild.BuildOptions} */
const jsOpts = {
entryPoints: [`${srcDir}/js/app.ts`],
bundle: true,
format: 'iife',
outfile: `${outDir}/app.bundle.js`,
minify: true,
sourcemap: true,
target: ['es2020'],
logLevel: 'info',
};
/** @type {esbuild.BuildOptions} */
const cssOpts = {
entryPoints: [`${srcDir}/css/all.css`],
bundle: true,
outdir: outDir,
outbase: `${srcDir}/css`,
minify: true,
sourcemap: true,
logLevel: 'info',
loader: { '.woff2': 'file' },
assetNames: '[name]',
entryNames: 'app.bundle',
};
if (watch) {
const jsCtx = await esbuild.context(jsOpts);
const cssCtx = await esbuild.context(cssOpts);
await jsCtx.watch();
await cssCtx.watch();
console.log('Watching for changes...');
} else {
await esbuild.build(jsOpts);
await esbuild.build(cssOpts);
}