-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7c7d73
commit c498d9a
Showing
11 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ZContentAny } from "z/structs/content-any"; | ||
import { ZContentString } from "z/structs/content-string"; | ||
import { ZContentType } from "z/structs/content-type"; | ||
import { ZItem } from "z/structs/item"; | ||
import { ZDoc } from "z/types/doc"; | ||
import { ZContentStruct } from "./content-struct"; | ||
import { DeleteSet } from "./delete-set"; | ||
|
||
export function applyUpdates(doc: ZDoc, items: ZItem[], ds: DeleteSet) { | ||
|
||
} | ||
|
||
export function generateUpdates(doc: ZDoc) { | ||
const items = []; | ||
for (const [client, updates] of doc.store.clients) { | ||
updates.forEach((update: ZItem) => { | ||
let contentData; | ||
if (update.content instanceof ZContentType) { | ||
contentData = update.content.type.getRefID(); | ||
} | ||
if (update.content instanceof ZContentString) { | ||
contentData = update.content.getContent(); | ||
} | ||
if (update.content instanceof ZContentAny) { | ||
contentData = update.content.getContent(); | ||
} | ||
items.push({ | ||
id: update.id, | ||
origin: update.origin, | ||
rightOrigin: update.rightOrigin, | ||
content: new ZContentStruct(update.content.getRef(), contentData) | ||
}); | ||
}); | ||
} | ||
return items; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class ZContentStruct { | ||
contentRef: number; | ||
data: any; | ||
|
||
constructor(contentRef: number, data: any) { | ||
this.contentRef = contentRef; | ||
this.data = data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,8 @@ export class ZContentString extends ZBaseContent { | |
|
||
delete(transaction: any) { | ||
} | ||
|
||
getRef() { | ||
return 4; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ export abstract class ZBaseType { | |
} | ||
|
||
abstract toJSON(); | ||
|
||
abstract getRefID(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters