wordinweb 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/collab.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { X as XmlElement, D as DocxDocument, C as ClientMessage, S as ServerMessage, P as PresencePosition, R as RosterEntry, a as ParticipantProfile, I as Intent, b as IdSidecar, L as LineageHead, T as ToolbarFeature, c as ToolbarMode, d as DocxViewApi, W as WriteStatus, U as UndoOutcome } from './index-C2J9egkh.js';
3
- export { e as bytesToB64, f as deriveEpochKeys, g as docKeyFromFragment, m as mintDocKey, s as sealCheckpoint, h as stretchShareCode } from './index-C2J9egkh.js';
2
+ import { X as XmlElement, D as DocxDocument, C as ClientMessage, S as ServerMessage, P as PresencePosition, R as RosterEntry, a as ParticipantProfile, I as Intent, b as IdSidecar, L as LineageHead, T as ToolbarFeature, c as ToolbarMode, d as DocxViewApi, W as WriteStatus, U as UndoOutcome } from './index-CGp6gVjn.js';
3
+ export { e as bytesToB64, f as deriveEpochKeys, g as docKeyFromFragment, m as mintDocKey, s as sealCheckpoint, h as stretchShareCode } from './index-CGp6gVjn.js';
4
4
 
5
5
  /**
6
6
  * How much of the document an applied intent disturbed — the input to
@@ -348,11 +348,8 @@ declare class CollabConnection {
348
348
  * the renderer re-mounts on this, but updates in place otherwise (no flash
349
349
  * for the common non-conflicting edits). */
350
350
  docEpoch: number;
351
- /** Per-client id allocator for carried node ids (split/format-range/insert):
352
- * a client-specific base block keeps concurrently-allocated ids disjoint
353
- * across clients so they never collide. */
354
- private idCounter;
355
- private idBase;
351
+ /** Per-client id allocator for carried node ids (split/format-range/insert). */
352
+ private readonly idAllocator;
356
353
  /** The epoch id of the session this connection joined (from the welcome).
357
354
  * The resume layer compares it against the bundle's stored genesisId:
358
355
  * same ⇒ seamless rejoin; different ⇒ someone re-seeded while away
@@ -552,6 +549,8 @@ declare class CollabConnection {
552
549
  */
