wordinweb 0.2.1 → 0.2.3

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();
@@ -913,8 +918,8 @@ interface CollabSession {
913
918
  * repaint sees every batched intent's scope.
914
919
  */
915
920
  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
921
+ /** Increases when a reconnect or reconciliation replaces the document
922
+ * object. The editor re-mounts on this; between replacements it updates in
918
923
  * place (no flash for the common non-conflicting edits). */
919
924
  docEpoch: number;
920
925
  /** True once joined and the snapshot is loaded. */
@@ -974,8 +979,9 @@ interface CollabSession {
974
979
  *
975
980
  * Null while the connection is live, and null when a refusal already
976
981
  * 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}.
982
+ * through a tunnel). An automatic same-epoch reconnect replays the tail
983
+ * silently. An intentional disconnect uses {@link arrival} for an explicit
984
+ * merge check.
979
985
  */
980
986
  offline: {
981
987
  editsHeld: number;
@@ -988,6 +994,14 @@ interface CollabSession {
988
994
  * the statement that automatic recovery has stopped.
989
995
  */
990
996
  reconnect: () => void;
997
+ /**
998
+ * Intentionally leave the transport while the document stays open. Edits
999
+ * continue into the offline tail until {@link reconnect} rejoins the same
1000
+ * room. This differs from a server refusal, which blocks edits.
1001
+ */
1002
+ disconnect: () => void;
1003
+ /** Reapply the stored offline tail after a page reload restores its base. */
1004
+ restoreOfflineView: () => void;
991
1005
  /**
992
1006
  * The server announced it will END this session, and this is the grace
993
1007
  * period before it does. `inMs` is the measured remainder at the moment the
@@ -1136,19 +1150,19 @@ interface CollabSession {
1136
1150
  * a DIFFERENT epoch than the tail was recorded against, the recommended
1137
1151
  * mode is `suggest` (replay as tracked changes; ≤ the suggest threshold)
1138
1152
  * or `draft` (large tails). `structural` counts the tail intents that
1139
- * have no suggestion form (splits/merges/tables/format — rebase.ts):
1153
+ * have no suggestion form (merges/tables/format — rebase.ts):
1140
1154
  * they are NOT replayed by `suggest` and survive in the banked draft
1141
1155
  * 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.
1156
+ * same-epoch automatic rejoin replays silently. An intentional disconnect
1157
+ * offers `replay`; a changed room offers `suggest` or `draft`.
1144
1158
  * Null when there's nothing to reconcile. `reconcile()` runs the choice.
1145
1159
  */
1146
1160
  arrival: {
1147
- mode: "suggest" | "draft";
1161
+ mode: "replay" | "suggest" | "draft";
1148
1162
  tailLength: number;
1149
1163
  structural: number;
1150
1164
  } | null;
1151
- reconcile: (mode: "suggest" | "draft") => void;
1165
+ reconcile: (mode: "replay" | "suggest" | "draft") => void;
1152
1166
  /** How many times the connection self-healed a drifted optimistic replica
1153
1167
  * (encrypted mode's quiescent mirror check — the B6a class). Telemetry;
1154
1168
  * the heal itself is automatic and already reflected in doc/docEpoch. */
@@ -1250,6 +1264,8 @@ declare function useCollab(opts: UseCollabOptions): CollabSession;
1250
1264
  declare const COLLAB_TOOLBAR_DEFAULTS: Partial<Record<ToolbarFeature, boolean>>;
1251
1265
  declare function CollabEditor(opts: UseCollabOptions & {
1252
1266
  editable?: boolean;
1267
+ /** Tracked-change display. Use markup to show suggestions in the document. */
1268
+ revisions?: "final" | "markup";
1253
1269
  /** Render the Word-style ribbon toolbar above the page (default true). */
1254
1270
  toolbar?: boolean;
1255
1271
  /** Ribbon mode: "simple" (Home only) or "advanced" (default). */