leafrelay 0.1.6 → 0.2.0
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/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/chunk-J46L4Q2T.js +5157 -0
- package/dist/chunk-J46L4Q2T.js.map +1 -0
- package/dist/{chunk-MNOPLM7M.js → chunk-PRWBFOB2.js} +187 -132
- package/dist/chunk-PRWBFOB2.js.map +1 -0
- package/dist/cli.js +21 -36
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +959 -0
- package/dist/daemon.js.map +1 -0
- package/dist/index.d.ts +11 -722
- package/dist/index.js +3 -69
- package/package.json +6 -3
- package/dist/chunk-MNOPLM7M.js.map +0 -1
- package/dist/cli.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,734 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type?: PacketType;
|
|
5
|
-
id?: string;
|
|
6
|
-
ack?: true | 'data';
|
|
7
|
-
endpoint?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
args?: unknown[];
|
|
10
|
-
data?: unknown;
|
|
11
|
-
ackId?: string;
|
|
12
|
-
reason?: string;
|
|
13
|
-
advice?: string;
|
|
14
|
-
}
|
|
15
|
-
interface OverleafRealtimeSocketOptions {
|
|
16
|
-
origin: string;
|
|
17
|
-
cookie: string;
|
|
18
|
-
reconnect?: boolean;
|
|
19
|
-
reconnectionDelay?: number;
|
|
20
|
-
reconnectionLimit?: number;
|
|
21
|
-
maxReconnectionAttempts?: number;
|
|
22
|
-
}
|
|
23
|
-
declare function encodePacket(packet: SocketPacket): string;
|
|
24
|
-
declare function decodePacket(value: string): SocketPacket;
|
|
25
|
-
declare function decodePayload(value: string): SocketPacket[];
|
|
26
|
-
declare class OverleafRealtimeSocket {
|
|
27
|
-
private readonly options;
|
|
28
|
-
private readonly events;
|
|
29
|
-
private readonly endpoint;
|
|
30
|
-
private readonly origin;
|
|
31
|
-
private cookie;
|
|
32
|
-
private socket?;
|
|
33
|
-
private connected;
|
|
34
|
-
private explicitlyDisconnected;
|
|
35
|
-
private reconnectEnabled;
|
|
36
|
-
private reconnectAttempts;
|
|
37
|
-
private reconnectTimer?;
|
|
38
|
-
private inactivityTimer?;
|
|
39
|
-
private closeTimeoutMs;
|
|
40
|
-
private acknowledgementId;
|
|
41
|
-
private readonly acknowledgements;
|
|
42
|
-
private readonly sendBuffer;
|
|
43
|
-
readonly io: {
|
|
44
|
-
reconnect: (enabled: boolean) => void;
|
|
45
|
-
};
|
|
46
|
-
constructor(url: string, options: OverleafRealtimeSocketOptions);
|
|
47
|
-
on(event: string, handler: (...args: any[]) => void): this;
|
|
48
|
-
once(event: string, handler: (...args: any[]) => void): this;
|
|
49
|
-
removeListener(event: string, handler: (...args: any[]) => void): this;
|
|
50
|
-
removeAllListeners(event?: string): this;
|
|
51
|
-
emit(event: string, ...args: any[]): this;
|
|
52
|
-
disconnect(): this;
|
|
53
|
-
private connect;
|
|
54
|
-
private receive;
|
|
55
|
-
private handlePacket;
|
|
56
|
-
private send;
|
|
57
|
-
private flush;
|
|
58
|
-
private resetInactivityTimer;
|
|
59
|
-
private handleClose;
|
|
60
|
-
private closeSocket;
|
|
61
|
-
private scheduleReconnect;
|
|
62
|
-
}
|
|
63
|
-
declare const overleafSocketProtocol: {
|
|
64
|
-
encodePacket: typeof encodePacket;
|
|
65
|
-
decodePacket: typeof decodePacket;
|
|
66
|
-
decodePayload: typeof decodePayload;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
type FileType = 'doc' | 'file' | 'folder' | 'outputs';
|
|
70
|
-
type FolderKey = 'docs' | 'fileRefs' | 'folders' | 'outputs';
|
|
71
|
-
declare const FolderKeys: Readonly<Record<string, FolderKey>>;
|
|
72
|
-
interface ProjectLinkedFileProvider {
|
|
73
|
-
provider: 'project_file';
|
|
74
|
-
source_project_id: string;
|
|
75
|
-
source_entity_path: string;
|
|
76
|
-
}
|
|
77
|
-
interface UrlLinkedFileProvider {
|
|
78
|
-
provider: 'url';
|
|
79
|
-
url: string;
|
|
80
|
-
}
|
|
81
|
-
interface FileEntity {
|
|
82
|
-
_id: string;
|
|
83
|
-
name: string;
|
|
84
|
-
_type?: FileType;
|
|
85
|
-
readonly?: boolean;
|
|
86
|
-
}
|
|
87
|
-
interface DocumentEntity extends FileEntity {
|
|
88
|
-
version?: number;
|
|
89
|
-
mtime?: number;
|
|
90
|
-
lastVersion?: number;
|
|
91
|
-
localCache?: string;
|
|
92
|
-
remoteCache?: string;
|
|
93
|
-
}
|
|
94
|
-
interface FileRefEntity extends FileEntity {
|
|
95
|
-
linkedFileData: ProjectLinkedFileProvider | UrlLinkedFileProvider | null;
|
|
96
|
-
created: string;
|
|
97
|
-
}
|
|
98
|
-
interface OutputFileEntity extends FileEntity {
|
|
99
|
-
path: string;
|
|
100
|
-
url: string;
|
|
101
|
-
type: string;
|
|
102
|
-
build: string;
|
|
103
|
-
}
|
|
104
|
-
interface FolderEntity extends FileEntity {
|
|
105
|
-
docs: DocumentEntity[];
|
|
106
|
-
fileRefs: FileRefEntity[];
|
|
107
|
-
folders: FolderEntity[];
|
|
108
|
-
outputs?: OutputFileEntity[];
|
|
109
|
-
}
|
|
110
|
-
interface MemberEntity {
|
|
111
|
-
_id: string;
|
|
112
|
-
first_name: string;
|
|
113
|
-
last_name?: string;
|
|
114
|
-
email: string;
|
|
115
|
-
privileges?: string;
|
|
116
|
-
signUpDate?: string;
|
|
117
|
-
}
|
|
118
|
-
interface ProjectSettingsSchema {
|
|
119
|
-
learnedWords: string[];
|
|
120
|
-
languages: Array<{
|
|
121
|
-
code: string;
|
|
122
|
-
name: string;
|
|
123
|
-
}>;
|
|
124
|
-
compilers: Array<{
|
|
125
|
-
code: string;
|
|
126
|
-
name: string;
|
|
127
|
-
}>;
|
|
128
|
-
}
|
|
129
|
-
interface ProjectEntity {
|
|
130
|
-
_id: string;
|
|
131
|
-
name: string;
|
|
132
|
-
rootDoc_id: string;
|
|
133
|
-
rootFolder: FolderEntity[];
|
|
134
|
-
publicAccessLevel: string;
|
|
135
|
-
compiler: string;
|
|
136
|
-
spellCheckLanguage: string;
|
|
137
|
-
deletedDocs: Array<{
|
|
138
|
-
_id: string;
|
|
139
|
-
name: string;
|
|
140
|
-
deletedAt: string;
|
|
141
|
-
}>;
|
|
142
|
-
members: MemberEntity[];
|
|
143
|
-
invites: MemberEntity[];
|
|
144
|
-
owner: MemberEntity;
|
|
145
|
-
features: Record<string, unknown>;
|
|
146
|
-
settings: ProjectSettingsSchema;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
interface Identity {
|
|
150
|
-
csrfToken: string;
|
|
151
|
-
cookies: string;
|
|
152
|
-
}
|
|
153
|
-
interface NewProjectResponseSchema {
|
|
154
|
-
project_id: string;
|
|
155
|
-
owner_ref: string;
|
|
156
|
-
owner: MemberEntity;
|
|
157
|
-
}
|
|
158
|
-
interface CompileResponseSchema {
|
|
159
|
-
status: 'success' | 'failure' | 'error';
|
|
160
|
-
compileGroup: string;
|
|
161
|
-
clsiServerId?: string;
|
|
162
|
-
pdfDownloadDomain?: string;
|
|
163
|
-
outputFiles: Array<OutputFileEntity>;
|
|
164
|
-
stats: {
|
|
165
|
-
"latexmk-errors": number;
|
|
166
|
-
"pdf-size": number;
|
|
167
|
-
"latex-runs": number;
|
|
168
|
-
"latex-runs-with-errors": number;
|
|
169
|
-
"latex-runs-0": number;
|
|
170
|
-
"latex-runs-with-error-0s": number;
|
|
171
|
-
};
|
|
172
|
-
timings: {
|
|
173
|
-
"sync": number;
|
|
174
|
-
"compile": number;
|
|
175
|
-
"output": number;
|
|
176
|
-
"compileE2E": number;
|
|
177
|
-
};
|
|
178
|
-
enableHybridPdfDownload: boolean;
|
|
179
|
-
}
|
|
180
|
-
interface SyncPdfResponseSchema {
|
|
181
|
-
file: string;
|
|
182
|
-
line: number;
|
|
183
|
-
column: number;
|
|
184
|
-
}
|
|
185
|
-
interface SyncCodeResponseSchema {
|
|
186
|
-
pdf: Array<{
|
|
187
|
-
page: number;
|
|
188
|
-
h: number;
|
|
189
|
-
v: number;
|
|
190
|
-
width: number;
|
|
191
|
-
height: number;
|
|
192
|
-
}>;
|
|
193
|
-
}
|
|
194
|
-
interface SnippetItemSchema {
|
|
195
|
-
meta: string;
|
|
196
|
-
score: number;
|
|
197
|
-
caption: string;
|
|
198
|
-
snippet: string;
|
|
199
|
-
}
|
|
200
|
-
interface MisspellingItemSchema {
|
|
201
|
-
index: number;
|
|
202
|
-
suggestions: string[];
|
|
203
|
-
}
|
|
204
|
-
interface MetadataResponseScheme {
|
|
205
|
-
projectId: string;
|
|
206
|
-
projectMeta: {
|
|
207
|
-
[id: string]: {
|
|
208
|
-
labels: string[];
|
|
209
|
-
packages: {
|
|
210
|
-
[K: string]: SnippetItemSchema[];
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
interface ProjectPersist {
|
|
216
|
-
id: string;
|
|
217
|
-
userId: string;
|
|
218
|
-
name: string;
|
|
219
|
-
lastUpdated?: string;
|
|
220
|
-
lastUpdatedBy?: MemberEntity;
|
|
221
|
-
source?: 'owner' | 'collaborator' | 'readOnly';
|
|
222
|
-
accessLevel: 'owner' | 'collaborator' | 'readOnly';
|
|
223
|
-
archived?: boolean;
|
|
224
|
-
trashed?: boolean;
|
|
225
|
-
scm?: any;
|
|
226
|
-
}
|
|
227
|
-
interface ProjectTagsResponseSchema {
|
|
228
|
-
__v: number;
|
|
229
|
-
_id: string;
|
|
230
|
-
name: string;
|
|
231
|
-
user_id: string;
|
|
232
|
-
project_ids: string[];
|
|
233
|
-
}
|
|
234
|
-
interface ProjectLabelResponseSchema {
|
|
235
|
-
id: string;
|
|
236
|
-
comment: string;
|
|
237
|
-
version: string;
|
|
238
|
-
user_id: string;
|
|
239
|
-
created_at: number;
|
|
240
|
-
user_display_name?: string;
|
|
241
|
-
}
|
|
242
|
-
interface ProjectUpdateMeta {
|
|
243
|
-
users: {
|
|
244
|
-
id: string;
|
|
245
|
-
first_name: string;
|
|
246
|
-
last_name?: string;
|
|
247
|
-
email: string;
|
|
248
|
-
}[];
|
|
249
|
-
start_ts: number;
|
|
250
|
-
end_ts: number;
|
|
251
|
-
}
|
|
252
|
-
interface ProjectHistoryResponseSchema {
|
|
253
|
-
fromV: number;
|
|
254
|
-
toV: number;
|
|
255
|
-
meta: ProjectUpdateMeta;
|
|
256
|
-
labels: ProjectLabelResponseSchema[];
|
|
257
|
-
pathnames: string[];
|
|
258
|
-
project_ops: {
|
|
259
|
-
add?: {
|
|
260
|
-
pathname: string;
|
|
261
|
-
};
|
|
262
|
-
remove?: {
|
|
263
|
-
pathname: string;
|
|
264
|
-
};
|
|
265
|
-
atV: number;
|
|
266
|
-
}[];
|
|
267
|
-
}
|
|
268
|
-
interface ProjectUpdateResponseSchema {
|
|
269
|
-
updates: ProjectHistoryResponseSchema[];
|
|
270
|
-
nextBeforeTimestamp: number;
|
|
271
|
-
}
|
|
272
|
-
interface ProjectFileDiffResponseSchema {
|
|
273
|
-
diff: {
|
|
274
|
-
u?: string;
|
|
275
|
-
d?: string;
|
|
276
|
-
i?: string;
|
|
277
|
-
meta?: ProjectUpdateMeta;
|
|
278
|
-
}[];
|
|
279
|
-
}
|
|
280
|
-
interface ProjectFileTreeDiffResponseSchema {
|
|
281
|
-
diff: {
|
|
282
|
-
pathname: string;
|
|
283
|
-
newPathname?: string;
|
|
284
|
-
operation?: 'edited' | 'added' | 'removed' | 'renamed';
|
|
285
|
-
deletedAtV?: number;
|
|
286
|
-
}[];
|
|
287
|
-
}
|
|
288
|
-
interface ProjectMessageResponseSchema {
|
|
289
|
-
id: string;
|
|
290
|
-
content: string;
|
|
291
|
-
timestamp: number;
|
|
292
|
-
user_id: string;
|
|
293
|
-
user: {
|
|
294
|
-
id: string;
|
|
295
|
-
first_name: string;
|
|
296
|
-
last_name?: string;
|
|
297
|
-
email: string;
|
|
298
|
-
};
|
|
299
|
-
clientId: string;
|
|
300
|
-
}
|
|
301
|
-
interface ResponseSchema {
|
|
302
|
-
type: 'success' | 'error';
|
|
303
|
-
statusCode?: number;
|
|
304
|
-
raw?: ArrayBuffer;
|
|
1
|
+
type ReplicaState = 'starting' | 'syncing' | 'active' | 'paused' | 'stopping' | 'error';
|
|
2
|
+
interface ReplicaStatus {
|
|
3
|
+
state: ReplicaState;
|
|
305
4
|
message?: string;
|
|
306
|
-
userInfo?: {
|
|
307
|
-
userId: string;
|
|
308
|
-
userEmail: string;
|
|
309
|
-
};
|
|
310
|
-
identity?: Identity;
|
|
311
|
-
projects?: ProjectPersist[];
|
|
312
|
-
entity?: FileEntity;
|
|
313
|
-
entities?: {
|
|
314
|
-
path: string;
|
|
315
|
-
type: string;
|
|
316
|
-
}[];
|
|
317
|
-
compile?: CompileResponseSchema;
|
|
318
|
-
content?: Uint8Array;
|
|
319
|
-
syncPdf?: SyncPdfResponseSchema;
|
|
320
|
-
syncCode?: SyncCodeResponseSchema;
|
|
321
|
-
meta?: MetadataResponseScheme;
|
|
322
|
-
misspellings?: MisspellingItemSchema[];
|
|
323
|
-
tags?: ProjectTagsResponseSchema[];
|
|
324
|
-
labels?: ProjectLabelResponseSchema[];
|
|
325
|
-
updates?: ProjectUpdateResponseSchema;
|
|
326
|
-
diff?: ProjectFileDiffResponseSchema;
|
|
327
|
-
treeDiff?: ProjectFileTreeDiffResponseSchema;
|
|
328
|
-
messages?: ProjectMessageResponseSchema[];
|
|
329
|
-
settings?: ProjectSettingsSchema;
|
|
330
5
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
private historyRequestChain;
|
|
335
|
-
private lastHistoryRequestAt;
|
|
336
|
-
private isHistoryRoute;
|
|
337
|
-
private waitForHistoryRequest;
|
|
338
|
-
private retryAfterMs;
|
|
339
|
-
constructor(url: string);
|
|
340
|
-
private getCsrfToken;
|
|
341
|
-
private getUserId;
|
|
342
|
-
_initSocketV0(identity: Identity, query?: string): OverleafRealtimeSocket;
|
|
343
|
-
passportLogin(email: string, password: string): Promise<ResponseSchema>;
|
|
344
|
-
cookiesLogin(cookies: string): Promise<ResponseSchema>;
|
|
345
|
-
updateCookies(identity: Identity): Promise<Identity>;
|
|
346
|
-
setIdentity(identity: Identity): this;
|
|
347
|
-
/**
|
|
348
|
-
* Check if an HTTP error is transient (worth retrying).
|
|
349
|
-
* Retries on: 5xx server errors, network errors (fetch failures), and 429 rate limiting.
|
|
350
|
-
*/
|
|
351
|
-
private isTransientError;
|
|
352
|
-
protected request(type: 'GET' | 'POST' | 'PUT' | 'DELETE', route: string, body?: FormData | object, callback?: (res?: string) => object | undefined, extraHeaders?: object): Promise<ResponseSchema>;
|
|
353
|
-
protected download(route: string): Promise<Buffer<ArrayBuffer>>;
|
|
354
|
-
logout(identity: Identity): Promise<ResponseSchema>;
|
|
355
|
-
userProjectsJson(identity: Identity): Promise<ResponseSchema>;
|
|
356
|
-
getProjectsJson(identity: Identity): Promise<ResponseSchema>;
|
|
357
|
-
projectEntitiesJson(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
358
|
-
newProject(identity: Identity, projectName: string, template: 'none' | 'example'): Promise<ResponseSchema>;
|
|
359
|
-
cloneProject(identity: Identity, projectId: string, projectName: string): Promise<ResponseSchema>;
|
|
360
|
-
renameProject(identity: Identity, projectId: string, newProjectName: string): Promise<ResponseSchema>;
|
|
361
|
-
deleteProject(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
362
|
-
archiveProject(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
363
|
-
unarchiveProject(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
364
|
-
trashProject(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
365
|
-
untrashProject(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
366
|
-
getFile(identity: Identity, projectId: string, fileId: string): Promise<{
|
|
367
|
-
type: string;
|
|
368
|
-
content: Uint8Array<ArrayBuffer>;
|
|
369
|
-
}>;
|
|
370
|
-
addDoc(identity: Identity, projectId: string, parentFolderId: string, filename: string): Promise<ResponseSchema>;
|
|
371
|
-
uploadFile(identity: Identity, projectId: string, parentFolderId: string, filename: string, fileContent: Uint8Array): Promise<ResponseSchema>;
|
|
372
|
-
uploadProject(identity: Identity, filename: string, fileContent: Uint8Array): Promise<ResponseSchema>;
|
|
373
|
-
addFolder(identity: Identity, projectId: string, folderName: string, parentFolderId: string): Promise<ResponseSchema>;
|
|
374
|
-
deleteEntity(identity: Identity, projectId: string, fileType: FileType, fileId: string): Promise<ResponseSchema>;
|
|
375
|
-
deleteAuxFiles(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
376
|
-
renameEntity(identity: Identity, projectId: string, entityType: string, entityId: string, name: string): Promise<ResponseSchema>;
|
|
377
|
-
moveEntity(identity: Identity, projectId: string, entityType: string, entityId: string, newParentFolderId: string): Promise<ResponseSchema>;
|
|
378
|
-
compile(identity: Identity, projectId: string, rootResourcePath: string | null, draft?: boolean, stopOnFirstError?: boolean): Promise<ResponseSchema>;
|
|
379
|
-
stopCompile(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
380
|
-
indexAll(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
381
|
-
getMetadata(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
382
|
-
proxyRequestToSpellingApi(identity: Identity, language: string, userId: string, words: string[]): Promise<ResponseSchema>;
|
|
383
|
-
spellingControllerLearn(identity: Identity, userId: string, word: string): Promise<ResponseSchema>;
|
|
384
|
-
spellingControllerUnlearn(identity: Identity, word: string): Promise<ResponseSchema>;
|
|
385
|
-
getProjectSettings(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
386
|
-
updateProjectSettings(identity: Identity, projectId: string, setting: any): Promise<ResponseSchema>;
|
|
387
|
-
getFileFromClsi(identity: Identity, url: string, compileGroup: string, clsiServerId?: string, pdfDownloadDomain?: string): Promise<{
|
|
388
|
-
type: string;
|
|
389
|
-
content: Uint8Array<ArrayBuffer>;
|
|
390
|
-
}>;
|
|
391
|
-
/** Download from an absolute URL, optionally including web frontend cookies. */
|
|
392
|
-
private _downloadAbsolute;
|
|
393
|
-
proxySyncPdf(identity: Identity, projectId: string, page: number, h: number, v: number, buildId: string): Promise<ResponseSchema>;
|
|
394
|
-
proxySyncCode(identity: Identity, projectId: string, file: string, line: number, column: number, buildId: string): Promise<ResponseSchema>;
|
|
395
|
-
getAllTags(identity: Identity): Promise<ResponseSchema>;
|
|
396
|
-
createTag(identity: Identity, name: string): Promise<ResponseSchema>;
|
|
397
|
-
renameTag(identity: Identity, tagId: string, name: string): Promise<ResponseSchema>;
|
|
398
|
-
deleteTag(identity: Identity, tagId: string): Promise<ResponseSchema>;
|
|
399
|
-
addProjectToTag(identity: Identity, tagId: string, projectId: string): Promise<ResponseSchema>;
|
|
400
|
-
removeProjectFromTag(identity: Identity, tagId: string, projectId: string): Promise<ResponseSchema>;
|
|
401
|
-
proxyToHistoryApiAndGetUpdates(identity: Identity, projectId: string, before?: number): Promise<ResponseSchema>;
|
|
402
|
-
proxyToHistoryApiAndGetFileDiff(identity: Identity, projectId: string, pathname: string, from: number, to: number): Promise<ResponseSchema>;
|
|
403
|
-
proxyToHistoryApiAndGetFileTreeDiff(identity: Identity, projectId: string, from: number, to: number): Promise<ResponseSchema>;
|
|
404
|
-
downloadZipOfVersion(identity: Identity, projectId: string, version: number): Promise<{
|
|
405
|
-
type: string;
|
|
406
|
-
content: Uint8Array<ArrayBuffer>;
|
|
407
|
-
}>;
|
|
408
|
-
getLabels(identity: Identity, projectId: string): Promise<ResponseSchema>;
|
|
409
|
-
createLabel(identity: Identity, projectId: string, comment: string, version: number): Promise<ResponseSchema>;
|
|
410
|
-
deleteLabel(identity: Identity, projectId: string, labelId: string): Promise<ResponseSchema>;
|
|
411
|
-
getMessages(identity: Identity, projectId: string, limit?: number): Promise<ResponseSchema>;
|
|
412
|
-
sendMessage(identity: Identity, projectId: string, client_id: string, content: string): Promise<ResponseSchema>;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
declare class ExtendedBaseAPI extends BaseAPI {
|
|
416
|
-
refreshLinkedFile(identity: Identity, project_id: string, file_id: string): Promise<ResponseSchema>;
|
|
417
|
-
createLinkedFile(identity: Identity, project_id: string, parent_folder_id: string, name: string, provider: string, data: any): Promise<ResponseSchema>;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
interface UpdateUserSchema {
|
|
421
|
-
id: string;
|
|
422
|
-
user_id: string;
|
|
423
|
-
name: string;
|
|
424
|
-
email: string;
|
|
425
|
-
doc_id: string;
|
|
426
|
-
row: number;
|
|
427
|
-
column: number;
|
|
428
|
-
last_updated_at?: number;
|
|
429
|
-
}
|
|
430
|
-
interface OnlineUserSchema {
|
|
431
|
-
client_age: number;
|
|
432
|
-
client_id: string;
|
|
433
|
-
connected: boolean;
|
|
434
|
-
cursorData?: {
|
|
435
|
-
column: number;
|
|
436
|
-
doc_id: string;
|
|
437
|
-
row: number;
|
|
438
|
-
};
|
|
439
|
-
email: string;
|
|
440
|
-
first_name: string;
|
|
441
|
-
last_name?: string;
|
|
442
|
-
last_updated_at: string;
|
|
443
|
-
user_id: string;
|
|
444
|
-
}
|
|
445
|
-
interface UpdateSchema {
|
|
446
|
-
doc: string;
|
|
447
|
-
op?: {
|
|
448
|
-
p: number;
|
|
449
|
-
i?: string;
|
|
450
|
-
d?: string;
|
|
451
|
-
u?: boolean;
|
|
452
|
-
}[];
|
|
453
|
-
v: number;
|
|
454
|
-
lastV?: number;
|
|
455
|
-
hash?: string;
|
|
456
|
-
meta?: {
|
|
457
|
-
source: string;
|
|
458
|
-
ts: number;
|
|
459
|
-
user_id: string;
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
interface EventsHandler {
|
|
463
|
-
onFileCreated?: (parentFolderId: string, type: FileType, entity: FileEntity) => void;
|
|
464
|
-
onFileRenamed?: (entityId: string, newName: string) => void;
|
|
465
|
-
onFileRemoved?: (entityId: string) => void;
|
|
466
|
-
onFileMoved?: (entityId: string, newParentFolderId: string) => void;
|
|
467
|
-
onFileChanged?: (update: UpdateSchema) => void;
|
|
468
|
-
onDisconnected?: () => void;
|
|
469
|
-
onConnectionAccepted?: (publicId: string) => void;
|
|
470
|
-
onClientUpdated?: (user: UpdateUserSchema) => void;
|
|
471
|
-
onClientDisconnected?: (id: string) => void;
|
|
472
|
-
onReceivedMessage?: (message: ProjectMessageResponseSchema) => void;
|
|
473
|
-
onSpellCheckLanguageUpdated?: (language: string) => void;
|
|
474
|
-
onCompilerUpdated?: (compiler: string) => void;
|
|
475
|
-
onRootDocUpdated?: (rootDocId: string) => void;
|
|
476
|
-
}
|
|
477
|
-
type ConnectionScheme = 'Alt' | 'realtime';
|
|
478
|
-
type AlternativeSocketFactory = (url: string, api: BaseAPI, identity: Identity, projectId: string, record: Promise<ProjectEntity>) => any;
|
|
479
|
-
declare class SocketIOAPI {
|
|
480
|
-
private url;
|
|
481
|
-
private readonly api;
|
|
482
|
-
private readonly identity;
|
|
483
|
-
private readonly projectId;
|
|
484
|
-
private static alternativeSocketFactory?;
|
|
485
|
-
private scheme;
|
|
486
|
-
private record?;
|
|
487
|
-
private _handlers;
|
|
488
|
-
private connectedPublicId?;
|
|
489
|
-
private socket?;
|
|
490
|
-
private emit;
|
|
491
|
-
/** Track the scheme used when the socket was last initialized */
|
|
492
|
-
private _socketInitScheme?;
|
|
493
|
-
constructor(url: string, api: BaseAPI, identity: Identity, projectId: string);
|
|
494
|
-
static setAlternativeSocketFactory(factory: AlternativeSocketFactory): void;
|
|
495
|
-
init(): void;
|
|
496
|
-
/** Returns true if the socket needs re-initialization (scheme changed, or socket was never init'd) */
|
|
497
|
-
get needsReinit(): boolean;
|
|
498
|
-
get connectionScheme(): ConnectionScheme;
|
|
499
|
-
private initInternalHandlers;
|
|
500
|
-
disconnect(): void;
|
|
501
|
-
get handlers(): EventsHandler[];
|
|
502
|
-
get isUsingAlternativeConnectionScheme(): boolean;
|
|
503
|
-
toggleAlternativeConnectionScheme(url: string, updatedRecord?: ProjectEntity): void;
|
|
504
|
-
resumeEventHandlers(handlers: Array<EventsHandler>): void;
|
|
505
|
-
updateEventHandlers(handlers: EventsHandler): void;
|
|
506
|
-
get unSyncFileChanges(): number;
|
|
507
|
-
syncFileChanges(): Promise<any>;
|
|
508
|
-
/**
|
|
509
|
-
* Reference: services/web/frontend/js/ide/connection/ConnectionManager.js#L427
|
|
510
|
-
* @param {string} projectId - The project id.
|
|
511
|
-
* @returns {Promise}
|
|
512
|
-
*/
|
|
513
|
-
joinProject(project_id: string): Promise<ProjectEntity>;
|
|
514
|
-
/**
|
|
515
|
-
* Reference: services/web/frontend/js/ide/editor/Document.js#L500
|
|
516
|
-
* @param {string} docId - The document id.
|
|
517
|
-
* @returns {Promise}
|
|
518
|
-
*/
|
|
519
|
-
joinDoc(docId: string): Promise<any>;
|
|
520
|
-
/**
|
|
521
|
-
* Reference: services/web/frontend/js/ide/editor/Document.js#L591
|
|
522
|
-
* @param {string} docId - The document id.
|
|
523
|
-
* @returns {Promise}
|
|
524
|
-
*/
|
|
525
|
-
leaveDoc(docId: string): Promise<any>;
|
|
526
|
-
/**
|
|
527
|
-
* Reference: services/web/frontend/js/ide/editor/ShareJsDocs.js#L78
|
|
528
|
-
* @param {string} docId - The document id.
|
|
529
|
-
* @param {any} update - The changes.
|
|
530
|
-
* @returns {Promise}
|
|
531
|
-
*/
|
|
532
|
-
applyOtUpdate(docId: string, update: UpdateSchema): Promise<void>;
|
|
533
|
-
/**
|
|
534
|
-
* Reference: services/web/frontend/js/ide/online-users/OnlineUserManager.js#L42
|
|
535
|
-
* @returns {Promise}
|
|
536
|
-
*/
|
|
537
|
-
getConnectedUsers(): Promise<OnlineUserSchema[]>;
|
|
538
|
-
/**
|
|
539
|
-
* Reference: services/web/frontend/js/ide/online-users/OnlineUserManager.js#L150
|
|
540
|
-
* @param {string} docId - The document id.
|
|
541
|
-
* @returns {Promise}
|
|
542
|
-
*/
|
|
543
|
-
updatePosition(doc_id: string, row: number, column: number): Promise<any>;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
type LogLevel = 'info' | 'warn' | 'error';
|
|
547
|
-
type LogSink = (level: LogLevel, args: readonly unknown[]) => void;
|
|
548
|
-
declare function setLogSink(nextSink: LogSink | undefined): void;
|
|
549
|
-
declare function log(...args: unknown[]): void;
|
|
550
|
-
declare function warn(...args: unknown[]): void;
|
|
551
|
-
declare function error(...args: unknown[]): void;
|
|
552
|
-
|
|
553
|
-
interface ServerSession {
|
|
554
|
-
url: string;
|
|
555
|
-
userId: string;
|
|
556
|
-
userEmail: string;
|
|
557
|
-
identity: Identity;
|
|
558
|
-
updatedAt: string;
|
|
559
|
-
}
|
|
560
|
-
interface LeafRelayConfig {
|
|
561
|
-
version: 1;
|
|
562
|
-
servers: Record<string, ServerSession>;
|
|
563
|
-
}
|
|
564
|
-
declare function configPath(environment?: NodeJS.ProcessEnv): string;
|
|
565
|
-
declare function normalizeServerUrl(value: string): string;
|
|
566
|
-
declare function serverKey(value: string): string;
|
|
567
|
-
declare function readConfig(path?: string): Promise<LeafRelayConfig>;
|
|
568
|
-
declare function writeConfig(config: LeafRelayConfig, path?: string): Promise<void>;
|
|
569
|
-
declare function saveServerSession(session: ServerSession, path?: string): Promise<void>;
|
|
570
|
-
declare function getServerSession(server: string, environment?: NodeJS.ProcessEnv, path?: string): Promise<ServerSession | undefined>;
|
|
571
|
-
|
|
572
|
-
interface RemoteEntry {
|
|
573
|
-
path: string;
|
|
574
|
-
type: FileType;
|
|
575
|
-
entity: FileEntity;
|
|
576
|
-
parent?: FolderEntity;
|
|
577
|
-
}
|
|
578
|
-
type RemoteChange = {
|
|
579
|
-
path: string;
|
|
580
|
-
previousPath?: string;
|
|
581
|
-
};
|
|
582
|
-
declare class RemoteProject {
|
|
583
|
-
private readonly url;
|
|
584
|
-
private readonly projectId;
|
|
585
|
-
private readonly cookies;
|
|
586
|
-
private readonly api;
|
|
587
|
-
private identity;
|
|
588
|
-
private socket;
|
|
589
|
-
private project;
|
|
590
|
-
private readonly entries;
|
|
591
|
-
private readonly idToPath;
|
|
592
|
-
private changeHandler?;
|
|
593
|
-
constructor(url: string, projectId: string, cookies: string);
|
|
594
|
-
connect(): Promise<void>;
|
|
595
|
-
disconnect(): void;
|
|
596
|
-
onChange(handler: (change: RemoteChange) => void): void;
|
|
597
|
-
listEntries(): RemoteEntry[];
|
|
598
|
-
entry(path: string): RemoteEntry | undefined;
|
|
599
|
-
read(path: string): Promise<Uint8Array>;
|
|
600
|
-
mkdir(path: string): Promise<void>;
|
|
601
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
602
|
-
remove(path: string): Promise<void>;
|
|
603
|
-
getCurrentVersion(): Promise<number>;
|
|
604
|
-
getFileTreeDiff(from: number, to: number): Promise<ProjectFileTreeDiffResponseSchema | undefined>;
|
|
605
|
-
private writeDocument;
|
|
606
|
-
private ensureParent;
|
|
607
|
-
private requireEntry;
|
|
608
|
-
private reindex;
|
|
609
|
-
private indexFolder;
|
|
610
|
-
private folderById;
|
|
611
|
-
private removeFromParent;
|
|
612
|
-
private emitChange;
|
|
613
|
-
private registerEvents;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
declare const SYNC_STATE_SCHEMA_VERSION = 2;
|
|
617
|
-
interface LocalReplicaSyncState {
|
|
618
|
-
schemaVersion: number;
|
|
619
|
-
projectUri: string;
|
|
620
|
-
remoteVersion: number;
|
|
621
|
-
files: {
|
|
622
|
-
[path: string]: string;
|
|
623
|
-
};
|
|
624
|
-
textBases: {
|
|
625
|
-
[path: string]: string;
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
declare function sha256(content: Uint8Array): string;
|
|
629
|
-
declare function parseSyncState(serialized: string, projectUri: string): LocalReplicaSyncState | undefined;
|
|
630
|
-
declare function createSyncState(projectUri: string, remoteVersion: number): LocalReplicaSyncState;
|
|
631
|
-
declare function updateSyncCheckpoint(state: LocalReplicaSyncState, path: string, content: Uint8Array): void;
|
|
632
|
-
declare function removeSyncCheckpoint(state: LocalReplicaSyncState, path: string): void;
|
|
633
|
-
declare function readTextBase(state: LocalReplicaSyncState | undefined, path: string): Uint8Array | undefined;
|
|
634
|
-
|
|
635
|
-
interface ReplicaFileSystem {
|
|
636
|
-
listFiles(): Promise<string[]>;
|
|
637
|
-
read(path: string): Promise<Uint8Array | undefined>;
|
|
638
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
639
|
-
remove(path: string): Promise<void>;
|
|
640
|
-
watch(onChange: (path: string) => void): Promise<() => Promise<void>>;
|
|
641
|
-
}
|
|
642
|
-
interface RemoteReplica {
|
|
643
|
-
listEntries(): RemoteEntry[];
|
|
644
|
-
entry(path: string): RemoteEntry | undefined;
|
|
645
|
-
read(path: string): Promise<Uint8Array>;
|
|
646
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
647
|
-
remove(path: string): Promise<void>;
|
|
648
|
-
getCurrentVersion(): Promise<number>;
|
|
649
|
-
getFileTreeDiff(from: number, to: number): Promise<ProjectFileTreeDiffResponseSchema | undefined>;
|
|
650
|
-
onChange(handler: (change: {
|
|
651
|
-
path: string;
|
|
652
|
-
previousPath?: string;
|
|
653
|
-
}) => void): void;
|
|
654
|
-
}
|
|
655
|
-
interface SyncStateStore {
|
|
656
|
-
load(): Promise<LocalReplicaSyncState | undefined>;
|
|
657
|
-
save(state: LocalReplicaSyncState): Promise<void>;
|
|
658
|
-
}
|
|
659
|
-
interface SyncEngineOptions {
|
|
660
|
-
projectUri: string;
|
|
661
|
-
local: ReplicaFileSystem;
|
|
662
|
-
remote: RemoteReplica;
|
|
663
|
-
stateStore: SyncStateStore;
|
|
664
|
-
ignore(path: string): boolean;
|
|
665
|
-
log(message: string): void;
|
|
666
|
-
onConflict(path: string, reason: string): void;
|
|
667
|
-
}
|
|
668
|
-
declare class SyncEngine {
|
|
669
|
-
private readonly options;
|
|
670
|
-
private state?;
|
|
671
|
-
private queue;
|
|
672
|
-
private conflicts;
|
|
673
|
-
private stopLocalWatch?;
|
|
674
|
-
private eventTimers;
|
|
675
|
-
constructor(options: SyncEngineOptions);
|
|
676
|
-
start(): Promise<void>;
|
|
677
|
-
stop(): Promise<void>;
|
|
678
|
-
private startupReconcile;
|
|
679
|
-
private schedule;
|
|
680
|
-
private reconcilePath;
|
|
681
|
-
private remoteFilePaths;
|
|
682
|
-
private shouldIgnore;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
declare class NodeReplicaFileSystem implements ReplicaFileSystem {
|
|
686
|
-
private readonly root;
|
|
687
|
-
private readonly ignore;
|
|
688
|
-
private watcher?;
|
|
689
|
-
constructor(root: string, ignore: (path: string) => boolean);
|
|
690
|
-
listFiles(): Promise<string[]>;
|
|
691
|
-
read(path: string): Promise<Uint8Array | undefined>;
|
|
692
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
693
|
-
remove(path: string): Promise<void>;
|
|
694
|
-
watch(onChange: (path: string) => void): Promise<() => Promise<void>>;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
interface LocalProjectSettings {
|
|
698
|
-
uri: string;
|
|
6
|
+
interface ReplicaAttachResult {
|
|
7
|
+
replicaId: string;
|
|
8
|
+
root: string;
|
|
699
9
|
serverName: string;
|
|
700
|
-
serverUrl: string;
|
|
701
10
|
projectId: string;
|
|
702
11
|
projectName: string;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
};
|
|
12
|
+
shared: boolean;
|
|
13
|
+
status: ReplicaStatus;
|
|
14
|
+
conflicts: string[];
|
|
707
15
|
}
|
|
708
|
-
declare function readProjectSettings(directory: string): Promise<LocalProjectSettings>;
|
|
709
16
|
|
|
710
17
|
interface RunningServe {
|
|
18
|
+
readonly replica: ReplicaAttachResult;
|
|
711
19
|
stop(): Promise<void>;
|
|
712
20
|
}
|
|
713
21
|
declare function startServe(directory?: string): Promise<RunningServe>;
|
|
714
22
|
|
|
715
|
-
|
|
716
|
-
private readonly projectUri;
|
|
717
|
-
private readonly path;
|
|
718
|
-
private serialized?;
|
|
719
|
-
constructor(directory: string, projectUri: string);
|
|
720
|
-
load(): Promise<LocalReplicaSyncState | undefined>;
|
|
721
|
-
save(state: LocalReplicaSyncState): Promise<void>;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
declare const DEFAULT_IGNORE_PATTERNS: string[];
|
|
725
|
-
declare function createIgnoreMatcher(patterns: unknown): (path: string) => boolean;
|
|
726
|
-
|
|
727
|
-
interface TextMergeResult {
|
|
728
|
-
status: 'merged' | 'conflict' | 'binary';
|
|
729
|
-
content?: Uint8Array;
|
|
730
|
-
}
|
|
731
|
-
declare function encodeTextBase(content: Uint8Array): string | undefined;
|
|
732
|
-
declare function mergeText(baseContent: Uint8Array, localContent: Uint8Array, remoteContent: Uint8Array): TextMergeResult;
|
|
733
|
-
|
|
734
|
-
export { BaseAPI, type CompileResponseSchema, DEFAULT_IGNORE_PATTERNS, type DocumentEntity, type EventsHandler, ExtendedBaseAPI, type FileEntity, type FileRefEntity, FileSyncStateStore, type FileType, type FolderEntity, type FolderKey, FolderKeys, type Identity, type LeafRelayConfig, type LocalProjectSettings, type LocalReplicaSyncState, type LogLevel, type LogSink, type MemberEntity, type MetadataResponseScheme, type MisspellingItemSchema, type NewProjectResponseSchema, NodeReplicaFileSystem, type OnlineUserSchema, type OutputFileEntity, OverleafRealtimeSocket, type OverleafRealtimeSocketOptions, type ProjectEntity, type ProjectFileDiffResponseSchema, type ProjectFileTreeDiffResponseSchema, type ProjectHistoryResponseSchema, type ProjectLabelResponseSchema, type ProjectLinkedFileProvider, type ProjectMessageResponseSchema, type ProjectPersist, type ProjectSettingsSchema, type ProjectTagsResponseSchema, type ProjectUpdateMeta, type ProjectUpdateResponseSchema, type RemoteChange, type RemoteEntry, RemoteProject, type RemoteReplica, type ReplicaFileSystem, type ResponseSchema, type RunningServe, SYNC_STATE_SCHEMA_VERSION, type ServerSession, type SnippetItemSchema, SocketIOAPI, type SyncCodeResponseSchema, SyncEngine, type SyncEngineOptions, type SyncPdfResponseSchema, type SyncStateStore, type TextMergeResult, type UpdateSchema, type UpdateUserSchema, type UrlLinkedFileProvider, configPath, createIgnoreMatcher, createSyncState, encodeTextBase, error, getServerSession, log, mergeText, normalizeServerUrl, overleafSocketProtocol, parseSyncState, readConfig, readProjectSettings, readTextBase, removeSyncCheckpoint, saveServerSession, serverKey, setLogSink, sha256, startServe, updateSyncCheckpoint, warn, writeConfig };
|
|
23
|
+
export { type RunningServe, startServe };
|