Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x 10x 16x 16x 4x 4x 2x 16x | import { parseLDT, LDTParseError, type LDTProfile } from '@ies-tools/core';
import type { UpdateMessage } from './protocol.js';
/** User-facing labels for native LDT alternative lamp configurations. */
export function lampSetLabels(profile: LDTProfile): string[] {
return profile.lampSets.map(
(set, index) => `${index + 1}: ${set.description || 'Lamp configuration'} · ${set.totalLumens} lm · ${set.watts} W`,
);
}
/** Source text and labels are transported as data, never interpolated into webview HTML. */
export function createPreviewUpdate(text: string, format: 'ies' | 'ldt', fileName?: string): UpdateMessage {
let labels: string[] = [];
if (format === 'ldt') {
try {
labels = lampSetLabels(parseLDT(text));
} catch (error) {
// Invalid live edits still reach the viewer, which presents the parser's error message.
Iif (!(error instanceof LDTParseError)) throw error;
}
}
return { type: 'update', text, format, lampSetLabels: labels, ...(fileName === undefined ? {} : { fileName }) };
}
|