@hesprs/sync-engine-sdk 3.0.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.
Files changed (91) hide show
  1. package/dist/debug-wrapper.d.ts +6 -0
  2. package/dist/debug-wrapper.js +1 -0
  3. package/dist/dev.d.ts +5 -0
  4. package/dist/dev.js +1 -0
  5. package/dist/index.d.ts +35 -0
  6. package/dist/index.js +1 -0
  7. package/dist/node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/context.d.ts +29 -0
  8. package/dist/node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.d.ts +14 -0
  9. package/dist/node_modules/.bun/uni-kv@.._.._uni-kv.tgz/node_modules/uni-kv/dist/interface.d.ts +46 -0
  10. package/dist/obsidian-bridge.d.ts +15 -0
  11. package/dist/obsidian-bridge.js +1 -0
  12. package/dist/packages/plugin/src/components/FilterEditorModal.d.ts +17 -0
  13. package/dist/packages/plugin/src/components/HeadersEditorModal.d.ts +18 -0
  14. package/dist/packages/plugin/src/components/MigrationModal.d.ts +45 -0
  15. package/dist/packages/plugin/src/components/MigrationModal.js +1 -0
  16. package/dist/packages/plugin/src/components/ModuleEditorModal.d.ts +26 -0
  17. package/dist/packages/plugin/src/components/SourceEditorModal.d.ts +16 -0
  18. package/dist/packages/plugin/src/components/UnknownModuleModal.d.ts +19 -0
  19. package/dist/packages/plugin/src/components/file-tree/index.d.ts +7 -0
  20. package/dist/packages/plugin/src/components/module-management/index.d.ts +23 -0
  21. package/dist/packages/plugin/src/components/render-progress.js +1 -0
  22. package/dist/packages/plugin/src/fs/hierarchical-optimizer.d.ts +1 -0
  23. package/dist/packages/plugin/src/fs/index.d.ts +13 -0
  24. package/dist/packages/plugin/src/fs/interface.d.ts +71 -0
  25. package/dist/packages/plugin/src/fs/middlewares/custom-headers.d.ts +1 -0
  26. package/dist/packages/plugin/src/fs/middlewares/rate-limiter.d.ts +1 -0
  27. package/dist/packages/plugin/src/fs/middlewares/retry.d.ts +1 -0
  28. package/dist/packages/plugin/src/fs/vault/index.d.ts +3 -0
  29. package/dist/packages/plugin/src/fs/vault/request.d.ts +71 -0
  30. package/dist/packages/plugin/src/fs/wrappers/asymmetric-storage.d.ts +2 -0
  31. package/dist/packages/plugin/src/fs/wrappers/cancellation.d.ts +2 -0
  32. package/dist/packages/plugin/src/fs/wrappers/context.d.ts +2 -0
  33. package/dist/packages/plugin/src/fs/wrappers/memory-control.d.ts +1 -0
  34. package/dist/packages/plugin/src/fs/wrappers/optimization.d.ts +1 -0
  35. package/dist/packages/plugin/src/index.d.ts +30 -0
  36. package/dist/packages/plugin/src/modules/Bootstrap.d.ts +85 -0
  37. package/dist/packages/plugin/src/modules/EventBus.d.ts +35 -0
  38. package/dist/packages/plugin/src/modules/Extensibility.d.ts +96 -0
  39. package/dist/packages/plugin/src/modules/I18n.d.ts +22 -0
  40. package/dist/packages/plugin/src/modules/ModulesModal.d.ts +49 -0
  41. package/dist/packages/plugin/src/modules/Observability.d.ts +58 -0
  42. package/dist/packages/plugin/src/modules/ProgressModal.d.ts +66 -0
  43. package/dist/packages/plugin/src/modules/Registrar.d.ts +147 -0
  44. package/dist/packages/plugin/src/modules/Scheduler.d.ts +43 -0
  45. package/dist/packages/plugin/src/modules/Storage.d.ts +54 -0
  46. package/dist/packages/plugin/src/modules/Sync.d.ts +84 -0
  47. package/dist/packages/plugin/src/settings/controls.d.ts +21 -0
  48. package/dist/packages/plugin/src/settings/development.d.ts +17 -0
  49. package/dist/packages/plugin/src/settings/features.d.ts +24 -0
  50. package/dist/packages/plugin/src/settings/filter.d.ts +11 -0
  51. package/dist/packages/plugin/src/settings/head.d.ts +23 -0
  52. package/dist/packages/plugin/src/settings/miscellaneous.d.ts +21 -0
  53. package/dist/packages/plugin/src/sync/conflict-resolve/keep-local.d.ts +1 -0
  54. package/dist/packages/plugin/src/sync/conflict-resolve/keep-remote.d.ts +1 -0
  55. package/dist/packages/plugin/src/sync/conflict-resolve/latest-survive.d.ts +1 -0
  56. package/dist/packages/plugin/src/sync/conflict-resolve/rename-and-keep-both.d.ts +1 -0
  57. package/dist/packages/plugin/src/sync/decision/bidirectional.d.ts +2 -0
  58. package/dist/packages/plugin/src/sync/decision/interface.d.ts +90 -0
  59. package/dist/packages/plugin/src/sync/index.d.ts +21 -0
  60. package/dist/packages/plugin/src/sync/tasks/AddRecord.d.ts +8 -0
  61. package/dist/packages/plugin/src/sync/tasks/CreateLocalDir.d.ts +8 -0
  62. package/dist/packages/plugin/src/sync/tasks/CreateRemoteDir.d.ts +8 -0
  63. package/dist/packages/plugin/src/sync/tasks/Download.d.ts +8 -0
  64. package/dist/packages/plugin/src/sync/tasks/MoveLocal.d.ts +8 -0
  65. package/dist/packages/plugin/src/sync/tasks/MoveRemote.d.ts +8 -0
  66. package/dist/packages/plugin/src/sync/tasks/RemoveLocal.d.ts +8 -0
  67. package/dist/packages/plugin/src/sync/tasks/RemoveRecord.d.ts +7 -0
  68. package/dist/packages/plugin/src/sync/tasks/RemoveRemote.d.ts +8 -0
  69. package/dist/packages/plugin/src/sync/tasks/ResolveConflict.d.ts +11 -0
  70. package/dist/packages/plugin/src/sync/tasks/Upload.d.ts +8 -0
  71. package/dist/packages/plugin/src/sync/tasks/interface.d.ts +36 -0
  72. package/dist/packages/plugin/src/sync/utils/detect-moves.d.ts +2 -0
  73. package/dist/packages/plugin/src/sync/utils/post-traversal.d.ts +1 -0
  74. package/dist/packages/plugin/src/types.d.ts +40 -0
  75. package/dist/packages/plugin/src/utils/glob-match.d.ts +5 -0
  76. package/dist/packages/plugin/src/utils/pipe.d.ts +14 -0
  77. package/dist/packages/plugin/src/utils/pipe.js +1 -0
  78. package/dist/packages/plugin/src/utils/round-percent.js +1 -0
  79. package/dist/packages/plugin/src/utils/sha-256.d.ts +4 -0
  80. package/dist/packages/plugin/src/utils/sha-256.js +1 -0
  81. package/dist/packages/plugin/src/utils/to-error-message.js +1 -0
  82. package/dist/packages/plugin/test/e2e-utils.d.ts +5 -0
  83. package/dist/packages/plugin/test/test-kit.d.ts +58 -0
  84. package/dist/packages/plugin/test/test-kit.js +1 -0
  85. package/dist/packages/shared/src/get-status.js +1 -0
  86. package/dist/packages/shared/src/path.js +1 -0
  87. package/dist/prefix.d.ts +6 -0
  88. package/dist/prefix.js +1 -0
  89. package/dist/transform.d.ts +15 -0
  90. package/dist/transform.js +1 -0
  91. package/package.json +65 -0
