@hesprs/sync-engine-sdk 3.0.6 → 3.1.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/dist/dev.spec.d.ts +1 -1
- package/dist/index-LOl_cerr.spec.d.ts +558 -0
- package/dist/index.js +1 -1
- package/dist/index.spec.d.ts +795 -2
- package/dist/plugin/src/components/MigrationModal.js +1 -1
- package/dist/plugin/src/settings/utils.js +1 -0
- package/dist/transform.js +1 -1
- package/package.json +5 -5
- package/dist/index-BJDjAUwk.spec.d.ts +0 -1333
package/dist/dev.spec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as RootFs, G as Fs, P as TaskNames, ct as RecordStat, dt as StatsMap, et as WrappedFs, h as RequestParam, it as FolderStat, lt as RecordStatsMap, m as Request, nt as Binary, rt as FileStat, ut as Stat, v as Decider } from "./index-LOl_cerr.spec.js";
|
|
2
2
|
//#region src/sdk/debug-wrapper.d.ts
|
|
3
3
|
declare function debugWrapper(original: Fs, log: (content: string) => void): WrappedFs;
|
|
4
4
|
//#endregion
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { App, ListedFiles, RequestUrlParam, Stat } from "obsidian";
|
|
2
|
+
//#region test/e2e-utils.d.ts
|
|
3
|
+
type General = any;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
7
|
+
type TogglableValue<T = number> = {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
value: T;
|
|
10
|
+
};
|
|
11
|
+
type FileStat = {
|
|
12
|
+
isDir: false;
|
|
13
|
+
key: string;
|
|
14
|
+
mtime: number;
|
|
15
|
+
size: number;
|
|
16
|
+
uid: string;
|
|
17
|
+
};
|
|
18
|
+
type FolderStat = {
|
|
19
|
+
isDir: true;
|
|
20
|
+
key: string;
|
|
21
|
+
};
|
|
22
|
+
type Stat$1 = FileStat | FolderStat;
|
|
23
|
+
type RecordStat = {
|
|
24
|
+
isDir: false;
|
|
25
|
+
local: string;
|
|
26
|
+
remote: string;
|
|
27
|
+
} | {
|
|
28
|
+
isDir: true;
|
|
29
|
+
};
|
|
30
|
+
type StatsMap = Map<string, Stat$1>;
|
|
31
|
+
type RecordStatsMap = Map<string, RecordStat>;
|
|
32
|
+
type GlobMatchRule = {
|
|
33
|
+
expr: string;
|
|
34
|
+
caseSensitive: boolean;
|
|
35
|
+
};
|
|
36
|
+
type Progress<T = string> = {
|
|
37
|
+
total: number;
|
|
38
|
+
completed: number;
|
|
39
|
+
current?: T;
|
|
40
|
+
};
|
|
41
|
+
type Binary = Uint8Array<ArrayBuffer>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/fs/interface.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* All keys use unified format:
|
|
46
|
+
* - root: `/`
|
|
47
|
+
* - file: `note.md`, `folder/note.md`
|
|
48
|
+
* - folder: `folder/`, `folder/nested/`
|
|
49
|
+
*/
|
|
50
|
+
type RootFs = {
|
|
51
|
+
getUid(): string;
|
|
52
|
+
read(key: string, stat: FileStat): MaybePromise<Binary>;
|
|
53
|
+
readStream(key: string, stat: FileStat): MaybePromise<ReadableStream<Binary>>;
|
|
54
|
+
write(key: string, value: Binary, stat: FileStat): MaybePromise<string>;
|
|
55
|
+
writeStream(key: string, value: ReadableStream<Binary>, stat: FileStat): MaybePromise<string>;
|
|
56
|
+
delete(key: string): MaybePromise<void>;
|
|
57
|
+
move(oldKey: string, newKey: string): MaybePromise<void>;
|
|
58
|
+
mkdir(key: string, recursive?: boolean): MaybePromise<void>;
|
|
59
|
+
stat(key: string): MaybePromise<Stat$1>;
|
|
60
|
+
exists(key: string): MaybePromise<boolean>;
|
|
61
|
+
list(key: string, reporter: ListReporter): MaybePromise<Array<Stat$1>>;
|
|
62
|
+
};
|
|
63
|
+
type ListReporter = (progress: Required<Progress>) => MaybePromise<'include' | 'exclude' | 'advance'>;
|
|
64
|
+
type WrappedFs = RootFs & {
|
|
65
|
+
original: Fs;
|
|
66
|
+
};
|
|
67
|
+
type Fs = WrappedFs | RootFs;
|
|
68
|
+
type WriteAtom = {
|
|
69
|
+
type: 'write';
|
|
70
|
+
key: string;
|
|
71
|
+
execute: () => MaybePromise<string>;
|
|
72
|
+
resolve: (uid: string) => void;
|
|
73
|
+
reject: (err: Error) => void;
|
|
74
|
+
};
|
|
75
|
+
type DeleteAtom = {
|
|
76
|
+
type: 'delete';
|
|
77
|
+
key: string;
|
|
78
|
+
execute: () => MaybePromise<void>;
|
|
79
|
+
resolve: () => void;
|
|
80
|
+
reject: (err: Error) => void;
|
|
81
|
+
};
|
|
82
|
+
type MoveAtom = {
|
|
83
|
+
type: 'move';
|
|
84
|
+
oldKey: string;
|
|
85
|
+
newKey: string;
|
|
86
|
+
execute: () => MaybePromise<void>;
|
|
87
|
+
resolve: () => void;
|
|
88
|
+
reject: (err: Error) => void;
|
|
89
|
+
};
|
|
90
|
+
type MkdirAtom = {
|
|
91
|
+
type: 'mkdir';
|
|
92
|
+
key: string;
|
|
93
|
+
execute: () => MaybePromise<void>;
|
|
94
|
+
resolve: () => void;
|
|
95
|
+
reject: (err: Error) => void;
|
|
96
|
+
};
|
|
97
|
+
type InputAtom = WriteAtom | DeleteAtom | MoveAtom | MkdirAtom;
|
|
98
|
+
type CustomAtom = {
|
|
99
|
+
type: 'custom';
|
|
100
|
+
execute: () => MaybePromise<void>;
|
|
101
|
+
};
|
|
102
|
+
type OutputAtom = InputAtom | CustomAtom;
|
|
103
|
+
type OptimizerInput = {
|
|
104
|
+
atoms: Array<InputAtom>;
|
|
105
|
+
fs: Fs;
|
|
106
|
+
executeAtom: (atom: OutputAtom) => Promise<void | string>;
|
|
107
|
+
};
|
|
108
|
+
type OptimizerOutput = Array<OutputAtom>;
|
|
109
|
+
type BatchOptimizer = (input: OptimizerInput) => OptimizerOutput;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../../node_modules/.bun/uni-kv@..+..+uni-kv.tgz/node_modules/uni-kv/dist/interface.d.ts
|
|
112
|
+
//#region src/interface.d.ts
|
|
113
|
+
type Database<D extends Record<string, unknown>, M extends Record<string, unknown>, F extends boolean> = {
|
|
114
|
+
getStore<K extends keyof D>(name: K): Store<D[K], F>;
|
|
115
|
+
getStoreNames(): IsPromise<Array<string>, F>;
|
|
116
|
+
deleteStore(name: string): IsPromise<void, F>;
|
|
117
|
+
clearStores(): IsPromise<void, F>;
|
|
118
|
+
getMeta<T extends keyof M>(key: T): IsPromise<M[T] | undefined, F>;
|
|
119
|
+
setMeta<T extends keyof M>(key: T, value: M[T]): IsPromise<void, F>;
|
|
120
|
+
dispose(): IsPromise<void, F>;
|
|
121
|
+
};
|
|
122
|
+
type Store<T, F extends boolean> = {
|
|
123
|
+
get(key: string): IsPromise<T | undefined, F>;
|
|
124
|
+
set(key: string, value: T): IsPromise<void, F>;
|
|
125
|
+
delete(key: string): IsPromise<void, F>;
|
|
126
|
+
clear(): IsPromise<void, F>;
|
|
127
|
+
keys(): IsPromise<Array<string>, F>;
|
|
128
|
+
values(): IsPromise<Array<T>, F>;
|
|
129
|
+
entries(): IsPromise<Array<[string, T]>, F>;
|
|
130
|
+
batch(operations: Array<StoreOperations<T>>): IsPromise<Array<GetResult<T>>, F>;
|
|
131
|
+
};
|
|
132
|
+
type StoreSync<T = unknown> = Store<T, false>;
|
|
133
|
+
type StoreAsync<T = unknown> = Store<T, true>;
|
|
134
|
+
type DatabaseSync<D extends Record<string, unknown> = Record<string, unknown>, M extends Record<string, unknown> = {}> = Database<D, M, false>;
|
|
135
|
+
type DatabaseAsync<D extends Record<string, unknown> = Record<string, unknown>, M extends Record<string, unknown> = {}> = Database<D, M, true>;
|
|
136
|
+
type GetOperation = {
|
|
137
|
+
type: 'get';
|
|
138
|
+
key: string;
|
|
139
|
+
};
|
|
140
|
+
type GetResult<T> = {
|
|
141
|
+
key: string;
|
|
142
|
+
value: T | undefined;
|
|
143
|
+
};
|
|
144
|
+
type SetOperation<T> = {
|
|
145
|
+
type: 'set';
|
|
146
|
+
key: string;
|
|
147
|
+
value: T;
|
|
148
|
+
};
|
|
149
|
+
type DeleteOperation = {
|
|
150
|
+
type: 'delete';
|
|
151
|
+
key: string;
|
|
152
|
+
};
|
|
153
|
+
type StoreOperations<T> = GetOperation | SetOperation<T> | DeleteOperation;
|
|
154
|
+
type IsPromise<T, F extends boolean> = F extends true ? Promise<T> : T;
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/modules/Storage.d.ts
|
|
157
|
+
type RecordStore = StoreAsync<RecordStat>;
|
|
158
|
+
declare class Storage {
|
|
159
|
+
private readonly ctx;
|
|
160
|
+
private readonly memoryDB;
|
|
161
|
+
private readonly indexedDB;
|
|
162
|
+
constructor(ctx: {
|
|
163
|
+
getNamespace: () => string;
|
|
164
|
+
});
|
|
165
|
+
private readonly getRecordStore;
|
|
166
|
+
private readonly deleteRecordStore;
|
|
167
|
+
private readonly clearRecordStores;
|
|
168
|
+
private readonly recordStoreExists;
|
|
169
|
+
readonly root: {
|
|
170
|
+
clearRecordStores: () => Promise<void>;
|
|
171
|
+
deleteRecordStore: (namespace?: string) => MaybePromise<void>;
|
|
172
|
+
getRecordStore: (namespace?: string) => {
|
|
173
|
+
get(key: string): Promise<RecordStat | undefined>;
|
|
174
|
+
set(key: string, value: RecordStat): Promise<void>;
|
|
175
|
+
delete(key: string): Promise<void>;
|
|
176
|
+
clear(): Promise<void>;
|
|
177
|
+
keys(): Promise<string[]>;
|
|
178
|
+
values(): Promise<RecordStat[]>;
|
|
179
|
+
entries(): Promise<[string, RecordStat][]>;
|
|
180
|
+
batch(operations: StoreOperations<RecordStat>[]): Promise<GetResult<RecordStat>[]>;
|
|
181
|
+
};
|
|
182
|
+
indexedDB: DatabaseAsync<General, General>;
|
|
183
|
+
memoryDB: {
|
|
184
|
+
getStore<K extends string | number | symbol>(name: K): {
|
|
185
|
+
get(key: string): any;
|
|
186
|
+
set(key: string, value: any): void;
|
|
187
|
+
delete(key: string): void;
|
|
188
|
+
clear(): void;
|
|
189
|
+
keys(): string[];
|
|
190
|
+
values(): any[];
|
|
191
|
+
entries(): [string, any][];
|
|
192
|
+
batch(operations: StoreOperations<any>[]): GetResult<any>[];
|
|
193
|
+
};
|
|
194
|
+
getStoreNames(): string[];
|
|
195
|
+
deleteStore(name: string): void;
|
|
196
|
+
clearStores(): void;
|
|
197
|
+
getMeta<T extends string | number | symbol>(key: T): any;
|
|
198
|
+
setMeta<T extends string | number | symbol>(key: T, value: any): void;
|
|
199
|
+
dispose(): void;
|
|
200
|
+
};
|
|
201
|
+
recordStoreExists: (namespace?: string) => MaybePromise<boolean>;
|
|
202
|
+
};
|
|
203
|
+
readonly dispose: () => void;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/sync/tasks/interface.d.ts
|
|
207
|
+
type BaseTaskOptions = {
|
|
208
|
+
localFs: Fs;
|
|
209
|
+
remoteFs: Fs;
|
|
210
|
+
record: RecordStore;
|
|
211
|
+
};
|
|
212
|
+
type TaskNames = 'addRecord' | 'removeRecord' | 'createLocalDir' | 'createRemoteDir' | 'download' | 'resolveConflict' | 'removeLocal' | 'removeRemote' | 'upload' | 'moveLocal' | 'moveRemote';
|
|
213
|
+
type ConflictResolverPayload = {
|
|
214
|
+
local: FileStat;
|
|
215
|
+
remote: FileStat;
|
|
216
|
+
key: string;
|
|
217
|
+
localFs: Fs;
|
|
218
|
+
remoteFs: Fs;
|
|
219
|
+
record: RecordStore;
|
|
220
|
+
};
|
|
221
|
+
type ConflictResolver = (payload: ConflictResolverPayload) => MaybePromise<void>;
|
|
222
|
+
declare abstract class BaseTask<T extends TaskOptions = TaskOptions> {
|
|
223
|
+
readonly options: BaseTaskOptions & T;
|
|
224
|
+
constructor(options: BaseTaskOptions & T);
|
|
225
|
+
protected readonly remoteFs: Fs;
|
|
226
|
+
protected readonly localFs: Fs;
|
|
227
|
+
protected readonly record: RecordStore;
|
|
228
|
+
name: TaskNames;
|
|
229
|
+
prettyName: string;
|
|
230
|
+
readonly key: string;
|
|
231
|
+
readonly local: (BaseTaskOptions & T)['local'];
|
|
232
|
+
readonly remote: (BaseTaskOptions & T)['remote'];
|
|
233
|
+
abstract exec(): MaybePromise<void>;
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/sync/tasks/AddRecord.d.ts
|
|
237
|
+
declare class AddRecord extends BaseTask<OptionsWithBothStats> {
|
|
238
|
+
exec(): Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/sync/tasks/CreateRemoteDir.d.ts
|
|
242
|
+
declare class CreateRemoteDir extends BaseTask<OptionsWithLocalFolderStat> {
|
|
243
|
+
exec(): Promise<void>;
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/sync/tasks/Download.d.ts
|
|
247
|
+
declare class Download extends BaseTask<OptionsWithRemoteFileStat> {
|
|
248
|
+
exec(): Promise<void>;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/sync/tasks/MoveLocal.d.ts
|
|
252
|
+
declare class MoveLocal extends BaseTask<OptionsWithRemoteStatAndOldKey> {
|
|
253
|
+
exec(): Promise<void>;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/sync/tasks/MoveRemote.d.ts
|
|
257
|
+
declare class MoveRemote extends BaseTask<OptionsWithLocalStatAndOldKey> {
|
|
258
|
+
exec(): Promise<void>;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/sync/tasks/RemoveLocal.d.ts
|
|
262
|
+
declare class RemoveLocal extends BaseTask<OptionsWithLocalStat> {
|
|
263
|
+
exec(): Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/sync/tasks/RemoveRecord.d.ts
|
|
267
|
+
declare class RemoveRecord extends BaseTask {
|
|
268
|
+
exec(): Promise<void>;
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/sync/tasks/RemoveRemote.d.ts
|
|
272
|
+
declare class RemoveRemote extends BaseTask<OptionsWithRemoteStat> {
|
|
273
|
+
exec(): Promise<void>;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/sync/tasks/ResolveConflict.d.ts
|
|
277
|
+
declare class ResolveConflict extends BaseTask<OptionsWithBothFileStats & {
|
|
278
|
+
resolver: ConflictResolver;
|
|
279
|
+
}> {
|
|
280
|
+
exec: () => MaybePromise<void>;
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/sync/tasks/Upload.d.ts
|
|
284
|
+
declare class Upload extends BaseTask<OptionsWithLocalFileStat> {
|
|
285
|
+
exec(): Promise<void>;
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/sync/decision/interface.d.ts
|
|
289
|
+
type TaskOptions = {
|
|
290
|
+
key: string;
|
|
291
|
+
remote?: Stat$1;
|
|
292
|
+
local?: Stat$1;
|
|
293
|
+
};
|
|
294
|
+
type OptionsWithRemoteFileStat = {
|
|
295
|
+
remote: FileStat;
|
|
296
|
+
} & TaskOptions;
|
|
297
|
+
type OptionsWithLocalFileStat = {
|
|
298
|
+
local: FileStat;
|
|
299
|
+
} & TaskOptions;
|
|
300
|
+
type OptionsWithRemoteFolderStat = {
|
|
301
|
+
remote: FolderStat;
|
|
302
|
+
} & TaskOptions;
|
|
303
|
+
type OptionsWithLocalFolderStat = {
|
|
304
|
+
local: FolderStat;
|
|
305
|
+
} & TaskOptions;
|
|
306
|
+
type OptionsWithLocalStat = {
|
|
307
|
+
local: Stat$1;
|
|
308
|
+
} & TaskOptions;
|
|
309
|
+
type OptionsWithRemoteStat = {
|
|
310
|
+
remote: Stat$1;
|
|
311
|
+
} & TaskOptions;
|
|
312
|
+
type OptionsWithBothStats = {
|
|
313
|
+
local: Stat$1;
|
|
314
|
+
remote: Stat$1;
|
|
315
|
+
} & TaskOptions;
|
|
316
|
+
type OptionsWithBothFileStats = {
|
|
317
|
+
local: FileStat;
|
|
318
|
+
remote: FileStat;
|
|
319
|
+
} & TaskOptions;
|
|
320
|
+
type OptionsWithLocalStatAndOldKey = {
|
|
321
|
+
local: Stat$1;
|
|
322
|
+
oldKey: string;
|
|
323
|
+
} & TaskOptions;
|
|
324
|
+
type OptionsWithRemoteStatAndOldKey = {
|
|
325
|
+
remote: Stat$1;
|
|
326
|
+
oldKey: string;
|
|
327
|
+
} & TaskOptions;
|
|
328
|
+
type TaskOptionsMap = {
|
|
329
|
+
download: OptionsWithRemoteFileStat;
|
|
330
|
+
upload: OptionsWithLocalFileStat;
|
|
331
|
+
resolveConflict: OptionsWithBothFileStats;
|
|
332
|
+
removeLocal: OptionsWithLocalStat;
|
|
333
|
+
removeRemote: OptionsWithRemoteStat;
|
|
334
|
+
createLocalDir: OptionsWithRemoteFolderStat;
|
|
335
|
+
createRemoteDir: OptionsWithLocalFolderStat;
|
|
336
|
+
removeRecord: TaskOptions;
|
|
337
|
+
addRecord: OptionsWithBothStats;
|
|
338
|
+
moveLocal: OptionsWithRemoteStatAndOldKey;
|
|
339
|
+
moveRemote: OptionsWithLocalStatAndOldKey;
|
|
340
|
+
};
|
|
341
|
+
declare const taskMap: {
|
|
342
|
+
readonly addRecord: typeof AddRecord;
|
|
343
|
+
readonly createLocalDir: typeof CreateLocalDir;
|
|
344
|
+
readonly createRemoteDir: typeof CreateRemoteDir;
|
|
345
|
+
readonly download: typeof Download;
|
|
346
|
+
readonly moveLocal: typeof MoveLocal;
|
|
347
|
+
readonly moveRemote: typeof MoveRemote;
|
|
348
|
+
readonly removeLocal: typeof RemoveLocal;
|
|
349
|
+
readonly removeRecord: typeof RemoveRecord;
|
|
350
|
+
readonly removeRemote: typeof RemoveRemote;
|
|
351
|
+
readonly resolveConflict: typeof ResolveConflict;
|
|
352
|
+
readonly upload: typeof Upload;
|
|
353
|
+
};
|
|
354
|
+
type TaskFactory = <N extends TaskNames>(name: N, options: TaskOptionsMap[N]) => InstanceType<(typeof taskMap)[N]>;
|
|
355
|
+
type Decider = (input: DeciderInput) => Array<BaseTask>;
|
|
356
|
+
type DeciderInput = {
|
|
357
|
+
localStats: StatsMap;
|
|
358
|
+
remoteStats: StatsMap;
|
|
359
|
+
records: RecordStatsMap;
|
|
360
|
+
taskFactory: TaskFactory;
|
|
361
|
+
logger: (log: string) => void;
|
|
362
|
+
};
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/sync/tasks/CreateLocalDir.d.ts
|
|
365
|
+
declare class CreateLocalDir extends BaseTask<OptionsWithRemoteFolderStat> {
|
|
366
|
+
exec(): Promise<void>;
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/modules/Registrar.d.ts
|
|
370
|
+
type RejectableWrapper<T> = (value: T) => T | undefined;
|
|
371
|
+
type OrderedWrapperEntry<T> = {
|
|
372
|
+
priority: number;
|
|
373
|
+
apply: RejectableWrapper<T>;
|
|
374
|
+
};
|
|
375
|
+
type RemoteRequestMiddlewareEntry = OrderedWrapperEntry<Request>;
|
|
376
|
+
type LocalRequestMiddlewareEntry = OrderedWrapperEntry<VaultRequest>;
|
|
377
|
+
type FsWrapperEntry = OrderedWrapperEntry<Fs>;
|
|
378
|
+
type CheckConnectionResult = {
|
|
379
|
+
success: true;
|
|
380
|
+
} | {
|
|
381
|
+
success: false;
|
|
382
|
+
reason: string;
|
|
383
|
+
};
|
|
384
|
+
type RemoteFsEntry = {
|
|
385
|
+
instantiate: (request: Request) => RootFs;
|
|
386
|
+
prettyName: () => string;
|
|
387
|
+
checkConnection: (request: Request) => MaybePromise<CheckConnectionResult>;
|
|
388
|
+
};
|
|
389
|
+
type DeciderEntry = {
|
|
390
|
+
decider: Decider;
|
|
391
|
+
prettyName: () => string;
|
|
392
|
+
};
|
|
393
|
+
type ConflictResolverEntry = {
|
|
394
|
+
prettyName: () => string;
|
|
395
|
+
resolver: ConflictResolver;
|
|
396
|
+
};
|
|
397
|
+
type GeneralFn = (...args: ReadonlyArray<General>) => unknown;
|
|
398
|
+
type RejectableApply<F extends GeneralFn> = (...input: Parameters<F>) => ReturnType<F> | undefined;
|
|
399
|
+
type OrderedApplyEntry<F extends GeneralFn> = {
|
|
400
|
+
apply: RejectableApply<F>;
|
|
401
|
+
priority: number;
|
|
402
|
+
};
|
|
403
|
+
type RemoteLister = (info: Infras & {
|
|
404
|
+
trigger: string;
|
|
405
|
+
reporter: ListReporter;
|
|
406
|
+
}) => MaybePromise<Array<Stat$1>>;
|
|
407
|
+
type RemoteListerEntry = OrderedApplyEntry<RemoteLister>;
|
|
408
|
+
type OptimizerEntry = OrderedApplyEntry<BatchOptimizer>;
|
|
409
|
+
type RequestParam = Omit<RequestUrlParam, 'body'> & {
|
|
410
|
+
body?: string | Binary;
|
|
411
|
+
};
|
|
412
|
+
type RequestResponse = {
|
|
413
|
+
text: () => string;
|
|
414
|
+
bytes: () => Binary;
|
|
415
|
+
json: () => General;
|
|
416
|
+
headers: Record<string, string>;
|
|
417
|
+
status: number;
|
|
418
|
+
};
|
|
419
|
+
type Request = (params: RequestParam | string) => Promise<RequestResponse>;
|
|
420
|
+
type Infras = {
|
|
421
|
+
localFs: Fs;
|
|
422
|
+
remoteFs: Fs;
|
|
423
|
+
record: RecordStore;
|
|
424
|
+
};
|
|
425
|
+
declare class Registrar {
|
|
426
|
+
private readonly ctx;
|
|
427
|
+
private readonly cleanupCallbacks;
|
|
428
|
+
private readonly localFsWrapperRegistry;
|
|
429
|
+
private readonly remoteFsWrapperRegistry;
|
|
430
|
+
private readonly localOptimizerRegistry;
|
|
431
|
+
private readonly remoteOptimizerRegistry;
|
|
432
|
+
private readonly remoteListerRegistry;
|
|
433
|
+
private readonly remoteRequestMiddlewareRegistry;
|
|
434
|
+
private readonly localRequestMiddlewareRegistry;
|
|
435
|
+
private readonly remoteFsRegistry;
|
|
436
|
+
private readonly deciderRegistry;
|
|
437
|
+
private readonly conflictResolverRegistry;
|
|
438
|
+
readonly settings: {
|
|
439
|
+
remoteFs: string;
|
|
440
|
+
decider: string;
|
|
441
|
+
conflictResolver: string;
|
|
442
|
+
};
|
|
443
|
+
constructor(ctx: {
|
|
444
|
+
app: App;
|
|
445
|
+
getRecordStore: (namespace?: string) => StoreAsync<RecordStat>;
|
|
446
|
+
});
|
|
447
|
+
private readonly getVaultRequest;
|
|
448
|
+
private readonly createLocalFs;
|
|
449
|
+
private readonly createRemoteFs;
|
|
450
|
+
private readonly getRequest;
|
|
451
|
+
private readonly getCheckConnection;
|
|
452
|
+
private readonly getDecider;
|
|
453
|
+
private readonly optimizeLocal;
|
|
454
|
+
private readonly optimizeRemote;
|
|
455
|
+
private readonly listRemote;
|
|
456
|
+
private readonly getConflictResolver;
|
|
457
|
+
private readonly getNamespace;
|
|
458
|
+
private readonly initializeSync;
|
|
459
|
+
root: {
|
|
460
|
+
conflictResolverRegistry: Map<string, ConflictResolverEntry>;
|
|
461
|
+
createLocalFs: () => Fs;
|
|
462
|
+
createRemoteFs: (remoteFs?: string) => RootFs;
|
|
463
|
+
deciderRegistry: Map<string, DeciderEntry>;
|
|
464
|
+
getCheckConnection: (remoteFs?: string) => () => MaybePromise<CheckConnectionResult>;
|
|
465
|
+
getConflictResolver: () => ConflictResolver;
|
|
466
|
+
getDecider: () => Decider;
|
|
467
|
+
getNamespace: (localFs?: Fs, remoteFs?: Fs) => string;
|
|
468
|
+
getRequest: () => Request;
|
|
469
|
+
getVaultRequest: () => VaultRequest;
|
|
470
|
+
initializeSync: () => Infras;
|
|
471
|
+
listRemote: RemoteLister;
|
|
472
|
+
optimizeLocal: BatchOptimizer;
|
|
473
|
+
optimizeRemote: BatchOptimizer;
|
|
474
|
+
registerConflictResolver: (key: string, entry: ConflictResolverEntry) => () => boolean;
|
|
475
|
+
registerCss: (css: string) => () => void;
|
|
476
|
+
registerDecider: (key: string, entry: DeciderEntry) => () => boolean;
|
|
477
|
+
registerLocalFsWrapper: (entry: FsWrapperEntry) => () => boolean;
|
|
478
|
+
registerLocalOptimizer: (entry: OptimizerEntry) => () => boolean;
|
|
479
|
+
registerLocalRequestMiddleware: (entry: LocalRequestMiddlewareEntry) => () => boolean;
|
|
480
|
+
registerRemoteFs: (key: string, entry: RemoteFsEntry) => () => boolean;
|
|
481
|
+
registerRemoteFsWrapper: (entry: FsWrapperEntry) => () => boolean;
|
|
482
|
+
registerRemoteLister: (entry: RemoteListerEntry) => () => boolean;
|
|
483
|
+
registerRemoteOptimizer: (entry: OptimizerEntry) => () => boolean;
|
|
484
|
+
registerRemoteRequestMiddleware: (entry: RemoteRequestMiddlewareEntry) => () => boolean;
|
|
485
|
+
remoteFsRegistry: Map<string, RemoteFsEntry>;
|
|
486
|
+
};
|
|
487
|
+
readonly dispose: () => void;
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/fs/vault/request.d.ts
|
|
491
|
+
type VaultRequestParam = {
|
|
492
|
+
method: 'GET';
|
|
493
|
+
key: string;
|
|
494
|
+
} | {
|
|
495
|
+
method: 'GET_STREAM';
|
|
496
|
+
key: string;
|
|
497
|
+
} | {
|
|
498
|
+
method: 'PUT';
|
|
499
|
+
key: string;
|
|
500
|
+
value: Binary;
|
|
501
|
+
headers?: {
|
|
502
|
+
mtime?: number;
|
|
503
|
+
ctime?: number;
|
|
504
|
+
};
|
|
505
|
+
} | {
|
|
506
|
+
method: 'APPEND';
|
|
507
|
+
key: string;
|
|
508
|
+
value: Binary;
|
|
509
|
+
headers?: {
|
|
510
|
+
mtime?: number;
|
|
511
|
+
ctime?: number;
|
|
512
|
+
};
|
|
513
|
+
} | {
|
|
514
|
+
method: 'DELETE';
|
|
515
|
+
key: string;
|
|
516
|
+
headers?: {
|
|
517
|
+
permanent?: boolean;
|
|
518
|
+
};
|
|
519
|
+
} | {
|
|
520
|
+
method: 'MOVE';
|
|
521
|
+
key: string;
|
|
522
|
+
headers: {
|
|
523
|
+
destination: string;
|
|
524
|
+
};
|
|
525
|
+
} | {
|
|
526
|
+
method: 'MKDIR';
|
|
527
|
+
key: string;
|
|
528
|
+
} | {
|
|
529
|
+
method: 'EXISTS';
|
|
530
|
+
key: string;
|
|
531
|
+
} | {
|
|
532
|
+
method: 'STAT';
|
|
533
|
+
key: string;
|
|
534
|
+
headers?: {
|
|
535
|
+
cached?: boolean;
|
|
536
|
+
};
|
|
537
|
+
} | {
|
|
538
|
+
method: 'LIST';
|
|
539
|
+
key: string;
|
|
540
|
+
headers?: {
|
|
541
|
+
cached?: boolean;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
type VaultRequestResponseMap = {
|
|
545
|
+
GET: Binary;
|
|
546
|
+
GET_STREAM: ReadableStream<Binary>;
|
|
547
|
+
PUT: void;
|
|
548
|
+
APPEND: void;
|
|
549
|
+
DELETE: void;
|
|
550
|
+
MOVE: void;
|
|
551
|
+
MKDIR: void;
|
|
552
|
+
EXISTS: boolean;
|
|
553
|
+
STAT: Stat;
|
|
554
|
+
LIST: ListedFiles;
|
|
555
|
+
};
|
|
556
|
+
type VaultRequest = <T extends VaultRequestParam>(params: T) => Promise<VaultRequestResponseMap[T['method']]>;
|
|
557
|
+
//#endregion
|
|
558
|
+
export { RootFs as $, AddRecord as A, StoreOperations as B, RemoveRemote as C, MoveLocal as D, MoveRemote as E, RecordStore as F, Fs as G, BatchOptimizer as H, Storage as I, MkdirAtom as J, InputAtom as K, DatabaseAsync as L, ConflictResolver as M, ConflictResolverPayload as N, Download as O, TaskNames as P, OutputAtom as Q, DatabaseSync as R, ResolveConflict as S, RemoveLocal as T, CustomAtom as U, StoreSync as V, DeleteAtom as W, OptimizerInput as X, MoveAtom as Y, OptimizerOutput as Z, CreateLocalDir as _, FsWrapperEntry as a, GlobMatchRule as at, TaskFactory as b, OptimizerEntry as c, RecordStat as ct, RemoteLister as d, StatsMap as dt, WrappedFs as et, RemoteListerEntry as f, TogglableValue as ft, RequestResponse as g, RequestParam as h, DeciderEntry as i, FolderStat as it, BaseTask as j, CreateRemoteDir as k, Registrar as l, RecordStatsMap as lt, Request as m, CheckConnectionResult as n, Binary as nt, Infras as o, MaybePromise as ot, RemoteRequestMiddlewareEntry as p, General as pt, ListReporter as q, ConflictResolverEntry as r, FileStat as rt, LocalRequestMiddlewareEntry as s, Progress as st, VaultRequest as t, WriteAtom as tt, RemoteFsEntry as u, Stat$1 as ut, Decider as v, RemoveRecord as w, Upload as x, DeciderInput as y, StoreAsync as z };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pipe as e,readWithSize as t,writeWithValue as n}from"./plugin/src/utils/pipe.js";import r from"./plugin/src/components/MigrationModal.js";import i from"./prefix.js";function
|
|
1
|
+
import{pipe as e,readWithSize as t,writeWithValue as n}from"./plugin/src/utils/pipe.js";import r from"./plugin/src/components/MigrationModal.js";import i from"./prefix.js";import{s as a}from"./plugin/src/settings/utils.js";function o(e){let t=e;for(;`original`in t;)t=t.original;return t}export{o as digOriginal,e as pipe,i as prefixWrapper,t as readWithSize,a as s,r as setNeedMigration,n as writeWithValue};
|