mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-08-26 13:27:05 +00:00
Why: - Large downloaded batches can outlive the finite remote operation and be suspended before every document reaches the Vault. - The v1.0 activity contract requires local application to remain distinct from remote-operation reporting. Changes: - Add an Obsidian-owned local application activity boundary which reuses Wake Lock policy without incrementing remote activity. - Retain one boundary through queue processing and the final recovery snapshot, releasing and reacquiring it around suspension. - Log final snapshot failures, preserve processing results, and cover the lifecycle with focused tests and documentation.
56 lines
3.4 KiB
TypeScript
56 lines
3.4 KiB
TypeScript
import { InjectableConflictService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableConflictService";
|
|
import { InjectableDatabaseEventService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableDatabaseEventService";
|
|
import { InjectableFileProcessingService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableFileProcessingService";
|
|
import { InjectableRemoteService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableRemoteService";
|
|
import { InjectableReplicationService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableReplicationService";
|
|
import { InjectableReplicatorService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableReplicatorService";
|
|
import { InjectableTestService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableTestService";
|
|
import { InjectableTweakValueService } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableTweakValueService";
|
|
import { ConfigServiceBrowserCompat } from "@vrtmrz/livesync-commonlib/compat/services/implements/browser/ConfigServiceBrowserCompat";
|
|
import type { ObsidianServiceContext } from "@/modules/services/ObsidianServiceContext";
|
|
import { KeyValueDBService } from "@vrtmrz/livesync-commonlib/compat/services/base/KeyValueDBService";
|
|
import { ControlService } from "@vrtmrz/livesync-commonlib/compat/services/base/ControlService";
|
|
import { reactiveSource } from "octagonal-wheels/dataobject/reactive";
|
|
|
|
type ActivityOptions = {
|
|
label?: string;
|
|
};
|
|
|
|
export class ObsidianDatabaseEventService extends InjectableDatabaseEventService<ObsidianServiceContext> {}
|
|
|
|
// InjectableReplicatorService
|
|
export class ObsidianReplicatorService extends InjectableReplicatorService<ObsidianServiceContext> {
|
|
readonly boundedLocalApplicationActivityCount = reactiveSource(0);
|
|
|
|
async runBoundedLocalApplicationActivity<T>(
|
|
task: () => T | PromiseLike<T>,
|
|
options?: ActivityOptions
|
|
): Promise<T> {
|
|
this.boundedLocalApplicationActivityCount.value++;
|
|
try {
|
|
return this.dependencies.activityRunner
|
|
? await this.dependencies.activityRunner.run(task, options)
|
|
: await task();
|
|
} finally {
|
|
this.boundedLocalApplicationActivityCount.value--;
|
|
}
|
|
}
|
|
}
|
|
// InjectableFileProcessingService
|
|
export class ObsidianFileProcessingService extends InjectableFileProcessingService<ObsidianServiceContext> {}
|
|
// InjectableReplicationService
|
|
export class ObsidianReplicationService extends InjectableReplicationService<ObsidianServiceContext> {}
|
|
// InjectableRemoteService
|
|
export class ObsidianRemoteService extends InjectableRemoteService<ObsidianServiceContext> {}
|
|
// InjectableConflictService
|
|
export class ObsidianConflictService extends InjectableConflictService<ObsidianServiceContext> {}
|
|
// InjectableTweakValueService
|
|
export class ObsidianTweakValueService extends InjectableTweakValueService<ObsidianServiceContext> {}
|
|
// InjectableTestService
|
|
export class ObsidianTestService extends InjectableTestService<ObsidianServiceContext> {}
|
|
export class ObsidianConfigService extends ConfigServiceBrowserCompat<ObsidianServiceContext> {}
|
|
|
|
export class ObsidianKeyValueDBService extends KeyValueDBService<ObsidianServiceContext> {}
|
|
|
|
export class ObsidianControlService extends ControlService<ObsidianServiceContext> {}
|