feat(journal): var stuff

This commit is contained in:
2026-09-01 15:39:36 +08:00
parent 49260ae4f6
commit 7c4865ba8c
5 changed files with 315 additions and 82 deletions
+10 -4
View File
@@ -22,7 +22,7 @@
*/
import type { VarDeclaration, TagModifier } from "./declare-parser";
import { evaluateExpression } from "./variable-expression";
import { evaluateExpression, exprValueToString } from "./variable-expression";
// ---------------------------------------------------------------------------
// Types
@@ -349,7 +349,7 @@ export function computeInitialValues(
},
});
const rawValue = String(result.value);
const rawValue = exprValueToString(result.value);
baseValues.set(key, rawValue);
// Check if this is a tagmap value — if so, activate matching modifiers
@@ -422,7 +422,13 @@ function applyTagMapActivations(
},
});
const value = evalResult.value;
// Modifier expressions must evaluate to a number
if (evalResult.value.kind !== "number") {
throw new Error(
`Modifier expression "${mod.expression}" must evaluate to a number`,
);
}
const value = evalResult.value.value;
const targetIsTagMap = isTagMapValue(baseValues.get(mod.target));
if (targetIsTagMap) {
@@ -571,7 +577,7 @@ function reevaluateDependents(
},
});
const rawValue = String(result.value);
const rawValue = exprValueToString(result.value);
// Check for tagmap transition on this declared variable
const oldCombined = getCombined(key, fallback);