* Align a live text-delta against the per-turn accumulated length using the * wire `offset`. Returns 'skip' for duplicates (offset behind local state), * 'gap' when deltas were missed (offset ahead — trigger a re-snapshot), and * 'append' otherwise.
(localLen: number, offset: number | undefined)
| 608 | * 'append' otherwise. |
| 609 | */ |
| 610 | function alignDelta(localLen: number, offset: number | undefined): 'append' | 'skip' | 'gap' { |
| 611 | if (offset === undefined) return 'append'; |
| 612 | if (offset < localLen) return 'skip'; |
| 613 | if (offset > localLen) return 'gap'; |
| 614 | return 'append'; |
| 615 | } |
| 616 | |
| 617 | function _project( |
| 618 | rawType: string, |