mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-06-19 12:50:19 +00:00
more tweaks
This commit is contained in:
+3
-3
@@ -26,7 +26,7 @@ type BaseRule<TType extends string, TValue> = {
|
||||
valueDisplayFunc?: (settings: Partial<ObsidianLiveSyncSettings>) => string;
|
||||
obsoleteValues?: TValue[];
|
||||
};
|
||||
type NumberRuleExact = BaseRule<"number", number> & {};
|
||||
type NumberRuleExact = BaseRule<"number", number> & {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
type NumberRuleRange = BaseRule<"number", number> & {
|
||||
min?: number;
|
||||
max?: number;
|
||||
@@ -37,8 +37,8 @@ type StringRangeRule = BaseRule<"string", string> & {
|
||||
maxLength?: number;
|
||||
regexp?: string;
|
||||
};
|
||||
type StringRule = BaseRule<"string", string> & {};
|
||||
type BooleanRule = BaseRule<"boolean", boolean> & {};
|
||||
type StringRule = BaseRule<"string", string> & {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
type BooleanRule = BaseRule<"boolean", boolean> & {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
export type RuleForType<T> = T extends number ? NumberRuleExact | NumberRuleRange : T extends string ? StringRule | StringRangeRule : T extends boolean ? BooleanRule : never;
|
||||
type DoctorCheckSettings = Omit<Partial<ObsidianLiveSyncSettings>, "remoteConfigurations" | "pluginSyncExtendedSetting">;
|
||||
export type DoctorRegulation = {
|
||||
|
||||
+1
-1
@@ -891,7 +891,7 @@ export interface RemoteConfigurations {
|
||||
*/
|
||||
P2P_ActiveRemoteConfigurationId: string;
|
||||
}
|
||||
interface ObsidianLiveSyncSettings_PluginSetting extends SyncMethodSettings, UISettings, FileHandlingSettings, MergeBehaviourSettings, EncryptedUserSettings, PeriodicReplicationSettings, InternalFileSettings, PluginSyncSettings, ModeSettings, ExtraTweakSettings, BetaTweakSettings, ObsoleteSettings, DebugModeSettings, SettingSyncSettings, SafetyValveSettings, DataOnSettings, RemoteConfigurations {
|
||||
interface ObsidianLiveSyncSettings_PluginSetting extends SyncMethodSettings, UISettings, FileHandlingSettings, MergeBehaviourSettings, EncryptedUserSettings, PeriodicReplicationSettings, InternalFileSettings, PluginSyncSettings, ModeSettings, ExtraTweakSettings, BetaTweakSettings, ObsoleteSettings, DebugModeSettings, SettingSyncSettings, SafetyValveSettings, DataOnSettings, RemoteConfigurations { // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface
|
||||
}
|
||||
export type RemoteDBSettings = CouchDBConnection & BucketSyncSetting & RemoteTypeSettings & EncryptionSettings & ChunkSettings & EdenSettings & DataOnRemoteDBSettings & ObsoleteRemoteDBSettings & OnDemandChunkSettings & BetaRemoteDBSettings & ReplicationSetting & RemoteDBTweakSettings & FileHandlingSettings & ProcessingBehaviourSettings & OptionalAndNotExposedRemoteDBSettings & CrossPlatformInteroperabilitySettings & ConflictHandlingSettings & EdgeCaseHandlingSettings & DeletedFileMetadataSettings & P2PSyncSetting & RemoteConfigurations;
|
||||
export type ObsidianLiveSyncSettings = ObsidianLiveSyncSettings_PluginSetting & RemoteDBSettings & LocalDBSettings;
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ export type CustomRegExpSourceList<D extends string = ","> = TaggedType<string,
|
||||
export type ParsedCustomRegExp = [isInverted: boolean, pattern: string];
|
||||
export type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
} & {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
|
||||
Vendored
+3
-3
@@ -27,11 +27,11 @@ export declare const Parallels: (ps?: Set<Promise<unknown>>) => {
|
||||
export declare function allSettledWithConcurrencyLimit<T>(processes: Promise<T>[], limit: number): Promise<void>;
|
||||
export declare function getDocData(doc: string | string[]): string;
|
||||
export declare function getDocDataAsArray(doc: string | string[]): string[];
|
||||
export declare function getDocDataAsArrayBuffer(doc: string | string[] | ArrayBuffer): Uint8Array<ArrayBuffer>;
|
||||
export declare function getDocDataAsArrayBuffer(doc: string | string[] | ArrayBuffer): Uint8Array;
|
||||
export declare function isTextBlob(blob: Blob): boolean;
|
||||
export declare function createTextBlob(data: string | string[]): Blob;
|
||||
export declare function createBinaryBlob(data: Uint8Array<ArrayBuffer> | ArrayBuffer): Blob;
|
||||
export declare function createBlob(data: string | string[] | Uint8Array<ArrayBuffer> | ArrayBuffer | Blob): Blob;
|
||||
export declare function createBinaryBlob(data: Uint8Array | ArrayBuffer): Blob;
|
||||
export declare function createBlob(data: string | string[] | Uint8Array | ArrayBuffer | Blob): Blob;
|
||||
export declare function isTextDocument(doc: LoadedEntry): boolean;
|
||||
export declare function readAsBlob(doc: LoadedEntry): Blob;
|
||||
export declare function readContent(doc: LoadedEntry): string | ArrayBuffer;
|
||||
|
||||
@@ -25,7 +25,7 @@ export declare class EntryManager {
|
||||
setting: ISettingService;
|
||||
path: IPathService;
|
||||
};
|
||||
serviceModules: {};
|
||||
serviceModules: {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
};
|
||||
get isOnDemandChunkEnabled(): boolean;
|
||||
isTargetFile(filenameSrc: string): boolean;
|
||||
|
||||
+3
-3
@@ -2,11 +2,11 @@
|
||||
import * as fflate from "fflate";
|
||||
import type { EntryDoc } from "@lib/common/types";
|
||||
export declare function _compressText(text: string): Promise<string>;
|
||||
export declare const wrappedInflate: (data: Uint8Array<ArrayBuffer>, opts: fflate.AsyncInflateOptions) => Promise<Uint8Array<ArrayBuffer>>;
|
||||
export declare const wrappedDeflate: (data: Uint8Array<ArrayBuffer>, opts: fflate.AsyncDeflateOptions) => Promise<Uint8Array<ArrayBuffer>>;
|
||||
export declare const wrappedInflate: (data: Uint8Array, opts: fflate.AsyncInflateOptions) => Promise<Uint8Array>;
|
||||
export declare const wrappedDeflate: (data: Uint8Array, opts: fflate.AsyncDeflateOptions) => Promise<Uint8Array>;
|
||||
export declare function _decompressText(compressed: string, _useUTF16?: boolean): Promise<string>;
|
||||
export declare function compressDoc(doc: EntryDoc): Promise<import("@lib/common/types").NoteEntry | import("@lib/common/types").NewEntry | import("@lib/common/types").PlainEntry | import("@lib/common/types").EntryLeaf | import("@lib/common/types").EntryChunkPack | import("@lib/common/types").EntryVersionInfo | import("@lib/common/types").EntryMilestoneInfo | import("@lib/common/types").EntryNodeInfo>;
|
||||
export declare function decompressDoc(doc: EntryDoc): Promise<import("@lib/common/types").NoteEntry | import("@lib/common/types").NewEntry | import("@lib/common/types").PlainEntry | import("@lib/common/types").EntryLeaf | import("@lib/common/types").EntryChunkPack | import("@lib/common/types").EntryVersionInfo | import("@lib/common/types").EntryMilestoneInfo | import("@lib/common/types").EntryNodeInfo>;
|
||||
export declare function wrapFflateFunc<T, U>(func: (data: T, opts: U, cb: fflate.FlateCallback) => unknown): (data: T, opts: U) => Promise<Uint8Array<ArrayBuffer>>;
|
||||
export declare function wrapFflateFunc<T, U>(func: (data: T, opts: U, cb: fflate.FlateCallback) => unknown): (data: T, opts: U) => Promise<Uint8Array>;
|
||||
export declare const replicationFilter: (db: PouchDB.Database<EntryDoc>, compress: boolean) => void;
|
||||
export declare const MARK_SHIFT_COMPRESSED = "\u000ELZ\u001D";
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ export declare const encryptHKDF: typeof encryptHKDFWorker;
|
||||
export declare const decryptHKDF: typeof decryptHKDFWorker;
|
||||
export declare let preprocessOutgoing: (doc: AnyEntry | EntryLeaf) => Promise<AnyEntry | EntryLeaf>;
|
||||
export declare let preprocessIncoming: (doc: EntryDoc) => Promise<EntryDoc>;
|
||||
export declare function getConfiguredFunctionsForEncryption(passphrase: string, useDynamicIterationCount: boolean, migrationDecrypt: boolean, getPBKDF2Salt: () => Promise<Uint8Array<ArrayBuffer>>, algorithm: E2EEAlgorithm): {
|
||||
export declare function getConfiguredFunctionsForEncryption(passphrase: string, useDynamicIterationCount: boolean, migrationDecrypt: boolean, getPBKDF2Salt: () => Promise<Uint8Array>, algorithm: E2EEAlgorithm): {
|
||||
incoming: (doc: AnyEntry | EntryLeaf) => Promise<AnyEntry | EntryLeaf>;
|
||||
outgoing: (doc: EntryDoc) => Promise<AnyEntry | EntryLeaf>;
|
||||
};
|
||||
export declare const enableEncryption: (db: PouchDB.Database<EntryDoc>, passphrase: string, useDynamicIterationCount: boolean, migrationDecrypt: boolean, getPBKDF2Salt: () => Promise<Uint8Array<ArrayBuffer>>, algorithm: E2EEAlgorithm) => void;
|
||||
export declare const enableEncryption: (db: PouchDB.Database<EntryDoc>, passphrase: string, useDynamicIterationCount: boolean, migrationDecrypt: boolean, getPBKDF2Salt: () => Promise<Uint8Array>, algorithm: E2EEAlgorithm) => void;
|
||||
export declare function disableEncryption(): void;
|
||||
export declare const EDEN_ENCRYPTED_KEY: DocumentID;
|
||||
export declare const EDEN_ENCRYPTED_KEY_HKDF: DocumentID;
|
||||
|
||||
@@ -39,7 +39,7 @@ export declare abstract class LiveSyncAbstractReplicator {
|
||||
get rawDatabase(): PouchDB.Database<EntryDoc>;
|
||||
get currentSettings(): import("@lib/common/types.ts").ObsidianLiveSyncSettings;
|
||||
sendChunks(setting: RemoteDBSettings, remoteDB: PouchDB.Database<EntryDoc> | undefined, showResult: boolean, fromSeq?: number | string): Promise<boolean>;
|
||||
abstract getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
||||
abstract getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array>;
|
||||
ensurePBKDF2Salt(setting: RemoteDBSettings, showMessage?: boolean, useCache?: boolean): Promise<boolean>;
|
||||
env: LiveSyncReplicatorEnv;
|
||||
initializeDatabaseForReplication(): Promise<boolean>;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ type CreateSyncParamsHanderOptions = {
|
||||
};
|
||||
export type SyncParamsHandler = {
|
||||
fetch: (refresh?: boolean) => Promise<SyncParameters | false>;
|
||||
getPBKDF2Salt: (refresh?: boolean) => Promise<Uint8Array<ArrayBuffer>>;
|
||||
getPBKDF2Salt: (refresh?: boolean) => Promise<Uint8Array>;
|
||||
};
|
||||
export declare function createSyncParamsHanderForServer(key: string, options: CreateSyncParamsHanderOptions): SyncParamsHandler;
|
||||
export declare function clearHandlers(): void;
|
||||
|
||||
@@ -12,7 +12,7 @@ export declare class LiveSyncCouchDBReplicator extends LiveSyncAbstractReplicato
|
||||
getInitialSyncParameters(setting: RemoteDBSettings): Promise<SyncParameters>;
|
||||
getSyncParameters(setting: RemoteDBSettings): Promise<SyncParameters>;
|
||||
putSyncParameters(setting: RemoteDBSettings, params: SyncParameters): Promise<boolean>;
|
||||
getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
||||
getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array>;
|
||||
migrate(from: number, to: number): Promise<boolean>;
|
||||
terminateSync(): void;
|
||||
openReplication(setting: RemoteDBSettings, keepAlive: boolean, showResult: boolean, ignoreCleanLock: boolean): Promise<boolean | undefined>;
|
||||
|
||||
@@ -60,12 +60,12 @@ export declare abstract class JournalSyncAbstract {
|
||||
abstract listFiles(from: string, limit?: number): Promise<string[]>;
|
||||
abstract isAvailable(): Promise<boolean>;
|
||||
getRemoteKey(): string;
|
||||
getReplicationPBKDF2Salt(refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
||||
getReplicationPBKDF2Salt(refresh?: boolean): Promise<Uint8Array>;
|
||||
isEncryptionPrevented(fileName: string): boolean;
|
||||
private decryptDataV2;
|
||||
private decryptDataV1;
|
||||
decryptDownloaded(key: string, encrypted: Uint8Array<ArrayBuffer>, set: RemoteDBSettings): Promise<Uint8Array<ArrayBuffer>>;
|
||||
encryptForUpload(key: string, data: Uint8Array<ArrayBuffer>, set: RemoteDBSettings): Promise<Uint8Array<ArrayBuffer>>;
|
||||
decryptDownloaded(key: string, encrypted: Uint8Array, set: RemoteDBSettings): Promise<Uint8Array>;
|
||||
encryptForUpload(key: string, data: Uint8Array, set: RemoteDBSettings): Promise<Uint8Array>;
|
||||
_createJournalPack(override?: number | string): Promise<{
|
||||
changes: (EntryDoc & PouchDB.Core.GetMeta)[];
|
||||
hasNext: boolean;
|
||||
|
||||
@@ -12,7 +12,7 @@ export declare class LiveSyncJournalReplicator extends LiveSyncAbstractReplicato
|
||||
get client(): JournalSyncMinio;
|
||||
get simpleStore(): SimpleStore<CheckPointInfo>;
|
||||
_client: JournalSyncMinio;
|
||||
getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
||||
getReplicationPBKDF2Salt(setting: RemoteDBSettings, refresh?: boolean): Promise<Uint8Array>;
|
||||
setupJournalSyncClient(): JournalSyncMinio;
|
||||
ensureBucketIsCompatible(deviceNodeID: string, currentVersionRange: ChunkVersionRange): Promise<ENSURE_DB_RESULT>;
|
||||
constructor(env: LiveSyncJournalReplicatorEnv);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// REPO: https://github.com/vrtmrz/livesync-commonlib Commit hash: 6de1db1
|
||||
import type { LiveSyncReplicatorEnv } from "@lib/replication/LiveSyncAbstractReplicator";
|
||||
export interface LiveSyncJournalReplicatorEnv extends LiveSyncReplicatorEnv {
|
||||
export interface LiveSyncJournalReplicatorEnv extends LiveSyncReplicatorEnv { // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export declare class LiveSyncTrysteroReplicator extends LiveSyncAbstractReplicat
|
||||
get rawReplicator(): TrysteroReplicator | undefined;
|
||||
get rawHost(): P2PHost | undefined;
|
||||
get isChunkSendingSupported(): boolean;
|
||||
getReplicationPBKDF2Salt(_setting: RemoteDBSettings, _refresh?: boolean): Promise<Uint8Array<ArrayBuffer>>;
|
||||
getReplicationPBKDF2Salt(_setting: RemoteDBSettings, _refresh?: boolean): Promise<Uint8Array>;
|
||||
terminateSync(): void;
|
||||
private _buildEnv;
|
||||
open(): Promise<void>;
|
||||
|
||||
@@ -57,7 +57,7 @@ export type AllReplicationClientStatus = {
|
||||
export declare class TrysteroReplicator {
|
||||
_env: ReplicatorHostEnv;
|
||||
server?: P2PHost;
|
||||
replicationStatus(): {};
|
||||
replicationStatus(): {}; // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type
|
||||
get settings(): import("@lib/common/types").P2PSyncSetting;
|
||||
get db(): PouchDB.Database<EntryDoc>;
|
||||
get deviceName(): string;
|
||||
|
||||
+10
-1
@@ -1,5 +1,4 @@
|
||||
// REPO: https://github.com/vrtmrz/livesync-commonlib Commit hash: 6de1db1
|
||||
import EventEmitter from "events";
|
||||
import type { RpcSession } from "@lib/rpc/RpcSession";
|
||||
/**
|
||||
* A PouchDB-compatible proxy that forwards all database operations to a remote
|
||||
@@ -74,3 +73,13 @@ export declare class RpcPouchDBProxy extends EventEmitter {
|
||||
revsDiff(diff: PouchDB.Core.RevisionDiffOptions): Promise<PouchDB.Core.RevisionDiffResponse>;
|
||||
allDocs<T extends object>(opts?: PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsResponse<T>>;
|
||||
}
|
||||
|
||||
class EventEmitter {
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
emit(event: string | symbol, ...args: any[]): boolean; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
removeAllListeners(event: string | symbol): this;
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ import type { IAPIService, IPathService, ISettingService, IVaultService } from "
|
||||
import { createInstanceLogFunction } from "@lib/services/lib/logUtils.ts";
|
||||
import type { FileWithFileStat } from "@lib/common/models/fileaccess.type";
|
||||
import type { IFileSystemAdapter } from "./adapters";
|
||||
export declare function toArrayBuffer(arr: Uint8Array<ArrayBuffer> | ArrayBuffer | DataView<ArrayBuffer>): ArrayBuffer;
|
||||
export declare function toArrayBuffer(arr: Uint8Array | ArrayBuffer | DataView): ArrayBuffer;
|
||||
export interface FileAccessBaseDependencies {
|
||||
vaultService: IVaultService;
|
||||
storageAccessManager: IStorageAccessManager;
|
||||
@@ -59,7 +59,7 @@ export declare class FileAccessBase<TAdapter extends IFileSystemAdapter<any, any
|
||||
adapterRead(file: ExtractFile<TAdapter> | string): Promise<string>;
|
||||
adapterReadBinary(file: ExtractFile<TAdapter> | string): Promise<ArrayBuffer>;
|
||||
adapterReadAuto(file: ExtractFile<TAdapter> | string): Promise<string | ArrayBuffer>;
|
||||
adapterWrite(file: ExtractFile<TAdapter> | string, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<void>;
|
||||
adapterWrite(file: ExtractFile<TAdapter> | string, data: string | ArrayBuffer | Uint8Array, options?: UXDataWriteOptions): Promise<void>;
|
||||
adapterList(basePath: string): Promise<{
|
||||
files: string[];
|
||||
folders: string[];
|
||||
@@ -68,8 +68,8 @@ export declare class FileAccessBase<TAdapter extends IFileSystemAdapter<any, any
|
||||
vaultRead(file: ExtractFile<TAdapter>): Promise<string>;
|
||||
vaultReadBinary(file: ExtractFile<TAdapter>): Promise<ArrayBuffer>;
|
||||
vaultReadAuto(file: ExtractFile<TAdapter>): Promise<string | ArrayBuffer>;
|
||||
vaultModify(file: ExtractFile<TAdapter>, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<boolean>;
|
||||
vaultCreate(path: string, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<ExtractFile<TAdapter>>;
|
||||
vaultModify(file: ExtractFile<TAdapter>, data: string | ArrayBuffer | Uint8Array, options?: UXDataWriteOptions): Promise<boolean>;
|
||||
vaultCreate(path: string, data: string | ArrayBuffer | Uint8Array, options?: UXDataWriteOptions): Promise<ExtractFile<TAdapter>>;
|
||||
trigger(name: string, ...data: unknown[]): void;
|
||||
reconcileInternalFile(path: string): Promise<void>;
|
||||
/**
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ export interface IReplicationService {
|
||||
markResolved(): Promise<void>;
|
||||
}
|
||||
export interface IRemoteService {
|
||||
connect(uri: string, auth: CouchDBCredentials, disableRequestURI: boolean, passphrase: string | false, useDynamicIterationCount: boolean, performSetup: boolean, skipInfo: boolean, compression: boolean, customHeaders: Record<string, string>, useRequestAPI: boolean, getPBKDF2Salt: () => Promise<Uint8Array<ArrayBuffer>>): Promise<string | {
|
||||
connect(uri: string, auth: CouchDBCredentials, disableRequestURI: boolean, passphrase: string | false, useDynamicIterationCount: boolean, performSetup: boolean, skipInfo: boolean, compression: boolean, customHeaders: Record<string, string>, useRequestAPI: boolean, getPBKDF2Salt: () => Promise<Uint8Array>): Promise<string | {
|
||||
db: PouchDB.Database<EntryDoc>;
|
||||
info: PouchDB.Core.DatabaseInfo;
|
||||
}>;
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ export declare abstract class RemoteService<T extends ServiceContext = ServiceCo
|
||||
showError(msg: string, max_log_level?: LOG_LEVEL): void;
|
||||
clearErrors(): void;
|
||||
performFetch(req: string | Request, opts?: RequestInit, fetchMethod?: FetchMethod): Promise<Response>;
|
||||
connect(uri: string, auth: CouchDBCredentials, disableRequestURI: boolean, passphrase: string | false, useDynamicIterationCount: boolean, performSetup: boolean, skipInfo: boolean, compression: boolean, customHeaders: Record<string, string>, useRequestAPI: boolean, getPBKDF2Salt: () => Promise<Uint8Array<ArrayBuffer>>): Promise<string | {
|
||||
connect(uri: string, auth: CouchDBCredentials, disableRequestURI: boolean, passphrase: string | false, useDynamicIterationCount: boolean, performSetup: boolean, skipInfo: boolean, compression: boolean, customHeaders: Record<string, string>, useRequestAPI: boolean, getPBKDF2Salt: () => Promise<Uint8Array>): Promise<string | {
|
||||
db: PouchDB.Database<EntryDoc>;
|
||||
info: PouchDB.Core.DatabaseInfo;
|
||||
}>;
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ export interface DispatcherHandler<T extends unknown[], U> {
|
||||
/**
|
||||
* An interface for dispatch handlers that can add and remove handler functions.
|
||||
*/
|
||||
export interface DispatchHandler<T extends unknown[], U> extends DispatcherHandler<T, U>, MultiRegisterHandler<T, U> {
|
||||
export interface DispatchHandler<T extends unknown[], U> extends DispatcherHandler<T, U>, MultiRegisterHandler<T, U> { // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface
|
||||
}
|
||||
/**
|
||||
* A binder that allows assigning and invoking a single handler function.
|
||||
@@ -312,9 +312,9 @@ export interface BooleanMultipleHandlerFunction<TFunc extends (...args: any[]) =
|
||||
*/
|
||||
removeHandler: (callback: TFunc) => void;
|
||||
}
|
||||
export interface MultiBinderInstance<T extends unknown[], U> extends InvokableHandler<T, U>, MultiRegisterHandler<T, U> {
|
||||
export interface MultiBinderInstance<T extends unknown[], U> extends InvokableHandler<T, U>, MultiRegisterHandler<T, U> { // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface
|
||||
}
|
||||
export interface BooleanMultiBinderInstance<T extends unknown[]> extends InvokableBooleanHandler<T>, MultiRegisterHandler<T, boolean> {
|
||||
export interface BooleanMultiBinderInstance<T extends unknown[]> extends InvokableBooleanHandler<T>, MultiRegisterHandler<T, boolean> { // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface
|
||||
}
|
||||
export declare function allFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
export declare function bailFirstFailureFunction<TFunc extends (...args: any[]) => Promise<boolean>>(name?: string): BooleanMultipleHandlerFunction<TFunc>; // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// REPO: https://github.com/vrtmrz/livesync-commonlib Commit hash: 6de1db1
|
||||
import { arrayBufferToBase64, base64ToArrayBuffer, base64ToArrayBufferInternalBrowser, readString, writeString, tryConvertBase64ToArrayBuffer } from "octagonal-wheels/binary";
|
||||
export { arrayBufferToBase64, base64ToArrayBuffer, base64ToArrayBufferInternalBrowser, readString, writeString, tryConvertBase64ToArrayBuffer, };
|
||||
export declare function arrayBufferToBase64Single(buffer: Uint8Array<ArrayBuffer> | ArrayBuffer): Promise<string>;
|
||||
export declare function arrayBufferToBase64Single(buffer: Uint8Array | ArrayBuffer): Promise<string>;
|
||||
export { uint8ArrayToHexString, hexStringToUint8Array } from "octagonal-wheels/binary/hex";
|
||||
export { encodeBinaryEach, decodeToArrayBuffer } from "octagonal-wheels/binary/encodedUTF16";
|
||||
export { decodeBinary, encodeBinary } from "octagonal-wheels/binary";
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ export declare function splitPieces2WorkerV2(dataSrc: Blob, pieceSize: number, p
|
||||
export declare function splitPieces2WorkerRabinKarp(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
||||
export declare function encryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
||||
export declare function decryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
||||
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
||||
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
||||
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array): Promise<string>;
|
||||
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array): Promise<string>;
|
||||
export declare const tasks: Map<number, ProcessItem>;
|
||||
/**
|
||||
* Remove a completed (or aborted) task from both the tasks map and its worker's taskKeys set.
|
||||
|
||||
+2
-2
@@ -31,8 +31,8 @@ export declare function splitPieces2WorkerV2(dataSrc: Blob, pieceSize: number, p
|
||||
export declare function splitPieces2WorkerRabinKarp(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
||||
export declare function encryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
||||
export declare function decryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
||||
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
||||
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
||||
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array): Promise<string>;
|
||||
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array): Promise<string>;
|
||||
export declare function startWorker(data: Omit<EncryptHKDFArguments, "key">): EncryptHKDFProcessItem;
|
||||
export declare function startWorker(data: Omit<EncryptArguments, "key">): EncryptProcessItem;
|
||||
export declare function startWorker(data: Omit<SplitArguments, "key">): SplitProcessItem;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ export type EncryptHKDFArguments = {
|
||||
type: "encryptHKDF" | "decryptHKDF";
|
||||
input: string;
|
||||
passphrase: string;
|
||||
pbkdf2Salt: Uint8Array<ArrayBuffer>;
|
||||
pbkdf2Salt: Uint8Array;
|
||||
};
|
||||
export type SplitArguments = {
|
||||
key: number;
|
||||
|
||||
@@ -39,7 +39,7 @@ export declare class DocumentHistoryModal extends Modal {
|
||||
loadRevs(initialRev?: string): Promise<void>;
|
||||
BlobURLs: Map<string, string>;
|
||||
revokeURL(key: string): void;
|
||||
generateBlobURL(key: string, data: Uint8Array<ArrayBuffer>): string;
|
||||
generateBlobURL(key: string, data: Uint8Array): string;
|
||||
prepareContentView(usePreformatted?: boolean): void;
|
||||
appendTextDiff(diff: [number, string][]): void;
|
||||
appendSearchHighlightedText(container: HTMLElement, text: string): void;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ export declare const enum UserMode {
|
||||
/**
|
||||
* Update User Mode - for users who are updating configuration. May be `existing-user` as well, but possibly they want to treat it differently.
|
||||
*/
|
||||
Update = "unknown"
|
||||
Update = "unknown" // eslint-disable-line @typescript-eslint/no-duplicate-enum-values -- Duplicate enum value
|
||||
}
|
||||
/**
|
||||
* Setup Manager to handle onboarding and configuration setup
|
||||
|
||||
@@ -4,9 +4,9 @@ import * as polyfill from "werift";
|
||||
import { main } from "./main";
|
||||
|
||||
const rtcPolyfillCtor = (polyfill as any).RTCPeerConnection;
|
||||
if (typeof (globalThis as any).RTCPeerConnection === "undefined" && typeof rtcPolyfillCtor === "function") {
|
||||
if (typeof (global as any).RTCPeerConnection === "undefined" && typeof rtcPolyfillCtor === "function") {
|
||||
// Fill only the standard WebRTC global in Node CLI runtime.
|
||||
(globalThis as any).RTCPeerConnection = rtcPolyfillCtor;
|
||||
(global as any).RTCPeerConnection = rtcPolyfillCtor;
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
||||
@@ -83,8 +83,8 @@ function createNodeLocalStorageShim(): LocalStorageShape {
|
||||
}
|
||||
|
||||
export function ensureGlobalNodeLocalStorage() {
|
||||
if (!("localStorage" in globalThis) || typeof (globalThis as any).localStorage?.getItem !== "function") {
|
||||
(globalThis as any).localStorage = createNodeLocalStorageShim();
|
||||
if (!("localStorage" in global) || typeof (global as any).localStorage?.getItem !== "function") {
|
||||
(global as any).localStorage = createNodeLocalStorageShim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
/* Path mapping */
|
||||
"paths": {
|
||||
"@/*": ["../../*"],
|
||||
"@lib/*": ["../../lib/src/*"]
|
||||
"@lib/*": ["../../lib/src/*", "../../../_types/src/lib/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["*.ts", "**/*.ts", "**/*.tsx"],
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// "baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["../../*"],
|
||||
"@lib/*": ["../../lib/src/*"]
|
||||
"@lib/*": ["../../lib/src/*", "../../../_types/src/lib/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["*.ts", "**/*.ts", "**/*.tsx", "**/*.svelte"],
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"moduleDetection": "force",
|
||||
"paths": {
|
||||
"@/*": ["../../*"],
|
||||
"@lib/*": ["../../lib/src/*"]
|
||||
"@lib/*": ["../../lib/src/*", "../../../_types/src/lib/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||
|
||||
+121
-23
@@ -1,43 +1,141 @@
|
||||
import { Project, SyntaxKind } from "npm:ts-morph";
|
||||
|
||||
function processFile(filePath: string,origin: string, repoHash: string): string {
|
||||
function processFile(filePath: string, origin: string, repoHash: string): string {
|
||||
const project = new Project();
|
||||
const sourceFile = project.addSourceFileAtPath(filePath);
|
||||
// 0. insert a commit hash comment at the top of the file
|
||||
sourceFile.insertText(0, `// REPO: ${origin} Commit hash: ${repoHash}\n`);
|
||||
|
||||
// 1. Collect all 'any' type nodes in the file
|
||||
const anyTypeNodes = sourceFile.getDescendantsOfKind(SyntaxKind.AnyKeyword);
|
||||
const sourceText = sourceFile.getFullText();
|
||||
const lineBreak = sourceText.includes("\r\n") ? "\r\n" : "\n";
|
||||
const lines = sourceText.split(/\r?\n/);
|
||||
const targetLines = new Set<number>();
|
||||
let updated = false;
|
||||
|
||||
// 2. Collect the line numbers that contain 'any'
|
||||
anyTypeNodes.forEach((anyNode: any) => {
|
||||
const { line } = sourceFile.getLineAndColumnAtPos(anyNode.getStart());
|
||||
targetLines.add(line - 1);
|
||||
// 0. insert a commit hash comment at the top of the file
|
||||
sourceFile.insertText(0, `// REPO: ${origin} Commit hash: ${repoHash}\n`);
|
||||
updated = true;
|
||||
|
||||
// 1. Replacements for Uint8Array<ArrayBuffer> and DataView<ArrayBuffer>
|
||||
let sourceText = sourceFile.getFullText();
|
||||
if (sourceText.includes("Uint8Array<ArrayBuffer>") || sourceText.includes("DataView<ArrayBuffer>")) {
|
||||
sourceText = sourceText.replace(/Uint8Array<ArrayBuffer>/g, "Uint8Array");
|
||||
sourceText = sourceText.replace(/DataView<ArrayBuffer>/g, "DataView");
|
||||
sourceFile.replaceWithText(sourceText);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 2. Remove EventEmitter import from "events" and declare class EventEmitter inline
|
||||
const imports = sourceFile.getImportDeclarations();
|
||||
imports.forEach((importDecl) => {
|
||||
if (importDecl.getModuleSpecifierValue() === "events") {
|
||||
const defaultImport = importDecl.getDefaultImport();
|
||||
if (defaultImport && defaultImport.getText() === "EventEmitter") {
|
||||
importDecl.remove();
|
||||
sourceFile.addClass({
|
||||
name: "EventEmitter",
|
||||
isExported: false,
|
||||
methods: [
|
||||
{ name: "on", parameters: [{ name: "event", type: "string | symbol" }, { name: "listener", type: "(...args: any[]) => void" }], returnType: "this" },
|
||||
{ name: "once", parameters: [{ name: "event", type: "string | symbol" }, { name: "listener", type: "(...args: any[]) => void" }], returnType: "this" },
|
||||
{ name: "off", parameters: [{ name: "event", type: "string | symbol" }, { name: "listener", type: "(...args: any[]) => void" }], returnType: "this" },
|
||||
{ name: "emit", parameters: [{ name: "event", type: "string | symbol" }, { name: "args", isRestParameter: true, type: "any[]" }], returnType: "boolean" },
|
||||
{ name: "addListener", parameters: [{ name: "event", type: "string | symbol" }, { name: "listener", type: "(...args: any[]) => void" }], returnType: "this" },
|
||||
{ name: "removeListener", parameters: [{ name: "event", type: "string | symbol" }, { name: "listener", type: "(...args: any[]) => void" }], returnType: "this" },
|
||||
{ name: "removeAllListeners", parameters: [{ name: "event", isOptional: true, type: "string | symbol" }], returnType: "this" },
|
||||
]
|
||||
});
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Add an inline disable only to lines that contain 'any'
|
||||
for (const lineIndex of targetLines) {
|
||||
// 3. Collect targets for inline disable comments
|
||||
const targetAnyLines = new Set<number>();
|
||||
const targetEmptyObjectLines = new Set<number>();
|
||||
const targetEmptyInterfaceLines = new Set<number>();
|
||||
const targetDuplicateEnumLines = new Set<number>();
|
||||
|
||||
// 3.1. 'any' type nodes
|
||||
const anyTypeNodes = sourceFile.getDescendantsOfKind(SyntaxKind.AnyKeyword);
|
||||
anyTypeNodes.forEach((anyNode: any) => {
|
||||
const { line } = sourceFile.getLineAndColumnAtPos(anyNode.getStart());
|
||||
targetAnyLines.add(line - 1);
|
||||
});
|
||||
|
||||
// 3.2. Empty object type literals {}
|
||||
const typeLiterals = sourceFile.getDescendantsOfKind(SyntaxKind.TypeLiteral);
|
||||
typeLiterals.forEach((node) => {
|
||||
if (node.getMembers().length === 0) {
|
||||
const { line } = sourceFile.getLineAndColumnAtPos(node.getStart());
|
||||
targetEmptyObjectLines.add(line - 1);
|
||||
}
|
||||
});
|
||||
|
||||
// 3.3. Empty interfaces
|
||||
const interfaces = sourceFile.getInterfaces();
|
||||
interfaces.forEach((node) => {
|
||||
if (node.getMembers().length === 0) {
|
||||
const { line } = sourceFile.getLineAndColumnAtPos(node.getStart());
|
||||
targetEmptyInterfaceLines.add(line - 1);
|
||||
}
|
||||
});
|
||||
|
||||
// 3.4. Duplicate enum member values
|
||||
const enums = sourceFile.getEnums();
|
||||
enums.forEach((enumDecl) => {
|
||||
const values = new Set<string>();
|
||||
enumDecl.getMembers().forEach((member) => {
|
||||
const initValue = member.getInitializer()?.getText();
|
||||
if (initValue) {
|
||||
if (values.has(initValue)) {
|
||||
const { line } = sourceFile.getLineAndColumnAtPos(member.getStart());
|
||||
targetDuplicateEnumLines.add(line - 1);
|
||||
} else {
|
||||
values.add(initValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 4. Inject ignore comments line by line
|
||||
const finalSourceText = sourceFile.getFullText();
|
||||
const lineBreak = finalSourceText.includes("\r\n") ? "\r\n" : "\n";
|
||||
const lines = finalSourceText.split(/\r?\n/);
|
||||
|
||||
// 4.1. Add inline disable to lines that contain 'any'
|
||||
for (const lineIndex of targetAnyLines) {
|
||||
const line = lines[lineIndex];
|
||||
if (!line) {
|
||||
continue;
|
||||
}
|
||||
if (line.includes("eslint-disable-line @typescript-eslint/no-explicit-any")) {
|
||||
continue;
|
||||
}
|
||||
if (!line) continue;
|
||||
if (line.includes("eslint-disable-line @typescript-eslint/no-explicit-any")) continue;
|
||||
lines[lineIndex] = `${line} // eslint-disable-line @typescript-eslint/no-explicit-any -- Only type declaration`;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 4.2. Add inline disable to lines that contain empty object {}
|
||||
for (const lineIndex of targetEmptyObjectLines) {
|
||||
const line = lines[lineIndex];
|
||||
if (!line) continue;
|
||||
if (line.includes("eslint-disable-line") || line.includes("eslint-disable-next-line")) continue;
|
||||
lines[lineIndex] = `${line} // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types -- Empty object type`;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 4.3. Add inline disable to lines that contain empty interface
|
||||
for (const lineIndex of targetEmptyInterfaceLines) {
|
||||
const line = lines[lineIndex];
|
||||
if (!line) continue;
|
||||
if (line.includes("eslint-disable-line") || line.includes("eslint-disable-next-line")) continue;
|
||||
lines[lineIndex] = `${line} // eslint-disable-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Empty interface`;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 4.4. Add inline disable to lines with duplicate enums
|
||||
for (const lineIndex of targetDuplicateEnumLines) {
|
||||
const line = lines[lineIndex];
|
||||
if (!line) continue;
|
||||
if (line.includes("eslint-disable-line") || line.includes("eslint-disable-next-line")) continue;
|
||||
lines[lineIndex] = `${line} // eslint-disable-line @typescript-eslint/no-duplicate-enum-values -- Duplicate enum value`;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
const updatedSourceText = lines.join(lineBreak);
|
||||
if (updated) {
|
||||
console.log(`Processed file: ${filePath}`);
|
||||
}
|
||||
// Output the result
|
||||
return updatedSourceText;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user