Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdabbs committed Dec 6, 2023
1 parent 104dd9e commit d7e2fe5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/core/src/Bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Bundle = {
spaces: Map<Id, Space>
traits: Map<Id, Trait<Id>>
theorems: Map<Id, Theorem>
mathlib?: { name: string; id: string }[]
version: Version
}

Expand All @@ -26,6 +27,14 @@ export const serializedSchema = z.object({
theorems: z.array(theoremSchema),
traits: z.array(traitSchema(z.string())),
version: z.object({ ref: z.string(), sha: z.string() }),
mathlib: z
.array(
z.object({
id: z.string(),
name: z.string(),
}),
)
.optional(),
})

export type Serialized = z.infer<typeof serializedSchema>
Expand All @@ -41,14 +50,16 @@ export function serialize(bundle: Bundle): Serialized {
}

export function deserialize(data: unknown): Bundle {
const serialized = serializedSchema.parse(data)
const { properties, spaces, theorems, traits, version, mathlib } =
serializedSchema.parse(data)

return {
properties: indexBy(serialized.properties, p => p.uid),
spaces: indexBy(serialized.spaces, s => s.uid),
theorems: indexBy(serialized.theorems, t => t.uid),
traits: indexBy(serialized.traits, traitId),
version: serialized.version,
properties: indexBy(properties, p => p.uid),
spaces: indexBy(spaces, s => s.uid),
theorems: indexBy(theorems, t => t.uid),
traits: indexBy(traits, traitId),
mathlib,
version,
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/viewer/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function sync(
return async (host: string, branch: string, etag?: string) => {
trace({ event: 'remote_fetch_started', host, branch })
const result = await pb.bundle.fetch({ host, branch, etag, fetch })
console.log('fetched', result)

if (result) {
trace({ event: 'remote_fetch_complete', result })
Expand Down

0 comments on commit d7e2fe5

Please sign in to comment.