canvu-react 0.4.33 → 0.4.34
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/chatbot.d.cts +2 -1
- package/dist/chatbot.d.ts +2 -1
- package/dist/native.cjs +239 -23
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +10 -1
- package/dist/native.d.ts +10 -1
- package/dist/native.js +240 -24
- package/dist/native.js.map +1 -1
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/realtime.cjs +18 -3
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +3 -2
- package/dist/realtime.d.ts +3 -2
- package/dist/realtime.js +18 -3
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.cjs +2124 -0
- package/dist/realtimeNative.cjs.map +1 -0
- package/dist/realtimeNative.d.cts +255 -0
- package/dist/realtimeNative.d.ts +255 -0
- package/dist/realtimeNative.js +2097 -0
- package/dist/realtimeNative.js.map +1 -0
- package/dist/types-B82WiQQh.d.ts +69 -0
- package/dist/types-BQUbxMgz.d.cts +69 -0
- package/dist/{types-UZYYwK-v.d.ts → types-DeDm865m.d.ts} +2 -67
- package/dist/{types-BS-YG8Hx.d.cts → types-NBYvslB-.d.cts} +2 -67
- package/package.json +7 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { a as RemotePresenceMarkupStroke, b as RemotePresenceCamera, c as RealtimeConnectionState, R as RemotePresencePeer } from './types-BQUbxMgz.cjs';
|
|
2
|
+
import { V as VectorSceneItem } from './types-BCCvY6ie.cjs';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
import { a as VectorCanvasRemoteAdapter } from './types-BUPc2Zgw.cjs';
|
|
5
|
+
import { S as StrokeStyle } from './shape-builders-CKEMjivV.cjs';
|
|
6
|
+
|
|
7
|
+
type RealtimeSessionPeer = RemotePresencePeer & {
|
|
8
|
+
readonly clientId: string;
|
|
9
|
+
readonly peerId: string;
|
|
10
|
+
readonly roomId: string;
|
|
11
|
+
readonly joinedAt: number;
|
|
12
|
+
readonly lastSeenAt: number;
|
|
13
|
+
readonly isSelf: boolean;
|
|
14
|
+
readonly connectionState?: RealtimeConnectionState;
|
|
15
|
+
};
|
|
16
|
+
type RealtimeDocumentSnapshot = {
|
|
17
|
+
readonly revision: number;
|
|
18
|
+
readonly items: VectorSceneItem[];
|
|
19
|
+
readonly updatedAt: number;
|
|
20
|
+
readonly updatedByClientId?: string;
|
|
21
|
+
readonly persistedRevision?: number;
|
|
22
|
+
};
|
|
23
|
+
type RealtimeConnectionInfo = {
|
|
24
|
+
readonly state: RealtimeConnectionState;
|
|
25
|
+
readonly connected: boolean;
|
|
26
|
+
readonly roomId: string;
|
|
27
|
+
readonly clientId: string | null;
|
|
28
|
+
readonly retryCount: number;
|
|
29
|
+
readonly lastConnectedAt: number | null;
|
|
30
|
+
readonly lastMessageAt: number | null;
|
|
31
|
+
readonly lastPongAt: number | null;
|
|
32
|
+
readonly lastError: string | null;
|
|
33
|
+
};
|
|
34
|
+
type RealtimePresencePayload = {
|
|
35
|
+
readonly cursor: {
|
|
36
|
+
readonly x: number;
|
|
37
|
+
readonly y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
readonly markupStroke?: RemotePresenceMarkupStroke | null;
|
|
40
|
+
readonly camera?: RemotePresenceCamera | null;
|
|
41
|
+
readonly activeTool?: string;
|
|
42
|
+
};
|
|
43
|
+
type RealtimeClientPeer = {
|
|
44
|
+
readonly clientId: string;
|
|
45
|
+
readonly peerId: string;
|
|
46
|
+
readonly displayName?: string;
|
|
47
|
+
readonly color?: string;
|
|
48
|
+
readonly image?: string;
|
|
49
|
+
};
|
|
50
|
+
type RealtimeClientMessage = {
|
|
51
|
+
readonly type: "session:join";
|
|
52
|
+
readonly roomId: string;
|
|
53
|
+
readonly peer: RealtimeClientPeer;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "session:leave";
|
|
56
|
+
readonly roomId: string;
|
|
57
|
+
readonly clientId: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "session:ping";
|
|
60
|
+
readonly roomId: string;
|
|
61
|
+
readonly clientId: string;
|
|
62
|
+
readonly sentAt: number;
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "presence:update";
|
|
65
|
+
readonly roomId: string;
|
|
66
|
+
readonly clientId: string;
|
|
67
|
+
readonly presence: RealtimePresencePayload;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "document:update";
|
|
70
|
+
readonly roomId: string;
|
|
71
|
+
readonly clientId: string;
|
|
72
|
+
readonly baseRevision: number;
|
|
73
|
+
readonly items: VectorSceneItem[];
|
|
74
|
+
};
|
|
75
|
+
type RealtimeServerMessage = {
|
|
76
|
+
readonly type: "session:welcome";
|
|
77
|
+
readonly roomId: string;
|
|
78
|
+
readonly clientId: string;
|
|
79
|
+
readonly serverTime: number;
|
|
80
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
81
|
+
readonly peers: RealtimeSessionPeer[];
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: "session:peer-joined";
|
|
84
|
+
readonly roomId: string;
|
|
85
|
+
readonly peer: RealtimeSessionPeer;
|
|
86
|
+
} | {
|
|
87
|
+
readonly type: "session:peer-left";
|
|
88
|
+
readonly roomId: string;
|
|
89
|
+
readonly clientId: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly type: "session:pong";
|
|
92
|
+
readonly roomId: string;
|
|
93
|
+
readonly clientId: string;
|
|
94
|
+
readonly sentAt: number;
|
|
95
|
+
readonly serverTime: number;
|
|
96
|
+
} | {
|
|
97
|
+
readonly type: "session:error";
|
|
98
|
+
readonly roomId?: string;
|
|
99
|
+
readonly code: string;
|
|
100
|
+
readonly message: string;
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "presence:sync";
|
|
103
|
+
readonly roomId: string;
|
|
104
|
+
readonly peers: RealtimeSessionPeer[];
|
|
105
|
+
readonly serverTime: number;
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: "document:sync";
|
|
108
|
+
readonly roomId: string;
|
|
109
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
110
|
+
} | {
|
|
111
|
+
readonly type: "document:resync-required";
|
|
112
|
+
readonly roomId: string;
|
|
113
|
+
readonly reason: string;
|
|
114
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
115
|
+
};
|
|
116
|
+
declare function parseRealtimeClientMessage(value: unknown): RealtimeClientMessage | undefined;
|
|
117
|
+
declare function parseRealtimeServerMessage(value: unknown): RealtimeServerMessage | undefined;
|
|
118
|
+
|
|
119
|
+
type RealtimeSessionPeerInput = {
|
|
120
|
+
id: string;
|
|
121
|
+
displayName?: string;
|
|
122
|
+
color?: string;
|
|
123
|
+
image?: string;
|
|
124
|
+
clientId?: string;
|
|
125
|
+
};
|
|
126
|
+
type UseRealtimeSessionOptions = {
|
|
127
|
+
url: string;
|
|
128
|
+
roomId: string;
|
|
129
|
+
peer: RealtimeSessionPeerInput;
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
draftStorage?: RealtimeDraftStorage | null;
|
|
132
|
+
reconnect?: boolean;
|
|
133
|
+
heartbeatMs?: number;
|
|
134
|
+
maxReconnectDelayMs?: number;
|
|
135
|
+
initialReconnectDelayMs?: number;
|
|
136
|
+
connectTimeoutMs?: number;
|
|
137
|
+
onError?: (message: string) => void;
|
|
138
|
+
};
|
|
139
|
+
type RealtimeDraftStorage = {
|
|
140
|
+
getItem: (key: string) => string | null | Promise<string | null>;
|
|
141
|
+
setItem: (key: string, value: string) => void | Promise<void>;
|
|
142
|
+
removeItem: (key: string) => void | Promise<void>;
|
|
143
|
+
};
|
|
144
|
+
type RealtimeViewportCamera = {
|
|
145
|
+
x: number;
|
|
146
|
+
y: number;
|
|
147
|
+
zoom: number;
|
|
148
|
+
};
|
|
149
|
+
type RealtimeViewportHandle = {
|
|
150
|
+
getCamera: () => RealtimeViewportCamera | null;
|
|
151
|
+
requestRender: () => void;
|
|
152
|
+
getViewportSize: () => {
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
type RealtimePlacementPreview = {
|
|
158
|
+
readonly kind: "rect" | "ellipse" | "architectural-cloud" | "marquee";
|
|
159
|
+
readonly rect: {
|
|
160
|
+
readonly x: number;
|
|
161
|
+
readonly y: number;
|
|
162
|
+
readonly width: number;
|
|
163
|
+
readonly height: number;
|
|
164
|
+
};
|
|
165
|
+
} | {
|
|
166
|
+
readonly kind: "line" | "arrow";
|
|
167
|
+
readonly start: {
|
|
168
|
+
readonly x: number;
|
|
169
|
+
readonly y: number;
|
|
170
|
+
};
|
|
171
|
+
readonly end: {
|
|
172
|
+
readonly x: number;
|
|
173
|
+
readonly y: number;
|
|
174
|
+
};
|
|
175
|
+
} | {
|
|
176
|
+
readonly kind: "stroke";
|
|
177
|
+
readonly tool: "draw" | "marker" | "laser";
|
|
178
|
+
readonly points: readonly {
|
|
179
|
+
readonly x: number;
|
|
180
|
+
readonly y: number;
|
|
181
|
+
}[];
|
|
182
|
+
readonly style?: StrokeStyle;
|
|
183
|
+
};
|
|
184
|
+
type RealtimeViewportPresenceBindings = {
|
|
185
|
+
remotePresence: RealtimeSessionPeer[];
|
|
186
|
+
onWorldPointerMove: (world: {
|
|
187
|
+
readonly x: number;
|
|
188
|
+
readonly y: number;
|
|
189
|
+
}) => void;
|
|
190
|
+
onWorldPointerLeave: () => void;
|
|
191
|
+
onPlacementPreviewChange: (preview: RealtimePlacementPreview | null) => void;
|
|
192
|
+
onCameraChange: () => void;
|
|
193
|
+
};
|
|
194
|
+
type BindViewportPresenceOptions = {
|
|
195
|
+
activeTool?: string;
|
|
196
|
+
viewportRef?: RefObject<RealtimeViewportHandle | null>;
|
|
197
|
+
};
|
|
198
|
+
type RealtimeSyncState = "connected" | "reconnecting" | "offline" | "conflicted";
|
|
199
|
+
type RealtimeDocumentConflict = {
|
|
200
|
+
readonly serverRevision: number;
|
|
201
|
+
readonly serverItems: VectorSceneItem[];
|
|
202
|
+
readonly localItems: VectorSceneItem[];
|
|
203
|
+
};
|
|
204
|
+
type UseRealtimeSessionResult = {
|
|
205
|
+
connection: RealtimeConnectionInfo;
|
|
206
|
+
sessionPeers: RealtimeSessionPeer[];
|
|
207
|
+
remotePresence: RealtimeSessionPeer[];
|
|
208
|
+
remoteAdapter: VectorCanvasRemoteAdapter;
|
|
209
|
+
document: RealtimeDocumentSnapshot | null;
|
|
210
|
+
hasLocalOfflineDraft: boolean;
|
|
211
|
+
hasPendingDocumentSync: boolean;
|
|
212
|
+
syncState: RealtimeSyncState;
|
|
213
|
+
conflict: RealtimeDocumentConflict | null;
|
|
214
|
+
bindViewportPresence: (options?: BindViewportPresenceOptions) => RealtimeViewportPresenceBindings;
|
|
215
|
+
syncViewportPresence: (options?: BindViewportPresenceOptions) => boolean;
|
|
216
|
+
resolveConflict: (action: "keep-local" | "use-server") => void;
|
|
217
|
+
clearLocalDraft: () => void;
|
|
218
|
+
flushDocumentSync: () => Promise<void>;
|
|
219
|
+
disconnect: () => void;
|
|
220
|
+
reconnectNow: () => void;
|
|
221
|
+
};
|
|
222
|
+
declare function createBrowserDraftStorage(): RealtimeDraftStorage | null;
|
|
223
|
+
declare function useRealtimeSession(options: UseRealtimeSessionOptions): UseRealtimeSessionResult;
|
|
224
|
+
|
|
225
|
+
type UseRealtimeCanvasDocumentOptions = {
|
|
226
|
+
session: Pick<UseRealtimeSessionResult, "connection" | "document" | "remoteAdapter" | "hasLocalOfflineDraft" | "hasPendingDocumentSync" | "syncState" | "conflict" | "resolveConflict" | "clearLocalDraft" | "flushDocumentSync"> | null;
|
|
227
|
+
items: readonly VectorSceneItem[];
|
|
228
|
+
onItemsChange?: (nextItems: VectorSceneItem[]) => void;
|
|
229
|
+
normalizeItems?: (nextItems: readonly VectorSceneItem[]) => VectorSceneItem[];
|
|
230
|
+
hydrateItems?: (nextItems: readonly VectorSceneItem[]) => Promise<VectorSceneItem[]>;
|
|
231
|
+
enabled?: boolean;
|
|
232
|
+
};
|
|
233
|
+
type UseRealtimeCanvasDocumentResult = {
|
|
234
|
+
items: readonly VectorSceneItem[];
|
|
235
|
+
onItemsChange?: (nextItems: VectorSceneItem[]) => void;
|
|
236
|
+
loading: boolean;
|
|
237
|
+
saving: boolean;
|
|
238
|
+
hasLocalOfflineDraft: boolean;
|
|
239
|
+
syncState: RealtimeSyncState;
|
|
240
|
+
conflict: RealtimeDocumentConflict | null;
|
|
241
|
+
resolveConflict: (action: "keep-local" | "use-server") => void;
|
|
242
|
+
clearLocalDraft: () => void;
|
|
243
|
+
flush: () => Promise<void>;
|
|
244
|
+
};
|
|
245
|
+
declare function useRealtimeCanvasDocument(options: UseRealtimeCanvasDocumentOptions): UseRealtimeCanvasDocumentResult;
|
|
246
|
+
|
|
247
|
+
type UseRealtimePeerFollowOptions = {
|
|
248
|
+
viewportRef: RefObject<RealtimeViewportHandle | null>;
|
|
249
|
+
sessionPeers: RealtimeSessionPeer[];
|
|
250
|
+
followedPeerId: string | null | undefined;
|
|
251
|
+
onFollowEnd?: () => void;
|
|
252
|
+
};
|
|
253
|
+
declare function useRealtimePeerFollow(options: UseRealtimePeerFollowOptions): void;
|
|
254
|
+
|
|
255
|
+
export { type RealtimeClientMessage, type RealtimeConnectionInfo, type RealtimeDocumentConflict, type RealtimeDocumentSnapshot, type RealtimeDraftStorage, type RealtimePlacementPreview, type RealtimePresencePayload, type RealtimeServerMessage, type RealtimeSessionPeer, type RealtimeSyncState, type RealtimeViewportHandle, type RealtimeViewportPresenceBindings, type UseRealtimeCanvasDocumentResult, type UseRealtimePeerFollowOptions, type UseRealtimeSessionOptions, type UseRealtimeSessionResult, createBrowserDraftStorage, parseRealtimeClientMessage, parseRealtimeServerMessage, useRealtimeCanvasDocument, useRealtimePeerFollow, useRealtimeSession };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { a as RemotePresenceMarkupStroke, b as RemotePresenceCamera, c as RealtimeConnectionState, R as RemotePresencePeer } from './types-B82WiQQh.js';
|
|
2
|
+
import { V as VectorSceneItem } from './types-BCCvY6ie.js';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
import { a as VectorCanvasRemoteAdapter } from './types-CYtq9Pr9.js';
|
|
5
|
+
import { S as StrokeStyle } from './shape-builders-Cyh8zvDG.js';
|
|
6
|
+
|
|
7
|
+
type RealtimeSessionPeer = RemotePresencePeer & {
|
|
8
|
+
readonly clientId: string;
|
|
9
|
+
readonly peerId: string;
|
|
10
|
+
readonly roomId: string;
|
|
11
|
+
readonly joinedAt: number;
|
|
12
|
+
readonly lastSeenAt: number;
|
|
13
|
+
readonly isSelf: boolean;
|
|
14
|
+
readonly connectionState?: RealtimeConnectionState;
|
|
15
|
+
};
|
|
16
|
+
type RealtimeDocumentSnapshot = {
|
|
17
|
+
readonly revision: number;
|
|
18
|
+
readonly items: VectorSceneItem[];
|
|
19
|
+
readonly updatedAt: number;
|
|
20
|
+
readonly updatedByClientId?: string;
|
|
21
|
+
readonly persistedRevision?: number;
|
|
22
|
+
};
|
|
23
|
+
type RealtimeConnectionInfo = {
|
|
24
|
+
readonly state: RealtimeConnectionState;
|
|
25
|
+
readonly connected: boolean;
|
|
26
|
+
readonly roomId: string;
|
|
27
|
+
readonly clientId: string | null;
|
|
28
|
+
readonly retryCount: number;
|
|
29
|
+
readonly lastConnectedAt: number | null;
|
|
30
|
+
readonly lastMessageAt: number | null;
|
|
31
|
+
readonly lastPongAt: number | null;
|
|
32
|
+
readonly lastError: string | null;
|
|
33
|
+
};
|
|
34
|
+
type RealtimePresencePayload = {
|
|
35
|
+
readonly cursor: {
|
|
36
|
+
readonly x: number;
|
|
37
|
+
readonly y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
readonly markupStroke?: RemotePresenceMarkupStroke | null;
|
|
40
|
+
readonly camera?: RemotePresenceCamera | null;
|
|
41
|
+
readonly activeTool?: string;
|
|
42
|
+
};
|
|
43
|
+
type RealtimeClientPeer = {
|
|
44
|
+
readonly clientId: string;
|
|
45
|
+
readonly peerId: string;
|
|
46
|
+
readonly displayName?: string;
|
|
47
|
+
readonly color?: string;
|
|
48
|
+
readonly image?: string;
|
|
49
|
+
};
|
|
50
|
+
type RealtimeClientMessage = {
|
|
51
|
+
readonly type: "session:join";
|
|
52
|
+
readonly roomId: string;
|
|
53
|
+
readonly peer: RealtimeClientPeer;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "session:leave";
|
|
56
|
+
readonly roomId: string;
|
|
57
|
+
readonly clientId: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "session:ping";
|
|
60
|
+
readonly roomId: string;
|
|
61
|
+
readonly clientId: string;
|
|
62
|
+
readonly sentAt: number;
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "presence:update";
|
|
65
|
+
readonly roomId: string;
|
|
66
|
+
readonly clientId: string;
|
|
67
|
+
readonly presence: RealtimePresencePayload;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "document:update";
|
|
70
|
+
readonly roomId: string;
|
|
71
|
+
readonly clientId: string;
|
|
72
|
+
readonly baseRevision: number;
|
|
73
|
+
readonly items: VectorSceneItem[];
|
|
74
|
+
};
|
|
75
|
+
type RealtimeServerMessage = {
|
|
76
|
+
readonly type: "session:welcome";
|
|
77
|
+
readonly roomId: string;
|
|
78
|
+
readonly clientId: string;
|
|
79
|
+
readonly serverTime: number;
|
|
80
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
81
|
+
readonly peers: RealtimeSessionPeer[];
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: "session:peer-joined";
|
|
84
|
+
readonly roomId: string;
|
|
85
|
+
readonly peer: RealtimeSessionPeer;
|
|
86
|
+
} | {
|
|
87
|
+
readonly type: "session:peer-left";
|
|
88
|
+
readonly roomId: string;
|
|
89
|
+
readonly clientId: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly type: "session:pong";
|
|
92
|
+
readonly roomId: string;
|
|
93
|
+
readonly clientId: string;
|
|
94
|
+
readonly sentAt: number;
|
|
95
|
+
readonly serverTime: number;
|
|
96
|
+
} | {
|
|
97
|
+
readonly type: "session:error";
|
|
98
|
+
readonly roomId?: string;
|
|
99
|
+
readonly code: string;
|
|
100
|
+
readonly message: string;
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "presence:sync";
|
|
103
|
+
readonly roomId: string;
|
|
104
|
+
readonly peers: RealtimeSessionPeer[];
|
|
105
|
+
readonly serverTime: number;
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: "document:sync";
|
|
108
|
+
readonly roomId: string;
|
|
109
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
110
|
+
} | {
|
|
111
|
+
readonly type: "document:resync-required";
|
|
112
|
+
readonly roomId: string;
|
|
113
|
+
readonly reason: string;
|
|
114
|
+
readonly document: RealtimeDocumentSnapshot;
|
|
115
|
+
};
|
|
116
|
+
declare function parseRealtimeClientMessage(value: unknown): RealtimeClientMessage | undefined;
|
|
117
|
+
declare function parseRealtimeServerMessage(value: unknown): RealtimeServerMessage | undefined;
|
|
118
|
+
|
|
119
|
+
type RealtimeSessionPeerInput = {
|
|
120
|
+
id: string;
|
|
121
|
+
displayName?: string;
|
|
122
|
+
color?: string;
|
|
123
|
+
image?: string;
|
|
124
|
+
clientId?: string;
|
|
125
|
+
};
|
|
126
|
+
type UseRealtimeSessionOptions = {
|
|
127
|
+
url: string;
|
|
128
|
+
roomId: string;
|
|
129
|
+
peer: RealtimeSessionPeerInput;
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
draftStorage?: RealtimeDraftStorage | null;
|
|
132
|
+
reconnect?: boolean;
|
|
133
|
+
heartbeatMs?: number;
|
|
134
|
+
maxReconnectDelayMs?: number;
|
|
135
|
+
initialReconnectDelayMs?: number;
|
|
136
|
+
connectTimeoutMs?: number;
|
|
137
|
+
onError?: (message: string) => void;
|
|
138
|
+
};
|
|
139
|
+
type RealtimeDraftStorage = {
|
|
140
|
+
getItem: (key: string) => string | null | Promise<string | null>;
|
|
141
|
+
setItem: (key: string, value: string) => void | Promise<void>;
|
|
142
|
+
removeItem: (key: string) => void | Promise<void>;
|
|
143
|
+
};
|
|
144
|
+
type RealtimeViewportCamera = {
|
|
145
|
+
x: number;
|
|
146
|
+
y: number;
|
|
147
|
+
zoom: number;
|
|
148
|
+
};
|
|
149
|
+
type RealtimeViewportHandle = {
|
|
150
|
+
getCamera: () => RealtimeViewportCamera | null;
|
|
151
|
+
requestRender: () => void;
|
|
152
|
+
getViewportSize: () => {
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
type RealtimePlacementPreview = {
|
|
158
|
+
readonly kind: "rect" | "ellipse" | "architectural-cloud" | "marquee";
|
|
159
|
+
readonly rect: {
|
|
160
|
+
readonly x: number;
|
|
161
|
+
readonly y: number;
|
|
162
|
+
readonly width: number;
|
|
163
|
+
readonly height: number;
|
|
164
|
+
};
|
|
165
|
+
} | {
|
|
166
|
+
readonly kind: "line" | "arrow";
|
|
167
|
+
readonly start: {
|
|
168
|
+
readonly x: number;
|
|
169
|
+
readonly y: number;
|
|
170
|
+
};
|
|
171
|
+
readonly end: {
|
|
172
|
+
readonly x: number;
|
|
173
|
+
readonly y: number;
|
|
174
|
+
};
|
|
175
|
+
} | {
|
|
176
|
+
readonly kind: "stroke";
|
|
177
|
+
readonly tool: "draw" | "marker" | "laser";
|
|
178
|
+
readonly points: readonly {
|
|
179
|
+
readonly x: number;
|
|
180
|
+
readonly y: number;
|
|
181
|
+
}[];
|
|
182
|
+
readonly style?: StrokeStyle;
|
|
183
|
+
};
|
|
184
|
+
type RealtimeViewportPresenceBindings = {
|
|
185
|
+
remotePresence: RealtimeSessionPeer[];
|
|
186
|
+
onWorldPointerMove: (world: {
|
|
187
|
+
readonly x: number;
|
|
188
|
+
readonly y: number;
|
|
189
|
+
}) => void;
|
|
190
|
+
onWorldPointerLeave: () => void;
|
|
191
|
+
onPlacementPreviewChange: (preview: RealtimePlacementPreview | null) => void;
|
|
192
|
+
onCameraChange: () => void;
|
|
193
|
+
};
|
|
194
|
+
type BindViewportPresenceOptions = {
|
|
195
|
+
activeTool?: string;
|
|
196
|
+
viewportRef?: RefObject<RealtimeViewportHandle | null>;
|
|
197
|
+
};
|
|
198
|
+
type RealtimeSyncState = "connected" | "reconnecting" | "offline" | "conflicted";
|
|
199
|
+
type RealtimeDocumentConflict = {
|
|
200
|
+
readonly serverRevision: number;
|
|
201
|
+
readonly serverItems: VectorSceneItem[];
|
|
202
|
+
readonly localItems: VectorSceneItem[];
|
|
203
|
+
};
|
|
204
|
+
type UseRealtimeSessionResult = {
|
|
205
|
+
connection: RealtimeConnectionInfo;
|
|
206
|
+
sessionPeers: RealtimeSessionPeer[];
|
|
207
|
+
remotePresence: RealtimeSessionPeer[];
|
|
208
|
+
remoteAdapter: VectorCanvasRemoteAdapter;
|
|
209
|
+
document: RealtimeDocumentSnapshot | null;
|
|
210
|
+
hasLocalOfflineDraft: boolean;
|
|
211
|
+
hasPendingDocumentSync: boolean;
|
|
212
|
+
syncState: RealtimeSyncState;
|
|
213
|
+
conflict: RealtimeDocumentConflict | null;
|
|
214
|
+
bindViewportPresence: (options?: BindViewportPresenceOptions) => RealtimeViewportPresenceBindings;
|
|
215
|
+
syncViewportPresence: (options?: BindViewportPresenceOptions) => boolean;
|
|
216
|
+
resolveConflict: (action: "keep-local" | "use-server") => void;
|
|
217
|
+
clearLocalDraft: () => void;
|
|
218
|
+
flushDocumentSync: () => Promise<void>;
|
|
219
|
+
disconnect: () => void;
|
|
220
|
+
reconnectNow: () => void;
|
|
221
|
+
};
|
|
222
|
+
declare function createBrowserDraftStorage(): RealtimeDraftStorage | null;
|
|
223
|
+
declare function useRealtimeSession(options: UseRealtimeSessionOptions): UseRealtimeSessionResult;
|
|
224
|
+
|
|
225
|
+
type UseRealtimeCanvasDocumentOptions = {
|
|
226
|
+
session: Pick<UseRealtimeSessionResult, "connection" | "document" | "remoteAdapter" | "hasLocalOfflineDraft" | "hasPendingDocumentSync" | "syncState" | "conflict" | "resolveConflict" | "clearLocalDraft" | "flushDocumentSync"> | null;
|
|
227
|
+
items: readonly VectorSceneItem[];
|
|
228
|
+
onItemsChange?: (nextItems: VectorSceneItem[]) => void;
|
|
229
|
+
normalizeItems?: (nextItems: readonly VectorSceneItem[]) => VectorSceneItem[];
|
|
230
|
+
hydrateItems?: (nextItems: readonly VectorSceneItem[]) => Promise<VectorSceneItem[]>;
|
|
231
|
+
enabled?: boolean;
|
|
232
|
+
};
|
|
233
|
+
type UseRealtimeCanvasDocumentResult = {
|
|
234
|
+
items: readonly VectorSceneItem[];
|
|
235
|
+
onItemsChange?: (nextItems: VectorSceneItem[]) => void;
|
|
236
|
+
loading: boolean;
|
|
237
|
+
saving: boolean;
|
|
238
|
+
hasLocalOfflineDraft: boolean;
|
|
239
|
+
syncState: RealtimeSyncState;
|
|
240
|
+
conflict: RealtimeDocumentConflict | null;
|
|
241
|
+
resolveConflict: (action: "keep-local" | "use-server") => void;
|
|
242
|
+
clearLocalDraft: () => void;
|
|
243
|
+
flush: () => Promise<void>;
|
|
244
|
+
};
|
|
245
|
+
declare function useRealtimeCanvasDocument(options: UseRealtimeCanvasDocumentOptions): UseRealtimeCanvasDocumentResult;
|
|
246
|
+
|
|
247
|
+
type UseRealtimePeerFollowOptions = {
|
|
248
|
+
viewportRef: RefObject<RealtimeViewportHandle | null>;
|
|
249
|
+
sessionPeers: RealtimeSessionPeer[];
|
|
250
|
+
followedPeerId: string | null | undefined;
|
|
251
|
+
onFollowEnd?: () => void;
|
|
252
|
+
};
|
|
253
|
+
declare function useRealtimePeerFollow(options: UseRealtimePeerFollowOptions): void;
|
|
254
|
+
|
|
255
|
+
export { type RealtimeClientMessage, type RealtimeConnectionInfo, type RealtimeDocumentConflict, type RealtimeDocumentSnapshot, type RealtimeDraftStorage, type RealtimePlacementPreview, type RealtimePresencePayload, type RealtimeServerMessage, type RealtimeSessionPeer, type RealtimeSyncState, type RealtimeViewportHandle, type RealtimeViewportPresenceBindings, type UseRealtimeCanvasDocumentResult, type UseRealtimePeerFollowOptions, type UseRealtimeSessionOptions, type UseRealtimeSessionResult, createBrowserDraftStorage, parseRealtimeClientMessage, parseRealtimeServerMessage, useRealtimeCanvasDocument, useRealtimePeerFollow, useRealtimeSession };
|