refactor: optimize reactive variable updates and parsing

- Replace `scanDeclareBlocks` with `parseDeclareCsv` in block processor
- Add error handling for declare block parsing
- Optimize `ReactiveVariableManager` by pre-computing variable keys
- Store template text and keys in data attributes for faster updates
- Adjust `VariableView` popup width via CSS class
This commit is contained in:
2026-07-13 11:13:07 +08:00
parent c106b6f79c
commit ffa023b92a
3 changed files with 26 additions and 20 deletions
+8 -4
View File
@@ -7,7 +7,7 @@
import { posix } from "path";
import { createHash } from "crypto";
import { scanDeclareBlocks, type VarDeclaration, type TagModifier } from "./declare-parser.js";
import { parseDeclareCsv, type VarDeclaration, type TagModifier } from "./declare-parser.js";
import {
FENCED_BLOCK_RE,
parseBlockAttrs,
@@ -86,9 +86,13 @@ export function processBlocks(
// ---- Dispatch by role ----
if (attrs.role === "declare") {
const result = scanDeclareBlocks(_match, fileRelativePath);
blocks.declarations.push(...result.variables);
blocks.tagModifiers.push(...result.tagModifiers);
try {
const result = parseDeclareCsv(body, fileRelativePath);
blocks.declarations.push(...result.variables);
blocks.tagModifiers.push(...result.tagModifiers);
} catch (e) {
console.warn(`[block-processor] ${fileRelativePath}: ${e}`);
}
}
if (attrs.role === "file") {