mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-06-17 03:40:14 +00:00
fix a bit some, node-importing is now barrelled into one file.
This commit is contained in:
@@ -25,7 +25,7 @@ export declare class EntryManager {
|
||||
setting: ISettingService;
|
||||
path: IPathService;
|
||||
};
|
||||
serviceModules: {};
|
||||
serviceModules: never;
|
||||
};
|
||||
get isOnDemandChunkEnabled(): boolean;
|
||||
isTargetFile(filenameSrc: string): boolean;
|
||||
|
||||
@@ -57,7 +57,6 @@ export type AllReplicationClientStatus = {
|
||||
export declare class TrysteroReplicator {
|
||||
_env: ReplicatorHostEnv;
|
||||
server?: P2PHost;
|
||||
replicationStatus(): {};
|
||||
get settings(): import("@lib/common/models/setting.type").P2PSyncSetting;
|
||||
get db(): PouchDB.Database<EntryDoc>;
|
||||
get deviceName(): string;
|
||||
|
||||
@@ -4,9 +4,18 @@ try {
|
||||
fs.rmSync("./_types", { recursive: true, force: true });
|
||||
console.log("[Postbuild] Generating type definitions for fallback...");
|
||||
execSync("npx tsc -p tsconfig.types.json", { stdio: "inherit" });
|
||||
|
||||
console.log("[Postbuild] Type definitions generated successfully.");
|
||||
} catch (error) {
|
||||
// Ignore compiler errors from tsc so that pre-existing type errors in the submodule
|
||||
// do not block the build from succeeding.
|
||||
console.warn("[Postbuild] Type definitions generated with some compilation warnings.");
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("[Postbuild] Type definitions generated successfully. Adding ignore comments...");
|
||||
execSync("Deno run -A ./utilsdeno/types-add-ignore.ts", { stdio: "inherit" });
|
||||
console.log("[Postbuild] Ignore comments added successfully.");
|
||||
} catch (error) {
|
||||
console.warn("[Postbuild] Failed to add ignore comments to type definitions.");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as path from "path";
|
||||
import { nodePath as path } from "@cli/lib/nodeModules";
|
||||
import type { UXFileInfoStub, UXFolderInfo } from "@lib/common/models/fileaccess.type";
|
||||
import type { IConversionAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { NodeFile, NodeFolder } from "./NodeTypes";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { nodePath as path, fs } from "@cli/lib/nodeModules";
|
||||
import type { FilePath } from "@lib/common/models/db.type";
|
||||
import type { UXStat } from "@lib/common/models/fileaccess.type";
|
||||
import type { IFileSystemAdapter } from "@lib/serviceModules/adapters";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as path from "path";
|
||||
import { nodePath as path } from "@cli/lib/nodeModules";
|
||||
import type { FilePath } from "@lib/common/models/db.type";
|
||||
import type { IPathAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { NodeFile } from "./NodeTypes";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { nodePath as path, fs } from "@cli/lib/nodeModules";
|
||||
import type { UXDataWriteOptions } from "@lib/common/models/fileaccess.type";
|
||||
import type { IStorageAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { NodeStat } from "./NodeTypes";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { nodePath as path, fs } from "@cli/lib/nodeModules";
|
||||
import type { UXDataWriteOptions } from "@lib/common/models/fileaccess.type";
|
||||
import type { IVaultAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { NodeFile, NodeFolder } from "./NodeTypes";
|
||||
|
||||
@@ -2,13 +2,14 @@ import { P2P_DEFAULT_SETTINGS } from "@lib/common/models/setting.const.defaults"
|
||||
import { LiveSyncTrysteroReplicator } from "@lib/replication/trystero/LiveSyncTrysteroReplicator";
|
||||
import type { ServiceContext } from "@lib/services/base/ServiceBase";
|
||||
import type { LiveSyncBaseCore } from "@/LiveSyncBaseCore";
|
||||
import { compatGlobal } from "@lib/common/coreEnvFunctions";
|
||||
type CLIP2PPeer = {
|
||||
peerId: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export function parseTimeoutSeconds(value: string, commandName: string): number {
|
||||
|
||||
@@ -10,14 +10,14 @@ import { performFullScan } from "@lib/serviceFeatures/offlineScanner";
|
||||
import { activateRemoteConfiguration, createRemoteConfigurationId } from "@lib/serviceFeatures/remoteConfig";
|
||||
import { UnresolvedErrorManager } from "@lib/services/base/UnresolvedErrorManager";
|
||||
import { stripAllPrefixes } from "@lib/string_and_binary/path";
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { nodePath as path, fs } from "@cli/lib/nodeModules";
|
||||
import { collectPeers, openP2PHost, parseTimeoutSeconds, syncWithPeer } from "./p2p";
|
||||
import type { CLICommandContext, CLIOptions } from "./types";
|
||||
import { promptForPassphrase, readStdinAsUtf8, toArrayBuffer, toDatabaseRelativePath } from "./utils";
|
||||
import type { EntryMilestoneInfo } from "@lib/common/models/db.definition";
|
||||
import type { LiveSyncCouchDBReplicator } from "@lib/replication/couchdb/LiveSyncReplicator";
|
||||
import type { LiveSyncJournalReplicator } from "@lib/replication/journal/LiveSyncJournalReplicator";
|
||||
import { compatGlobal } from "@lib/common/coreEnvFunctions";
|
||||
|
||||
function redactConnectionString(uri: string): string {
|
||||
return uri.replace(/\/\/([^@/]+)@/u, "//***@");
|
||||
@@ -156,11 +156,11 @@ export async function runCommand(options: CLIOptions, context: CLICommandContext
|
||||
);
|
||||
}
|
||||
}
|
||||
pollTimer = setTimeout(poll as unknown as () => void, currentIntervalMs);
|
||||
pollTimer = compatGlobal.setTimeout(poll as unknown as () => void, currentIntervalMs);
|
||||
};
|
||||
let pollTimer: ReturnType<typeof setTimeout> = setTimeout(poll as unknown as () => void, currentIntervalMs);
|
||||
let pollTimer: number = compatGlobal.setTimeout(poll as unknown as () => void, currentIntervalMs);
|
||||
core.services.appLifecycle.onUnload.addHandler(async () => {
|
||||
clearTimeout(pollTimer);
|
||||
compatGlobal.clearTimeout(pollTimer);
|
||||
return await Promise.resolve(true);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import * as path from "path";
|
||||
import * as readline from "node:readline/promises";
|
||||
|
||||
import { nodePath as path, readline } from "@cli/lib/nodeModules";
|
||||
export function toArrayBuffer(data: Buffer): ArrayBuffer {
|
||||
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as nodePath from "node:path";
|
||||
import * as nodeFs from "node:fs";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as readline from "node:readline/promises";
|
||||
import type { Stats } from "node:fs";
|
||||
export { nodePath, nodeFs, fs, readline, type Stats };
|
||||
@@ -3,9 +3,8 @@
|
||||
* Command-line version of Self-hosted LiveSync plugin for syncing vaults without Obsidian
|
||||
*/
|
||||
|
||||
import * as fs from "fs/promises";
|
||||
import * as fsSync from "fs";
|
||||
import * as path from "path";
|
||||
import { nodePath as path, fs, nodeFs as fsSync } from "@cli/lib/nodeModules";
|
||||
|
||||
import { NodeServiceContext, NodeServiceHub } from "./services/NodeServiceHub";
|
||||
import { configureNodeLocalStorage, ensureGlobalNodeLocalStorage } from "./services/NodeLocalStorage";
|
||||
import { LiveSyncBaseCore } from "@/LiveSyncBaseCore";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { nodePath as path, fs, type Stats } from "@cli/lib/nodeModules";
|
||||
import type { FilePath } from "@lib/common/models/db.type";
|
||||
import type { FileEventItem, UXFileInfoStub, UXInternalFileInfoStub } from "@lib/common/models/fileaccess.type";
|
||||
import type {
|
||||
@@ -11,9 +12,6 @@ import type {
|
||||
} from "@lib/managers/adapters";
|
||||
import type { FileEventItemSentinel } from "@lib/managers/StorageEventManager";
|
||||
import { watch as chokidarWatch, type FSWatcher } from "chokidar";
|
||||
import type { Stats } from "fs";
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import type { NodeFile, NodeFolder } from "@cli/adapters/NodeTypes";
|
||||
import type { IgnoreRules } from "@cli/serviceModules/IgnoreRules";
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
|
||||
import { fs, nodePath as path } from "@cli/lib/nodeModules";
|
||||
import { minimatch } from "minimatch";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { nodeFs, nodePath } from "@cli/lib/nodeModules";
|
||||
import { LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE } from "@lib/common/logger";
|
||||
import type { KeyValueDatabase } from "@lib/interfaces/KeyValueDatabase";
|
||||
import type { IKeyValueDBService, IVaultService } from "@lib/services/base/IService";
|
||||
@@ -5,8 +6,6 @@ import { ServiceBase, type ServiceContext } from "@lib/services/base/ServiceBase
|
||||
import type { InjectableAppLifecycleService } from "@lib/services/implements/injectable/InjectableAppLifecycleService";
|
||||
import type { InjectableDatabaseEventService } from "@lib/services/implements/injectable/InjectableDatabaseEventService";
|
||||
import { createInstanceLogFunction } from "@lib/services/lib/logUtils";
|
||||
import * as nodeFs from "node:fs";
|
||||
import * as nodePath from "node:path";
|
||||
import type { SimpleStore } from "octagonal-wheels/databases/SimpleStoreBase";
|
||||
|
||||
const NODE_KV_TYPED_KEY = "__nodeKvType";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as nodeFs from "node:fs";
|
||||
import * as nodePath from "node:path";
|
||||
import { nodeFs, nodePath } from "@cli/lib/nodeModules";
|
||||
|
||||
type LocalStorageShape = {
|
||||
getItem(key: string): string | null;
|
||||
|
||||
@@ -18,13 +18,14 @@ import { InjectableServiceHub } from "@lib/services/implements/injectable/Inject
|
||||
import { InjectableTestService } from "@lib/services/implements/injectable/InjectableTestService";
|
||||
import { InjectableTweakValueService } from "@lib/services/implements/injectable/InjectableTweakValueService";
|
||||
import { InjectableVaultServiceCompat } from "@lib/services/implements/injectable/InjectableVaultService";
|
||||
import * as nodePath from "node:path";
|
||||
|
||||
// import { HeadlessDatabaseService } from "@lib/services/implements/headless/HeadlessDatabaseService";
|
||||
import type { ObsidianLiveSyncSettings } from "@lib/common/models/setting.type";
|
||||
import { DatabaseService } from "@lib/services/base/DatabaseService";
|
||||
import type { ServiceInstances } from "@lib/services/ServiceHub";
|
||||
import { NodeKeyValueDBService } from "./NodeKeyValueDBService";
|
||||
import { NodeSettingService } from "./NodeSettingService";
|
||||
import { nodePath } from "@cli/lib/nodeModules";
|
||||
|
||||
export class NodeServiceContext extends ServiceContext {
|
||||
databasePath: string;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { SetupManager } from "@/modules/features/SetupManager";
|
||||
import { useSetupManagerHandlersFeature } from "@/serviceFeatures/setupObsidian/setupManagerHandlers";
|
||||
import { useP2PReplicatorCommands } from "@lib/replication/trystero/useP2PReplicatorCommands";
|
||||
import { useP2PReplicatorFeature } from "@lib/replication/trystero/useP2PReplicatorFeature";
|
||||
import { compatGlobal } from "@lib/common/coreEnvFunctions";
|
||||
|
||||
const SETTINGS_DIR = ".livesync";
|
||||
const SETTINGS_FILE = "settings.json";
|
||||
@@ -103,7 +104,7 @@ class LiveSyncWebApp {
|
||||
console.log("[AppLifecycle] Restart requested");
|
||||
await this.shutdown();
|
||||
await this.initialize();
|
||||
setTimeout(() => {
|
||||
compatGlobal.setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
@@ -34,6 +34,7 @@ import { SimpleStoreIDBv2 } from "octagonal-wheels/databases/SimpleStoreIDBv2";
|
||||
import type { BrowserAPIService } from "@lib/services/implements/browser/BrowserAPIService";
|
||||
import type { InjectableSettingService } from "@lib/services/implements/injectable/InjectableSettingService";
|
||||
import { LiveSyncTrysteroReplicator } from "@lib/replication/trystero/LiveSyncTrysteroReplicator";
|
||||
import { compatGlobal } from "@lib/common/coreEnvFunctions";
|
||||
|
||||
function addToList(item: string, list: string) {
|
||||
return unique(
|
||||
@@ -153,7 +154,7 @@ export class P2PReplicatorShim implements P2PReplicatorBase {
|
||||
|
||||
this._initP2PReplicator();
|
||||
|
||||
setTimeout(() => {
|
||||
compatGlobal.setTimeout(() => {
|
||||
if (this.settings.P2P_AutoStart && this.settings.P2P_Enabled) {
|
||||
void this.open();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function processFile(filePath: string) {
|
||||
return updatedSourceText;
|
||||
}
|
||||
|
||||
const targetDir = `../_types/`;
|
||||
const targetDir = `./_types/`;
|
||||
|
||||
async function processDir(dirPath: string) {
|
||||
for await (const entry of Deno.readDir(dirPath)) {
|
||||
|
||||
Reference in New Issue
Block a user