Files
wehub-resource-sync e30e75b5d4
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Changesets / Create Version PR (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00

145 lines
3.6 KiB
TypeScript

type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends object ? {
readonly [K in keyof T]: DeepReadonly<T[K]>;
} : T;
declare class GorpClient<T extends Record<string, unknown>, C> {
private readonly mutator;
private readonly _send;
private committed;
private optimistic;
private _pending;
private _nextSeq;
private readonly changeListeners;
private changes;
private previousState;
private optimisticDirty;
constructor(config: GorpClient.Config<T, C>);
get state(): DeepReadonly<T>;
get firstPendingSeq(): number;
apply(_param0: GorpMessage): void;
send(command: C): void;
onChange(callback: () => void): () => void;
resync(): void;
isChangedAt(path: string[]): boolean;
getChangedKeys(path: string[]): string[];
private beginFrame;
private replayMutator;
private rebuildOptimistic;
}
declare namespace GorpClient {
type Config<T extends Record<string, unknown>, C> = {
initialState: T;
mutator: (state: T, command: C, seq: number) => void;
send: (command: C) => void;
};
}
type GorpMessage = {
ops: GorpOperation[];
ack?: number;
};
type GorpOperation = {
type: "set";
path: string[];
value: unknown;
} | {
type: "append-text";
path: string[];
value: string;
};
interface GorpPubsub<C> {
readonly state: unknown;
receive(command: C): void;
subscribe(callback: (env: GorpMessage) => void): () => void;
}
declare class GorpRelay<T extends Record<string, unknown>, C> {
private readonly gorp;
private readonly _send;
private readonly subscribers;
constructor(config: GorpRelay.Config<T, C>);
get state(): DeepReadonly<T>;
receive(command: C): void;
applyUpstream(msg: GorpMessage): void;
subscribe(callback: (env: GorpMessage) => void): () => void;
serialize(): RelaySerializedState<T>;
restore(serialized: RelaySerializedState<T>): void;
}
declare namespace GorpRelay {
type Config<T extends Record<string, unknown>, C> = {
initialState: T;
send: (command: C) => void;
};
}
declare class GorpServer<T extends Record<string, unknown>, C> {
private readonly gorp;
private readonly mutator;
private readonly flusher;
private readonly _state;
private _nextSeq;
constructor(config: GorpServer.Config<T, C>);
get state(): T;
set state(value: T);
receive(command: C): void;
subscribe(callback: (env: GorpMessage) => void): () => void;
}
declare namespace GorpServer {
type Config<T extends Record<string, unknown>, C> = {
initialState: T;
mutator: (state: T, command: C, seq: number) => void;
};
}
type GorpSession = {
highWater: number;
lastActivity: number;
};
declare class GorpSessions<C> {
private readonly inner;
private readonly _sessions;
private readonly clients;
private outgoing;
private lastSeenAck;
private readonly unsubscribe;
constructor(inner: GorpPubsub<C>);
get sessions(): ReadonlyMap<string, GorpSession>;
addClient(sessionId: string, fromSeq: number, send: (msg: GorpMessage) => void): GorpSessions.ClientHandle<C>;
close(): void;
serialize(): GorpSessionsState;
restore(state: GorpSessionsState): void;
private fanOut;
private pruneSessions;
}
declare namespace GorpSessions {
interface ClientHandle<C> {
receive(command: C): void;
remove(): void;
}
}
type GorpSessionsState = {
sessions: Record<string, {
highWater: number;
}>;
};
type RelaySerializedState<T> = {
state: T;
};
declare function appendText(value: string): string;
declare namespace entry_root_exports {
export { GorpClient, GorpMessage, GorpRelay, GorpServer, GorpSessions, GorpSessionsState, RelaySerializedState, appendText };
}
export { entry_root_exports as entry_root };