diff --git a/libs/datasource/jwt/src/adapter/yjs/binary.ts b/libs/datasource/jwt/src/adapter/yjs/binary.ts index 5c677a4f51..468710ac4a 100644 --- a/libs/datasource/jwt/src/adapter/yjs/binary.ts +++ b/libs/datasource/jwt/src/adapter/yjs/binary.ts @@ -3,8 +3,8 @@ import { Array as YArray, Map as YMap } from 'yjs'; import { RemoteKvService } from '@toeverything/datasource/remote-kv'; export class YjsRemoteBinaries { - readonly _binaries: YMap>; // binary instance - readonly _remoteStorage?: RemoteKvService; + private readonly _binaries: YMap>; // binary instance + private readonly _remoteStorage?: RemoteKvService; constructor(binaries: YMap>, remote_token?: string) { this._binaries = binaries; diff --git a/libs/datasource/jwt/src/adapter/yjs/block.ts b/libs/datasource/jwt/src/adapter/yjs/block.ts index ad60aa31e0..1f49ad0ed1 100644 --- a/libs/datasource/jwt/src/adapter/yjs/block.ts +++ b/libs/datasource/jwt/src/adapter/yjs/block.ts @@ -32,19 +32,21 @@ type YjsBlockInstanceProps = { }; export class YjsBlockInstance implements BlockInstance { - readonly _id: string; - readonly _block: YMap; - readonly _binary?: YArray; - readonly _children: YArray; - readonly _setBlock: ( + private readonly _id: string; + private readonly _block: YMap; + private readonly _binary?: YArray; + private readonly _children: YArray; + private readonly _setBlock: ( id: string, block: BlockItem ) => Promise; - readonly _getUpdated: (id: string) => number | undefined; - readonly _getCreator: (id: string) => string | undefined; - readonly _getBlockInstance: (id: string) => YjsBlockInstance | undefined; - readonly _childrenListeners: Map; - readonly _contentListeners: Map; + private readonly _getUpdated: (id: string) => number | undefined; + private readonly _getCreator: (id: string) => string | undefined; + private readonly _getBlockInstance: ( + id: string + ) => YjsBlockInstance | undefined; + private readonly _childrenListeners: Map; + private readonly _contentListeners: Map; // eslint-disable-next-line @typescript-eslint/naming-convention _childrenMap: Map; diff --git a/libs/datasource/jwt/src/adapter/yjs/gatekeeper.ts b/libs/datasource/jwt/src/adapter/yjs/gatekeeper.ts index 1ee3e93ca3..7e02c5a09e 100644 --- a/libs/datasource/jwt/src/adapter/yjs/gatekeeper.ts +++ b/libs/datasource/jwt/src/adapter/yjs/gatekeeper.ts @@ -1,10 +1,9 @@ import { Map as YMap } from 'yjs'; export class GateKeeper { - // eslint-disable-next-line @typescript-eslint/naming-convention - _userId: string; - _creators: YMap; - _common: YMap; + private readonly _userId: string; + private readonly _creators: YMap; + private readonly _common: YMap; constructor(userId: string, creators: YMap, common: YMap) { this._userId = userId; diff --git a/libs/datasource/jwt/src/adapter/yjs/history.ts b/libs/datasource/jwt/src/adapter/yjs/history.ts index 34884a1150..6739cf9a50 100644 --- a/libs/datasource/jwt/src/adapter/yjs/history.ts +++ b/libs/datasource/jwt/src/adapter/yjs/history.ts @@ -5,10 +5,10 @@ import { HistoryCallback, HistoryManager } from '../../adapter'; type StackItem = UndoManager['undoStack'][0]; export class YjsHistoryManager implements HistoryManager { - readonly _blocks: YMap; - readonly _historyManager: UndoManager; - readonly _pushListeners: Map>; - readonly _popListeners: Map>; + private readonly _blocks: YMap; + private readonly _historyManager: UndoManager; + private readonly _pushListeners: Map>; + private readonly _popListeners: Map>; constructor(scope: YMap, tracker?: any[]) { this._blocks = scope; diff --git a/libs/datasource/jwt/src/adapter/yjs/index.ts b/libs/datasource/jwt/src/adapter/yjs/index.ts index 1a0a637859..eb886afae5 100644 --- a/libs/datasource/jwt/src/adapter/yjs/index.ts +++ b/libs/datasource/jwt/src/adapter/yjs/index.ts @@ -178,22 +178,22 @@ export type YjsInitOptions = { }; export class YjsAdapter implements AsyncDatabaseAdapter { - readonly _provider: YjsProviders; - readonly _doc: Doc; // doc instance - readonly _awareness: Awareness; // lightweight state synchronization - readonly _gatekeeper: GateKeeper; // Simple access control - readonly _history: YjsHistoryManager; + private readonly _provider: YjsProviders; + private readonly _doc: Doc; // doc instance + private readonly _awareness: Awareness; // lightweight state synchronization + private readonly _gatekeeper: GateKeeper; // Simple access control + private readonly _history: YjsHistoryManager; // Block Collection // key is a randomly generated global id - readonly _blocks: YMap>; - readonly _blockUpdated: YMap; + private readonly _blocks: YMap>; + private readonly _blockUpdated: YMap; // Maximum cache Block 1024, ttl 10 minutes - readonly _blockCaches: LRUCache; + private readonly _blockCaches: LRUCache; - readonly _binaries: YjsRemoteBinaries; + private readonly _binaries: YjsRemoteBinaries; - readonly _listener: Map>; + private readonly _listener: Map>; static async init( workspace: string, diff --git a/libs/datasource/jwt/src/adapter/yjs/operation.ts b/libs/datasource/jwt/src/adapter/yjs/operation.ts index e4b2da50dd..a8dfdaffa4 100644 --- a/libs/datasource/jwt/src/adapter/yjs/operation.ts +++ b/libs/datasource/jwt/src/adapter/yjs/operation.ts @@ -52,7 +52,7 @@ function auto_set(root: ContentOperation, key: string, data: BaseTypes): void { } export class YjsContentOperation implements ContentOperation { - readonly _content: YAbstractType; + private readonly _content: YAbstractType; constructor(content: YAbstractType) { this._content = content; @@ -197,7 +197,7 @@ export class YjsContentOperation implements ContentOperation { } class YjsTextOperation extends YjsContentOperation implements TextOperation { - readonly _textContent: YText; + private readonly _textContent: YText; constructor(content: YText) { super(content); @@ -241,8 +241,8 @@ class YjsArrayOperation extends YjsContentOperation implements ArrayOperation { - readonly _arrayContent: YArray; - readonly _listeners: Map; + private readonly _arrayContent: YArray; + private readonly _listeners: Map; constructor(content: YArray) { super(content); @@ -344,8 +344,8 @@ class YjsMapOperation extends YjsContentOperation implements MapOperation { - readonly _mapContent: YMap; - readonly _listeners: Map; + private readonly _mapContent: YMap; + private readonly _listeners: Map; constructor(content: YMap) { super(content); diff --git a/libs/datasource/jwt/src/block/abstract.ts b/libs/datasource/jwt/src/block/abstract.ts index 9d675ee803..29ee655dc2 100644 --- a/libs/datasource/jwt/src/block/abstract.ts +++ b/libs/datasource/jwt/src/block/abstract.ts @@ -26,11 +26,11 @@ export class AbstractBlock< B extends BlockInstance, C extends ContentOperation > { - readonly _id: string; + private readonly _id: string; readonly #block: BlockInstance; - readonly _history: HistoryManager; - readonly _root?: AbstractBlock; - readonly _parentListener: Map; + private readonly _history: HistoryManager; + private readonly _root?: AbstractBlock; + private readonly _parentListener: Map; _parent?: AbstractBlock; diff --git a/libs/datasource/jwt/src/block/base.ts b/libs/datasource/jwt/src/block/base.ts index cf79c08ea7..72183187b1 100644 --- a/libs/datasource/jwt/src/block/base.ts +++ b/libs/datasource/jwt/src/block/base.ts @@ -51,19 +51,19 @@ export class BaseBlock< B extends BlockInstance, C extends ContentOperation > extends AbstractBlock { - readonly _exporters?: Exporters; - readonly _contentExportersGetter: () => Map< + private readonly _exporters?: Exporters; + private readonly _contentExportersGetter: () => Map< string, ReadableContentExporter >; - readonly _metadataExportersGetter: () => Map< + private readonly _metadataExportersGetter: () => Map< string, ReadableContentExporter< Array<[string, number | string | string[]]>, any > >; - readonly _tagExportersGetter: () => Map< + private readonly _tagExportersGetter: () => Map< string, ReadableContentExporter >; diff --git a/libs/datasource/jwt/src/block/indexer.ts b/libs/datasource/jwt/src/block/indexer.ts index 39dd52c4e0..d9ecde1658 100644 --- a/libs/datasource/jwt/src/block/indexer.ts +++ b/libs/datasource/jwt/src/block/indexer.ts @@ -107,18 +107,18 @@ export class BlockIndexer< B extends BlockInstance, C extends ContentOperation > { - readonly _adapter: A; - readonly _idb: BlockIdbInstance; + private readonly _adapter: A; + private readonly _idb: BlockIdbInstance; - readonly _blockIndexer: DocumentIndexer; - readonly _blockMetadata: LRUCache; - readonly _eventBus: BlockEventBus; + private readonly _blockIndexer: DocumentIndexer; + private readonly _blockMetadata: LRUCache; + private readonly _eventBus: BlockEventBus; - readonly _blockBuilder: ( + private readonly _blockBuilder: ( block: BlockInstance ) => Promise>; - readonly _delayIndex: { documents: Map> }; + private readonly _delayIndex: { documents: Map> }; constructor( adapter: A, diff --git a/libs/datasource/jwt/src/index.ts b/libs/datasource/jwt/src/index.ts index 343f1f79ad..6ced321c2c 100644 --- a/libs/datasource/jwt/src/index.ts +++ b/libs/datasource/jwt/src/index.ts @@ -69,14 +69,14 @@ export class BlockClient< B extends BlockInstance, C extends ContentOperation > { - readonly _adapter: A; - readonly _workspace: string; + private readonly _adapter: A; + private readonly _workspace: string; // Maximum cache Block 8192, ttl 30 minutes - readonly _blockCaches: LRUCache>; - readonly _blockIndexer: BlockIndexer; + private readonly _blockCaches: LRUCache>; + private readonly _blockIndexer: BlockIndexer; - readonly _exporters: { + private readonly _exporters: { readonly content: BlockExporters; readonly metadata: BlockExporters< Array<[string, number | string | string[]]> @@ -84,12 +84,12 @@ export class BlockClient< readonly tag: BlockExporters; }; - readonly _eventBus: BlockEventBus; + private readonly _eventBus: BlockEventBus; - readonly _parentMapping: Map; - readonly _pageMapping: Map; + private readonly _parentMapping: Map; + private readonly _pageMapping: Map; - readonly _root: { node?: BaseBlock }; + private readonly _root: { node?: BaseBlock }; private constructor( adapter: A, diff --git a/libs/datasource/jwt/src/utils/event-bus.ts b/libs/datasource/jwt/src/utils/event-bus.ts index 9d128049e7..50f5363390 100644 --- a/libs/datasource/jwt/src/utils/event-bus.ts +++ b/libs/datasource/jwt/src/utils/event-bus.ts @@ -7,9 +7,9 @@ declare const JWT_DEV: boolean; const logger = getLogger('BlockDB:event_bus'); export class BlockEventBus { - readonly _eventBus: EventTarget; - readonly _eventCallbackCache: Map; - readonly _scopedCache: Map>; + private readonly _eventBus: EventTarget; + private readonly _eventCallbackCache: Map; + private readonly _scopedCache: Map>; constructor(event_bus?: EventTarget) { this._eventBus = event_bus || new EventTarget(); @@ -68,7 +68,7 @@ type ListenerOptions = { }; class BlockScopedEventBus extends BlockEventBus { - readonly _topic: string; + private readonly _topic: string; constructor(topic: string, event_bus?: EventTarget) { super(event_bus);