Initial public release

This commit is contained in:
BB-fat
2026-06-22 17:36:26 +08:00
commit f1036a860c
289 changed files with 54589 additions and 0 deletions
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import { RefStore } from "../ref-store";
describe("RefStore", () => {
it("stores and resolves ref → backendNodeId", () => {
const s = new RefStore();
s.set("e1", 42, { tabId: 7 });
expect(s.resolve("@e1")).toBe(42);
expect(s.resolve("e1")).toBe(42);
expect(s.resolve("@e1", { tabId: 7 })).toBe(42);
expect(s.resolve("@e1", { tabId: 8 })).toBeNull();
expect(s.resolveEntry("@e1")).toMatchObject({
backendNodeId: 42,
tabId: 7,
generation: 0,
});
expect(s.size()).toBe(1);
expect(s.isEmpty()).toBe(false);
});
it("replace() clears prior entries", () => {
const s = new RefStore();
s.set("@e1", 1);
s.set("@e2", 2);
s.replace([
["e10", { backendNodeId: 10, tabId: 1 }],
["@e11", { backendNodeId: 11, tabId: 1 }],
]);
expect(s.resolve("@e1")).toBeNull();
expect(s.resolve("@e10")).toBe(10);
expect(s.resolve("@e10", { tabId: 1 })).toBe(10);
expect(s.resolve("@e10", { tabId: 2 })).toBeNull();
expect(s.resolve("@e11")).toBe(11);
expect(s.size()).toBe(2);
});
});