fix(journal): re-init reactivity and drop var del

Make the reactivity engine re-initialize when the loaded declarations
change instead of only at import. ensureReactivity() reads the live
completions signal, compares a signature, and rebuilds from the store
(with exact bases) only when needed; dispatchCommand calls it before each
dispatch. Remove the unused DispatchContext.declarations/tagModifiers
fields, which were mount-time snapshots and could not be trusted.

Build initReactivity's maps into locals and commit only after the
circular check passes, so a failed re-init leaves the previous engine
intact; clear inFlight on commit.

Drop the unreachable var "del" action from the schema, render, and
reducer.
This commit is contained in:
hyper
2026-09-12 22:29:25 +08:00
parent 9f372fa2b0
commit 02442a1100
9 changed files with 131 additions and 70 deletions
@@ -517,6 +517,33 @@ describe("var-reactivity", () => {
}),
).not.toThrow();
});
test("keeps the previous configuration when a re-init fails", () => {
const warn = jest.spyOn(console, "warn").mockImplementation(() => {});
initReactivity({
declarations: [{ key: "$hp", expression: "10 + 5" }],
tagModifiers: [],
});
expect(computeInitialValues(store()).find((r) => r.key === "$hp")?.value).toBe(
"15",
);
expect(() =>
initReactivity({
declarations: [
{ key: "$a", expression: "$b + 1" },
{ key: "$b", expression: "$a + 1" },
],
tagModifiers: [],
}),
).toThrow();
// The failed re-init did not clobber the working configuration.
const results = computeInitialValues(store());
expect(results.find((r) => r.key === "$hp")?.value).toBe("15");
expect(results.find((r) => r.key === "$a")).toBeUndefined();
warn.mockRestore();
});
});
describe("computeInitialValues", () => {