@betteroffice/pptx 0.2.0 → 0.5.1

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.
@@ -0,0 +1,95 @@
1
+ import { C as CollaborationReplica, i as CollaborationTransport, e as CollaborationProviderOptions, A as AsyncCollaborationReplica, f as CollaborationStatus, a as PptxPresencePeer, P as PptxPresenceCursor, h as CollaborationStatusListener, d as CollaborationErrorListener, n as PptxPresenceListener } from './types-ui_ARP0o.js';
2
+
3
+ declare class CollaborationProvider {
4
+ private readonly piped;
5
+ private openEpoch;
6
+ private readonly replica;
7
+ private readonly transport;
8
+ private readonly maxFrameBytes;
9
+ private readonly maxMessagesPerFrame;
10
+ private readonly maxPendingBytes;
11
+ private readonly localClientId;
12
+ private readonly localUser;
13
+ private readonly remotePresence;
14
+ private readonly statusListeners;
15
+ private readonly errorListeners;
16
+ private readonly presenceListeners;
17
+ private readonly pendingFrames;
18
+ private unsubscribeReplica;
19
+ private unsubscribeTransport;
20
+ private hasTransportSubscription;
21
+ private connectionStatus;
22
+ private isSynced;
23
+ private wantsConnection;
24
+ private isOpen;
25
+ private isDestroyed;
26
+ private epoch;
27
+ private connectAttempt;
28
+ private nextListenerId;
29
+ private queuedBytes;
30
+ private readonly incoming;
31
+ private incomingBytes;
32
+ private incomingBusy;
33
+ private asyncReplica;
34
+ private incomingGeneration;
35
+ private isFlushing;
36
+ private localClock;
37
+ private reportedClockExhaustion;
38
+ private localCursor;
39
+ private applyingArrival;
40
+ private lastAwarenessSentAt;
41
+ private cursorTimer;
42
+ private heartbeatTimer;
43
+ private expiryTimer;
44
+ constructor(replica: CollaborationReplica, transport: CollaborationTransport, options?: CollaborationProviderOptions);
45
+ constructor(replica: AsyncCollaborationReplica, transport: CollaborationTransport, options?: CollaborationProviderOptions);
46
+ get status(): CollaborationStatus;
47
+ get synced(): boolean;
48
+ get pendingBytes(): number;
49
+ get peers(): readonly PptxPresencePeer[];
50
+ setCursor(cursor: PptxPresenceCursor | null): void;
51
+ connect(): void;
52
+ disconnect(): void;
53
+ destroy(): void;
54
+ onStatus(listener: CollaborationStatusListener): () => void;
55
+ onError(listener: CollaborationErrorListener): () => void;
56
+ onPresence(listener: PptxPresenceListener): () => void;
57
+ private beginArrival;
58
+ private leaveFrame;
59
+ private isCurrent;
60
+ private failConnection;
61
+ private takeTransportSubscription;
62
+ private cleanupTransport;
63
+ private handleTransportEvent;
64
+ private handleOpen;
65
+ private sendFullUpdate;
66
+ private replicaResult;
67
+ private handleMessage;
68
+ private answerSyncStep1;
69
+ private enqueueMessage;
70
+ private drainIncoming;
71
+ /** Takes the queued frames that carry only remote updates, up to the frame and worker byte limits, for one chunked apply. */
72
+ private takeUpdateBatch;
73
+ private remoteUpdates;
74
+ private applyUpdateBatch;
75
+ private forwardLocalUpdate;
76
+ private scheduleCursorBroadcast;
77
+ private broadcastLocalPresence;
78
+ private sendLeaveFrameBestEffort;
79
+ private startPresenceTimers;
80
+ private stopPresenceTimers;
81
+ private schedulePresenceExpiry;
82
+ private clearRemotePresence;
83
+ private emitPresence;
84
+ private sendFrame;
85
+ private queueFrame;
86
+ private flushPending;
87
+ private clearPending;
88
+ private setStatus;
89
+ private report;
90
+ }
91
+
92
+ declare const PRESENCE_LABEL_DURATION_MS = 3000;
93
+ declare function presenceColorForClientId(clientId: number): string;
94
+
95
+ export { CollaborationProvider as C, PRESENCE_LABEL_DURATION_MS as P, presenceColorForClientId as p };
@@ -0,0 +1,93 @@
1
+ type CollaborationUpdateOrigin = 'local' | 'remote';
2
+ interface CollaborationReplica {
3
+ readonly clientId: number;
4
+ encodeStateVector(): Uint8Array;
5
+ encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
6
+ applyUpdate(update: Uint8Array): unknown;
7
+ onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
8
+ /** Replicas that wrap a PresentationHandle must forward this to it. */
9
+ setCollaborative?(): void;
10
+ }
11
+ interface AsyncCollaborationReplica {
12
+ readonly clientId: number;
13
+ encodeStateVector(): Promise<Uint8Array>;
14
+ encodeStateAsUpdate(remoteStateVector?: Uint8Array): Promise<Uint8Array>;
15
+ /** Optional. Encodes the update for `remoteStateVector` as chunks of at most `maxChunkBytes`. */
16
+ encodeStateAsUpdateChunks?(remoteStateVector: Uint8Array, maxChunkBytes: number): Promise<Uint8Array[]>;
17
+ applyUpdate(update: Uint8Array): Promise<unknown>;
18
+ /** Optional. Resolves once the worker has merged the updates as a single change. */
19
+ applyUpdateChunks?(updates: readonly Uint8Array[]): Promise<unknown>;
20
+ onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
21
+ }
22
+ type CollaborationTransportEvent = {
23
+ type: 'open';
24
+ } | {
25
+ type: 'message';
26
+ data: Uint8Array;
27
+ } | {
28
+ type: 'close';
29
+ reason?: string;
30
+ } | {
31
+ type: 'error';
32
+ error: unknown;
33
+ } | {
34
+ type: 'drain';
35
+ };
36
+ interface CollaborationTransport {
37
+ /** Starts one connection attempt; transports may also reopen while still subscribed. */
38
+ connect(): void | Promise<void>;
39
+ disconnect(): void | Promise<void>;
40
+ /** Returns true only when the owned frame was accepted; false requires a later drain event. */
41
+ send(data: Uint8Array): boolean;
42
+ onEvent(listener: (event: CollaborationTransportEvent) => void): () => void;
43
+ }
44
+ type CollaborationStatus = 'disconnected' | 'connecting' | 'connected' | 'destroyed';
45
+ interface CollaborationStatusChange {
46
+ status: CollaborationStatus;
47
+ synced: boolean;
48
+ }
49
+ type CollaborationErrorCode = 'backpressure' | 'protocol' | 'replica' | 'transport';
50
+ declare class CollaborationError extends Error {
51
+ readonly code: CollaborationErrorCode;
52
+ readonly cause: unknown;
53
+ constructor(code: CollaborationErrorCode, message: string, cause?: unknown);
54
+ }
55
+ interface CollaborationProviderOptions {
56
+ maxFrameBytes?: number;
57
+ maxMessagesPerFrame?: number;
58
+ maxPendingBytes?: number;
59
+ user?: CollaborationUser;
60
+ }
61
+ type CollaborationStatusListener = (change: CollaborationStatusChange) => void;
62
+ type CollaborationErrorListener = (error: CollaborationError) => void;
63
+ interface CollaborationUser {
64
+ name: string;
65
+ color?: string;
66
+ }
67
+ interface PptxPresenceUser {
68
+ name: string;
69
+ color: string;
70
+ }
71
+ interface PptxPresenceCursor {
72
+ slideId: string;
73
+ shapeId?: string;
74
+ }
75
+ interface PptxPresenceState {
76
+ clientId: number;
77
+ clock: number;
78
+ user: PptxPresenceUser;
79
+ cursor: PptxPresenceCursor | null;
80
+ }
81
+ interface PptxPresencePeer {
82
+ state: PptxPresenceState;
83
+ lastSeen: number;
84
+ cursorMovedAt: number;
85
+ }
86
+ type PptxPresenceListener = (peers: readonly PptxPresencePeer[]) => void;
87
+ interface PptxPresence {
88
+ readonly peers: readonly PptxPresencePeer[];
89
+ setCursor(cursor: PptxPresenceCursor | null): void;
90
+ onPresence(listener: PptxPresenceListener): () => void;
91
+ }
92
+
93
+ export { type AsyncCollaborationReplica as A, type CollaborationReplica as C, type PptxPresenceCursor as P, type PptxPresencePeer as a, CollaborationError as b, type CollaborationErrorCode as c, type CollaborationErrorListener as d, type CollaborationProviderOptions as e, type CollaborationStatus as f, type CollaborationStatusChange as g, type CollaborationStatusListener as h, type CollaborationTransport as i, type CollaborationTransportEvent as j, type CollaborationUpdateOrigin as k, type CollaborationUser as l, type PptxPresence as m, type PptxPresenceListener as n, type PptxPresenceState as o, type PptxPresenceUser as p };