Implement main-thread Camino sessions and synchronous CRDT editing
This commit is contained in:
@@ -29,6 +29,17 @@ const expectation = (e: ObjectExpectation) => ({
|
||||
/** The protocol IR and replica wire schema intentionally share structure, not reference identity. */
|
||||
export function portableValueSchema(type: ValueType): unknown {
|
||||
switch (type.kind) {
|
||||
case "variant":
|
||||
return {
|
||||
kind: "variant",
|
||||
id: type.id,
|
||||
cases: Object.fromEntries(
|
||||
Object.entries(type.cases).map(([label, entry]) => [
|
||||
label,
|
||||
{ id: entry.id, value: portableValueSchema(entry.value) },
|
||||
]),
|
||||
),
|
||||
};
|
||||
case "change":
|
||||
return {
|
||||
kind: "record",
|
||||
@@ -65,6 +76,10 @@ export function portableValueSchema(type: ValueType): unknown {
|
||||
export function tsType(type: ValueType): string {
|
||||
portableValueSchema(type);
|
||||
switch (type.kind) {
|
||||
case "variant":
|
||||
return `(${Object.entries(type.cases)
|
||||
.map(([label, entry]) => `{ readonly kind: ${q(label)}; readonly value: ${tsType(entry.value)} }`)
|
||||
.join(" | ")})`;
|
||||
case "change":
|
||||
return `PreparedChange<${tsType(type.value)}>`;
|
||||
case "scalar":
|
||||
|
||||
Reference in New Issue
Block a user