Implement roadmap phases 1 through 8

This commit is contained in:
2026-03-14 02:30:15 -04:00
parent 86b8f4a73f
commit ddca4a16d5
10 changed files with 3862 additions and 198 deletions

View File

@@ -1,5 +1,11 @@
import type { WorldDelta, WorldSnapshot } from "./contracts";
export interface WorldStreamScope {
scopeKind?: string;
systemId?: string | null;
bubbleId?: string | null;
}
export async function fetchWorldSnapshot(signal?: AbortSignal) {
const response = await fetch("/api/world", { signal });
if (!response.ok) {
@@ -15,8 +21,22 @@ export function openWorldStream(
onOpen?: () => void;
onError?: () => void;
},
scope?: WorldStreamScope,
) {
const stream = new EventSource(`/api/world/stream?afterSequence=${afterSequence}`);
const query = new URLSearchParams({
afterSequence: String(afterSequence),
});
if (scope?.scopeKind) {
query.set("scopeKind", scope.scopeKind);
}
if (scope?.systemId) {
query.set("systemId", scope.systemId);
}
if (scope?.bubbleId) {
query.set("bubbleId", scope.bubbleId);
}
const stream = new EventSource(`/api/world/stream?${query.toString()}`);
stream.addEventListener("open", () => handlers.onOpen?.());
stream.addEventListener("error", () => handlers.onError?.());
stream.addEventListener("world-delta", (event) => {