@@ -0,0 +1,85 @@
1
+ import { Stat as Stat$1, TogglableValue } from "../types.js";
2
+ import { BatchOptimizer } from "../fs/interface.js";
3
+ import { DatabaseSync } from "../../../../node_modules/.bun/uni-kv@.._.._uni-kv.tgz/node_modules/uni-kv/dist/interface.js";
4
+ import { Dispatch, On } from "./EventBus.js";
5
+ import { ObsidianLanguageCode, Translate, TranslationResource } from "./I18n.js";
6
+ import { FileTreeTranslations } from "../components/file-tree/index.js";
7
+ import { HeadersEditorTranslations } from "../components/HeadersEditorModal.js";
8
+ import { ModuleEditorTranslations } from "../components/ModuleEditorModal.js";
9
+ import { UnknownModuleTranslations } from "../components/UnknownModuleModal.js";
10
+ import { ControlsSettingTranslations } from "../settings/controls.js";
11
+ import { DevelopmentSettingTranslations } from "../settings/development.js";
12
+ import { FeaturesSettingTranslations } from "../settings/features.js";
13
+ import { FilterSettingTranslations } from "../settings/filter.js";
14
+ import { HeadSettingTranslations } from "../settings/head.js";
15
+ import { MiscellaneousSettingTranslations } from "../settings/miscellaneous.js";
16
+ import { Events, Translations } from "../index.js";
17
+ import { ConflictResolverEntry, DeciderEntry, FsWrapperEntry, LocalRequestMiddlewareEntry, OptimizerEntry, RemoteFsEntry, RemoteListerEntry, RemoteRequestMiddlewareEntry, SettingEntry } from "./Registrar.js";
18
+ import "../fs/index.js";
19
+ import { App } from "obsidian";
20
+ //#region src/modules/Bootstrap.d.ts
21
+ type CustomHeaders = Array<{
22
+ type: 'plaintext' | 'secret';
23
+ value: string;
24
+ key: string;
25
+ }>;
26
+ type ExistingMemoryDB = DatabaseSync<{
27
+ localContext20000: Stat$1;
28
+ remoteContext10000: Stat$1;
29
+ remoteContext20000: Stat$1;
30
+ }, {
31
+ localContext20000Marker: string;
32
+ remoteContext10000Marker: string;
33
+ remoteContext20000Marker: string;
34
+ }>;
35
+ declare class Bootstrap {
36
+ private readonly ctx;
37
+ private readonly cleanupCallbacks;
38
+ private readonly memoryStates;
39
+ private isCancelled?;
40
+ private readonly localPool;
41
+ private readonly remotePool;
42
+ private localFs?;
43
+ private remoteFs?;
44
+ readonly i18n: {
45
+ bidirectional: string;
46
+ latestSurvive: string;
47
+ keepLocal: string;
48
+ keepRemote: string;
49
+ renameAndKeepBoth: string;
50
+ skip: string;
51
+ } & ControlsSettingTranslations & DevelopmentSettingTranslations & FeaturesSettingTranslations & FilterSettingTranslations & HeadSettingTranslations & MiscellaneousSettingTranslations & HeadersEditorTranslations & UnknownModuleTranslations & ModuleEditorTranslations & FileTreeTranslations;
52
+ readonly settings: {
53
+ maxMemoryConsumption: TogglableValue;
54
+ maxRequestConcurrency: TogglableValue;
55
+ minRequestInterval: TogglableValue;
56
+ realtimeSyncFastMode: boolean;
57
+ asymmetricStorage: boolean;
58
+ customHeaders: CustomHeaders;
59
+ };
60
+ constructor(ctx: {
61
+ app: App;
62
+ registerI18n: (code: ObsidianLanguageCode, resource: TranslationResource) => void;
63
+ on: On<Events>;
64
+ dispatch: Dispatch<Events>;
65
+ memoryDB: ExistingMemoryDB;
66
+ registerDecider: (id: string, entry: DeciderEntry) => void;
67
+ registerLocalFsWrapper: (entry: FsWrapperEntry) => void;
68
+ registerRemoteFs: (id: string, entry: RemoteFsEntry) => void;
69
+ registerRemoteFsWrapper: (entry: FsWrapperEntry) => void;
70
+ translate: Translate<Translations>;
71
+ optimizeLocal: BatchOptimizer;
72
+ optimizeRemote: BatchOptimizer;
73
+ registerLocalOptimizer: (optimizer: OptimizerEntry) => void;
74
+ registerRemoteOptimizer: (optimizer: OptimizerEntry) => void;
75
+ registerRemoteLister: (entry: RemoteListerEntry) => () => boolean;
76
+ registerSetting: (entry: SettingEntry) => () => boolean;
77
+ registerConflictResolver: (id: string, entry: ConflictResolverEntry) => void;
78
+ registerRemoteRequestMiddleware: (entry: RemoteRequestMiddlewareEntry) => void;
79
+ registerLocalRequestMiddleware: (entry: LocalRequestMiddlewareEntry) => void;
80
+ });
81
+ readonly start: () => void;
82
+ readonly dispose: () => void;
83
+ }
84
+ //#endregion
85
+ export { CustomHeaders, ExistingMemoryDB, Bootstrap as default };
@@ -0,0 +1,35 @@
1
+ import { General } from "../../test/e2e-utils.js";
2
+ import "../types.js";
3
+ import { Ref } from "../../../../node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.js";
4
+ //#region src/modules/EventBus.d.ts
5
+ type Dispatch<O extends object> = <K extends keyof O>(...[key, payload]: undefined extends O[K] ? [K] : [K, O[K]]) => void;
6
+ type On<O extends object> = <K extends keyof O>(key: K, callback: (payload: O[K]) => void) => () => void;
7
+ declare class EventBus {
8
+ readonly events: {
9
+ logSync: string;
10
+ logGeneral: string;
11
+ errorSync: string;
12
+ errorGeneral: string;
13
+ };
14
+ private readonly cleanupCallbacks;
15
+ private readonly isIdle;
16
+ private readonly syncLogs;
17
+ private readonly generalLogs;
18
+ constructor();
19
+ private readonly getThisSync;
20
+ private readonly putSyncLog;
21
+ private readonly putGeneralLog;
22
+ private readonly subscribers;
23
+ private readonly on;
24
+ private readonly dispatch;
25
+ private readonly getLogs;
26
+ readonly dispose: () => void;
27
+ readonly root: {
28
+ dispatch: Dispatch<General>;
29
+ getLogs: () => string;
30
+ isIdle: Ref<boolean>;
31
+ on: On<General>;
32
+ };
33
+ }
34
+ //#endregion
35
+ export { Dispatch, On, EventBus as default };
@@ -0,0 +1,96 @@
1
+ import { General } from "../../test/e2e-utils.js";
2
+ import "../types.js";
3
+ import { DatabaseAsync } from "../../../../node_modules/.bun/uni-kv@.._.._uni-kv.tgz/node_modules/uni-kv/dist/interface.js";
4
+ import { Ref } from "../../../../node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.js";
5
+ import { Dispatch } from "./EventBus.js";
6
+ import { Translate } from "./I18n.js";
7
+ import "../../../../index.js";
8
+ import { Context, Events, Translations } from "../index.js";
9
+ import { App } from "obsidian";
10
+ //#region src/modules/Extensibility.d.ts
11
+ type ModuleInstance = {
12
+ moduleSettings: object;
13
+ dispose?: () => void;
14
+ start?: () => void;
15
+ };
16
+ type ModuleCtor = new (ctx: object) => ModuleInstance;
17
+ type ModuleMeta = {
18
+ id: string;
19
+ name: string;
20
+ version: string;
21
+ description: string;
22
+ main: string;
23
+ icon?: string;
24
+ minPluginVersion?: string;
25
+ integrity: string;
26
+ };
27
+ type AugmentedModuleMeta = ModuleMeta & {
28
+ enabled: boolean;
29
+ source: string;
30
+ icon: string;
31
+ };
32
+ declare class Extensibility {
33
+ private readonly ctx;
34
+ private readonly moduleDir;
35
+ private readonly sourceCache;
36
+ private readonly discoveredModules;
37
+ private readonly loadedModules;
38
+ private readonly moduleStore;
39
+ private autoUpdateTimeout?;
40
+ readonly settings: {
41
+ moduleSources: Array<string>;
42
+ moduleAutoUpdate: boolean;
43
+ modules: Record<string, object>;
44
+ };
45
+ readonly i18n: {
46
+ failedToLoadModule: string;
47
+ failedToDownloadModule: string;
48
+ failedToFetchSource: string;
49
+ };
50
+ readonly events: {
51
+ moduleLoaded: string;
52
+ moduleUnloaded: string;
53
+ };
54
+ constructor(ctx: {
55
+ app: App;
56
+ __addModule__: Context['__addModule__'];
57
+ __getModule__: Context['__getModule__'];
58
+ dispatch: Dispatch<Events>;
59
+ translate: Translate<Translations>;
60
+ allModules: Set<General>;
61
+ isIdle: Ref<boolean>;
62
+ saveSettings: () => Promise<void>;
63
+ indexedDB: DatabaseAsync<Record<string, AugmentedModuleMeta>>;
64
+ });
65
+ readonly start: () => void;
66
+ private readonly createOperationFactory;
67
+ private readonly loadAllModules;
68
+ private readonly loadModule;
69
+ private readonly unloadModule;
70
+ private readonly downloadModule;
71
+ private readonly deleteModule;
72
+ private readonly fetchSources;
73
+ private readonly updateModules;
74
+ private readonly updateModuleMeta;
75
+ private readonly enableModule;
76
+ private readonly disableModule;
77
+ private readonly getModulePath;
78
+ private readonly parseModulePath;
79
+ readonly dispose: () => void;
80
+ readonly root: {
81
+ deleteModule: (id: string) => Promise<void>;
82
+ disableModule: (id: string) => void;
83
+ discoveredModules: Map<string, AugmentedModuleMeta>;
84
+ downloadModule: (meta: AugmentedModuleMeta, waitIdle?: boolean) => Promise<void>;
85
+ enableModule: (id: string) => Promise<void>;
86
+ fetchSources: (manual?: boolean) => Promise<AugmentedModuleMeta[]>;
87
+ loadAllModules: () => Promise<void>;
88
+ loadModule: (meta: AugmentedModuleMeta, start?: boolean, module?: string) => Promise<void>;
89
+ loadedModules: Map<string, ModuleCtor>;
90
+ unloadModule: (id: string) => void;
91
+ updateModuleMeta: (meta: AugmentedModuleMeta) => Promise<void>;
92
+ updateModules: () => Promise<void>;
93
+ };
94
+ }
95
+ //#endregion
96
+ export { AugmentedModuleMeta, ModuleCtor, ModuleInstance, ModuleMeta, Extensibility as default };
@@ -0,0 +1,22 @@
1
+ import { General } from "../../test/e2e-utils.js";
2
+ import "../types.js";
3
+ //#region src/modules/I18n.d.ts
4
+ type ObsidianLanguageCode = 'en' | 'af' | 'am' | 'ar' | 'az' | 'be' | 'bg' | 'bn' | 'ca' | 'cs' | 'da' | 'de' | 'dv' | 'el' | 'en-GB' | 'eo' | 'es' | 'eu' | 'fa' | 'fi' | 'fr' | 'ga' | 'gl' | 'he' | 'hi' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ka' | 'kh' | 'kn' | 'ko' | 'ky' | 'la' | 'lt' | 'lv' | 'ml' | 'ms' | 'nan-TW' | 'ne' | 'nl' | 'nn' | 'no' | 'oc' | 'or' | 'pl' | 'pt' | 'pt-BR' | 'ro' | 'ru' | 'sa' | 'si' | 'sk' | 'sl' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'te' | 'th' | 'tl' | 'tr' | 'tt' | 'uk' | 'ur' | 'uz' | 'vi' | 'zh' | 'zh-TW';
5
+ type Primitive = string | number | boolean | null | undefined;
6
+ type Fragment<A = undefined> = (frag: DocumentFragment, args: A) => void;
7
+ type TranslationResource = Record<string, string | Fragment<General>>;
8
+ type InterpolationValues = Record<string, Primitive>;
9
+ type TranslateParams<R extends Fragment<General> | string> = R extends Fragment<infer A> ? ([undefined] extends [A] ? [] : [A]) : [] | [InterpolationValues];
10
+ type Translate<O extends TranslationResource> = <K extends keyof O>(key: K, ...args: TranslateParams<O[K]>) => O[K] extends string ? string : DocumentFragment;
11
+ declare class I18n {
12
+ private readonly targetLangs;
13
+ readonly i18n: {};
14
+ private readonly registerI18n;
15
+ private readonly translate;
16
+ root: {
17
+ registerI18n: (code: ObsidianLanguageCode, resource: TranslationResource) => void;
18
+ translate: Translate<General>;
19
+ };
20
+ }
21
+ //#endregion
22
+ export { Fragment, InterpolationValues, ObsidianLanguageCode, Translate, TranslationResource, I18n as default };
@@ -0,0 +1,49 @@
1
+ import { Translate } from "./I18n.js";
2
+ import { AugmentedModuleMeta } from "./Extensibility.js";
3
+ import { ModuleManagementTranslations } from "../components/module-management/index.js";
4
+ import { SourceEditorTranslations } from "../components/SourceEditorModal.js";
5
+ import { App, Modal } from "obsidian";
6
+ //#region src/modules/ModulesModal.d.ts
7
+ type ModulesModalTranslations = ModuleManagementTranslations & SourceEditorTranslations & {
8
+ searchModules: string;
9
+ editSources: string;
10
+ moduleManagement: string;
11
+ showInstalledOnly: string;
12
+ configurations: string;
13
+ };
14
+ declare class ModulesModal extends Modal {
15
+ private readonly ctx;
16
+ private readonly t;
17
+ private readonly modalCleanup;
18
+ private sourceEditorModal?;
19
+ private showInstalledOnly;
20
+ constructor(ctx: {
21
+ app: App;
22
+ translate: Translate<ModulesModalTranslations>;
23
+ saveSettings: () => Promise<void>;
24
+ fetchSources: (manual?: boolean) => Promise<Array<AugmentedModuleMeta>>;
25
+ discoveredModules: Map<string, AugmentedModuleMeta>;
26
+ loadedModules: Map<string, unknown>;
27
+ downloadModule: (meta: AugmentedModuleMeta) => Promise<void>;
28
+ deleteModule: (id: string) => Promise<void>;
29
+ loadModule: (meta: AugmentedModuleMeta, start?: boolean) => Promise<void>;
30
+ unloadModule: (id: string) => void;
31
+ enableModule: (id: string) => Promise<void>;
32
+ disableModule: (id: string) => void;
33
+ updateModuleMeta: (meta: AugmentedModuleMeta) => Promise<void>;
34
+ });
35
+ readonly i18n: ModulesModalTranslations;
36
+ readonly settings: {
37
+ moduleSources: Array<string>;
38
+ };
39
+ root: {
40
+ closeModuleManagement: () => void;
41
+ openModuleManagement: () => void;
42
+ };
43
+ onOpen(): void;
44
+ onClose(): void;
45
+ private readonly openSourceEditorModal;
46
+ dispose(): void;
47
+ }
48
+ //#endregion
49
+ export { ModulesModal as default };
@@ -0,0 +1,58 @@
1
+ import { Progress } from "../types.js";
2
+ import { Ref } from "../../../../node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.js";
3
+ import { Dispatch, On } from "./EventBus.js";
4
+ import { Translate } from "./I18n.js";
5
+ import { SyncTerminateReason, TaskInfo } from "./Sync.js";
6
+ import { Events, Translations } from "../index.js";
7
+ import { App, Command, IconName } from "obsidian";
8
+ //#region src/modules/Observability.d.ts
9
+ type SyncStage = 'none' | 'walkingRemote' | 'awaitingConfirmation' | 'executing' | 'completed' | 'completedNoop' | 'cancelled' | 'failed';
10
+ type AddRibbonIcon = (icon: IconName, title: string, callback: (evt: MouseEvent) => void) => HTMLElement;
11
+ declare class Observability {
12
+ private readonly ctx;
13
+ private lastSyncTime;
14
+ private readonly sinceLastSyncText;
15
+ private readonly syncStage;
16
+ private readonly walkProgress;
17
+ private readonly executionProgress;
18
+ private readonly cleanupCallbacks;
19
+ private readonly t;
20
+ private readonly progressText;
21
+ readonly settings: {
22
+ noticeStatusOnMobile: boolean;
23
+ };
24
+ readonly i18n: {
25
+ startSync: string;
26
+ startNonInteractiveSync: string;
27
+ stopSync: string;
28
+ showProgress: string;
29
+ exportLogsToFile: string;
30
+ exportLogsFailed: string;
31
+ idle: string;
32
+ };
33
+ constructor(ctx: {
34
+ addStatusBarItem: () => HTMLElement;
35
+ on: On<Events>;
36
+ translate: Translate<Translations>;
37
+ isIdle: Ref<boolean>;
38
+ dispatch: Dispatch<Events>;
39
+ requestSync: (trigger: string) => Promise<SyncTerminateReason>;
40
+ showProgress: () => void;
41
+ addCommand: (command: Command) => Command;
42
+ addRibbonIcon: AddRibbonIcon;
43
+ getLogs: () => string;
44
+ app: App;
45
+ });
46
+ readonly start: () => void;
47
+ private readonly setupCommands;
48
+ private readonly exportLogs;
49
+ readonly dispose: () => void;
50
+ root: {
51
+ executionProgress: Ref<Progress<TaskInfo>>;
52
+ exportLogs: () => Promise<void>;
53
+ syncStage: Ref<SyncStage>;
54
+ walkProgress: Ref<Progress>;
55
+ };
56
+ }
57
+ //#endregion
58
+ export { AddRibbonIcon, SyncStage, Observability as default };
@@ -0,0 +1,66 @@
1
+ import { Progress } from "../types.js";
2
+ import { Ref } from "../../../../node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.js";
3
+ import { Dispatch, On } from "./EventBus.js";
4
+ import { Translate } from "./I18n.js";
5
+ import { BaseTask, TaskNames } from "../sync/tasks/interface.js";
6
+ import RemoveLocal from "../sync/tasks/RemoveLocal.js";
7
+ import "../sync/index.js";
8
+ import { TaskInfo } from "./Sync.js";
9
+ import { SyncStage } from "./Observability.js";
10
+ import { Events, Translations } from "../index.js";
11
+ import { App, Modal } from "obsidian";
12
+ //#region src/modules/ProgressModal.d.ts
13
+ type DeleteConfirmReturn = {
14
+ delete: Array<RemoveLocal>;
15
+ reupload: Array<RemoveLocal>;
16
+ };
17
+ declare class ProgressModal extends Modal {
18
+ private readonly ctx;
19
+ private readonly moduleCleanupCallbacks;
20
+ private readonly t;
21
+ private opening;
22
+ private readonly modalCleanupCallbacks;
23
+ private readonly dispatch;
24
+ private description?;
25
+ private detailContainer?;
26
+ private controls?;
27
+ constructor(ctx: {
28
+ app: App;
29
+ translate: Translate<Translations>;
30
+ on: On<Events>;
31
+ dispatch: Dispatch<Events>;
32
+ syncStage: Ref<SyncStage>;
33
+ walkProgress: Ref<Progress>;
34
+ executionProgress: Ref<Progress<TaskInfo>>;
35
+ });
36
+ readonly events: {
37
+ tasksConfirmed: Array<BaseTask>;
38
+ deleteConfirmed: DeleteConfirmReturn;
39
+ };
40
+ readonly i18n: {
41
+ syncProgress: string;
42
+ completed: string;
43
+ failedTasksDescription: string;
44
+ confirmDeleteDescription: string;
45
+ confirmTasksDescription: string;
46
+ hide: string;
47
+ confirm: string;
48
+ cancel: string;
49
+ done: string;
50
+ stopSync: string;
51
+ } & Record<TaskNames | SyncStage, string>;
52
+ private readonly renderHideStop;
53
+ private readonly renderConfirmCancel;
54
+ private readonly renderDone;
55
+ private readonly showDetails;
56
+ private readonly hideDetails;
57
+ onOpen(): void;
58
+ root: {
59
+ hideProgress: () => void;
60
+ showProgress: () => void;
61
+ };
62
+ onClose(): void;
63
+ dispose(): void;
64
+ }
65
+ //#endregion
66
+ export { DeleteConfirmReturn, ProgressModal as default };
@@ -0,0 +1,147 @@
1
+ import { General } from "../../test/e2e-utils.js";
2
+ import { Binary, MaybePromise, RecordStat, Stat as Stat$1 } from "../types.js";
3
+ import { BatchOptimizer, Fs, ListReporter, RootFs } from "../fs/interface.js";
4
+ import { StoreAsync } from "../../../../node_modules/.bun/uni-kv@.._.._uni-kv.tgz/node_modules/uni-kv/dist/interface.js";
5
+ import { On } from "./EventBus.js";
6
+ import { RecordStore } from "./Storage.js";
7
+ import { ConflictResolver } from "../sync/tasks/interface.js";
8
+ import { Decider } from "../sync/decision/interface.js";
9
+ import "../sync/index.js";
10
+ import { Events } from "../index.js";
11
+ import { VaultRequest } from "../fs/vault/request.js";
12
+ import "../fs/index.js";
13
+ import { App, Plugin, RequestUrlParam } from "obsidian";
14
+ //#region src/modules/Registrar.d.ts
15
+ type RejectableWrapper<T> = (value: T) => T | undefined;
16
+ type OrderedWrapperEntry<T> = {
17
+ priority: number;
18
+ apply: RejectableWrapper<T>;
19
+ };
20
+ type RemoteRequestMiddlewareEntry = OrderedWrapperEntry<Request>;
21
+ type LocalRequestMiddlewareEntry = OrderedWrapperEntry<VaultRequest>;
22
+ type FsWrapperEntry = OrderedWrapperEntry<Fs>;
23
+ type CheckConnectionResult = {
24
+ success: true;
25
+ } | {
26
+ success: false;
27
+ reason: string;
28
+ };
29
+ type RemoteFsEntry = {
30
+ instantiate: (request: Request) => RootFs;
31
+ prettyName: () => string;
32
+ checkConnection: (request: Request) => MaybePromise<CheckConnectionResult>;
33
+ };
34
+ type DeciderEntry = {
35
+ decider: Decider;
36
+ prettyName: () => string;
37
+ };
38
+ type ConflictResolverEntry = {
39
+ prettyName: () => string;
40
+ resolver: ConflictResolver;
41
+ };
42
+ type GeneralFn = (...args: ReadonlyArray<General>) => unknown;
43
+ type RejectableApply<F extends GeneralFn> = (...input: Parameters<F>) => ReturnType<F> | undefined;
44
+ type OrderedApplyEntry<F extends GeneralFn> = {
45
+ apply: RejectableApply<F>;
46
+ priority: number;
47
+ };
48
+ type RemoteLister = (info: Infras & {
49
+ trigger: string;
50
+ reporter: ListReporter;
51
+ }) => MaybePromise<Array<Stat$1>>;
52
+ type RemoteListerEntry = OrderedApplyEntry<RemoteLister>;
53
+ type OptimizerEntry = OrderedApplyEntry<BatchOptimizer>;
54
+ type SettingEntry = {
55
+ priority: number;
56
+ apply: (el: HTMLElement) => void;
57
+ };
58
+ type RequestParam = Omit<RequestUrlParam, 'body'> & {
59
+ body?: string | Binary;
60
+ };
61
+ type RequestResponse = {
62
+ text: () => string;
63
+ bytes: () => Binary;
64
+ json: () => General;
65
+ headers: Record<string, string>;
66
+ status: number;
67
+ };
68
+ type Request = (params: RequestParam | string) => Promise<RequestResponse>;
69
+ type Infras = {
70
+ localFs: Fs;
71
+ remoteFs: Fs;
72
+ record: RecordStore;
73
+ };
74
+ declare class Registrar {
75
+ private readonly ctx;
76
+ private settingTab?;
77
+ private readonly cleanupCallbacks;
78
+ private readonly localFsWrapperRegistry;
79
+ private readonly remoteFsWrapperRegistry;
80
+ private readonly localOptimizerRegistry;
81
+ private readonly remoteOptimizerRegistry;
82
+ private readonly remoteListerRegistry;
83
+ private readonly settingRegistry;
84
+ private readonly remoteRequestMiddlewareRegistry;
85
+ private readonly localRequestMiddlewareRegistry;
86
+ private readonly remoteFsRegistry;
87
+ private readonly deciderRegistry;
88
+ private readonly conflictResolverRegistry;
89
+ readonly settings: {
90
+ remoteFs: string;
91
+ decider: string;
92
+ conflictResolver: string;
93
+ };
94
+ constructor(ctx: {
95
+ app: App;
96
+ on: On<Events>;
97
+ getRecordStore: (namespace?: string) => StoreAsync<RecordStat>;
98
+ });
99
+ private readonly getVaultRequest;
100
+ private readonly createLocalFs;
101
+ private readonly createRemoteFs;
102
+ private readonly getRequest;
103
+ private readonly getCheckConnection;
104
+ private readonly getDecider;
105
+ private readonly optimizeLocal;
106
+ private readonly optimizeRemote;
107
+ private readonly listRemote;
108
+ private readonly getConflictResolver;
109
+ private readonly getNamespace;
110
+ private readonly initializeSync;
111
+ private readonly addSettingTab;
112
+ private readonly rerenderSettingTab;
113
+ root: {
114
+ addSettingTab: (plugin: Plugin) => void;
115
+ conflictResolverRegistry: Map<string, ConflictResolverEntry>;
116
+ createLocalFs: () => Fs;
117
+ createRemoteFs: (remoteFs?: string) => RootFs;
118
+ deciderRegistry: Map<string, DeciderEntry>;
119
+ getCheckConnection: (remoteFs?: string) => () => MaybePromise<CheckConnectionResult>;
120
+ getConflictResolver: () => ConflictResolver;
121
+ getDecider: () => Decider;
122
+ getNamespace: (localFs?: Fs, remoteFs?: Fs) => string;
123
+ getRequest: () => Request;
124
+ getVaultRequest: () => VaultRequest;
125
+ initializeSync: () => Infras;
126
+ listRemote: RemoteLister;
127
+ optimizeLocal: BatchOptimizer;
128
+ optimizeRemote: BatchOptimizer;
129
+ registerConflictResolver: (key: string, entry: ConflictResolverEntry) => () => boolean;
130
+ registerCss: (css: string) => () => void;
131
+ registerDecider: (key: string, entry: DeciderEntry) => () => boolean;
132
+ registerLocalFsWrapper: (entry: FsWrapperEntry) => () => boolean;
133
+ registerLocalOptimizer: (entry: OptimizerEntry) => () => boolean;
134
+ registerLocalRequestMiddleware: (entry: LocalRequestMiddlewareEntry) => () => boolean;
135
+ registerRemoteFs: (key: string, entry: RemoteFsEntry) => () => boolean;
136
+ registerRemoteFsWrapper: (entry: FsWrapperEntry) => () => boolean;
137
+ registerRemoteLister: (entry: RemoteListerEntry) => () => boolean;
138
+ registerRemoteOptimizer: (entry: OptimizerEntry) => () => boolean;
139
+ registerRemoteRequestMiddleware: (entry: RemoteRequestMiddlewareEntry) => () => boolean;
140
+ registerSetting: (entry: SettingEntry) => () => boolean;
141
+ remoteFsRegistry: Map<string, RemoteFsEntry>;
142
+ rerenderSettingTab: () => void | undefined;
143
+ };
144
+ readonly dispose: () => void;
145
+ }
146
+ //#endregion
147
+ export { CheckConnectionResult, ConflictResolverEntry, DeciderEntry, FsWrapperEntry, Infras, LocalRequestMiddlewareEntry, OptimizerEntry, RemoteFsEntry, RemoteLister, RemoteListerEntry, RemoteRequestMiddlewareEntry, Request, RequestParam, RequestResponse, SettingEntry, Registrar as default };
@@ -0,0 +1,43 @@
1
+ import { GlobMatchRule, TogglableValue } from "../types.js";
2
+ import { Ref } from "../../../../node_modules/.bun/synthkernel@._synthkernel.tgz/node_modules/synthkernel/dist/reactive.js";
3
+ import { SyncTerminateReason } from "./Sync.js";
4
+ import { SyncStage } from "./Observability.js";
5
+ import { App, EventRef } from "obsidian";
6
+ //#region src/modules/Scheduler.d.ts
7
+ declare class Scheduler {
8
+ private readonly ctx;
9
+ private readonly pendingRequests;
10
+ private isScheduling;
11
+ private realtimeSyncTimer?;
12
+ private scheduledSyncTimer?;
13
+ private startupSyncTimer?;
14
+ constructor(ctx: {
15
+ syncStage: Ref<SyncStage>;
16
+ executeSync: (trigger: string) => Promise<SyncTerminateReason>;
17
+ registerEvent: (ref: EventRef) => void;
18
+ app: App;
19
+ isIdle: Ref<boolean>;
20
+ });
21
+ settings: {
22
+ startupSync: TogglableValue;
23
+ scheduledSync: TogglableValue;
24
+ realtimeSync: TogglableValue;
25
+ exclusionRules: Array<GlobMatchRule>;
26
+ inclusionRules: Array<GlobMatchRule>;
27
+ };
28
+ private readonly requestSync;
29
+ start: () => void;
30
+ dispose: () => void;
31
+ private readonly startScheduledSync;
32
+ private readonly stopScheduledSync;
33
+ private readonly onChange;
34
+ private readonly scheduleFlush;
35
+ private readonly flush;
36
+ root: {
37
+ requestSync: (trigger: string) => Promise<SyncTerminateReason>;
38
+ startScheduledSync: () => void;
39
+ stopScheduledSync: () => void;
40
+ };
41
+ }
42
+ //#endregion
43
+ export { Scheduler as default };
@@ -0,0 +1,54 @@
1
+ import { General } from "../../test/e2e-utils.js";
2
+ import { RecordStat } from "../types.js";
3
+ import { DatabaseAsync, GetResult, StoreAsync, StoreOperations } from "../../../../node_modules/.bun/uni-kv@.._.._uni-kv.tgz/node_modules/uni-kv/dist/interface.js";
4
+ //#region src/modules/Storage.d.ts
5
+ type RecordStore = StoreAsync<RecordStat>;
6
+ declare class Storage {
7
+ private readonly ctx;
8
+ private readonly memoryDB;
9
+ private readonly indexedDB;
10
+ constructor(ctx: {
11
+ getNamespace: () => string;
12
+ });
13
+ private readonly getRecordStore;
14
+ private readonly deleteRecordStore;
15
+ private readonly clearRecordStores;
16
+ private readonly recordStoreExists;
17
+ readonly root: {
18
+ clearRecordStores: () => Promise<void>;
19
+ deleteRecordStore: (namespace?: string) => Promise<void>;
20
+ getRecordStore: (namespace?: string) => {
21
+ get(key: string): Promise<RecordStat | undefined>;
22
+ set(key: string, value: RecordStat): Promise<void>;
23
+ delete(key: string): Promise<void>;
24
+ clear(): Promise<void>;
25
+ keys(): Promise<string[]>;
26
+ values(): Promise<RecordStat[]>;
27
+ entries(): Promise<[string, RecordStat][]>;
28
+ batch(operations: StoreOperations<RecordStat>[]): Promise<GetResult<RecordStat>[]>;
29
+ };
30
+ indexedDB: DatabaseAsync<General, General>;
31
+ memoryDB: {
32
+ getStore<K extends string | number | symbol>(name: K): {
33
+ get(key: string): any;
34
+ set(key: string, value: any): void;
35
+ delete(key: string): void;
36
+ clear(): void;
37
+ keys(): string[];
38
+ values(): any[];
39
+ entries(): [string, any][];
40
+ batch(operations: StoreOperations<any>[]): GetResult<any>[];
41
+ };
42
+ getStoreNames(): string[];
43
+ deleteStore(name: string): void;
44
+ clearStores(): void;
45
+ getMeta<T extends string | number | symbol>(key: T): any;
46
+ setMeta<T extends string | number | symbol>(key: T, value: any): void;
47
+ dispose(): void;
48
+ };
49
+ recordStoreExists: (namespace?: string) => Promise<boolean>;
50
+ };
51
+ readonly dispose: () => void;
52
+ }
53
+ //#endregion
54
+ export { RecordStore, Storage as default };