553
550
  interface DocBundle {
554
551
  docId: string;
552
+ /** Human title chosen for this browser copy. It never enters the room URL. */
553
+ title?: string;
555
554
  /** Epoch of the session this state came from (doc 12 §5): on rejoin,
556
555
  * same ⇒ seamless resume; different ⇒ someone re-seeded while away. */
557
556
  genesisId: string;
@@ -592,11 +591,14 @@ interface DocBundle {
592
591
  /**
593
592
  * The genesisId of the epoch the offline tail was recorded AGAINST. This
594
593
  * is what lets a resume decide the arrival rung without guessing: same
595
- * epoch ⇒ the tail is morally a large pending queue and replays silently;
596
- * different (or absent, for a tail written by an older build) ⇒ true
597
- * divergence, offer suggest/draft — never silently bulldoze.
594
+ * epoch can replay after the required merge check; different (or absent,
595
+ * for a tail written by an older build) means true divergence and offers
596
+ * suggest/draft.
598
597
  */
599
598
  offlineTailEpoch?: string;
599
+ /** Confirmed room sequence when offline editing began. A stable-URL rejoin
600
+ * compares this with the room sequence to decide whether a review is needed. */
601
+ offlineBaseSeq?: number;
600
602
  /** Per-part media metadata (doc 16 §5.3): the sha (and E2EE iv/epoch)
601
603
  * of every media part this copy knows. The docx bytes carry the PIXELS;
602
604
  * this carries the ADDRESSES — without it a resumed holder couldn't
@@ -650,6 +652,8 @@ interface StoredDocSummary extends ParsedBundleKey {
650
652
  savedAt: number;
651
653
  /** Size of the stored document bytes. */
652
654
  byteLength: number;
655
+ /** Human title stored with the browser copy. */
656
+ title?: string;
653
657
  }
654
658
  /**
655
659
  * Storage seam for bundles. The browser implementation is IndexedDB (the
@@ -727,6 +731,7 @@ declare class BundlePersister {
727
731
  offlineTail?: () => {
728
732
  tail: Intent[];
729
733
  epoch?: string;
734
+ baseSeq?: number;
730
735
  } | null;
731
736
  });
732
737
  private get throttleMs();
@@ -839,6 +844,9 @@ interface UseCollabOptions {
839
844
  * (join cold, keep nothing).
840
845
  */
841
846
  store?: BundleStore;
847
+ /** Open the stored browser copy without creating a socket. Reconnect uses
848
+ * the normal resume path and reconciles the captured offline tail. */
849
+ startOffline?: boolean;
842
850
  /** Claim the identity from an existing live connection (doc 12 §7 "use
843
851
  * here instead"): set after an `already-open` refusal and remount. */
844
852
  takeover?: boolean;
@@ -913,8 +921,8 @@ interface CollabSession {
913
921
  * repaint sees every batched intent's scope.
914
922
  */
915
923
  takeRenderScope: () => Scope | null;
916
- /** Increases only when reconciliation RELOADED the document (a true
917
- * conflict). The editor re-mounts on this; between reloads it updates in
924
+ /** Increases when a reconnect or reconciliation replaces the document
925
+ * object. The editor re-mounts on this; between replacements it updates in
918
926
  * place (no flash for the common non-conflicting edits). */
919
927
  docEpoch: number;
920
928
  /** True once joined and the snapshot is loaded. */
@@ -974,8 +982,9 @@ interface CollabSession {
974
982
  *
975
983
  * Null while the connection is live, and null when a refusal already
976
984
  * blocks writes (a viewer's link does not become writable by going
977
- * through a tunnel). On reconnect the tail replays: silently as ordinary
978
- * edits when the session is the same epoch, else via {@link arrival}.
985
+ * through a tunnel). An automatic same-epoch reconnect replays the tail
986
+ * silently. An intentional disconnect uses {@link arrival} for an explicit
987
+ * merge check.
979
988
  */
980
989
  offline: {
981
990
  editsHeld: number;
@@ -988,6 +997,14 @@ interface CollabSession {
988
997
  * the statement that automatic recovery has stopped.
989
998
  */
990
999
  reconnect: () => void;
1000
+ /**
1001
+ * Intentionally leave the transport while the document stays open. Edits
1002
+ * continue into the offline tail until {@link reconnect} rejoins the same
1003
+ * room. This differs from a server refusal, which blocks edits.
1004
+ */
1005
+ disconnect: () => void;
1006
+ /** Reapply the stored offline tail after a page reload restores its base. */
1007
+ restoreOfflineView: () => void;
991
1008
  /**
992
1009
  * The server announced it will END this session, and this is the grace
993
1010
  * period before it does. `inMs` is the measured remainder at the moment the
@@ -1136,19 +1153,19 @@ interface CollabSession {
1136
1153
  * a DIFFERENT epoch than the tail was recorded against, the recommended
1137
1154
  * mode is `suggest` (replay as tracked changes; ≤ the suggest threshold)
1138
1155
  * or `draft` (large tails). `structural` counts the tail intents that
1139
- * have no suggestion form (splits/merges/tables/format — rebase.ts):
1156
+ * have no suggestion form (merges/tables/format — rebase.ts):
1140
1157
  * they are NOT replayed by `suggest` and survive in the banked draft
1141
1158
  * slot instead — say so, or their absence reads as silent loss. A
1142
- * same-epoch rejoin never surfaces here: its tail replays silently
1143
- * through the ordinary submit path, like a large pending queue.
1159
+ * same-epoch automatic rejoin replays silently. An intentional disconnect
1160
+ * offers `replay`; a changed room offers `suggest` or `draft`.
1144
1161
  * Null when there's nothing to reconcile. `reconcile()` runs the choice.
1145
1162
  */
1146
1163
  arrival: {
1147
- mode: "suggest" | "draft";
1164
+ mode: "replay" | "suggest" | "draft";
1148
1165
  tailLength: number;
1149
1166
  structural: number;
1150
1167
  } | null;
1151
- reconcile: (mode: "suggest" | "draft") => void;
1168
+ reconcile: (mode: "replay" | "suggest" | "draft") => void;
1152
1169
  /** How many times the connection self-healed a drifted optimistic replica
1153
1170
  * (encrypted mode's quiescent mirror check — the B6a class). Telemetry;
1154
1171
  * the heal itself is automatic and already reflected in doc/docEpoch. */
@@ -1250,6 +1267,8 @@ declare function useCollab(opts: UseCollabOptions): CollabSession;
1250
1267
  declare const COLLAB_TOOLBAR_DEFAULTS: Partial<Record<ToolbarFeature, boolean>>;
1251
1268
  declare function CollabEditor(opts: UseCollabOptions & {
1252
1269
  editable?: boolean;
1270
+ /** Tracked-change display. Use markup to show suggestions in the document. */
1271
+ revisions?: "final" | "markup";
1253
1272
  /** Render the Word-style ribbon toolbar above the page (default true). */
1254
1273
  toolbar?: boolean;
1255
1274
  /** Ribbon mode: "simple" (Home only) or "advanced" (default). */